diff options
author | Johan Dahlin <johan@gnome.org> | 2010-03-24 15:00:06 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2010-03-24 15:02:05 -0300 |
commit | 69c86caaea946de056dd63529dd6213aca6ab92c (patch) | |
tree | 8eceb8eb86d840b152a5e76cb0b31df43d302e49 | |
parent | 36224b1489b808a0f9af0c3e1f5524063daaf3e6 (diff) | |
download | gobject-introspection-69c86caaea946de056dd63529dd6213aca6ab92c.tar.gz |
[girepository] Remove trailing whitespace
-rw-r--r-- | gir/cairo-1.0.gir | 2 | ||||
-rw-r--r-- | girepository/gdump.c | 6 | ||||
-rw-r--r-- | girepository/ginfo.c | 318 | ||||
-rw-r--r-- | girepository/ginvoke.c | 44 | ||||
-rw-r--r-- | girepository/girepository.c | 110 | ||||
-rw-r--r-- | girepository/girepository.h | 38 | ||||
-rw-r--r-- | girepository/girffi.c | 26 | ||||
-rw-r--r-- | girepository/girffi.h | 4 | ||||
-rw-r--r-- | girepository/girmodule.c | 30 | ||||
-rw-r--r-- | girepository/girmodule.h | 2 | ||||
-rw-r--r-- | girepository/girnode.c | 246 | ||||
-rw-r--r-- | girepository/girnode.h | 62 | ||||
-rw-r--r-- | girepository/giroffsets.c | 8 | ||||
-rw-r--r-- | girepository/girparser.c | 456 | ||||
-rw-r--r-- | girepository/girwriter.c | 4 | ||||
-rw-r--r-- | girepository/gtypelib.c | 336 | ||||
-rw-r--r-- | girepository/gtypelib.h | 252 |
17 files changed, 972 insertions, 972 deletions
diff --git a/gir/cairo-1.0.gir b/gir/cairo-1.0.gir index 8794a13e..e0deccf7 100644 --- a/gir/cairo-1.0.gir +++ b/gir/cairo-1.0.gir @@ -4,7 +4,7 @@ xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0"> <namespace name="cairo" version="1.0"> - <record name="Context" c:type="cairo_t"/> + <record name="Context" c:type="cairo_t" foreign-type="1"/> <record name="Surface" c:type="cairo_surface_t"/> <record name="Matrix" c:type="cairo_matrix_t"/> <record name="Pattern" c:type="cairo_pattern_t"/> diff --git a/girepository/gdump.c b/girepository/gdump.c index b4a3e8eb..5cb10b04 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -158,7 +158,7 @@ dump_object_type (GType type, const char *symbol, GOutputStream *out) GString *parent_str; GType parent; gboolean first = TRUE; - + parent = type; parent_str = g_string_new (""); do @@ -170,9 +170,9 @@ dump_object_type (GType type, const char *symbol, GOutputStream *out) g_string_append_c (parent_str, ','); g_string_append (parent_str, g_type_name (parent)); } while (parent != G_TYPE_OBJECT && parent != G_TYPE_INVALID); - + escaped_printf (out, " parents=\"%s\"", parent_str->str); - + g_string_free (parent_str, TRUE); } diff --git a/girepository/ginfo.c b/girepository/ginfo.c index 76d60ef8..2d777e3e 100644 --- a/girepository/ginfo.c +++ b/girepository/ginfo.c @@ -48,10 +48,10 @@ struct _GIRealInfo GTypelib *typelib; guint32 offset; - + guint32 type_is_embedded : 1; /* Used by GITypeInfo */ guint32 reserved : 31; - + gpointer reserved2[4]; }; @@ -76,7 +76,7 @@ g_info_init (GIRealInfo *info, GIInfoType type, GIRepository *repository, GIBaseInfo *container, - GTypelib *typelib, + GTypelib *typelib, guint32 offset) { memset (info, 0, sizeof (GIRealInfo)); @@ -100,7 +100,7 @@ GIBaseInfo * g_info_new_full (GIInfoType type, GIRepository *repository, GIBaseInfo *container, - GTypelib *typelib, + GTypelib *typelib, guint32 offset) { GIRealInfo *info; @@ -108,7 +108,7 @@ g_info_new_full (GIInfoType type, g_return_val_if_fail (container != NULL || repository != NULL, NULL); info = g_new (GIRealInfo, 1); - + g_info_init (info, type, repository, container, typelib, offset); info->ref_count = 1; @@ -123,7 +123,7 @@ g_info_new_full (GIInfoType type, GIBaseInfo * g_info_new (GIInfoType type, GIBaseInfo *container, - GTypelib *typelib, + GTypelib *typelib, guint32 offset) { return g_info_new_full (type, ((GIRealInfo*)container)->repository, container, typelib, offset); @@ -201,7 +201,7 @@ g_base_info_unref (GIBaseInfo *info) GIInfoType g_base_info_get_type (GIBaseInfo *info) { - + return ((GIRealInfo*)info)->type; } @@ -265,7 +265,7 @@ g_base_info_get_name (GIBaseInfo *info) case GI_INFO_TYPE_FIELD: { FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset]; - + return g_typelib_get_string (rinfo->typelib, blob->name); } break; @@ -273,7 +273,7 @@ g_base_info_get_name (GIBaseInfo *info) case GI_INFO_TYPE_ARG: { ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + return g_typelib_get_string (rinfo->typelib, blob->name); } break; @@ -304,14 +304,14 @@ g_base_info_get_namespace (GIBaseInfo *info) if (rinfo->type == GI_INFO_TYPE_UNRESOLVED) { GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info; - + return unresolved->namespace; } return g_typelib_get_string (rinfo->typelib, header->namespace); } -gboolean +gboolean g_base_info_is_deprecated (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*) info; @@ -365,7 +365,7 @@ g_base_info_is_deprecated (GIBaseInfo *info) default: ; /* no deprecation flag for these */ } - + return FALSE; } @@ -399,7 +399,7 @@ cmp_attribute (const void *av, { const AttributeBlob *a = av; const AttributeBlob *b = bv; - + if (a->offset < b->offset) return -1; else if (a->offset == b->offset) @@ -415,7 +415,7 @@ find_first_attribute (GIRealInfo *rinfo) AttributeBlob blob, *first, *res, *previous; blob.offset = rinfo->offset; - + first = (AttributeBlob *) &rinfo->typelib->data[header->attributes]; res = bsearch (&blob, first, header->n_attributes, @@ -545,13 +545,13 @@ g_function_info_get_flags (GIFunctionInfo *info) GIFunctionInfoFlags flags; GIRealInfo *rinfo = (GIRealInfo *)info; FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset]; - + flags = 0; /* Make sure we don't flag Constructors as methods */ if (!blob->constructor && !blob->is_static) flags = flags | GI_FUNCTION_IS_METHOD; - + if (blob->constructor) flags = flags | GI_FUNCTION_IS_CONSTRUCTOR; @@ -576,8 +576,8 @@ g_function_info_get_property (GIFunctionInfo *info) GIRealInfo *rinfo = (GIRealInfo *)info; FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset]; GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container; - - return g_interface_info_get_property (container, blob->index); + + return g_interface_info_get_property (container, blob->index); } GIVFuncInfo * @@ -586,8 +586,8 @@ g_function_info_get_vfunc (GIFunctionInfo *info) GIRealInfo *rinfo = (GIRealInfo*)info; FunctionBlob *blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset]; GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container; - - return g_interface_info_get_vfunc (container, blob->index); + + return g_interface_info_get_vfunc (container, blob->index); } /* GICallableInfo functions */ @@ -636,7 +636,7 @@ g_type_info_init (GIBaseInfo *info, { GIRealInfo *rinfo = (GIRealInfo*)container; SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset]; - + g_info_init ((GIRealInfo*)info, GI_INFO_TYPE_TYPE, rinfo->repository, container, typelib, (type->flags.reserved == 0 && type->flags.reserved2 == 0) ? offset : type->offset); } @@ -734,7 +734,7 @@ g_callable_info_get_caller_owns (GICallableInfo *info) * * Returns: The number of arguments this callable expects. */ -gint +gint g_callable_info_get_n_args (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -765,8 +765,8 @@ g_callable_info_get_arg (GICallableInfo *info, gint offset; offset = signature_offset (info); - - return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, (GIBaseInfo*)info, rinfo->typelib, + + return (GIArgInfo *) g_info_new (GI_INFO_TYPE_ARG, (GIBaseInfo*)info, rinfo->typelib, offset + header->signature_blob_size + n * header->arg_blob_size); } @@ -792,9 +792,9 @@ g_callable_info_load_arg (GICallableInfo *info, gint offset; offset = signature_offset (info); - - g_info_init ((GIRealInfo*)arg, GI_INFO_TYPE_ARG, rinfo->repository, (GIBaseInfo*)info, rinfo->typelib, - offset + header->signature_blob_size + n * header->arg_blob_size); + + g_info_init ((GIRealInfo*)arg, GI_INFO_TYPE_ARG, rinfo->repository, (GIBaseInfo*)info, rinfo->typelib, + offset + header->signature_blob_size + n * header->arg_blob_size); } /* GIArgInfo function */ @@ -803,7 +803,7 @@ g_arg_info_get_direction (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (blob->in && blob->out) return GI_DIRECTION_INOUT; else if (blob->out) @@ -817,7 +817,7 @@ g_arg_info_is_return_value (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->return_value; } @@ -826,7 +826,7 @@ g_arg_info_is_dipper (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->dipper; } @@ -835,7 +835,7 @@ g_arg_info_is_optional (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->optional; } @@ -844,7 +844,7 @@ g_arg_info_may_be_null (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ArgBlob *blob = (ArgBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->allow_none; } @@ -899,7 +899,7 @@ GITypeInfo * g_arg_info_get_type (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; - + return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); } @@ -919,7 +919,7 @@ g_arg_info_load_type (GIArgInfo *info, GITypeInfo *type) { GIRealInfo *rinfo = (GIRealInfo*) info; - g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); + g_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); } /* GITypeInfo functions */ @@ -928,13 +928,13 @@ g_type_info_is_pointer (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (type->flags.reserved == 0 && type->flags.reserved2 == 0) return type->flags.pointer; else { InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + return iface->pointer; } } @@ -963,14 +963,14 @@ g_type_info_get_param_type (GITypeInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ParamTypeBlob *param = (ParamTypeBlob *)&rinfo->typelib->data[rinfo->offset]; switch (param->tag) { - case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_ARRAY: case GI_TYPE_TAG_GLIST: case GI_TYPE_TAG_GSLIST: case GI_TYPE_TAG_GHASH: @@ -1041,7 +1041,7 @@ g_type_info_get_array_length (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -1061,7 +1061,7 @@ g_type_info_get_array_fixed_size (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -1081,7 +1081,7 @@ g_type_info_is_zero_terminated (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -1098,7 +1098,7 @@ g_type_info_get_n_error_domains (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -1116,7 +1116,7 @@ g_type_info_get_error_domain (GITypeInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -1146,13 +1146,13 @@ g_error_domain_info_get_codes (GIErrorDomainInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ErrorDomainBlob *blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; - + return (GIInterfaceInfo *) g_info_from_entry (rinfo->repository, rinfo->typelib, blob->error_codes); } -/* GIValueInfo functions */ +/* GIValueInfo functions */ glong g_value_info_get_value (GIValueInfo *info) { @@ -1187,7 +1187,7 @@ g_field_info_get_size (GIFieldInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->bits; } @@ -1196,7 +1196,7 @@ g_field_info_get_offset (GIFieldInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->struct_offset; } @@ -1253,19 +1253,19 @@ g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info) GType (* get_type_func) (void); GIRealInfo *rinfo = (GIRealInfo*)info; - type_init = g_registered_type_info_get_type_init (info); - + type_init = g_registered_type_info_get_type_init (info); + if (type_init == NULL) return G_TYPE_NONE; else if (!strcmp (type_init, "intern")) return G_TYPE_OBJECT; - + get_type_func = NULL; if (!g_typelib_symbol (rinfo->typelib, type_init, (void**) &get_type_func)) return G_TYPE_NONE; - + return (* get_type_func) (); } @@ -1275,7 +1275,7 @@ g_struct_info_get_n_fields (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_fields; } @@ -1305,8 +1305,8 @@ g_struct_info_get_field (GIStructInfo *info, gint n) { GIRealInfo *rinfo = (GIRealInfo *)info; - - return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, + + return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, g_struct_get_field_offset (info, n)); } @@ -1315,7 +1315,7 @@ g_struct_info_get_n_methods (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_methods; } @@ -1325,11 +1325,11 @@ g_struct_info_get_method (GIStructInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; gint offset; offset = g_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size; - return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, + return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -1341,7 +1341,7 @@ find_method (GIBaseInfo *base, { /* FIXME hash */ GIRealInfo *rinfo = (GIRealInfo*)base; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; gint i; for (i = 0; i < n_methods; i++) @@ -1350,12 +1350,12 @@ find_method (GIBaseInfo *base, const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name]; if (strcmp (name, fname) == 0) - return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base, - rinfo->typelib, offset); - + return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, base, + rinfo->typelib, offset); + offset += header->function_blob_size; } - + return NULL; } @@ -1365,7 +1365,7 @@ g_struct_info_find_method (GIStructInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; offset = rinfo->offset + header->struct_blob_size @@ -1395,7 +1395,7 @@ g_struct_info_get_alignment (GIStructInfo *info) /** * g_struct_info_is_gtype_struct: * @info: GIStructInfo - * + * * Return true if this structure represents the "class structure" for some * #GObject or #GInterface. This function is mainly useful to hide this kind of structure * from generated public APIs. @@ -1425,10 +1425,10 @@ g_enum_info_get_value (GIEnumInfo *info, gint n) { GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; gint offset; - offset = rinfo->offset + header->enum_blob_size + offset = rinfo->offset + header->enum_blob_size + n * header->value_blob_size; return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -1530,13 +1530,13 @@ g_object_info_get_field (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + n * header->field_blob_size; - + return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -1546,7 +1546,7 @@ g_object_info_get_n_properties (GIObjectInfo *info) GIRealInfo *rinfo = (GIRealInfo *)info; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - return blob->n_properties; + return blob->n_properties; } GIPropertyInfo * @@ -1555,15 +1555,15 @@ g_object_info_get_property (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * header->field_blob_size + n * header->property_blob_size; - return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info, + return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -1582,17 +1582,17 @@ g_object_info_get_method (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * header->field_blob_size + blob->n_properties * header->property_blob_size + n * header->function_blob_size; - return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, - rinfo->typelib, offset); + return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, + rinfo->typelib, offset); } GIFunctionInfo * @@ -1601,7 +1601,7 @@ g_object_info_find_method (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; offset = rinfo->offset + header->object_blob_size @@ -1627,18 +1627,18 @@ g_object_info_get_signal (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * header->field_blob_size + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size + + blob->n_methods * header->function_blob_size + n * header->signal_blob_size; - return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info, - rinfo->typelib, offset); + return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info, + rinfo->typelib, offset); } gint @@ -1646,7 +1646,7 @@ g_object_info_get_n_vfuncs (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_vfuncs; } @@ -1656,19 +1656,19 @@ g_object_info_get_vfunc (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * header->field_blob_size + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size - + blob->n_signals * header->signal_blob_size + + blob->n_methods * header->function_blob_size + + blob->n_signals * header->signal_blob_size + n * header->vfunc_blob_size; - return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info, - rinfo->typelib, offset); + return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info, + rinfo->typelib, offset); } static GIVFuncInfo * @@ -1733,7 +1733,7 @@ g_object_info_get_n_constants (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_constants; } @@ -1743,26 +1743,26 @@ g_object_info_get_constant (GIObjectInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * header->field_blob_size + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size - + blob->n_signals * header->signal_blob_size - + blob->n_vfuncs * header->vfunc_blob_size + + blob->n_methods * header->function_blob_size + + blob->n_signals * header->signal_blob_size + + blob->n_vfuncs * header->vfunc_blob_size + n * header->constant_blob_size; - return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, - rinfo->typelib, offset); + return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, + rinfo->typelib, offset); } /** * g_object_info_get_class_struct: * @info: A #GIObjectInfo to query - * + * * Every #GObject has two structures; an instance structure and a class * structure. This function returns the metadata for the class structure. * @@ -1809,7 +1809,7 @@ g_interface_info_get_n_properties (GIInterfaceInfo *info) GIRealInfo *rinfo = (GIRealInfo *)info; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - return blob->n_properties; + return blob->n_properties; } GIPropertyInfo * @@ -1818,14 +1818,14 @@ g_interface_info_get_property (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->interface_blob_size + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2 + n * header->property_blob_size; - return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info, + return (GIPropertyInfo *) g_info_new (GI_INFO_TYPE_PROPERTY, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -1844,16 +1844,16 @@ g_interface_info_get_method (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->interface_blob_size + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2 - + blob->n_properties * header->property_blob_size + + blob->n_properties * header->property_blob_size + n * header->function_blob_size; - - return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, - rinfo->typelib, offset); + + return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, + rinfo->typelib, offset); } GIFunctionInfo * @@ -1862,7 +1862,7 @@ g_interface_info_find_method (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; offset = rinfo->offset + header->interface_blob_size @@ -1887,17 +1887,17 @@ g_interface_info_get_signal (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - - offset = rinfo->offset + header->interface_blob_size + + offset = rinfo->offset + header->interface_blob_size + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2 - + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size + + blob->n_properties * header->property_blob_size + + blob->n_methods * header->function_blob_size + n * header->signal_blob_size; - - return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info, - rinfo->typelib, offset); + + return (GISignalInfo *) g_info_new (GI_INFO_TYPE_SIGNAL, (GIBaseInfo*)info, + rinfo->typelib, offset); } gint @@ -1915,18 +1915,18 @@ g_interface_info_get_vfunc (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - - offset = rinfo->offset + header->interface_blob_size + + offset = rinfo->offset + header->interface_blob_size + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2 - + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size + + blob->n_properties * header->property_blob_size + + blob->n_methods * header->function_blob_size + blob->n_signals * header->signal_blob_size + n * header->vfunc_blob_size; - - return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info, - rinfo->typelib, offset); + + return (GIVFuncInfo *) g_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*)info, + rinfo->typelib, offset); } /** @@ -1962,7 +1962,7 @@ g_interface_info_get_n_constants (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_constants; } @@ -1972,19 +1972,19 @@ g_interface_info_get_constant (GIInterfaceInfo *info, { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; - + offset = rinfo->offset + header->interface_blob_size + (blob->n_prerequisites + (blob->n_prerequisites % 2)) * 2 + blob->n_properties * header->property_blob_size - + blob->n_methods * header->function_blob_size - + blob->n_signals * header->signal_blob_size - + blob->n_vfuncs * header->vfunc_blob_size + + blob->n_methods * header->function_blob_size + + blob->n_signals * header->signal_blob_size + + blob->n_vfuncs * header->vfunc_blob_size + n * header->constant_blob_size; - return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, - rinfo->typelib, offset); + return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, + rinfo->typelib, offset); } /** @@ -2015,7 +2015,7 @@ g_property_info_get_flags (GIPropertyInfo *info) GParamFlags flags; GIRealInfo *rinfo = (GIRealInfo *)info; PropertyBlob *blob = (PropertyBlob *)&rinfo->typelib->data[rinfo->offset]; - + flags = 0; if (blob->readable) @@ -2126,7 +2126,7 @@ g_vfunc_info_get_offset (GIVFuncInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; VFuncBlob *blob = (VFuncBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->struct_offset; } @@ -2138,7 +2138,7 @@ g_vfunc_info_get_signal (GIVFuncInfo *info) if (blob->class_closure) return g_interface_info_get_signal ((GIInterfaceInfo *)rinfo->container, blob->signal); - + return NULL; } @@ -2179,12 +2179,12 @@ GITypeInfo * g_constant_info_get_type (GIConstantInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; - + return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 8); } gint -g_constant_info_get_value (GIConstantInfo *info, +g_constant_info_get_value (GIConstantInfo *info, GArgument *value) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -2266,7 +2266,7 @@ g_union_info_get_n_fields (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_fields; } @@ -2275,10 +2275,10 @@ g_union_info_get_field (GIUnionInfo *info, gint n) { GIRealInfo *rinfo = (GIRealInfo *)info; - Header *header = (Header *)rinfo->typelib->data; - - return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, - rinfo->offset + header->union_blob_size + + Header *header = (Header *)rinfo->typelib->data; + + return (GIFieldInfo *) g_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, + rinfo->offset + header->union_blob_size + n * header->field_blob_size); } @@ -2287,7 +2287,7 @@ g_union_info_get_n_methods (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->n_functions; } @@ -2297,13 +2297,13 @@ g_union_info_get_method (GIUnionInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; gint offset; - offset = rinfo->offset + header->union_blob_size - + blob->n_fields * header->field_blob_size + offset = rinfo->offset + header->union_blob_size + + blob->n_fields * header->field_blob_size + n * header->function_blob_size; - return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, + return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, rinfo->typelib, offset); } @@ -2312,7 +2312,7 @@ g_union_info_is_discriminated (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->discriminated; } @@ -2321,7 +2321,7 @@ g_union_info_get_discriminator_offset (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - + return blob->discriminator_offset; } @@ -2329,7 +2329,7 @@ GITypeInfo * g_union_info_get_discriminator_type (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; - + return g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 24); } @@ -2339,19 +2339,19 @@ g_union_info_get_discriminator (GIUnionInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; - + if (blob->discriminated) { - Header *header = (Header *)rinfo->typelib->data; + Header *header = (Header *)rinfo->typelib->data; gint offset; - offset = rinfo->offset + header->union_blob_size - + blob->n_fields * header->field_blob_size + offset = rinfo->offset + header->union_blob_size + + blob->n_fields * header->field_blob_size + blob->n_functions * header->function_blob_size + n * header->constant_blob_size; - - return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, - rinfo->typelib, offset); + + return (GIConstantInfo *) g_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, + rinfo->typelib, offset); } return NULL; diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index b3333f85..2d4c3f56 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -40,31 +40,31 @@ g_invoke_error_quark (void) /** * g_function_info_invoke: * @info: a #GIFunctionInfo describing the function to invoke - * @in_args: an array of #GArgument<!-- -->s, one for each in + * @in_args: an array of #GArgument<!-- -->s, one for each in * parameter of @info. If there are no in parameter, @in_args * can be %NULL * @n_in_args: the length of the @in_args array * @out_args: an array of #GArgument<!-- -->s, one for each out * parameter of @info. If there are no out parameters, @out_args - * may be %NULL + * may be %NULL * @n_out_args: the length of the @out_args array - * @return_value: return location for the return value of the + * @return_value: return location for the return value of the * function. If the function returns void, @return_value may be * %NULL * @error: return location for detailed error information, or %NULL * - * Invokes the function described in @info with the given + * Invokes the function described in @info with the given * arguments. Note that inout parameters must appear in both * argument lists. This function uses dlsym() to obtain a pointer - * to the function, so the library or shared object containing the - * described function must either be linked to the caller, or must + * to the function, so the library or shared object containing the + * described function must either be linked to the caller, or must * have been dlopen()<!-- -->ed before calling this function. * * Returns: %TRUE if the function has been invoked, %FALSE if an - * error occurred. + * error occurred. */ -gboolean -g_function_info_invoke (GIFunctionInfo *info, +gboolean +g_function_info_invoke (GIFunctionInfo *info, const GArgument *in_args, int n_in_args, const GArgument *out_args, @@ -134,7 +134,7 @@ g_function_info_invoke (GIFunctionInfo *info, atypes = g_alloca (sizeof (ffi_type*) * n_invoke_args); args = g_alloca (sizeof (gpointer) * n_invoke_args); - + if (is_method) { atypes[0] = &ffi_type_pointer; @@ -162,7 +162,7 @@ g_function_info_invoke (GIFunctionInfo *info, args[i+offset] = (gpointer)&in_args[in_pos]; in_pos++; - + break; case GI_DIRECTION_OUT: atypes[i+offset] = &ffi_type_pointer; @@ -172,12 +172,12 @@ g_function_info_invoke (GIFunctionInfo *info, g_set_error (error, G_INVOKE_ERROR, G_INVOKE_ERROR_ARGUMENT_MISMATCH, - "Too few \"out\" arguments (handling out)"); + "Too few \"out\" arguments (handling out)"); goto out; } args[i+offset] = (gpointer)&out_args[out_pos]; - out_pos++; + out_pos++; break; case GI_DIRECTION_INOUT: atypes[i+offset] = &ffi_type_pointer; @@ -196,13 +196,13 @@ g_function_info_invoke (GIFunctionInfo *info, g_set_error (error, G_INVOKE_ERROR, G_INVOKE_ERROR_ARGUMENT_MISMATCH, - "Too few \"out\" arguments (handling inout)"); + "Too few \"out\" arguments (handling inout)"); goto out; } - + args[i+offset] = (gpointer)&in_args[in_pos]; - in_pos++; - out_pos++; + in_pos++; + out_pos++; break; default: g_assert_not_reached (); @@ -229,7 +229,7 @@ g_function_info_invoke (GIFunctionInfo *info, g_set_error (error, G_INVOKE_ERROR, G_INVOKE_ERROR_ARGUMENT_MISMATCH, - "Too many \"out\" arguments (at end)"); + "Too many \"out\" arguments (at end)"); goto out; } @@ -382,17 +382,17 @@ gi_cclosure_marshal_generic (GClosure *closure, ffi_cif cif; GCClosure *cc = (GCClosure*) closure; - if (return_gvalue && G_VALUE_TYPE (return_gvalue)) + if (return_gvalue && G_VALUE_TYPE (return_gvalue)) { rtype = value_to_ffi_type (return_gvalue, &rvalue); } - else + else { rtype = &ffi_type_void; } rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg))); - + n_args = n_param_values + 1; atypes = g_alloca (sizeof (ffi_type *) * n_args); args = g_alloca (sizeof (gpointer) * n_args); @@ -401,7 +401,7 @@ gi_cclosure_marshal_generic (GClosure *closure, { if (G_CCLOSURE_SWAP_DATA (closure)) { - atypes[n_args-1] = value_to_ffi_type (param_values + 0, + atypes[n_args-1] = value_to_ffi_type (param_values + 0, &args[n_args-1]); atypes[0] = &ffi_type_pointer; args[0] = &closure->data; diff --git a/girepository/girepository.c b/girepository/girepository.c index e590616d..e7004a9d 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -40,7 +40,7 @@ static GIRepository *default_repository = NULL; static GSList *search_path = NULL; static GSList *override_search_path = NULL; -struct _GIRepositoryPrivate +struct _GIRepositoryPrivate { GHashTable *typelibs; /* (string) namespace -> GTypelib */ GHashTable *lazy_typelibs; /* (string) namespace-version -> GTypelib */ @@ -49,16 +49,16 @@ struct _GIRepositoryPrivate G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT); -static void +static void g_irepository_init (GIRepository *repository) { repository->priv = G_TYPE_INSTANCE_GET_PRIVATE (repository, G_TYPE_IREPOSITORY, GIRepositoryPrivate); - repository->priv->typelibs + repository->priv->typelibs = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) NULL, (GDestroyNotify) g_typelib_free); - repository->priv->lazy_typelibs + repository->priv->lazy_typelibs = g_hash_table_new (g_str_hash, g_str_equal); repository->priv->info_by_gtype = g_hash_table_new_full (g_direct_hash, g_direct_equal, @@ -74,7 +74,7 @@ g_irepository_finalize (GObject *object) g_hash_table_destroy (repository->priv->typelibs); g_hash_table_destroy (repository->priv->lazy_typelibs); g_hash_table_destroy (repository->priv->info_by_gtype); - + (* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository)); } @@ -87,7 +87,7 @@ g_irepository_class_init (GIRepositoryClass *class) gobject_class->finalize = g_irepository_finalize; - g_type_class_add_private (class, sizeof (GIRepositoryPrivate)); + g_type_class_add_private (class, sizeof (GIRepositoryPrivate)); } static void @@ -170,11 +170,11 @@ GSList * build_search_path_with_overrides (void) { GSList *result; - if (override_search_path != NULL) + if (override_search_path != NULL) { result = g_slist_copy (override_search_path); g_slist_last (result)->next = g_slist_copy (search_path); - } + } else result = g_slist_copy (search_path); return result; @@ -216,7 +216,7 @@ get_repository (GIRepository *repository) } static GTypelib * -check_version_conflict (GTypelib *typelib, +check_version_conflict (GTypelib *typelib, const gchar *namespace, const gchar *expected_version, char **version_conflict) @@ -230,11 +230,11 @@ check_version_conflict (GTypelib *typelib, *version_conflict = NULL; return typelib; } - + header = (Header*)typelib->data; loaded_version = g_typelib_get_string (typelib, header->nsversion); g_assert (loaded_version != NULL); - + if (strcmp (expected_version, loaded_version) != 0) { if (version_conflict) @@ -259,7 +259,7 @@ get_registered_status (GIRepository *repository, if (lazy_status) *lazy_status = FALSE; typelib = g_hash_table_lookup (repository->priv->typelibs, namespace); - if (typelib) + if (typelib) return check_version_conflict (typelib, namespace, version, version_conflict); typelib = g_hash_table_lookup (repository->priv->lazy_typelibs, namespace); if (!typelib) @@ -291,7 +291,7 @@ load_dependencies_recurse (GIRepository *repository, if (dependencies != NULL) { int i; - + for (i = 0; dependencies[i]; i++) { char *dependency = dependencies[i]; @@ -302,7 +302,7 @@ load_dependencies_recurse (GIRepository *repository, last_dash = strrchr (dependency, '-'); dependency_namespace = g_strndup (dependency, last_dash - dependency); dependency_version = last_dash+1; - + if (!g_irepository_require (repository, dependency_namespace, dependency_version, 0, error)) { @@ -329,7 +329,7 @@ register_internal (GIRepository *repository, const gchar *version; g_return_val_if_fail (typelib != NULL, FALSE); - + header = (Header *)typelib->data; g_return_val_if_fail (header != NULL, FALSE); @@ -339,9 +339,9 @@ register_internal (GIRepository *repository, if (lazy) { - g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs, + g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs, namespace)); - g_hash_table_insert (repository->priv->lazy_typelibs, + g_hash_table_insert (repository->priv->lazy_typelibs, build_typelib_key (namespace, source), (void *)typelib); } else @@ -352,9 +352,9 @@ register_internal (GIRepository *repository, /* First, try loading all the dependencies */ if (!load_dependencies_recurse (repository, typelib, error)) return NULL; - + /* Check if we are transitioning from lazily loaded state */ - if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs, + if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs, namespace, (gpointer)&key, &value)) g_hash_table_remove (repository->priv->lazy_typelibs, key); @@ -416,7 +416,7 @@ g_irepository_load_typelib (GIRepository *repository, namespace = g_typelib_get_string (typelib, header->namespace); nsversion = g_typelib_get_string (typelib, header->nsversion); - if (get_registered_status (repository, namespace, nsversion, allow_lazy, + if (get_registered_status (repository, namespace, nsversion, allow_lazy, &is_lazy, &version_conflict)) { if (version_conflict != NULL) @@ -429,7 +429,7 @@ g_irepository_load_typelib (GIRepository *repository, } return namespace; } - return register_internal (repository, "<builtin>", + return register_internal (repository, "<builtin>", allow_lazy, typelib, error); } @@ -445,11 +445,11 @@ g_irepository_load_typelib (GIRepository *repository, * metadata in the namespace, you should call #g_irepository_require * instead which will ensure the namespace is loaded, and return as * quickly as this function will if it has already been loaded. - * + * * Returns: %TRUE if namespace-version is loaded, %FALSE otherwise */ gboolean -g_irepository_is_registered (GIRepository *repository, +g_irepository_is_registered (GIRepository *repository, const gchar *namespace, const gchar *version) { @@ -470,10 +470,10 @@ g_irepository_is_registered (GIRepository *repository, * All methods on #GIRepository also accept %NULL as an instance * parameter to mean this default repository, which is usually more * convenient for C. - * - * Returns: (transfer none): The global singleton #GIRepository + * + * Returns: (transfer none): The global singleton #GIRepository */ -GIRepository * +GIRepository * g_irepository_get_default (void) { return get_repository (NULL); @@ -490,7 +490,7 @@ g_irepository_get_default (void) * * Returns: number of metadata entries */ -gint +gint g_irepository_get_n_infos (GIRepository *repository, const gchar *namespace) { @@ -500,7 +500,7 @@ g_irepository_get_n_infos (GIRepository *repository, g_return_val_if_fail (namespace != NULL, -1); repository = get_repository (repository); - + typelib = get_registered (repository, namespace, NULL); g_return_val_if_fail (typelib != NULL, -1); @@ -533,7 +533,7 @@ find_interface (gpointer key, gint n_entries; const gchar *name; const gchar *type; - DirEntry *entry; + DirEntry *entry; index = 0; n_entries = ((Header *)typelib->data)->n_local_entries; @@ -624,7 +624,7 @@ find_interface (gpointer key, * * Returns: #GIBaseInfo containing metadata */ -GIBaseInfo * +GIBaseInfo * g_irepository_get_info (GIRepository *repository, const gchar *namespace, gint index) @@ -643,12 +643,12 @@ g_irepository_get_info (GIRepository *repository, data.iface = NULL; typelib = get_registered (repository, namespace, NULL); - + g_return_val_if_fail (typelib != NULL, NULL); find_interface ((void *)namespace, typelib, &data); - return data.iface; + return data.iface; } /** @@ -665,7 +665,7 @@ g_irepository_get_info (GIRepository *repository, * * Returns: #GIBaseInfo representing metadata about @type, or %NULL */ -GIBaseInfo * +GIBaseInfo * g_irepository_find_by_gtype (GIRepository *repository, GType gtype) { @@ -718,7 +718,7 @@ g_irepository_find_by_gtype (GIRepository *repository, * * Returns: #GIBaseInfo representing metadata about @name, or %NULL */ -GIBaseInfo * +GIBaseInfo * g_irepository_find_by_name (GIRepository *repository, const gchar *namespace, const gchar *name) @@ -737,7 +737,7 @@ g_irepository_find_by_name (GIRepository *repository, data.iface = NULL; typelib = get_registered (repository, namespace, NULL); - + g_return_val_if_fail (typelib != NULL, NULL); find_interface ((void *)namespace, typelib, &data); @@ -763,7 +763,7 @@ collect_namespaces (gpointer key, * * Returns: (utf8) (transfer full): List of namespaces */ -gchar ** +gchar ** g_irepository_get_loaded_namespaces (GIRepository *repository) { GList *l, *list = NULL; @@ -778,7 +778,7 @@ g_irepository_get_loaded_namespaces (GIRepository *repository) names = g_malloc0 (sizeof (gchar *) * (g_list_length (list) + 1)); i = 0; for (l = list; l; l = l->next) - names[i++] = g_strdup (l->data); + names[i++] = g_strdup (l->data); g_list_free (list); return names; @@ -895,14 +895,14 @@ g_irepository_get_c_prefix (GIRepository *repository, * @namespace_: GI namespace to use, e.g. "Gtk" * * If namespace @namespace_ is loaded, return the full path to the - * .typelib file it was loaded from. If the typelib for + * .typelib file it was loaded from. If the typelib for * namespace @namespace_ was included in a shared library, return * the special string "$lt;builtin$gt;". * * Returns: Filesystem path (or $lt;builtin$gt;) if successful, %NULL if namespace is not loaded */ -const gchar * +const gchar * g_irepository_get_typelib_path (GIRepository *repository, const gchar *namespace) { @@ -915,7 +915,7 @@ g_irepository_get_typelib_path (GIRepository *repository, { if (!g_hash_table_lookup_extended (repository->priv->lazy_typelibs, namespace, &orig_key, &value)) - + return NULL; } return ((char*)orig_key) + strlen ((char *) orig_key) + 1; @@ -933,14 +933,14 @@ find_namespace_version (const gchar *namespace, GError *error = NULL; GMappedFile *mfile = NULL; char *fname; - + fname = g_strdup_printf ("%s-%s.typelib", namespace, version); tmp_path = build_search_path_with_overrides (); for (ldir = tmp_path; ldir; ldir = ldir->next) { char *path = g_build_filename (ldir->data, fname, NULL); - + mfile = g_mapped_file_new (path, FALSE, &error); if (error) { @@ -1022,7 +1022,7 @@ compare_candidate_reverse (struct NamespaceVersionCandidadate *c1, return -1; else if (result < 0) return 1; - else + else { /* Now check the path index, which says how early in the search path * we found it. This ensures that of equal version targets, we @@ -1067,7 +1067,7 @@ find_namespace_latest (const gchar *namespace, namespace_typelib = g_strdup_printf ("%s.typelib", namespace); index = 0; - tmp_path = build_search_path_with_overrides (); + tmp_path = build_search_path_with_overrides (); for (ldir = tmp_path; ldir; ldir = ldir->next) { GDir *dir; @@ -1078,7 +1078,7 @@ find_namespace_latest (const gchar *namespace, dir = g_dir_open (dirname, 0, NULL); if (dir == NULL) continue; - while ((entry = g_dir_read_name (dir)) != NULL) + while ((entry = g_dir_read_name (dir)) != NULL) { GMappedFile *mfile; char *path, *version; @@ -1086,7 +1086,7 @@ find_namespace_latest (const gchar *namespace, if (!g_str_has_suffix (entry, ".typelib")) continue; - + if (g_str_has_prefix (entry, namespace_dash)) { const char *last_dash; @@ -1126,21 +1126,21 @@ find_namespace_latest (const gchar *namespace, { struct NamespaceVersionCandidadate *elected; candidates = g_slist_sort (candidates, (GCompareFunc) compare_candidate_reverse); - + elected = (struct NamespaceVersionCandidadate *) candidates->data; /* Remove the elected one so we don't try to free its contents */ candidates = g_slist_delete_link (candidates, candidates); - + result = elected->mfile; *path_ret = elected->path; *version_ret = elected->version; g_free (elected); /* just free the container */ g_slist_foreach (candidates, (GFunc) free_candidate, NULL); g_slist_free (candidates); - } + } g_free (namespace_dash); g_free (namespace_typelib); - g_slist_free (tmp_path); + g_slist_free (tmp_path); return result; } @@ -1182,7 +1182,7 @@ g_irepository_require (GIRepository *repository, repository = get_repository (repository); - typelib = get_registered_status (repository, namespace, version, allow_lazy, + typelib = get_registered_status (repository, namespace, version, allow_lazy, &is_lazy, &version_conflict); if (typelib) return typelib; @@ -1205,7 +1205,7 @@ g_irepository_require (GIRepository *repository, { mfile = find_namespace_latest (namespace, &tmp_version, &path); } - + if (mfile == NULL) { if (version != NULL) @@ -1225,7 +1225,7 @@ g_irepository_require (GIRepository *repository, header = (Header *) typelib->data; typelib_namespace = g_typelib_get_string (typelib, header->namespace); typelib_version = g_typelib_get_string (typelib, header->nsversion); - + if (strcmp (typelib_namespace, namespace) != 0) { g_set_error (error, G_IREPOSITORY_ERROR, @@ -1245,7 +1245,7 @@ g_irepository_require (GIRepository *repository, goto out; } - if (!register_internal (repository, path, allow_lazy, + if (!register_internal (repository, path, allow_lazy, typelib, error)) { g_typelib_free (typelib); @@ -1255,7 +1255,7 @@ g_irepository_require (GIRepository *repository, out: g_free (tmp_version); g_free (path); - return ret; + return ret; } static gboolean diff --git a/girepository/girepository.h b/girepository/girepository.h index 93cf126a..083b11c0 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -34,9 +34,9 @@ G_BEGIN_DECLS #define G_IS_IREPOSITORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_IREPOSITORY)) #define G_IREPOSITORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G_TYPE_IREPOSITORY, GIRepositoryClass)) -typedef struct _GIRepository GIRepository; -typedef struct _GIRepositoryClass GIRepositoryClass; -typedef struct _GIRepositoryPrivate GIRepositoryPrivate; +typedef struct _GIRepository GIRepository; +typedef struct _GIRepositoryClass GIRepositoryClass; +typedef struct _GIRepositoryPrivate GIRepositoryPrivate; typedef struct _GIBaseInfoStub GIBaseInfo; @@ -73,8 +73,8 @@ typedef GIBaseInfo GIErrorDomainInfo; typedef struct _GIUnresolvedInfo GIUnresolvedInfo; typedef struct _GTypelib GTypelib; -struct _GIRepository -{ +struct _GIRepository +{ GObject parent; /*< private >*/ @@ -82,8 +82,8 @@ struct _GIRepository }; struct _GIRepositoryClass -{ - GObjectClass parent; +{ + GObjectClass parent; }; typedef enum @@ -173,7 +173,7 @@ void gi_cclosure_marshal_generic (GClosure *closure, /* Types of objects registered in the repository */ -typedef enum +typedef enum { GI_INFO_TYPE_INVALID, GI_INFO_TYPE_FUNCTION, @@ -226,7 +226,7 @@ gboolean g_base_info_equal (GIBaseInfo *info1, GIBaseInfo * g_info_new (GIInfoType type, GIBaseInfo *container, - GTypelib *typelib, + GTypelib *typelib, guint32 offset); @@ -247,7 +247,7 @@ GIFunctionInfoFlags g_function_info_get_flags (GIFunctionInfo *info); GIPropertyInfo * g_function_info_get_property (GIFunctionInfo *info); GIVFuncInfo * g_function_info_get_vfunc (GIFunctionInfo *info); -typedef union +typedef union { gboolean v_boolean; gint8 v_int8; @@ -282,7 +282,7 @@ typedef enum G_INVOKE_ERROR_ARGUMENT_MISMATCH } GInvokeError; -gboolean g_function_info_invoke (GIFunctionInfo *info, +gboolean g_function_info_invoke (GIFunctionInfo *info, const GArgument *in_args, int n_in_args, const GArgument *out_args, @@ -323,8 +323,8 @@ typedef enum { GI_SCOPE_TYPE_INVALID, /* The argument is not of callback type */ GI_SCOPE_TYPE_CALL, /* The callback and associated user_data is only used during the call to this function */ - GI_SCOPE_TYPE_ASYNC, /* The callback and associated user_data is - only used until the callback is invoked, and the callback + GI_SCOPE_TYPE_ASYNC, /* The callback and associated user_data is + only used until the callback is invoked, and the callback is invoked always exactly once. */ GI_SCOPE_TYPE_NOTIFIED /* The callback and and associated user_data is used until the caller is notfied via the destroy_notify */ @@ -353,7 +353,7 @@ typedef enum { GI_TYPE_TAG_INT8 = 2, GI_TYPE_TAG_UINT8 = 3, GI_TYPE_TAG_INT16 = 4, - GI_TYPE_TAG_UINT16 = 5, + GI_TYPE_TAG_UINT16 = 5, GI_TYPE_TAG_INT32 = 6, GI_TYPE_TAG_UINT32 = 7, GI_TYPE_TAG_INT64 = 8, @@ -407,7 +407,7 @@ GIInterfaceInfo * g_error_domain_info_get_codes (GIErrorDomainInfo *in /* GIValueInfo */ - + glong g_value_info_get_value (GIValueInfo *info); @@ -477,8 +477,8 @@ GITypeTag g_enum_info_get_storage_type (GIEnumInfo *in /* GIObjectInfo */ -const gchar * g_object_info_get_type_name (GIObjectInfo *info); -const gchar * g_object_info_get_type_init (GIObjectInfo *info); +const gchar * g_object_info_get_type_name (GIObjectInfo *info); +const gchar * g_object_info_get_type_init (GIObjectInfo *info); gboolean g_object_info_get_abstract (GIObjectInfo *info); GIObjectInfo * g_object_info_get_parent (GIObjectInfo *info); gint g_object_info_get_n_interfaces (GIObjectInfo *info); @@ -508,7 +508,7 @@ GIConstantInfo * g_object_info_get_constant (GIObjectInfo *in gint n); GIStructInfo * g_object_info_get_class_struct (GIObjectInfo *info); - + /* GIInterfaceInfo */ gint g_interface_info_get_n_prerequisites (GIInterfaceInfo *info); @@ -521,7 +521,7 @@ gint g_interface_info_get_n_methods (GIInterfaceInfo *in GIFunctionInfo * g_interface_info_get_method (GIInterfaceInfo *info, gint n); GIFunctionInfo * g_interface_info_find_method (GIInterfaceInfo *info, - const gchar *name); + const gchar *name); gint g_interface_info_get_n_signals (GIInterfaceInfo *info); GISignalInfo * g_interface_info_get_signal (GIInterfaceInfo *info, gint n); diff --git a/girepository/girffi.c b/girepository/girffi.c index 769cd6b0..88cafec9 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -114,7 +114,7 @@ g_ir_ffi_get_ffi_type (GITypeTag tag, g_assert_not_reached (); return NULL; -} +} /** * g_type_info_get_ffi_type: @@ -140,13 +140,13 @@ g_callable_info_get_ffi_arg_types (GICallableInfo *callable_info) { ffi_type **arg_types; gint n_args, i; - + g_return_val_if_fail (callable_info != NULL, NULL); n_args = g_callable_info_get_n_args (callable_info); - + arg_types = (ffi_type **) g_new0 (ffi_type *, n_args + 1); - + for (i = 0; i < n_args; ++i) { GIArgInfo *arg_info = g_callable_info_get_arg (callable_info, i); @@ -181,7 +181,7 @@ g_callable_info_get_ffi_return_type (GICallableInfo *callable_info) type_tag = g_type_info_get_tag (return_type); return_ffi_type = g_type_info_get_ffi_type (return_type); g_base_info_unref((GIBaseInfo*)return_type); - + return return_ffi_type; } @@ -212,12 +212,12 @@ g_function_info_prep_invoker (GIFunctionInfo *info, gboolean is_method; gboolean throws; gint n_args, n_invoke_args, i; - + g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (invoker != NULL, FALSE); - + symbol = g_function_info_get_symbol ((GIFunctionInfo*) info); - + if (!g_typelib_symbol (g_base_info_get_typelib((GIBaseInfo *) info), symbol, &(invoker->native_address))) { @@ -249,7 +249,7 @@ g_function_info_prep_invoker (GIFunctionInfo *info, /* TODO: avoid malloc here? */ atypes = g_malloc0 (sizeof (ffi_type*) * n_invoke_args); - + if (is_method) { atypes[0] = &ffi_type_pointer; @@ -286,7 +286,7 @@ g_function_info_prep_invoker (GIFunctionInfo *info, /** * g_function_info_invoker_destroy: * @invoker: A #GIFunctionInvoker - * + * * Release all resources allocated for the internals of @invoker; callers * are responsible for freeing any resources allocated for the structure * itself however. @@ -320,11 +320,11 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info, { ffi_closure *closure; ffi_status status; - + g_return_val_if_fail (callable_info != NULL, FALSE); g_return_val_if_fail (cif != NULL, FALSE); g_return_val_if_fail (callback != NULL, FALSE); - + closure = mmap (NULL, sizeof (ffi_closure), PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, sysconf (_SC_PAGE_SIZE)); @@ -359,7 +359,7 @@ g_callable_info_prepare_closure (GICallableInfo *callable_info, munmap(closure, sizeof (closure)); return NULL; } - + return closure; } diff --git a/girepository/girffi.h b/girepository/girffi.h index 10a20a24..54ce7b58 100644 --- a/girepository/girffi.h +++ b/girepository/girffi.h @@ -36,7 +36,7 @@ typedef struct _GIFunctionInvoker GIFunctionInvoker; struct _GIFunctionInvoker { ffi_cif cif; gpointer native_address; - + gpointer padding[3]; }; @@ -45,7 +45,7 @@ ffi_type * g_type_info_get_ffi_type (GITypeInfo *info); gboolean g_function_info_prep_invoker (GIFunctionInfo *info, GIFunctionInvoker *invoker, GError **error); - + void g_function_invoker_destroy (GIFunctionInvoker *invoker); diff --git a/girepository/girmodule.c b/girepository/girmodule.c index b954d15d..66efceb2 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -1,4 +1,4 @@ -/* GObject introspection: Typelib creation +/* GObject introspection: Typelib creation * * Copyright (C) 2005 Matthias Clasen * @@ -30,13 +30,13 @@ GIrModule * -g_ir_module_new (const gchar *name, +g_ir_module_new (const gchar *name, const gchar *version, const gchar *shared_library, const gchar *c_prefix) { GIrModule *module; - + module = g_new0 (GIrModule, 1); module->name = g_strdup (name); @@ -94,18 +94,18 @@ g_ir_module_fatal (GIrModule *module, char *formatted; va_list args; - + va_start (args, msg); - + formatted = g_strdup_vprintf (msg, args); - + if (line) g_printerr ("%s-%s.gir:%d: error: %s\n", module->name, module->version, line, formatted); else g_printerr ("%s-%s.gir: error: %s\n", module->name, module->version, formatted); - + exit (1); - + va_end (args); } @@ -247,7 +247,7 @@ g_ir_module_build_typelib (GIrModule *module, g_message ("%d entries (%d local), %d dependencies\n", n_entries, n_local_entries, g_list_length (module->dependencies)); - + dir_size = n_entries * sizeof (DirEntry); size = header_size + dir_size; @@ -256,7 +256,7 @@ g_ir_module_build_typelib (GIrModule *module, for (e = module->entries; e; e = e->next) { GIrNode *node = e->data; - + size += g_ir_node_get_full_size (node); size += g_ir_node_get_attribute_size (node); @@ -266,14 +266,14 @@ g_ir_module_build_typelib (GIrModule *module, /* Adjust size for strings allocated in header below specially */ size += ALIGN_VALUE (strlen (module->name) + 1, 4); - if (module->shared_library) + if (module->shared_library) size += ALIGN_VALUE (strlen (module->shared_library) + 1, 4); if (dependencies != NULL) size += ALIGN_VALUE (strlen (dependencies) + 1, 4); if (module->c_prefix != NULL) size += ALIGN_VALUE (strlen (module->c_prefix) + 1, 4); - g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n", + g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n", size, header_size, dir_size, size - header_size - dir_size); data = g_malloc0 (size); @@ -361,13 +361,13 @@ g_ir_module_build_typelib (GIrModule *module, goto restart; } - + offset = offset2; if (node->type == G_IR_NODE_XREF) { const char *namespace = ((GIrNodeXRef*)node)->namespace; - + entry->blob_type = 0; entry->local = FALSE; entry->offset = write_string (namespace, strings, data, &offset2); @@ -419,7 +419,7 @@ g_ir_module_build_typelib (GIrModule *module, write_attributes (module, node, strings, data, &offset, &offset2); } - + g_message ("reallocating to %d bytes", offset2); data = g_realloc (data, offset2); diff --git a/girepository/girmodule.h b/girepository/girmodule.h index da3fb35d..3ebb3eb7 100644 --- a/girepository/girmodule.h +++ b/girepository/girmodule.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS typedef struct _GIrModule GIrModule; struct _GIrModule -{ +{ gchar *name; gchar *version; gchar *shared_library; diff --git a/girepository/girnode.c b/girepository/girnode.c index ede6d3b7..43bdfa63 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -213,7 +213,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_CALLBACK: { GIrNodeFunction *function = (GIrNodeFunction *)node; - + g_free (node->name); g_free (function->symbol); g_ir_node_free ((GIrNode *)function->result); @@ -226,7 +226,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_TYPE: { GIrNodeType *type = (GIrNodeType *)node; - + g_free (node->name); g_ir_node_free ((GIrNode *)type->parameter_type1); g_ir_node_free ((GIrNode *)type->parameter_type2); @@ -240,7 +240,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_PARAM: { GIrNodeParam *param = (GIrNodeParam *)node; - + g_free (node->name); g_ir_node_free ((GIrNode *)param->type); } @@ -249,7 +249,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_PROPERTY: { GIrNodeProperty *property = (GIrNodeProperty *)node; - + g_free (node->name); g_ir_node_free ((GIrNode *)property->type); } @@ -258,7 +258,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_SIGNAL: { GIrNodeSignal *signal = (GIrNodeSignal *)node; - + g_free (node->name); for (l = signal->parameters; l; l = l->next) g_ir_node_free ((GIrNode *)l->data); @@ -270,7 +270,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_VFUNC: { GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node; - + g_free (node->name); g_free (vfunc->invoker); for (l = vfunc->parameters; l; l = l->next) @@ -283,7 +283,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_FIELD: { GIrNodeField *field = (GIrNodeField *)node; - + g_free (node->name); g_ir_node_free ((GIrNode *)field->type); g_ir_node_free ((GIrNode *)field->callback); @@ -294,7 +294,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_INTERFACE: { GIrNodeInterface *iface = (GIrNodeInterface *)node; - + g_free (node->name); g_free (iface->gtype_name); g_free (iface->gtype_init); @@ -313,7 +313,7 @@ g_ir_node_free (GIrNode *node) } break; - + case G_IR_NODE_VALUE: { g_free (node->name); @@ -324,7 +324,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_FLAGS: { GIrNodeEnum *enum_ = (GIrNodeEnum *)node; - + g_free (node->name); g_free (enum_->gtype_name); g_free (enum_->gtype_init); @@ -338,7 +338,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_BOXED: { GIrNodeBoxed *boxed = (GIrNodeBoxed *)node; - + g_free (node->name); g_free (boxed->gtype_name); g_free (boxed->gtype_init); @@ -366,7 +366,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_CONSTANT: { GIrNodeConstant *constant = (GIrNodeConstant *)node; - + g_free (node->name); g_free (constant->value); g_ir_node_free ((GIrNode *)constant->type); @@ -376,7 +376,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_ERROR_DOMAIN: { GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node; - + g_free (node->name); g_free (domain->getquark); g_free (domain->codes); @@ -386,7 +386,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_XREF: { GIrNodeXRef *xref = (GIrNodeXRef *)node; - + g_free (node->name); g_free (xref->namespace); } @@ -395,7 +395,7 @@ g_ir_node_free (GIrNode *node) case G_IR_NODE_UNION: { GIrNodeUnion *union_ = (GIrNodeUnion *)node; - + g_free (node->name); g_free (union_->gtype_name); g_free (union_->gtype_init); @@ -411,7 +411,7 @@ g_ir_node_free (GIrNode *node) default: g_error ("Unhandled node type %d\n", node->type); break; - } + } g_hash_table_destroy (node->attributes); @@ -472,7 +472,7 @@ g_ir_node_get_size (GIrNode *node) case G_IR_NODE_FLAGS: { GIrNodeEnum *enum_ = (GIrNodeEnum *)node; - + size = sizeof (EnumBlob); for (l = enum_->values; l; l = l->next) size += g_ir_node_get_size ((GIrNode *)l->data); @@ -549,7 +549,7 @@ g_ir_node_get_size (GIrNode *node) } break; - default: + default: g_error ("Unhandled node type '%s'\n", g_ir_node_type_to_string (node->type)); size = 0; @@ -617,12 +617,12 @@ g_ir_node_get_full_size_internal (GIrNode *parent, case G_IR_NODE_PARAM: { GIrNodeParam *param = (GIrNodeParam *)node; - + /* See the comment in the G_IR_NODE_PARAM/ArgBlob writing below */ size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob); if (node->name) size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type); + size += g_ir_node_get_full_size_internal (node, (GIrNode *)param->type); } break; @@ -661,7 +661,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, case GI_TYPE_TAG_ERROR: { gint n; - + if (type->errors) n = g_strv_length (type->errors); else @@ -719,7 +719,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, case G_IR_NODE_FLAGS: { GIrNodeEnum *enum_ = (GIrNodeEnum *)node; - + size = sizeof (EnumBlob); size += ALIGN_VALUE (strlen (node->name) + 1, 4); if (enum_->gtype_name) @@ -729,7 +729,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, } for (l = enum_->values; l; l = l->next) - size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data); + size += g_ir_node_get_full_size_internal (node, (GIrNode *)l->data); } break; @@ -774,10 +774,10 @@ g_ir_node_get_full_size_internal (GIrNode *parent, case G_IR_NODE_PROPERTY: { GIrNodeProperty *prop = (GIrNodeProperty *)node; - + size = sizeof (PropertyBlob); size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type); + size += g_ir_node_get_full_size_internal (node, (GIrNode *)prop->type); } break; @@ -826,7 +826,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, size += ALIGN_VALUE (strlen (node->name) + 1, 4); /* FIXME non-string values */ size += ALIGN_VALUE (strlen (constant->value) + 1, 4); - size += g_ir_node_get_full_size_internal (node, (GIrNode *)constant->type); + size += g_ir_node_get_full_size_internal (node, (GIrNode *)constant->type); } break; @@ -843,7 +843,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, case G_IR_NODE_XREF: { GIrNodeXRef *xref = (GIrNodeXRef *)node; - + size = 0; size += ALIGN_VALUE (strlen (node->name) + 1, 4); size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4); @@ -867,7 +867,7 @@ g_ir_node_get_full_size_internal (GIrNode *parent, } break; - default: + default: g_error ("Unknown type tag %d\n", node->type); size = 0; } @@ -947,7 +947,7 @@ g_ir_node_add_member (GIrNode *node, { g_return_if_fail (node != NULL); g_return_if_fail (member != NULL); - + switch (node->type) { case G_IR_NODE_OBJECT: @@ -1026,7 +1026,7 @@ parse_boolean_value (const gchar *str) { if (strcmp (str, "TRUE") == 0) return TRUE; - + if (strcmp (str, "FALSE") == 0) return FALSE; @@ -1048,31 +1048,31 @@ find_entry_node (GIrModule *module, g_assert (name != NULL); g_assert (strlen (name) > 0); - + names = g_strsplit (name, ".", 0); n_names = g_strv_length (names); if (n_names > 2) g_error ("Too many name parts"); - + for (l = module->entries, i = 1; l; l = l->next, i++) { GIrNode *node = (GIrNode *)l->data; - + if (n_names > 1) { if (node->type != G_IR_NODE_XREF) continue; - + if (((GIrNodeXRef *)node)->namespace == NULL || strcmp (((GIrNodeXRef *)node)->namespace, names[0]) != 0) continue; } - + if (strcmp (node->name, names[n_names - 1]) == 0) { if (idx) *idx = i; - + result = node; goto out; } @@ -1084,9 +1084,9 @@ find_entry_node (GIrModule *module, ((GIrNodeXRef *)node)->namespace = g_strdup (names[0]); node->name = g_strdup (names[1]); - + module->entries = g_list_append (module->entries, node); - + if (idx) *idx = g_list_length (module->entries); @@ -1229,23 +1229,23 @@ get_index_of_member_type (GIrNodeInterface *node, } static void -serialize_type (GIrModule *module, +serialize_type (GIrModule *module, GList *modules, - GIrNodeType *node, + GIrNodeType *node, GString *str) { gint i; const gchar* basic[] = { - "void", - "boolean", - "int8", - "uint8", - "int16", - "uint16", - "int32", - "uint32", - "int64", - "uint64", + "void", + "boolean", + "int8", + "uint8", + "int16", + "uint16", + "int32", + "uint32", + "int64", + "uint64", "short", "ushort", "int", @@ -1254,14 +1254,14 @@ serialize_type (GIrModule *module, "ulong", "ssize", "size", - "float", + "float", "double", "time_t", "GType", - "utf8", + "utf8", "filename", }; - + if (node->tag < GI_TYPE_TAG_ARRAY) { g_string_append_printf (str, "%s%s", basic[node->tag], @@ -1276,11 +1276,11 @@ serialize_type (GIrModule *module, g_string_append_printf (str, "length=%d", node->length); else if (node->has_size) g_string_append_printf (str, "fixed-size=%d", node->size); - + if (node->zero_terminated) - g_string_append_printf (str, "%szero-terminated=1", + g_string_append_printf (str, "%szero-terminated=1", node->has_length ? "," : ""); - + g_string_append (str, "]"); } else if (node->tag == GI_TYPE_TAG_INTERFACE) @@ -1309,9 +1309,9 @@ serialize_type (GIrModule *module, g_string_append (str, "GList"); if (node->parameter_type1) { - g_string_append (str, "<"); + g_string_append (str, "<"); serialize_type (module, modules, node->parameter_type1, str); - g_string_append (str, ">"); + g_string_append (str, ">"); } } else if (node->tag == GI_TYPE_TAG_GSLIST) @@ -1319,9 +1319,9 @@ serialize_type (GIrModule *module, g_string_append (str, "GSList"); if (node->parameter_type1) { - g_string_append (str, "<"); + g_string_append (str, "<"); serialize_type (module, modules, node->parameter_type1, str); - g_string_append (str, ">"); + g_string_append (str, ">"); } } else if (node->tag == GI_TYPE_TAG_GHASH) @@ -1329,11 +1329,11 @@ serialize_type (GIrModule *module, g_string_append (str, "GHashTable<"); if (node->parameter_type1) { - g_string_append (str, "<"); + g_string_append (str, "<"); serialize_type (module, modules, node->parameter_type1, str); - g_string_append (str, ","); + g_string_append (str, ","); serialize_type (module, modules, node->parameter_type2, str); - g_string_append (str, ">"); + g_string_append (str, ">"); } } else if (node->tag == GI_TYPE_TAG_ERROR) @@ -1341,14 +1341,14 @@ serialize_type (GIrModule *module, g_string_append (str, "GError"); if (node->errors) { - g_string_append (str, "<"); + g_string_append (str, "<"); for (i = 0; node->errors[i]; i++) { if (i > 0) g_string_append (str, ","); g_string_append (str, node->errors[i]); } - g_string_append (str, ">"); + g_string_append (str, ">"); } } } @@ -1450,27 +1450,27 @@ g_ir_node_build_typelib (GIrNode *node, SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset]; *offset += sizeof (SimpleTypeBlob); - + if (type->tag < GI_TYPE_TAG_ARRAY || type->tag == GI_TYPE_TAG_UTF8 || type->tag == GI_TYPE_TAG_FILENAME) - { + { blob->flags.reserved = 0; blob->flags.reserved2 = 0; blob->flags.pointer = type->is_pointer; blob->flags.reserved3 = 0; blob->flags.tag = type->tag; } - else + else { GString *str; gchar *s; gpointer value; - + str = g_string_new (0); serialize_type (module, modules, type, str); s = g_string_free (str, FALSE); - + types_count += 1; value = g_hash_table_lookup (types, s); if (value) @@ -1482,7 +1482,7 @@ g_ir_node_build_typelib (GIrNode *node, { unique_types_count += 1; g_hash_table_insert (types, s, GUINT_TO_POINTER(*offset2)); - + blob->offset = *offset2; switch (type->tag) { @@ -1490,7 +1490,7 @@ g_ir_node_build_typelib (GIrNode *node, { ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2]; guint32 pos; - + array->pointer = 1; array->reserved = 0; array->tag = type->tag; @@ -1504,15 +1504,15 @@ g_ir_node_build_typelib (GIrNode *node, array->dimensions.size = type->size; else array->dimensions.length = -1; - + pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type); *offset2 += sizeof (ArrayTypeBlob); - + g_ir_node_build_typelib ((GIrNode *)type->parameter_type1, node, build, &pos, offset2); } break; - + case GI_TYPE_TAG_INTERFACE: { InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2]; @@ -1526,69 +1526,69 @@ g_ir_node_build_typelib (GIrNode *node, } break; - + case GI_TYPE_TAG_GLIST: case GI_TYPE_TAG_GSLIST: { ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; guint32 pos; - + param->pointer = 1; param->reserved = 0; param->tag = type->tag; param->reserved2 = 0; param->n_types = 1; - + pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob); - - g_ir_node_build_typelib ((GIrNode *)type->parameter_type1, + + g_ir_node_build_typelib ((GIrNode *)type->parameter_type1, node, build, &pos, offset2); } break; - + case GI_TYPE_TAG_GHASH: { ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; guint32 pos; - + param->pointer = 1; param->reserved = 0; param->tag = type->tag; param->reserved2 = 0; param->n_types = 2; - + pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2; - - g_ir_node_build_typelib ((GIrNode *)type->parameter_type1, + + g_ir_node_build_typelib ((GIrNode *)type->parameter_type1, node, build, &pos, offset2); - g_ir_node_build_typelib ((GIrNode *)type->parameter_type2, + g_ir_node_build_typelib ((GIrNode *)type->parameter_type2, node, build, &pos, offset2); } break; - + case GI_TYPE_TAG_ERROR: { ErrorTypeBlob *blob = (ErrorTypeBlob *)&data[*offset2]; gint i; - + blob->pointer = 1; blob->reserved = 0; blob->tag = type->tag; blob->reserved2 = 0; - if (type->errors) + if (type->errors) blob->n_domains = g_strv_length (type->errors); else blob->n_domains = 0; - + *offset2 = ALIGN_VALUE (*offset2 + G_STRUCT_OFFSET (ErrorTypeBlob, domains) + 2 * blob->n_domains, 4); for (i = 0; i < blob->n_domains; i++) blob->domains[i] = find_entry (module, modules, type->errors[i]); } break; - + default: g_error ("Unknown type tag %d\n", type->tag); break; @@ -1649,7 +1649,7 @@ g_ir_node_build_typelib (GIrNode *node, blob->construct_only = prop->construct_only; blob->reserved = 0; - g_ir_node_build_typelib ((GIrNode *)prop->type, + g_ir_node_build_typelib ((GIrNode *)prop->type, node, build, offset, offset2); } break; @@ -1683,7 +1683,7 @@ g_ir_node_build_typelib (GIrNode *node, g_debug ("building function '%s'", function->symbol); - g_ir_node_build_typelib ((GIrNode *)function->result->type, + g_ir_node_build_typelib ((GIrNode *)function->result->type, node, build, &signature, offset2); blob2->may_return_null = function->result->allow_none; @@ -1693,7 +1693,7 @@ g_ir_node_build_typelib (GIrNode *node, blob2->n_arguments = n; signature += 4; - + for (l = function->parameters; l; l = l->next) { GIrNode *param = (GIrNode *)l->data; @@ -1723,8 +1723,8 @@ g_ir_node_build_typelib (GIrNode *node, blob->reserved = 0; blob->name = write_string (node->name, strings, data, offset2); blob->signature = signature; - - g_ir_node_build_typelib ((GIrNode *)function->result->type, + + g_ir_node_build_typelib ((GIrNode *)function->result->type, node, build, &signature, offset2); blob2->may_return_null = function->result->allow_none; @@ -1734,7 +1734,7 @@ g_ir_node_build_typelib (GIrNode *node, blob2->n_arguments = n; signature += 4; - + for (l = function->parameters; l; l = l->next) { GIrNode *param = (GIrNode *)l->data; @@ -1772,8 +1772,8 @@ g_ir_node_build_typelib (GIrNode *node, blob->class_closure = 0; /* FIXME */ blob->name = write_string (node->name, strings, data, offset2); blob->signature = signature; - - g_ir_node_build_typelib ((GIrNode *)signal->result->type, + + g_ir_node_build_typelib ((GIrNode *)signal->result->type, node, build, &signature, offset2); blob2->may_return_null = signal->result->allow_none; @@ -1783,7 +1783,7 @@ g_ir_node_build_typelib (GIrNode *node, blob2->n_arguments = n; signature += 4; - + for (l = signal->parameters; l; l = l->next) { GIrNode *param = (GIrNode *)l->data; @@ -1829,8 +1829,8 @@ g_ir_node_build_typelib (GIrNode *node, blob->struct_offset = vfunc->offset; blob->reserved2 = 0; blob->signature = signature; - - g_ir_node_build_typelib ((GIrNode *)vfunc->result->type, + + g_ir_node_build_typelib ((GIrNode *)vfunc->result->type, node, build, &signature, offset2); blob2->may_return_null = vfunc->result->allow_none; @@ -1840,7 +1840,7 @@ g_ir_node_build_typelib (GIrNode *node, blob2->n_arguments = n; signature += 4; - + for (l = vfunc->parameters; l; l = l->next) { GIrNode *param = (GIrNode *)l->data; @@ -1873,7 +1873,7 @@ g_ir_node_build_typelib (GIrNode *node, blob->reserved = 0; blob->closure = param->closure; blob->destroy = param->destroy; - + g_ir_node_build_typelib ((GIrNode *)param->type, node, build, offset, offset2); } break; @@ -1883,7 +1883,7 @@ g_ir_node_build_typelib (GIrNode *node, StructBlob *blob = (StructBlob *)&data[*offset]; GIrNodeStruct *struct_ = (GIrNodeStruct *)node; GList *members; - + blob->blob_type = BLOB_TYPE_STRUCT; blob->deprecated = struct_->deprecated; blob->is_gtype_struct = struct_->is_gtype_struct; @@ -1995,7 +1995,7 @@ g_ir_node_build_typelib (GIrNode *node, { *offset += 28; blob->discriminated = TRUE; - g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type, + g_ir_node_build_typelib ((GIrNode *)union_->discriminator_type, build, offset, offset2); } else @@ -2004,7 +2004,7 @@ g_ir_node_build_typelib (GIrNode *node, *offset += sizeof (UnionBlob); blob->discriminated = FALSE; blob->discriminator_type.offset = 0; - + members = g_list_copy (union_->members); g_ir_node_build_members (&members, G_IR_NODE_FIELD, &blob->n_fields, @@ -2022,7 +2022,7 @@ g_ir_node_build_typelib (GIrNode *node, for (l = union_->discriminators; l; l = l->next) { GIrNode *member = (GIrNode *)l->data; - + g_ir_node_build_typelib (member, node, build, offset, offset2); } } @@ -2035,13 +2035,13 @@ g_ir_node_build_typelib (GIrNode *node, EnumBlob *blob = (EnumBlob *)&data[*offset]; GIrNodeEnum *enum_ = (GIrNodeEnum *)node; - *offset += sizeof (EnumBlob); + *offset += sizeof (EnumBlob); if (node->type == G_IR_NODE_ENUM) blob->blob_type = BLOB_TYPE_ENUM; else blob->blob_type = BLOB_TYPE_FLAGS; - + blob->deprecated = enum_->deprecated; blob->reserved = 0; blob->storage_type = enum_->storage_type; @@ -2071,7 +2071,7 @@ g_ir_node_build_typelib (GIrNode *node, } } break; - + case G_IR_NODE_OBJECT: { ObjectBlob *blob = (ObjectBlob *)&data[*offset]; @@ -2101,7 +2101,7 @@ g_ir_node_build_typelib (GIrNode *node, blob->n_signals = 0; blob->n_vfuncs = 0; blob->n_constants = 0; - + *offset += sizeof(ObjectBlob); for (l = object->interfaces; l; l = l->next) { @@ -2109,7 +2109,7 @@ g_ir_node_build_typelib (GIrNode *node, *(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data); *offset += 2; } - + members = g_list_copy (object->members); *offset = ALIGN_VALUE (*offset, 4); @@ -2164,7 +2164,7 @@ g_ir_node_build_typelib (GIrNode *node, blob->n_signals = 0; blob->n_vfuncs = 0; blob->n_constants = 0; - + *offset += sizeof (InterfaceBlob); for (l = iface->prerequisites; l; l = l->next) { @@ -2172,7 +2172,7 @@ g_ir_node_build_typelib (GIrNode *node, *(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data); *offset += 2; } - + members = g_list_copy (iface->members); *offset = ALIGN_VALUE (*offset, 4); @@ -2306,7 +2306,7 @@ g_ir_node_build_typelib (GIrNode *node, DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), glong); break; case GI_TYPE_TAG_SIZE: /* FIXME */ - case GI_TYPE_TAG_TIME_T: + case GI_TYPE_TAG_TIME_T: case GI_TYPE_TAG_ULONG: blob->size = sizeof (gulong); DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), gulong); @@ -2326,14 +2326,14 @@ g_ir_node_build_typelib (GIrNode *node, break; } *offset2 += ALIGN_VALUE (blob->size, 4); - + g_ir_node_build_typelib ((GIrNode *)constant->type, node, build, &pos, offset2); } break; default: g_assert_not_reached (); } - + g_debug ("node %s%s%s%p type '%s', offset %d -> %d, offset2 %d -> %d", node->name ? "'" : "", node->name ? node->name : "", @@ -2347,12 +2347,12 @@ g_ir_node_build_typelib (GIrNode *node, } /* if str is already in the pool, return previous location, otherwise write str - * to the typelib at offset, put it in the pool and update offset. If the + * to the typelib at offset, put it in the pool and update offset. If the * typelib is not large enough to hold the string, reallocate it. */ -guint32 +guint32 write_string (const gchar *str, - GHashTable *strings, + GHashTable *strings, guchar *data, guint32 *offset) { @@ -2363,7 +2363,7 @@ write_string (const gchar *str, string_size += strlen (str); value = g_hash_table_lookup (strings, str); - + if (value) return GPOINTER_TO_UINT (value); @@ -2376,7 +2376,7 @@ write_string (const gchar *str, *offset = ALIGN_VALUE (start + strlen (str) + 1, 4); strcpy ((gchar*)&data[start], str); - + return start; } diff --git a/girepository/girnode.h b/girepository/girnode.h index 427f8e90..14848847 100644 --- a/girepository/girnode.h +++ b/girepository/girnode.h @@ -28,7 +28,7 @@ G_BEGIN_DECLS typedef struct _GIrTypelibBuild GIrTypelibBuild; -typedef struct _GIrNode GIrNode; +typedef struct _GIrNode GIrNode; typedef struct _GIrNodeFunction GIrNodeFunction; typedef struct _GIrNodeParam GIrNodeParam; typedef struct _GIrNodeType GIrNodeType; @@ -53,10 +53,10 @@ struct _GIrTypelibBuild { GHashTable *types; GList *offset_ordered_nodes; guint32 n_attributes; - guchar *data; + guchar *data; }; -typedef enum +typedef enum { G_IR_NODE_INVALID = 0, G_IR_NODE_FUNCTION = 1, @@ -64,7 +64,7 @@ typedef enum G_IR_NODE_STRUCT = 3, G_IR_NODE_BOXED = 4, G_IR_NODE_ENUM = 5, - G_IR_NODE_FLAGS = 6, + G_IR_NODE_FLAGS = 6, G_IR_NODE_OBJECT = 7, G_IR_NODE_INTERFACE = 8, G_IR_NODE_CONSTANT = 9, @@ -102,7 +102,7 @@ struct _GIrNodeFunction GIrNode node; gboolean deprecated; - gboolean is_varargs; /* Not in typelib yet */ + gboolean is_varargs; /* Not in typelib yet */ gboolean is_method; gboolean is_setter; @@ -117,7 +117,7 @@ struct _GIrNodeFunction GList *parameters; }; -struct _GIrNodeType +struct _GIrNodeType { GIrNode node; @@ -138,15 +138,15 @@ struct _GIrNodeType gint length; gboolean has_size; gint size; - + GIrNodeType *parameter_type1; - GIrNodeType *parameter_type2; + GIrNodeType *parameter_type2; gchar *interface; gchar **errors; }; -struct _GIrNodeParam +struct _GIrNodeParam { GIrNode node; @@ -159,10 +159,10 @@ struct _GIrNodeParam gboolean transfer; gboolean shallow_transfer; GIScopeType scope; - + gint8 closure; gint8 destroy; - + GIrNodeType *type; }; @@ -177,11 +177,11 @@ struct _GIrNodeProperty gboolean writable; gboolean construct; gboolean construct_only; - + GIrNodeType *type; }; -struct _GIrNodeSignal +struct _GIrNodeSignal { GIrNode node; @@ -194,30 +194,30 @@ struct _GIrNodeSignal gboolean detailed; gboolean action; gboolean no_hooks; - + gboolean has_class_closure; gboolean true_stops_emit; - + gint class_closure; - + GList *parameters; - GIrNodeParam *result; + GIrNodeParam *result; }; -struct _GIrNodeVFunc +struct _GIrNodeVFunc { GIrNode node; - gboolean is_varargs; /* Not in typelib yet */ + gboolean is_varargs; /* Not in typelib yet */ gboolean must_chain_up; gboolean must_be_implemented; gboolean must_not_be_implemented; gboolean is_class_closure; - + char *invoker; GList *parameters; - GIrNodeParam *result; + GIrNodeParam *result; gint offset; }; @@ -231,7 +231,7 @@ struct _GIrNodeField gint bits; gint offset; GIrNodeFunction *callback; - + GIrNodeType *type; }; @@ -247,13 +247,13 @@ struct _GIrNodeInterface gchar *parent; gchar *glib_type_struct; - + GList *interfaces; GList *prerequisites; gint alignment; gint size; - + GList *members; }; @@ -273,7 +273,7 @@ struct _GIrNodeConstant gboolean deprecated; GIrNodeType *type; - + gchar *value; }; @@ -291,7 +291,7 @@ struct _GIrNodeEnum }; struct _GIrNodeBoxed -{ +{ GIrNode node; gboolean deprecated; @@ -301,7 +301,7 @@ struct _GIrNodeBoxed gint alignment; gint size; - + GList *members; }; @@ -318,7 +318,7 @@ struct _GIrNodeStruct gint alignment; gint size; - + GList *members; }; @@ -327,7 +327,7 @@ struct _GIrNodeUnion GIrNode node; gboolean deprecated; - + GList *members; GList *discriminators; @@ -347,7 +347,7 @@ struct _GIrNodeErrorDomain GIrNode node; gboolean deprecated; - + gchar *name; gchar *getquark; gchar *codes; @@ -370,7 +370,7 @@ 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, + GHashTable *strings, guchar *data, guint32 *offset); diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index dcfd75e5..ab9bde0b 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -235,7 +235,7 @@ get_type_size_alignment (GIrNodeType *type, if (type->tag == GI_TYPE_TAG_ARRAY) { gint elt_size, elt_alignment; - + if (!type->has_size || !get_type_size_alignment(type->parameter_type1, module, modules, &elt_size, &elt_alignment, who)) @@ -244,10 +244,10 @@ get_type_size_alignment (GIrNodeType *type, *alignment = -1; return FALSE; } - + *size = type->size * elt_size; *alignment = elt_alignment; - + return TRUE; } else if (type->is_pointer) @@ -300,7 +300,7 @@ get_field_size_alignment (GIrNodeField *field, { gchar *who; gboolean success; - + who = g_strdup_printf ("field %s.%s.%s", module->name, parent_node->name, ((GIrNode *)field)->name); if (field->callback) diff --git a/girepository/girparser.c b/girepository/girparser.c index 77416177..12c1d989 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -124,7 +124,7 @@ static void cleanup (GMarkupParseContext *context, GError *error, gpointer user_data); -static GMarkupParser markup_parser = +static GMarkupParser markup_parser = { start_element_handler, end_element_handler, @@ -141,7 +141,7 @@ start_alias (GMarkupParseContext *context, ParseContext *ctx, GError **error); -static const gchar *find_attribute (const gchar *name, +static const gchar *find_attribute (const gchar *name, const gchar **attribute_names, const gchar **attribute_values); @@ -188,7 +188,7 @@ firstpass_start_element_handler (GMarkupParseContext *context, { ParseContext *ctx = user_data; - if (strcmp (element_name, "alias") == 0) + if (strcmp (element_name, "alias") == 0) { start_alias (context, element_name, attribute_names, attribute_values, ctx, error); @@ -219,7 +219,7 @@ firstpass_end_element_handler (GMarkupParseContext *context, { } -static GMarkupParser firstpass_parser = +static GMarkupParser firstpass_parser = { firstpass_start_element_handler, firstpass_end_element_handler, @@ -235,12 +235,12 @@ locate_gir (GIrParser *parser, const gchar *const *datadirs; const gchar *const *dir; char *path = NULL; - + datadirs = g_get_system_data_dirs (); - + if (parser->includes != NULL) { - for (dir = (const gchar *const *)parser->includes; *dir; dir++) + for (dir = (const gchar *const *)parser->includes; *dir; dir++) { path = g_build_filename (*dir, girname, NULL); if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) @@ -249,7 +249,7 @@ locate_gir (GIrParser *parser, path = NULL; } } - for (dir = datadirs; *dir; dir++) + for (dir = datadirs; *dir; dir++) { path = g_build_filename (*dir, GIR_SUFFIX, girname, NULL); if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) @@ -300,16 +300,16 @@ backtrace_stderr (void) static const gchar * -find_attribute (const gchar *name, +find_attribute (const gchar *name, const gchar **attribute_names, const gchar **attribute_values) { gint i; - + for (i = 0; attribute_names[i] != NULL; i++) if (strcmp (attribute_names[i], name) == 0) return attribute_values[i]; - + return 0; } @@ -325,10 +325,10 @@ static GIrNode * pop_node (ParseContext *ctx) { g_assert (ctx->node_stack != 0); - + GSList *top = ctx->node_stack; GIrNode *node = top->data; - + g_debug ("popping node %d %s", node->type, node->name); ctx->node_stack = top->next; g_slist_free_1 (top); @@ -379,21 +379,21 @@ static BasicTypeInfo basic_types[] = { { "double", GI_TYPE_TAG_DOUBLE, 0 }, { "time_t", GI_TYPE_TAG_TIME_T, 0 }, { "GType", GI_TYPE_TAG_GTYPE, 0 }, - { "utf8", GI_TYPE_TAG_UTF8, 1 }, + { "utf8", GI_TYPE_TAG_UTF8, 1 }, { "filename", GI_TYPE_TAG_FILENAME,1 }, -}; +}; static const BasicTypeInfo * parse_basic (const char *str) { gint i; gint n_basic = G_N_ELEMENTS (basic_types); - + for (i = 0; i < n_basic; i++) { if (g_str_has_prefix (str, basic_types[i].str)) return &(basic_types[i]); - } + } return NULL; } @@ -401,21 +401,21 @@ static GIrNodeType * parse_type_internal (const gchar *str, char **next, gboolean in_glib, gboolean in_gobject) { - const BasicTypeInfo *basic; + const BasicTypeInfo *basic; GIrNodeType *type; char *temporary_type = NULL; - + type = (GIrNodeType *)g_ir_node_new (G_IR_NODE_TYPE); - + type->unparsed = g_strdup (str); /* See comment below on GLib.List handling */ - if (in_gobject && strcmp (str, "Type") == 0) + if (in_gobject && strcmp (str, "Type") == 0) { temporary_type = g_strdup ("GLib.Type"); str = temporary_type; } - + basic = parse_basic (str); if (basic != NULL) { @@ -429,7 +429,7 @@ parse_type_internal (const gchar *str, char **next, gboolean in_glib, { /* If we're inside GLib, handle "List" etc. by prefixing with * "GLib." so the parsing code below doesn't have to get more - * special. + * special. */ if (g_str_has_prefix (str, "List<") || strcmp (str, "List") == 0) @@ -495,12 +495,12 @@ parse_type_internal (const gchar *str, char **next, gboolean in_glib, type->is_error = TRUE; type->is_pointer = TRUE; str += strlen ("Error"); - + if (*str == '<') { (str)++; char *tmp, *end; - + end = strchr (str, '>'); tmp = g_strndup (str, end - str); type->errors = g_strsplit (tmp, ",", 0); @@ -509,23 +509,23 @@ parse_type_internal (const gchar *str, char **next, gboolean in_glib, str = end; } } - else + else { type->tag = GI_TYPE_TAG_INTERFACE; - type->is_interface = TRUE; + type->is_interface = TRUE; const char *start = str; /* must be an interface type */ - while (g_ascii_isalnum (*str) || - *str == '.' || - *str == '-' || + while (g_ascii_isalnum (*str) || + *str == '.' || + *str == '-' || *str == '_' || *str == ':') (str)++; type->interface = g_strndup (start, str - start); } - + if (next) *next = (char*)str; g_assert (type->tag >= 0 && type->tag <= GI_TYPE_TAG_ERROR); @@ -534,7 +534,7 @@ parse_type_internal (const gchar *str, char **next, gboolean in_glib, /* error: */ g_ir_node_free ((GIrNode *)type); - g_free (temporary_type); + g_free (temporary_type); return NULL; } @@ -574,7 +574,7 @@ resolve_aliases (ParseContext *ctx, const gchar *type) lookup = type; g_free (prefixed); - + return lookup; } @@ -598,9 +598,9 @@ is_disguised_structure (ParseContext *ctx, const gchar *type) result = g_hash_table_lookup (ctx->current_module->disguised_structures, lookup) != NULL; - + g_free (prefixed); - + return result; } @@ -650,7 +650,7 @@ start_glib_boxed (GMarkupParseContext *context, typename = find_attribute ("glib:type-name", attribute_names, attribute_values); typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) { MISSING_ATTRIBUTE (context, error, element_name, "glib:name"); @@ -668,7 +668,7 @@ start_glib_boxed (GMarkupParseContext *context, } boxed = (GIrNodeBoxed *) g_ir_node_new (G_IR_NODE_BOXED); - + ((GIrNode *)boxed)->name = g_strdup (name); boxed->gtype_name = g_strdup (typename); boxed->gtype_init = g_strdup (typeinit); @@ -676,11 +676,11 @@ start_glib_boxed (GMarkupParseContext *context, boxed->deprecated = TRUE; else boxed->deprecated = FALSE; - + push_node (ctx, (GIrNode *)boxed); - ctx->current_module->entries = + ctx->current_module->entries = g_list_append (ctx->current_module->entries, boxed); - + state_switch (ctx, STATE_BOXED); return TRUE; @@ -700,7 +700,7 @@ start_function (GMarkupParseContext *context, const gchar *throws; GIrNodeFunction *function; gboolean found = FALSE; - + switch (ctx->state) { case STATE_NAMESPACE: @@ -735,7 +735,7 @@ start_function (GMarkupParseContext *context, symbol = find_attribute ("c:identifier", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); throws = find_attribute ("throws", attribute_names, attribute_values); - + if (name == NULL) { MISSING_ATTRIBUTE (context, error, element_name, "name"); @@ -748,7 +748,7 @@ start_function (GMarkupParseContext *context, } function = (GIrNodeFunction *) g_ir_node_new (G_IR_NODE_FUNCTION); - + ((GIrNode *)function)->name = g_strdup (name); function->symbol = g_strdup (symbol); function->parameters = NULL; @@ -756,12 +756,12 @@ start_function (GMarkupParseContext *context, function->deprecated = TRUE; else function->deprecated = FALSE; - + if (strcmp (element_name, "method") == 0 || strcmp (element_name, "constructor") == 0) { function->is_method = TRUE; - + if (strcmp (element_name, "constructor") == 0) function->is_constructor = TRUE; else @@ -784,8 +784,8 @@ start_function (GMarkupParseContext *context, if (ctx->node_stack == NULL) { - ctx->current_module->entries = - g_list_append (ctx->current_module->entries, function); + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, function); } else if (ctx->current_typed) { @@ -801,7 +801,7 @@ start_function (GMarkupParseContext *context, case G_IR_NODE_OBJECT: { GIrNodeInterface *iface; - + iface = (GIrNodeInterface *)CURRENT_NODE (ctx); iface->members = g_list_append (iface->members, function); } @@ -809,7 +809,7 @@ start_function (GMarkupParseContext *context, case G_IR_NODE_BOXED: { GIrNodeBoxed *boxed; - + boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx); boxed->members = g_list_append (boxed->members, function); } @@ -817,14 +817,14 @@ start_function (GMarkupParseContext *context, case G_IR_NODE_STRUCT: { GIrNodeStruct *struct_; - + struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx); struct_->members = g_list_append (struct_->members, function); } break; case G_IR_NODE_UNION: { GIrNodeUnion *union_; - + union_ = (GIrNodeUnion *)CURRENT_NODE (ctx); union_->members = g_list_append (union_->members, function); } @@ -832,10 +832,10 @@ start_function (GMarkupParseContext *context, default: g_assert_not_reached (); } - + push_node(ctx, (GIrNode *)function); state_switch (ctx, STATE_FUNCTION); - + return TRUE; } @@ -889,7 +889,7 @@ start_parameter (GMarkupParseContext *context, const gchar *closure; const gchar *destroy; GIrNodeParam *param; - + if (!(strcmp (element_name, "parameter") == 0 && ctx->state == STATE_FUNCTION_PARAMETERS)) return FALSE; @@ -904,7 +904,7 @@ start_parameter (GMarkupParseContext *context, scope = find_attribute ("scope", attribute_names, attribute_values); closure = find_attribute ("closure", attribute_names, attribute_values); destroy = find_attribute ("destroy", attribute_names, attribute_values); - + if (name == NULL) name = "unknown"; @@ -961,12 +961,12 @@ start_parameter (GMarkupParseContext *context, param->scope = GI_SCOPE_TYPE_NOTIFIED; else param->scope = GI_SCOPE_TYPE_INVALID; - + param->closure = closure ? atoi (closure) : -1; param->destroy = destroy ? atoi (destroy) : -1; - + ((GIrNode *)param)->name = g_strdup (name); - + switch (CURRENT_NODE (ctx)->type) { case G_IR_NODE_FUNCTION: @@ -989,7 +989,7 @@ start_parameter (GMarkupParseContext *context, case G_IR_NODE_VFUNC: { GIrNodeVFunc *vfunc; - + vfunc = (GIrNodeVFunc *)CURRENT_NODE (ctx); vfunc->parameters = g_list_append (vfunc->parameters, param); } @@ -1027,16 +1027,16 @@ start_field (GMarkupParseContext *context, default: return FALSE; } - + if (strcmp (element_name, "field") != 0) return FALSE; - + name = find_attribute ("name", attribute_names, attribute_values); readable = find_attribute ("readable", attribute_names, attribute_values); writable = find_attribute ("writable", attribute_names, attribute_values); bits = find_attribute ("bits", attribute_names, attribute_values); branch = find_attribute ("branch", attribute_names, attribute_values); - + if (name == NULL) { MISSING_ATTRIBUTE (context, error, element_name, "name"); @@ -1051,18 +1051,18 @@ start_field (GMarkupParseContext *context, */ field->readable = readable == NULL || strcmp (readable, "0") == 0; field->writable = writable != NULL && strcmp (writable, "1") == 0; - + if (bits) field->bits = atoi (bits); else field->bits = 0; - + switch (CURRENT_NODE (ctx)->type) { case G_IR_NODE_OBJECT: { GIrNodeInterface *iface; - + iface = (GIrNodeInterface *)CURRENT_NODE (ctx); iface->members = g_list_append (iface->members, field); state_switch (ctx, STATE_CLASS_FIELD); @@ -1071,7 +1071,7 @@ start_field (GMarkupParseContext *context, case G_IR_NODE_INTERFACE: { GIrNodeInterface *iface; - + iface = (GIrNodeInterface *)CURRENT_NODE (ctx); iface->members = g_list_append (iface->members, field); state_switch (ctx, STATE_INTERFACE_FIELD); @@ -1080,7 +1080,7 @@ start_field (GMarkupParseContext *context, case G_IR_NODE_BOXED: { GIrNodeBoxed *boxed; - + boxed = (GIrNodeBoxed *)CURRENT_NODE (ctx); boxed->members = g_list_append (boxed->members, field); state_switch (ctx, STATE_BOXED_FIELD); @@ -1089,7 +1089,7 @@ start_field (GMarkupParseContext *context, case G_IR_NODE_STRUCT: { GIrNodeStruct *struct_; - + struct_ = (GIrNodeStruct *)CURRENT_NODE (ctx); struct_->members = g_list_append (struct_->members, field); state_switch (ctx, STATE_STRUCT_FIELD); @@ -1098,19 +1098,19 @@ start_field (GMarkupParseContext *context, case G_IR_NODE_UNION: { GIrNodeUnion *union_; - + union_ = (GIrNodeUnion *)CURRENT_NODE (ctx); union_->members = g_list_append (union_->members, field); if (branch) { GIrNodeConstant *constant; - + constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT); ((GIrNode *)constant)->name = g_strdup (name); - constant->value = g_strdup (branch); + constant->value = g_strdup (branch); constant->type = union_->discriminator_type; constant->deprecated = FALSE; - + union_->discriminators = g_list_append (union_->discriminators, constant); } state_switch (ctx, STATE_UNION_FIELD); @@ -1119,7 +1119,7 @@ start_field (GMarkupParseContext *context, default: g_assert_not_reached (); } - + return TRUE; } @@ -1182,18 +1182,18 @@ start_enum (GMarkupParseContext *context, const gchar *typename; const gchar *typeinit; const gchar *deprecated; - + name = find_attribute ("name", attribute_names, attribute_values); typename = find_attribute ("glib:type-name", attribute_names, attribute_values); typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - else - { + else + { GIrNodeEnum *enum_; - + if (strcmp (element_name, "enumeration") == 0) enum_ = (GIrNodeEnum *) g_ir_node_new (G_IR_NODE_ENUM); else @@ -1207,12 +1207,12 @@ start_enum (GMarkupParseContext *context, enum_->deprecated = FALSE; push_node (ctx, (GIrNode *) enum_); - ctx->current_module->entries = - g_list_append (ctx->current_module->entries, enum_); - + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, enum_); + state_switch (ctx, STATE_ENUM); } - + return TRUE; } return FALSE; @@ -1235,25 +1235,25 @@ start_property (GMarkupParseContext *context, const gchar *writable; const gchar *construct; const gchar *construct_only; - + name = find_attribute ("name", attribute_names, attribute_values); readable = find_attribute ("readable", attribute_names, attribute_values); writable = find_attribute ("writable", attribute_names, attribute_values); construct = find_attribute ("construct", attribute_names, attribute_values); construct_only = find_attribute ("construct-only", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - else - { + else + { GIrNodeProperty *property; GIrNodeInterface *iface; - + property = (GIrNodeProperty *) g_ir_node_new (G_IR_NODE_PROPERTY); ctx->current_typed = (GIrNode*) property; ((GIrNode *)property)->name = g_strdup (name); - + /* Assume properties are readable */ if (readable == NULL || strcmp (readable, "1") == 0) property->readable = TRUE; @@ -1282,7 +1282,7 @@ start_property (GMarkupParseContext *context, else g_assert_not_reached (); } - + return TRUE; } return FALSE; @@ -1292,7 +1292,7 @@ static gint parse_value (const gchar *str) { gchar *shift_op; - + /* FIXME just a quick hack */ shift_op = strstr (str, "<<"); @@ -1302,7 +1302,7 @@ parse_value (const gchar *str) base = strtol (str, NULL, 10); shift = strtol (shift_op + 3, NULL, 10); - + return base << shift; } else @@ -1325,24 +1325,24 @@ start_member (GMarkupParseContext *context, const gchar *name; const gchar *value; const gchar *deprecated; - + name = find_attribute ("name", attribute_names, attribute_values); value = find_attribute ("value", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - else - { + else + { GIrNodeEnum *enum_; GIrNodeValue *value_; value_ = (GIrNodeValue *) g_ir_node_new (G_IR_NODE_VALUE); ((GIrNode *)value_)->name = g_strdup (name); - + value_->value = parse_value (value); - + if (deprecated) value_->deprecated = TRUE; else @@ -1351,7 +1351,7 @@ start_member (GMarkupParseContext *context, enum_ = (GIrNodeEnum *)CURRENT_NODE (ctx); enum_->values = g_list_append (enum_->values, value_); } - + return TRUE; } return FALSE; @@ -1373,17 +1373,17 @@ start_constant (GMarkupParseContext *context, const gchar *name; const gchar *value; const gchar *deprecated; - + name = find_attribute ("name", attribute_names, attribute_values); value = find_attribute ("value", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else if (value == NULL) MISSING_ATTRIBUTE (context, error, element_name, "value"); - else - { + else + { GIrNodeConstant *constant; constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT); @@ -1401,7 +1401,7 @@ start_constant (GMarkupParseContext *context, if (ctx->state == STATE_NAMESPACE) { push_node (ctx, (GIrNode *) constant); - ctx->current_module->entries = + ctx->current_module->entries = g_list_append (ctx->current_module->entries, constant); } else @@ -1428,7 +1428,7 @@ start_constant (GMarkupParseContext *context, break; } } - + return TRUE; } return FALSE; @@ -1449,20 +1449,20 @@ start_errordomain (GMarkupParseContext *context, const gchar *getquark; const gchar *codes; const gchar *deprecated; - + name = find_attribute ("name", attribute_names, attribute_values); getquark = find_attribute ("get-quark", attribute_names, attribute_values); codes = find_attribute ("codes", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else if (getquark == NULL) MISSING_ATTRIBUTE (context, error, element_name, "getquark"); else if (codes == NULL) MISSING_ATTRIBUTE (context, error, element_name, "codes"); - else - { + else + { GIrNodeErrorDomain *domain; domain = (GIrNodeErrorDomain *) g_ir_node_new (G_IR_NODE_ERROR_DOMAIN); @@ -1477,12 +1477,12 @@ start_errordomain (GMarkupParseContext *context, domain->deprecated = FALSE; push_node (ctx, (GIrNode *) domain); - ctx->current_module->entries = + ctx->current_module->entries = g_list_append (ctx->current_module->entries, domain); state_switch (ctx, STATE_ERRORDOMAIN); } - + return TRUE; } return FALSE; @@ -1504,13 +1504,13 @@ start_interface (GMarkupParseContext *context, const gchar *typeinit; const gchar *deprecated; const gchar *glib_type_struct; - + name = find_attribute ("name", attribute_names, attribute_values); typename = find_attribute ("glib:type-name", attribute_names, attribute_values); typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values); glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else if (typename == NULL) @@ -1530,15 +1530,15 @@ start_interface (GMarkupParseContext *context, iface->deprecated = TRUE; else iface->deprecated = FALSE; - + push_node (ctx, (GIrNode *) iface); - ctx->current_module->entries = - g_list_append (ctx->current_module->entries, iface); - + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, iface); + state_switch (ctx, STATE_INTERFACE); - + } - + return TRUE; } return FALSE; @@ -1562,7 +1562,7 @@ start_class (GMarkupParseContext *context, const gchar *typeinit; const gchar *deprecated; const gchar *abstract; - + name = find_attribute ("name", attribute_names, attribute_values); parent = find_attribute ("parent", attribute_names, attribute_values); glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values); @@ -1570,7 +1570,7 @@ start_class (GMarkupParseContext *context, typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); abstract = find_attribute ("abstract", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else if (typename == NULL) @@ -1595,12 +1595,12 @@ start_class (GMarkupParseContext *context, iface->abstract = abstract && strcmp (abstract, "1") == 0; push_node (ctx, (GIrNode *) iface); - ctx->current_module->entries = - g_list_append (ctx->current_module->entries, iface); - + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, iface); + state_switch (ctx, STATE_CLASS); } - + return TRUE; } return FALSE; @@ -1626,14 +1626,14 @@ start_type (GMarkupParseContext *context, if (!(is_array || is_varargs || (strcmp (element_name, "type") == 0))) return FALSE; - if (ctx->state == STATE_TYPE) + if (ctx->state == STATE_TYPE) { ctx->type_depth++; ctx->type_stack = g_list_prepend (ctx->type_stack, ctx->type_parameters); ctx->type_parameters = NULL; - } + } else if (ctx->state == STATE_FUNCTION_PARAMETER || - ctx->state == STATE_FUNCTION_RETURN || + ctx->state == STATE_FUNCTION_RETURN || ctx->state == STATE_STRUCT_FIELD || ctx->state == STATE_UNION_FIELD || ctx->state == STATE_CLASS_PROPERTY || @@ -1705,7 +1705,7 @@ start_type (GMarkupParseContext *context, if (is_varargs) return TRUE; - if (is_array) + if (is_array) { const char *zero; const char *len; @@ -1716,15 +1716,15 @@ start_type (GMarkupParseContext *context, typenode->tag = GI_TYPE_TAG_ARRAY; typenode->is_pointer = TRUE; typenode->is_array = TRUE; - + zero = find_attribute ("zero-terminated", attribute_names, attribute_values); len = find_attribute ("length", attribute_names, attribute_values); size = find_attribute ("fixed-size", attribute_names, attribute_values); - + typenode->zero_terminated = !(zero && strcmp (zero, "1") != 0); typenode->has_length = len != NULL; typenode->length = typenode->has_length ? atoi (len) : -1; - + typenode->has_size = size != NULL; typenode->size = typenode->has_size ? atoi (size) : -1; @@ -1741,7 +1741,7 @@ start_type (GMarkupParseContext *context, if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); - + pointer_depth = 0; ctype = find_attribute ("c:type", attribute_names, attribute_values); if (ctype != NULL) @@ -1750,12 +1750,12 @@ start_type (GMarkupParseContext *context, while (cp > ctype && *cp-- == '*') pointer_depth++; } - + if (ctx->current_typed->type == G_IR_NODE_PARAM && ((GIrNodeParam *)ctx->current_typed)->out && pointer_depth > 0) pointer_depth--; - + typenode = parse_type (ctx, name); /* A 'disguised' structure is one where the c:type is a typedef that @@ -1770,7 +1770,7 @@ start_type (GMarkupParseContext *context, } ctx->type_parameters = g_list_append (ctx->type_parameters, typenode); - + return TRUE; } @@ -1833,7 +1833,7 @@ end_type_top (ParseContext *ctx) } g_list_free (ctx->type_parameters); - out: + out: ctx->type_depth = 0; ctx->type_parameters = NULL; ctx->current_typed = NULL; @@ -1979,7 +1979,7 @@ start_return_value (GMarkupParseContext *context, default: g_assert_not_reached (); } - + return TRUE; } @@ -2002,14 +2002,14 @@ start_implements (GMarkupParseContext *context, return FALSE; state_switch (ctx, STATE_IMPLEMENTS); - + name = find_attribute ("name", attribute_names, attribute_values); if (name == NULL) { MISSING_ATTRIBUTE (context, error, element_name, "name"); return FALSE; } - + iface = (GIrNodeInterface *)CURRENT_NODE (ctx); iface->interfaces = g_list_append (iface->interfaces, g_strdup (name)); @@ -2024,7 +2024,7 @@ start_glib_signal (GMarkupParseContext *context, ParseContext *ctx, GError **error) { - if (strcmp (element_name, "glib:signal") == 0 && + if (strcmp (element_name, "glib:signal") == 0 && (ctx->state == STATE_CLASS || ctx->state == STATE_INTERFACE)) { @@ -2035,7 +2035,7 @@ start_glib_signal (GMarkupParseContext *context, const gchar *action; const gchar *no_hooks; const gchar *has_class_closure; - + name = find_attribute ("name", attribute_names, attribute_values); when = find_attribute ("when", attribute_names, attribute_values); no_recurse = find_attribute ("no-recurse", attribute_names, attribute_values); @@ -2043,7 +2043,7 @@ start_glib_signal (GMarkupParseContext *context, action = find_attribute ("action", attribute_names, attribute_values); no_hooks = find_attribute ("no-hooks", attribute_names, attribute_values); has_class_closure = find_attribute ("has-class-closure", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else @@ -2052,9 +2052,9 @@ start_glib_signal (GMarkupParseContext *context, GIrNodeSignal *signal; signal = (GIrNodeSignal *)g_ir_node_new (G_IR_NODE_SIGNAL); - + ((GIrNode *)signal)->name = g_strdup (name); - + signal->run_first = FALSE; signal->run_last = FALSE; signal->run_cleanup = FALSE; @@ -2062,9 +2062,9 @@ start_glib_signal (GMarkupParseContext *context, signal->run_last = TRUE; else if (strcmp (when, "FIRST") == 0) signal->run_first = TRUE; - else + else signal->run_cleanup = TRUE; - + if (no_recurse && strcmp (no_recurse, "1") == 0) signal->no_recurse = TRUE; else @@ -2092,7 +2092,7 @@ start_glib_signal (GMarkupParseContext *context, push_node (ctx, (GIrNode *)signal); state_switch (ctx, STATE_FUNCTION); } - + return TRUE; } return FALSE; @@ -2116,14 +2116,14 @@ start_vfunc (GMarkupParseContext *context, const gchar *is_class_closure; const gchar *offset; const gchar *invoker; - + name = find_attribute ("name", attribute_names, attribute_values); - must_chain_up = find_attribute ("must-chain-up", attribute_names, attribute_values); + must_chain_up = find_attribute ("must-chain-up", attribute_names, attribute_values); override = find_attribute ("override", attribute_names, attribute_values); is_class_closure = find_attribute ("is-class-closure", attribute_names, attribute_values); offset = find_attribute ("offset", attribute_names, attribute_values); invoker = find_attribute ("invoker", attribute_names, attribute_values); - + if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else @@ -2132,7 +2132,7 @@ start_vfunc (GMarkupParseContext *context, GIrNodeVFunc *vfunc; vfunc = (GIrNodeVFunc *)g_ir_node_new (G_IR_NODE_VFUNC); - + ((GIrNode *)vfunc)->name = g_strdup (name); if (must_chain_up && strcmp (must_chain_up, "1") == 0) @@ -2155,12 +2155,12 @@ start_vfunc (GMarkupParseContext *context, vfunc->must_be_implemented = FALSE; vfunc->must_not_be_implemented = FALSE; } - + if (is_class_closure && strcmp (is_class_closure, "1") == 0) vfunc->is_class_closure = TRUE; else vfunc->is_class_closure = FALSE; - + if (offset) vfunc->offset = atoi (offset); else @@ -2174,7 +2174,7 @@ start_vfunc (GMarkupParseContext *context, push_node (ctx, (GIrNode *)vfunc); state_switch (ctx, STATE_FUNCTION); } - + return TRUE; } return FALSE; @@ -2189,7 +2189,7 @@ start_struct (GMarkupParseContext *context, ParseContext *ctx, GError **error) { - if (strcmp (element_name, "record") == 0 && + if (strcmp (element_name, "record") == 0 && (ctx->state == STATE_NAMESPACE || ctx->state == STATE_UNION || ctx->state == STATE_STRUCT || @@ -2202,7 +2202,7 @@ start_struct (GMarkupParseContext *context, const gchar *gtype_init; const gchar *gtype_struct; GIrNodeStruct *struct_; - + name = find_attribute ("name", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); disguised = find_attribute ("disguised", attribute_names, attribute_values); @@ -2227,7 +2227,7 @@ start_struct (GMarkupParseContext *context, } struct_ = (GIrNodeStruct *) g_ir_node_new (G_IR_NODE_STRUCT); - + ((GIrNode *)struct_)->name = g_strdup (name ? name : ""); if (deprecated) struct_->deprecated = TRUE; @@ -2236,23 +2236,23 @@ start_struct (GMarkupParseContext *context, if (disguised && strcmp (disguised, "1") == 0) struct_->disguised = TRUE; - + struct_->is_gtype_struct = gtype_struct != NULL; struct_->gtype_name = g_strdup (gtype_name); struct_->gtype_init = g_strdup (gtype_init); if (ctx->node_stack == NULL) - ctx->current_module->entries = + ctx->current_module->entries = g_list_append (ctx->current_module->entries, struct_); push_node (ctx, (GIrNode *)struct_); - + state_switch (ctx, STATE_STRUCT); return TRUE; } return FALSE; } - + static gboolean start_union (GMarkupParseContext *context, @@ -2272,12 +2272,12 @@ start_union (GMarkupParseContext *context, const gchar *deprecated; const gchar *typename; const gchar *typeinit; - + name = find_attribute ("name", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); typename = find_attribute ("glib:type-name", attribute_names, attribute_values); typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values); - + if (name == NULL && ctx->node_stack == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else @@ -2285,7 +2285,7 @@ start_union (GMarkupParseContext *context, GIrNodeUnion *union_; union_ = (GIrNodeUnion *) g_ir_node_new (G_IR_NODE_UNION); - + ((GIrNode *)union_)->name = g_strdup (name ? name : ""); union_->gtype_name = g_strdup (typename); union_->gtype_init = g_strdup (typeinit); @@ -2295,10 +2295,10 @@ start_union (GMarkupParseContext *context, union_->deprecated = FALSE; if (ctx->node_stack == NULL) - ctx->current_module->entries = + ctx->current_module->entries = g_list_append (ctx->current_module->entries, union_); push_node (ctx, (GIrNode *)union_); - + state_switch (ctx, STATE_UNION); } return TRUE; @@ -2319,7 +2319,7 @@ start_discriminator (GMarkupParseContext *context, { const gchar *type; const gchar *offset; - + type = find_attribute ("type", attribute_names, attribute_values); offset = find_attribute ("offset", attribute_names, attribute_values); if (type == NULL) @@ -2327,12 +2327,12 @@ start_discriminator (GMarkupParseContext *context, else if (offset == NULL) MISSING_ATTRIBUTE (context, error, element_name, "offset"); { - ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type + ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_type = parse_type (ctx, type); - ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset + ((GIrNodeUnion *)CURRENT_NODE (ctx))->discriminator_offset = atoi (offset); } - + return TRUE; } @@ -2411,7 +2411,7 @@ parse_include (GMarkupParseContext *context, return success; } - + extern GLogLevelFlags logged_levels; static void @@ -2443,10 +2443,10 @@ start_element_handler (GMarkupParseContext *context, g_string_free (tags, TRUE); } - switch (element_name[0]) + switch (element_name[0]) { case 'a': - if (ctx->state == STATE_NAMESPACE && strcmp (element_name, "alias") == 0) + if (ctx->state == STATE_NAMESPACE && strcmp (element_name, "alias") == 0) { state_switch (ctx, STATE_ALIAS); goto out; @@ -2461,13 +2461,13 @@ start_element_handler (GMarkupParseContext *context, goto out; break; case 'b': - if (start_enum (context, element_name, + if (start_enum (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; break; case 'c': - if (start_function (context, element_name, + if (start_function (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; @@ -2475,36 +2475,36 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_class (context, element_name, + else if (start_class (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; break; case 'd': - if (start_discriminator (context, element_name, + if (start_discriminator (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; break; case 'e': - if (start_enum (context, element_name, + if (start_enum (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_errordomain (context, element_name, + else if (start_errordomain (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; break; case 'f': - if (start_function (context, element_name, + if (start_function (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_field (context, element_name, + else if (start_field (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; @@ -2552,7 +2552,7 @@ start_element_handler (GMarkupParseContext *context, state_switch (ctx, STATE_INCLUDE); goto out; } - if (start_interface (context, element_name, + if (start_interface (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; @@ -2563,11 +2563,11 @@ start_element_handler (GMarkupParseContext *context, break; case 'm': - if (start_function (context, element_name, + if (start_function (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_member (context, element_name, + else if (start_member (context, element_name, attribute_names, attribute_values, ctx, error)) goto out; @@ -2657,7 +2657,7 @@ start_element_handler (GMarkupParseContext *context, if (name == NULL) MISSING_ATTRIBUTE (context, error, element_name, "name"); else - { + { GIrNodeInterface *iface; iface = (GIrNodeInterface *)CURRENT_NODE(ctx); @@ -2679,7 +2679,7 @@ start_element_handler (GMarkupParseContext *context, const gchar *version; version = find_attribute ("version", attribute_names, attribute_values); - + if (version == NULL) MISSING_ATTRIBUTE (context, error, element_name, "version"); else if (strcmp (version, "1.0") != 0) @@ -2690,17 +2690,17 @@ start_element_handler (GMarkupParseContext *context, version); else state_switch (ctx, STATE_REPOSITORY); - + goto out; } else if (start_return_value (context, element_name, attribute_names, attribute_values, ctx, error)) - goto out; + goto out; else if (start_struct (context, element_name, attribute_names, attribute_values, ctx, error)) - goto out; + goto out; break; case 'u': @@ -2738,9 +2738,9 @@ start_element_handler (GMarkupParseContext *context, { ctx->unknown_depth += 1; } - + out: - if (*error) + if (*error) { g_markup_parse_context_get_position (context, &line_number, &char_number); @@ -2753,7 +2753,7 @@ static gboolean require_one_of_end_elements (GMarkupParseContext *context, ParseContext *ctx, const char *actual_name, - GError **error, + GError **error, ...) { va_list args; @@ -2763,7 +2763,7 @@ require_one_of_end_elements (GMarkupParseContext *context, va_start (args, error); - while ((expected = va_arg (args, const char*)) != NULL) + while ((expected = va_arg (args, const char*)) != NULL) { if (strcmp (expected, actual_name) == 0) { @@ -2782,7 +2782,7 @@ require_one_of_end_elements (GMarkupParseContext *context, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Unexpected end tag '%s' on line %d char %d; current state=%d", - actual_name, + actual_name, line_number, char_number, ctx->state); backtrace_stderr(); return FALSE; @@ -2799,7 +2799,7 @@ state_switch_end_struct_or_union (GMarkupParseContext *context, { state_switch (ctx, STATE_NAMESPACE); } - else + else { if (CURRENT_NODE (ctx)->type == G_IR_NODE_STRUCT) state_switch (ctx, STATE_STRUCT); @@ -2860,13 +2860,13 @@ end_element_handler (GMarkupParseContext *context, state_switch (ctx, STATE_REPOSITORY); } break; - + case STATE_PACKAGE: if (require_end_element (context, ctx, "package", element_name, error)) { state_switch (ctx, STATE_REPOSITORY); } - break; + break; case STATE_NAMESPACE: if (require_end_element (context, ctx, "namespace", element_name, error)) @@ -2915,7 +2915,7 @@ end_element_handler (GMarkupParseContext *context, { state_switch (ctx, STATE_NAMESPACE); } - else + else { g_debug("case STATE_FUNCTION %d", CURRENT_NODE (ctx)->type); if (ctx->in_embedded_type) @@ -2925,7 +2925,7 @@ end_element_handler (GMarkupParseContext *context, } else if (CURRENT_NODE (ctx)->type == G_IR_NODE_INTERFACE) state_switch (ctx, STATE_INTERFACE); - else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT) + else if (CURRENT_NODE (ctx)->type == G_IR_NODE_OBJECT) state_switch (ctx, STATE_CLASS); else if (CURRENT_NODE (ctx)->type == G_IR_NODE_BOXED) state_switch (ctx, STATE_BOXED); @@ -3011,8 +3011,8 @@ end_element_handler (GMarkupParseContext *context, case STATE_ENUM: if (strcmp ("member", element_name) == 0) break; - else if (require_one_of_end_elements (context, ctx, - element_name, error, "enumeration", + else if (require_one_of_end_elements (context, ctx, + element_name, error, "enumeration", "bitfield", NULL)) { pop_node (ctx); @@ -3127,10 +3127,10 @@ end_element_handler (GMarkupParseContext *context, } } -static void +static void text_handler (GMarkupParseContext *context, const gchar *text, - gsize text_len, + gsize text_len, gpointer user_data, GError **error) { @@ -3149,25 +3149,25 @@ cleanup (GMarkupParseContext *context, g_ir_module_free (m->data); g_list_free (ctx->modules); ctx->modules = NULL; - + ctx->current_module = NULL; } static GList * -post_filter_toplevel_varargs_functions (GList *list, +post_filter_toplevel_varargs_functions (GList *list, GList **varargs_callbacks_out) { GList *iter; GList *varargs_callbacks = *varargs_callbacks_out; - + iter = list; while (iter) { GList *link = iter; GIrNode *node = iter->data; - + iter = iter->next; - + if (node->type == G_IR_NODE_FUNCTION) { if (((GIrNodeFunction*)node)->is_varargs) @@ -3185,9 +3185,9 @@ post_filter_toplevel_varargs_functions (GList *list, } } } - + *varargs_callbacks_out = varargs_callbacks; - + return list; } @@ -3196,9 +3196,9 @@ post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out) { GList *iter; GList *varargs_callbacks; - + list = post_filter_toplevel_varargs_functions (list, varargs_callbacks_out); - + varargs_callbacks = *varargs_callbacks_out; iter = list; @@ -3206,20 +3206,20 @@ post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out) { GList *link = iter; GIrNode *node = iter->data; - + iter = iter->next; - + if (node->type == G_IR_NODE_FUNCTION) { GList *param; gboolean function_done = FALSE; - + for (param = ((GIrNodeFunction *)node)->parameters; param; param = param->next) { GIrNodeParam *node = (GIrNodeParam *)param->data; - + if (function_done) break; @@ -3242,9 +3242,9 @@ post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out) } } } - + *varargs_callbacks_out = varargs_callbacks; - + return list; } @@ -3253,18 +3253,18 @@ post_filter (GIrModule *module) { GList *iter; GList *varargs_callbacks = NULL; - + module->entries = post_filter_varargs_functions (module->entries, &varargs_callbacks); iter = module->entries; while (iter) { GIrNode *node = iter->data; - + iter = iter->next; - - if (node->type == G_IR_NODE_OBJECT || - node->type == G_IR_NODE_INTERFACE) + + if (node->type == G_IR_NODE_OBJECT || + node->type == G_IR_NODE_INTERFACE) { GIrNodeInterface *iface = (GIrNodeInterface*)node; iface->members = post_filter_varargs_functions (iface->members, @@ -3335,7 +3335,7 @@ g_ir_parser_parse_string (GIrParser *parser, goto out; g_markup_parse_context_free (context); - + context = g_markup_parse_context_new (&markup_parser, 0, &ctx, NULL); if (!g_markup_parse_context_parse (context, buffer, length, error)) goto out; @@ -3359,9 +3359,9 @@ g_ir_parser_parse_string (GIrParser *parser, g_hash_table_destroy (ctx.disguised_structures); g_list_free (ctx.include_modules); } - + g_markup_parse_context_free (context); - + return ctx.modules; } @@ -3415,10 +3415,10 @@ g_ir_parser_parse_file (GIrParser *parser, if (!g_file_get_contents (filename, &buffer, &length, error)) return NULL; - + modules = g_ir_parser_parse_string (parser, namespace, buffer, length, error); - for (iter = modules; iter; iter = iter->next) + for (iter = modules; iter; iter = iter->next) { post_filter ((GIrModule*)iter->data); } diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 5a9459fd..2d18d145 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -170,7 +170,7 @@ function_generate (GIdlWriter * writer, GIdlNodeFunction * node) { GIdlNodeParam *param = l->data; const gchar *direction = g_idl_node_param_direction_string (param); - + markup_s = g_string_new ("<parameter"); g_string_append_printf (markup_s, " name=\"%s\"", param->node.name); @@ -186,7 +186,7 @@ function_generate (GIdlWriter * writer, GIdlNodeFunction * node) if (param->allow_none) g_string_append (markup_s, g_markup_printf_escaped (" allow-none=\"1\"")); - + if (strcmp (direction, "in") != 0) g_string_append (markup_s, g_markup_printf_escaped (" direction=\"%s\"", diff --git a/girepository/gtypelib.c b/girepository/gtypelib.c index a34ca32f..da7e5ee6 100644 --- a/girepository/gtypelib.c +++ b/girepository/gtypelib.c @@ -1,4 +1,4 @@ -/* GObject introspection: typelib validation, auxiliary functions +/* GObject introspection: typelib validation, auxiliary functions * related to the binary typelib format * * Copyright (C) 2005 Matthias Clasen @@ -46,7 +46,7 @@ static void pop_context (ValidateContext *ctx) { g_assert (ctx->context_stack != NULL); - ctx->context_stack = g_slist_delete_link (ctx->context_stack, + ctx->context_stack = g_slist_delete_link (ctx->context_stack, ctx->context_stack); } @@ -69,7 +69,7 @@ get_dir_entry_checked (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid directory index %d", index); - return FALSE; + return FALSE; } offset = header->directory + (index - 1) * header->entry_blob_size; @@ -139,7 +139,7 @@ g_typelib_get_dir_entry (GTypelib *typelib, return (DirEntry *)&typelib->data[header->directory + (index - 1) * header->entry_blob_size]; } -void +void g_typelib_check_sanity (void) { /* Check that struct layout is as we expect */ @@ -161,7 +161,7 @@ g_typelib_check_sanity (void) * * Everything else in the code however should be using sizeof(). */ - + CHECK_SIZE (Header, 112); CHECK_SIZE (DirEntry, 12); CHECK_SIZE (SimpleTypeBlob, 4); @@ -237,7 +237,7 @@ validate_name (GTypelib *typelib, if (!name) return FALSE; - if (!memchr (name, '\0', MAX_NAME_LEN)) + if (!memchr (name, '\0', MAX_NAME_LEN)) { g_set_error (error, G_TYPELIB_ERROR, @@ -246,8 +246,8 @@ validate_name (GTypelib *typelib, msg, name); return FALSE; } - - if (strspn (name, G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_") < strlen (name)) + + if (strspn (name, G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_") < strlen (name)) { g_set_error (error, G_TYPELIB_ERROR, @@ -256,11 +256,11 @@ validate_name (GTypelib *typelib, msg, name); return FALSE; } - + return TRUE; } -static gboolean +static gboolean validate_header (ValidateContext *ctx, GError **error) { @@ -285,7 +285,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR_INVALID_HEADER, "Magic string not found"); return FALSE; - + } if (header->major_version != 2 || header->minor_version != 0) @@ -295,7 +295,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR_INVALID_HEADER, "Version mismatch"); return FALSE; - + } if (header->n_entries < header->n_local_entries) @@ -304,7 +304,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Inconsistent entry counts"); - return FALSE; + return FALSE; } if (header->size != typelib->len) @@ -313,12 +313,12 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Typelib size mismatch"); - return FALSE; + return FALSE; } - + /* This is a sanity check for a specific typelib; it * prevents us from loading an incompatible typelib. - * + * * The hardcoded checks in g_typelib_check_sanity to * protect against inadvertent or buggy changes to the typelib format * itself. @@ -347,7 +347,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Blob size mismatch"); - return FALSE; + return FALSE; } if (!is_aligned (header->directory)) @@ -356,7 +356,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Misaligned directory"); - return FALSE; + return FALSE; } if (!is_aligned (header->attributes)) @@ -365,7 +365,7 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Misaligned attributes"); - return FALSE; + return FALSE; } if (header->attributes == 0 && header->n_attributes > 0) @@ -374,11 +374,11 @@ validate_header (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_HEADER, "Wrong number of attributes"); - return FALSE; + return FALSE; } if (!validate_name (typelib, "namespace", typelib->data, header->namespace, error)) - return FALSE; + return FALSE; return TRUE; } @@ -406,7 +406,7 @@ validate_array_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Pointer type exected for tag %d", blob->tag); - return FALSE; + return FALSE; } /* FIXME validate length */ @@ -460,18 +460,18 @@ validate_param_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Pointer type exected for tag %d", blob->tag); - return FALSE; + return FALSE; } - + if (blob->n_types != n_params) { g_set_error (error, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Parameter type number mismatch"); - return FALSE; + return FALSE; } - + for (i = 0; i < n_params; i++) { if (!validate_type_blob (typelib, @@ -506,9 +506,9 @@ validate_error_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Pointer type exected for tag %d", blob->tag); - return FALSE; + return FALSE; } - + for (i = 0; i < blob->n_domains; i++) { if (blob->domains[i] == 0 || blob->domains[i] > header->n_entries) @@ -517,7 +517,7 @@ validate_error_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid directory index %d", blob->domains[i]); - return FALSE; + return FALSE; } entry = g_typelib_get_dir_entry (typelib, blob->domains[i]); @@ -529,7 +529,7 @@ validate_error_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Wrong blob type"); - return FALSE; + return FALSE; } } @@ -545,10 +545,10 @@ validate_type_blob (GTypelib *typelib, { SimpleTypeBlob *simple; InterfaceTypeBlob *iface; - + simple = (SimpleTypeBlob *)&typelib->data[offset]; - if (simple->flags.reserved == 0 && + if (simple->flags.reserved == 0 && simple->flags.reserved2 == 0) { if (simple->flags.tag >= GI_TYPE_TAG_ARRAY) @@ -559,7 +559,7 @@ validate_type_blob (GTypelib *typelib, "Wrong tag in simple type"); return FALSE; } - + if (simple->flags.tag >= GI_TYPE_TAG_UTF8 && !simple->flags.pointer) { @@ -567,7 +567,7 @@ validate_type_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Pointer type exected for tag %d", simple->flags.tag); - return FALSE; + return FALSE; } return TRUE; @@ -578,28 +578,28 @@ validate_type_blob (GTypelib *typelib, switch (iface->tag) { case GI_TYPE_TAG_ARRAY: - if (!validate_array_type_blob (typelib, simple->offset, + if (!validate_array_type_blob (typelib, simple->offset, signature_offset, return_type, error)) return FALSE; break; case GI_TYPE_TAG_INTERFACE: - if (!validate_iface_type_blob (typelib, simple->offset, + if (!validate_iface_type_blob (typelib, simple->offset, signature_offset, return_type, error)) return FALSE; break; case GI_TYPE_TAG_GLIST: case GI_TYPE_TAG_GSLIST: - if (!validate_param_type_blob (typelib, simple->offset, + if (!validate_param_type_blob (typelib, simple->offset, signature_offset, return_type, 1, error)) return FALSE; break; case GI_TYPE_TAG_GHASH: - if (!validate_param_type_blob (typelib, simple->offset, + if (!validate_param_type_blob (typelib, simple->offset, signature_offset, return_type, 2, error)) return FALSE; break; case GI_TYPE_TAG_ERROR: - if (!validate_error_type_blob (typelib, simple->offset, + if (!validate_error_type_blob (typelib, simple->offset, signature_offset, return_type, error)) return FALSE; break; @@ -634,10 +634,10 @@ validate_arg_blob (GTypelib *typelib, blob = (ArgBlob*) &typelib->data[offset]; if (!validate_name (typelib, "argument", typelib->data, blob->name, error)) - return FALSE; - - if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (ArgBlob, arg_type), + return FALSE; + + if (!validate_type_blob (typelib, + offset + G_STRUCT_OFFSET (ArgBlob, arg_type), signature_offset, FALSE, error)) return FALSE; @@ -693,18 +693,18 @@ validate_signature_blob (GTypelib *typelib, if (blob->return_type.offset != 0) { - if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (SignatureBlob, return_type), + if (!validate_type_blob (typelib, + offset + G_STRUCT_OFFSET (SignatureBlob, return_type), offset, TRUE, error)) return FALSE; } for (i = 0; i < blob->n_arguments; i++) { - if (!validate_arg_blob (typelib, - offset + sizeof (SignatureBlob) + - i * sizeof (ArgBlob), - offset, + if (!validate_arg_blob (typelib, + offset + sizeof (SignatureBlob) + + i * sizeof (ArgBlob), + offset, error)) return FALSE; } @@ -746,12 +746,12 @@ validate_function_blob (ValidateContext *ctx, } if (!validate_name (typelib, "function", typelib->data, blob->name, error)) - return FALSE; + return FALSE; push_context (ctx, get_string_nofail (typelib, blob->name)); - + if (!validate_name (typelib, "function symbol", typelib->data, blob->symbol, error)) - return FALSE; + return FALSE; switch (container_type) { @@ -765,7 +765,7 @@ validate_function_blob (ValidateContext *ctx, default: is_method = FALSE; } - + if (blob->constructor) { switch (container_type) @@ -820,7 +820,7 @@ validate_function_blob (ValidateContext *ctx, sigblob = (SignatureBlob*) &typelib->data[blob->signature]; - if (blob->constructor) + if (blob->constructor) { SimpleTypeBlob *simple = return_type_from_signature (typelib, blob->signature, @@ -877,15 +877,15 @@ validate_callback_blob (ValidateContext *ctx, } if (!validate_name (typelib, "callback", typelib->data, blob->name, error)) - return FALSE; + return FALSE; push_context (ctx, get_string_nofail (typelib, blob->name)); - + if (!validate_signature_blob (typelib, blob->signature, error)) return FALSE; pop_context (ctx); - + return TRUE; } @@ -950,9 +950,9 @@ validate_constant_blob (GTypelib *typelib, } if (!validate_name (typelib, "constant", typelib->data, blob->name, error)) - return FALSE; - - if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type), + return FALSE; + + if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type), 0, FALSE, error)) return FALSE; @@ -964,7 +964,7 @@ validate_constant_blob (GTypelib *typelib, "Misaligned constant value"); return FALSE; } - + type = (SimpleTypeBlob *)&typelib->data[offset + G_STRUCT_OFFSET (ConstantBlob, type)]; if (type->flags.reserved == 0 && type->flags.reserved2 == 0) { @@ -1011,8 +1011,8 @@ validate_value_blob (GTypelib *typelib, blob = (ValueBlob*) &typelib->data[offset]; if (!validate_name (typelib, "value", typelib->data, blob->name, error)) - return FALSE; - + return FALSE; + return TRUE; } @@ -1035,9 +1035,9 @@ validate_field_blob (ValidateContext *ctx, } blob = (FieldBlob*) &typelib->data[offset]; - + if (!validate_name (typelib, "field", typelib->data, blob->name, error)) - return FALSE; + return FALSE; if (blob->has_embedded_type) { @@ -1045,7 +1045,7 @@ validate_field_blob (ValidateContext *ctx, return FALSE; } else if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (FieldBlob, type), + offset + G_STRUCT_OFFSET (FieldBlob, type), 0, FALSE, error)) return FALSE; @@ -1069,12 +1069,12 @@ validate_property_blob (GTypelib *typelib, } blob = (PropertyBlob*) &typelib->data[offset]; - + if (!validate_name (typelib, "property", typelib->data, blob->name, error)) - return FALSE; - + return FALSE; + if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (PropertyBlob, type), + offset + G_STRUCT_OFFSET (PropertyBlob, type), 0, FALSE, error)) return FALSE; @@ -1102,17 +1102,17 @@ validate_signal_blob (GTypelib *typelib, blob = (SignalBlob*) &typelib->data[offset]; if (!validate_name (typelib, "signal", typelib->data, blob->name, error)) - return FALSE; - - if ((blob->run_first != 0) + - (blob->run_last != 0) + + return FALSE; + + if ((blob->run_first != 0) + + (blob->run_last != 0) + (blob->run_cleanup != 0) != 1) { g_set_error (error, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid signal run flags"); - return FALSE; + return FALSE; } if (blob->has_class_closure) @@ -1122,15 +1122,15 @@ validate_signal_blob (GTypelib *typelib, ObjectBlob *object; object = (ObjectBlob*)&typelib->data[container_offset]; - + n_signals = object->n_signals; } else { InterfaceBlob *iface; - + iface = (InterfaceBlob*)&typelib->data[container_offset]; - + n_signals = iface->n_signals; } @@ -1140,13 +1140,13 @@ validate_signal_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid class closure index"); - return FALSE; + return FALSE; } } if (!validate_signature_blob (typelib, blob->signature, error)) return FALSE; - + return TRUE; } @@ -1171,8 +1171,8 @@ validate_vfunc_blob (GTypelib *typelib, blob = (VFuncBlob*) &typelib->data[offset]; if (!validate_name (typelib, "vfunc", typelib->data, blob->name, error)) - return FALSE; - + return FALSE; + if (blob->class_closure) { if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT) @@ -1180,15 +1180,15 @@ validate_vfunc_blob (GTypelib *typelib, ObjectBlob *object; object = (ObjectBlob*)&typelib->data[container_offset]; - + n_vfuncs = object->n_vfuncs; } else { InterfaceBlob *iface; - + iface = (InterfaceBlob*)&typelib->data[container_offset]; - + n_vfuncs = iface->n_vfuncs; } @@ -1198,13 +1198,13 @@ validate_vfunc_blob (GTypelib *typelib, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid class closure index"); - return FALSE; + return FALSE; } } if (!validate_signature_blob (typelib, blob->signature, error)) return FALSE; - + return TRUE; } @@ -1240,17 +1240,17 @@ validate_struct_blob (ValidateContext *ctx, } if (!validate_name (typelib, "struct", typelib->data, blob->name, error)) - return FALSE; + return FALSE; push_context (ctx, get_string_nofail (typelib, blob->name)); - + if (!blob->unregistered) { if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_name, error)) - return FALSE; + return FALSE; if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_init, error)) - return FALSE; + return FALSE; } else { @@ -1260,11 +1260,11 @@ validate_struct_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Gtype data in struct"); - return FALSE; + return FALSE; } } - if (typelib->len < offset + sizeof (StructBlob) + + if (typelib->len < offset + sizeof (StructBlob) + blob->n_fields * sizeof (FieldBlob) + blob->n_methods * sizeof (FunctionBlob)) { @@ -1292,9 +1292,9 @@ validate_struct_blob (ValidateContext *ctx, for (i = 0; i < blob->n_methods; i++) { - if (!validate_function_blob (ctx, - field_offset + - i * sizeof (FunctionBlob), + if (!validate_function_blob (ctx, + field_offset + + i * sizeof (FunctionBlob), blob_type, error)) return FALSE; @@ -1334,14 +1334,14 @@ validate_enum_blob (ValidateContext *ctx, "Wrong blob type"); return FALSE; } - + if (!blob->unregistered) { if (!validate_name (typelib, "enum", typelib->data, blob->gtype_name, error)) - return FALSE; + return FALSE; if (!validate_name (typelib, "enum", typelib->data, blob->gtype_init, error)) - return FALSE; + return FALSE; } else { @@ -1351,14 +1351,14 @@ validate_enum_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Gtype data in unregistered enum"); - return FALSE; + return FALSE; } } if (!validate_name (typelib, "enum", typelib->data, blob->name, error)) - return FALSE; - - if (typelib->len < offset + sizeof (EnumBlob) + + return FALSE; + + if (typelib->len < offset + sizeof (EnumBlob) + blob->n_values * sizeof (ValueBlob)) { g_set_error (error, @@ -1369,21 +1369,21 @@ validate_enum_blob (ValidateContext *ctx, } push_context (ctx, get_string_nofail (typelib, blob->name)); - + for (i = 0; i < blob->n_values; i++) { - if (!validate_value_blob (typelib, - offset + sizeof (EnumBlob) + - i * sizeof (ValueBlob), + if (!validate_value_blob (typelib, + offset + sizeof (EnumBlob) + + i * sizeof (ValueBlob), error)) return FALSE; #if 0 - v1 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) + + v1 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) + i * sizeof (ValueBlob)]; - for (j = 0; j < i; j++) + for (j = 0; j < i; j++) { - v2 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) + + v2 = (ValueBlob *)&typelib->data[offset + sizeof (EnumBlob) + j * sizeof (ValueBlob)]; if (v1->value == v2->value) @@ -1397,11 +1397,11 @@ validate_enum_blob (ValidateContext *ctx, return FALSE; } } -#endif +#endif } pop_context (ctx); - + return TRUE; } @@ -1437,15 +1437,15 @@ validate_object_blob (ValidateContext *ctx, "Wrong blob type"); return FALSE; } - + if (!validate_name (typelib, "object", typelib->data, blob->gtype_name, error)) - return FALSE; - + return FALSE; + if (!validate_name (typelib, "object", typelib->data, blob->gtype_init, error)) - return FALSE; - + return FALSE; + if (!validate_name (typelib, "object", typelib->data, blob->name, error)) - return FALSE; + return FALSE; if (blob->parent > header->n_entries) { @@ -1453,7 +1453,7 @@ validate_object_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid parent index"); - return FALSE; + return FALSE; } if (blob->parent != 0) @@ -1470,10 +1470,10 @@ validate_object_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Parent not object"); - return FALSE; + return FALSE; } } - + if (blob->gtype_struct != 0) { DirEntry *entry; @@ -1487,11 +1487,11 @@ validate_object_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Class struct invalid type or not local"); - return FALSE; + return FALSE; } - } - - if (typelib->len < offset + sizeof (ObjectBlob) + + } + + if (typelib->len < offset + sizeof (ObjectBlob) + (blob->n_interfaces + blob->n_interfaces % 2) * 2 + blob->n_fields * sizeof (FieldBlob) + blob->n_properties * sizeof (PropertyBlob) + @@ -1499,7 +1499,7 @@ validate_object_blob (ValidateContext *ctx, blob->n_signals * sizeof (SignalBlob) + blob->n_vfuncs * sizeof (VFuncBlob) + blob->n_constants * sizeof (ConstantBlob)) - + { g_set_error (error, G_TYPELIB_ERROR, @@ -1522,9 +1522,9 @@ validate_object_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid interface index"); - return FALSE; + return FALSE; } - + entry = get_dir_entry_checked (typelib, iface, error); if (!entry) return FALSE; @@ -1536,14 +1536,14 @@ validate_object_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Not an interface"); - return FALSE; + return FALSE; } } offset2 += 2 * (blob->n_interfaces %2); push_context (ctx, get_string_nofail (typelib, blob->name)); - + for (i = 0; i < blob->n_fields; i++, offset2 += sizeof (FieldBlob)) { if (!validate_field_blob (ctx, offset2, error)) @@ -1595,7 +1595,7 @@ validate_interface_blob (ValidateContext *ctx, InterfaceBlob *blob; gint i; guint32 offset2; - + header = (Header *)typelib->data; if (typelib->len < offset + sizeof (InterfaceBlob)) @@ -1617,24 +1617,24 @@ validate_interface_blob (ValidateContext *ctx, "Wrong blob type; expected interface, got %d", blob->blob_type); return FALSE; } - + if (!validate_name (typelib, "interface", typelib->data, blob->gtype_name, error)) - return FALSE; - + return FALSE; + if (!validate_name (typelib, "interface", typelib->data, blob->gtype_init, error)) - return FALSE; - + return FALSE; + if (!validate_name (typelib, "interface", typelib->data, blob->name, error)) - return FALSE; - - if (typelib->len < offset + sizeof (InterfaceBlob) + + return FALSE; + + if (typelib->len < offset + sizeof (InterfaceBlob) + (blob->n_prerequisites + blob->n_prerequisites % 2) * 2 + blob->n_properties * sizeof (PropertyBlob) + blob->n_methods * sizeof (FunctionBlob) + blob->n_signals * sizeof (SignalBlob) + blob->n_vfuncs * sizeof (VFuncBlob) + blob->n_constants * sizeof (ConstantBlob)) - + { g_set_error (error, G_TYPELIB_ERROR, @@ -1657,7 +1657,7 @@ validate_interface_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Invalid prerequisite index"); - return FALSE; + return FALSE; } entry = g_typelib_get_dir_entry (typelib, req); @@ -1669,14 +1669,14 @@ validate_interface_blob (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, "Not an interface or object"); - return FALSE; + return FALSE; } } offset2 += 2 * (blob->n_prerequisites % 2); push_context (ctx, get_string_nofail (typelib, blob->name)); - + for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob)) { if (!validate_property_blob (typelib, offset2, error)) @@ -1688,13 +1688,13 @@ validate_interface_blob (ValidateContext *ctx, if (!validate_function_blob (ctx, offset2, BLOB_TYPE_INTERFACE, error)) return FALSE; } - + for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob)) { if (!validate_signal_blob (typelib, offset2, offset, error)) return FALSE; } - + for (i = 0; i < blob->n_vfuncs; i++, offset2 += sizeof (VFuncBlob)) { if (!validate_vfunc_blob (typelib, offset2, offset, error)) @@ -1746,7 +1746,7 @@ validate_blob (ValidateContext *ctx, } common = (CommonBlob*)&typelib->data[offset]; - + switch (common->blob_type) { case BLOB_TYPE_FUNCTION: @@ -1788,7 +1788,7 @@ validate_blob (ValidateContext *ctx, return FALSE; break; default: - g_set_error (error, + g_set_error (error, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_ENTRY, "Invalid blob type"); @@ -1798,7 +1798,7 @@ validate_blob (ValidateContext *ctx, return TRUE; } -static gboolean +static gboolean validate_directory (ValidateContext *ctx, GError **error) { @@ -1806,7 +1806,7 @@ validate_directory (ValidateContext *ctx, Header *header = (Header *)typelib->data; DirEntry *entry; gint i; - + if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry)) { g_set_error (error, @@ -1821,8 +1821,8 @@ validate_directory (ValidateContext *ctx, entry = g_typelib_get_dir_entry (typelib, i + 1); if (!validate_name (typelib, "entry", typelib->data, entry->name, error)) - return FALSE; - + return FALSE; + if ((entry->local && entry->blob_type == BLOB_TYPE_INVALID) || entry->blob_type > BLOB_TYPE_UNION) { @@ -1830,7 +1830,7 @@ validate_directory (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_DIRECTORY, "Invalid entry type"); - return FALSE; + return FALSE; } if (i < header->n_local_entries) @@ -1868,7 +1868,7 @@ validate_directory (ValidateContext *ctx, } if (!validate_name (typelib, "namespace", typelib->data, entry->offset, error)) - return FALSE; + return FALSE; } } @@ -1888,9 +1888,9 @@ validate_attributes (ValidateContext *ctx, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID, "The buffer is too short"); - return FALSE; + return FALSE; } - + return TRUE; } @@ -1902,7 +1902,7 @@ prefix_with_context (GError **error, GString *str = g_string_new (NULL); GSList *link; char *buf; - + link = ctx->context_stack; if (!link) { @@ -1922,7 +1922,7 @@ prefix_with_context (GError **error, g_free (buf); } -gboolean +gboolean g_typelib_validate (GTypelib *typelib, GError **error) { @@ -1965,7 +1965,7 @@ _g_typelib_do_dlopen (GTypelib *typelib) { Header *header; const char *shlib_str; - + header = (Header *) typelib->data; /* note that NULL shlib means to open the main app, which is allowed */ if (header->shared_library) @@ -2059,11 +2059,11 @@ _g_typelib_ensure_open (GTypelib *typelib) * g_typelib_new_from_memory: * @memory: address of memory chunk containing the typelib * @len: length of memory chunk containing the typelib - * + * * Creates a new #GTypelib from a memory location. The memory block * pointed to by @typelib will be automatically g_free()d when the * repository is destroyed. - * + * * Return value: the new #GTypelib **/ GTypelib * @@ -2084,9 +2084,9 @@ g_typelib_new_from_memory (guchar *memory, gsize len) * g_typelib_new_from_const_memory: * @memory: address of memory chunk containing the typelib * @len: length of memory chunk containing the typelib - * + * * Creates a new #GTypelib from a memory location. - * + * * Return value: the new #GTypelib **/ GTypelib * @@ -2106,9 +2106,9 @@ g_typelib_new_from_const_memory (const guchar *memory, gsize len) /** * g_typelib_new_from_mapped_file: * @mfile: a #GMappedFile, that will be free'd when the repository is destroyed - * + * * Creates a new #GTypelib from a #GMappedFile. - * + * * Return value: the new #GTypelib **/ GTypelib * @@ -2128,7 +2128,7 @@ g_typelib_new_from_mapped_file (GMappedFile *mfile) /** * g_typelib_free: * @typelib: a #GTypelib - * + * * Free a #GTypelib. **/ void @@ -2167,7 +2167,7 @@ gboolean g_typelib_symbol (GTypelib *typelib, const char *symbol_name, gpointer *symbol) { GList *l; - + _g_typelib_ensure_open (typelib); /* @@ -2177,9 +2177,9 @@ g_typelib_symbol (GTypelib *typelib, const char *symbol_name, gpointer *symbol) * will be the custom one, which overrides the main one. A bit * inefficient, but the problem will go away when gir-repository * does. - * + * * For modules with no shared library, we dlopen'd the current - * process above. + * process above. */ for (l = typelib->modules; l; l = l->next) { diff --git a/girepository/gtypelib.h b/girepository/gtypelib.h index f02dcfc2..99d4472c 100644 --- a/girepository/gtypelib.h +++ b/girepository/gtypelib.h @@ -35,21 +35,21 @@ G_BEGIN_DECLS * * The "typelib" is a binary, readonly, memory-mappable database * containing reflective information about a GObject library. - * - * The format of GObject typelib is strongly influenced by the Mozilla XPCOM - * format. + * + * The format of GObject typelib is strongly influenced by the Mozilla XPCOM + * format. * * Some of the differences to XPCOM include: - * - Type information is stored not quite as compactly (XPCOM stores it inline - * in function descriptions in variable-sized blobs of 1 to n bytes. We store - * 16 bits of type information for each parameter, which is enough to encode - * simple types inline. Complex (e.g. recursive) types are stored out of line + * - Type information is stored not quite as compactly (XPCOM stores it inline + * in function descriptions in variable-sized blobs of 1 to n bytes. We store + * 16 bits of type information for each parameter, which is enough to encode + * simple types inline. Complex (e.g. recursive) types are stored out of line * in a separate list of types. - * - String and complex type data is stored outside of typelib entry blobs, - * references are stored as offsets relative to the start of the typelib. - * One possibility is to store the strings and types in a pools at the end - * of the typelib. - * + * - String and complex type data is stored outside of typelib entry blobs, + * references are stored as offsets relative to the start of the typelib. + * One possibility is to store the strings and types in a pools at the end + * of the typelib. + * * The typelib has the following general format. * * typelib ::= header, directory, blobs, attributes, attributedata @@ -63,8 +63,8 @@ G_BEGIN_DECLS * attributedata ::= string data for attributes * * Details - * - * We describe the fragments that make up the typelib in the form of C structs + * + * We describe the fragments that make up the typelib in the form of C structs * (although some fall short of being valid C structs since they contain multiple * flexible arrays). */ @@ -113,11 +113,11 @@ Changes since 0.1: - use 'blob' as collective name for the various blob types - rename 'type' field in blobs to 'blob_type' - rename 'type_name' and 'type_init' fields to 'gtype_name', 'gtype_init' -- shrink directory entries to 12 bytes +- shrink directory entries to 12 bytes - merge struct and boxed blobs - split interface blobs into enum, object and interface blobs - add an 'unregistered' flag to struct and enum blobs -- add a 'wraps_vfunc' flag to function blobs and link them to +- add a 'wraps_vfunc' flag to function blobs and link them to the vfuncs they wrap - restrict value blobs to only occur inside enums and flags again - add constant blobs, allow them toplevel, in interfaces and in objects @@ -133,8 +133,8 @@ Changes since 0.1: /** * G_IR_MAGIC: - * - * Identifying prefix for the typelib. This was inspired by XPCOM, + * + * Identifying prefix for the typelib. This was inspired by XPCOM, * which in turn borrowed from PNG. */ #define G_IR_MAGIC "GOBJ\nMETADATA\r\n\032" @@ -153,7 +153,7 @@ Changes since 0.1: * @BLOB_TYPE_CONSTANT: A #ConstantBlob * @BLOB_TYPE_ERROR_DOMAIN: A #ErrorDomainBlob * @BLOB_TYPE_UNION: A #UnionBlob - * + * * The integral value of this enumeration appears in each "Blob" * component of a typelib to identify its type. */ @@ -182,8 +182,8 @@ typedef enum { /** * Header: * @magic: See #G_IR_MAGIC. - * @major_version: The version of the typelib format. Minor version changes indicate - * compatible changes and should still allow the typelib to be parsed + * @major_version: The version of the typelib format. Minor version changes indicate + * compatible changes and should still allow the typelib to be parsed * by a parser designed for the same major_version. * @minor_version: See major_version. * @n_entries: The number of entries in the directory. @@ -197,7 +197,7 @@ typedef enum { * dependencies are required in order to avoid having programs * consuming a typelib check for an "Unresolved" type return * from every API call. - * @size: The size in bytes of the typelib. + * @size: The size in bytes of the typelib. * @namespace: Offset of the namespace string in the typelib. * @nsversion: Offset of the namespace version string in the typelib. * @shared_library: This field is the set of shared libraries associated @@ -222,13 +222,13 @@ typedef enum { * @struct_blob_size: See above. * @error_domain_blob_size: See above. * @interface_blob_size: For variable-size blobs, the size of the struct up to the first - * flexible array member. Recording this information here allows to - * write parser which continue to work if the format is extended by - * adding new fields before the first flexible array member in + * flexible array member. Recording this information here allows to + * write parser which continue to work if the format is extended by + * adding new fields before the first flexible array member in * variable-size blobs. - * + * * The header structure appears exactly once at the beginning of a typelib. It is a - * collection of meta-information, such as the number of entries and dependencies. + * collection of meta-information, such as the number of entries and dependencies. */ typedef struct { gchar magic[16]; @@ -268,7 +268,7 @@ typedef struct { guint16 object_blob_size; guint16 interface_blob_size; guint16 union_blob_size; - + guint16 padding[7]; } Header; @@ -280,10 +280,10 @@ typedef struct { * @offset: If is_local is set, this is the offset of the blob in the typelib. * Otherwise, it is the offset of the namespace in which the blob has * to be looked up by name. - * + * * References to directory entries are stored as 1-based 16-bit indexes. - * - * All blobs pointed to by a directory entry start with the same layout for + * + * All blobs pointed to by a directory entry start with the same layout for * the first 8 bytes (the reserved flags may be used by some blob types) */ typedef struct { @@ -298,9 +298,9 @@ typedef struct { /** * SimpleTypeBlob: - * @is_pointer: Indicates whether the type is passed by reference. + * @is_pointer: Indicates whether the type is passed by reference. * @tag: A #GITypeTag - * @offset: Offset relative to header->types that points to a TypeBlob. + * @offset: Offset relative to header->types that points to a TypeBlob. * Unlike other offsets, this is in words (ie 32bit units) rather * than bytes. * @@ -320,53 +320,53 @@ typedef struct { */ typedef union { - struct + struct { guint reserved : 8; guint reserved2 :16; guint pointer : 1; guint reserved3 : 2; - guint tag : 5; + guint tag : 5; } flags; guint32 offset; } SimpleTypeBlob; /* * ArgBlob: - * @name: A suggested name for the parameter. + * @name: A suggested name for the parameter. * @in: The parameter is an input to the function - * @out: The parameter is used to return an output of the function. - * Parameters can be both in and out. Out parameters implicitly - * add another level of indirection to the parameter type. Ie if - * the type is uint32 in an out parameter, the function actually + * @out: The parameter is used to return an output of the function. + * Parameters can be both in and out. Out parameters implicitly + * add another level of indirection to the parameter type. Ie if + * the type is uint32 in an out parameter, the function actually * takes an uint32*. - * @dipper: The parameter is a pointer to a struct or object that will - * receive an output of the function. + * @dipper: The parameter is a pointer to a struct or object that will + * receive an output of the function. * @allow_none: Only meaningful for types which are passed as pointers. - * For an in parameter, indicates if it is ok to pass NULL in, for - * an out parameter, whether it may return NULL. Note that NULL is a + * For an in parameter, indicates if it is ok to pass NULL in, for + * an out parameter, whether it may return NULL. Note that NULL is a * valid GList and GSList value, thus allow_none will normally be set * for parameters of these types. * @optional: For an out parameter, indicates that NULL may be passed in * if the value is not needed. - * @transfer_ownership: For an in parameter, indicates that the function takes over - * ownership of the parameter value. For an out parameter, it - * indicates that the caller is responsible for freeing the return + * @transfer_ownership: For an in parameter, indicates that the function takes over + * ownership of the parameter value. For an out parameter, it + * indicates that the caller is responsible for freeing the return * value. * @transfer_container_ownership: For container types, indicates that the - * ownership of the container, but not of its contents is transferred. This is typically the case + * ownership of the container, but not of its contents is transferred. This is typically the case * for out parameters returning lists of statically allocated things. - * @is_return_value: The parameter should be considered the return value of the function. - * Only out parameters can be marked as return value, and there can be - * at most one per function call. If an out parameter is marked as - * return value, the actual return value of the function should be + * @is_return_value: The parameter should be considered the return value of the function. + * Only out parameters can be marked as return value, and there can be + * at most one per function call. If an out parameter is marked as + * return value, the actual return value of the function should be * either void or a boolean indicating the success of the call. * @scope: A #GIScopeType. If the parameter is of a callback type, this denotes the scope * of the user_data and the callback function pointer itself * (for languages that emit code at run-time). - * @closure: Index of the closure (user_data) parameter associated with the callback, + * @closure: Index of the closure (user_data) parameter associated with the callback, * or -1. - * @destroy: Index of the destroy notfication callback parameter associated with + * @destroy: Index of the destroy notfication callback parameter associated with * the callback, or -1. * @arg_type: Describes the type of the parameter. See details below. * @@ -402,9 +402,9 @@ typedef struct { * @caller_owns_return_value: If set, the caller is responsible for freeing the return value * if it is no longer needed. * @caller_owns_return_container: This flag is only relevant if the return type is a container type. - * If the flag is set, the caller is resonsible for freeing the + * If the flag is set, the caller is resonsible for freeing the * container, but not its contents. - * @n_arguments: The number of arguments that this function expects, also the length + * @n_arguments: The number of arguments that this function expects, also the length * of the array of ArgBlobs. * @arguments: An array of ArgBlob for the arguments of the function. */ @@ -426,9 +426,9 @@ typedef struct { * @blob_type: A #GTypelibBlobType * @deprecated: Whether the blob is deprecated. * @name: The name of the blob. - * + * * The #CommonBlob is shared between #FunctionBlob, - * #CallbackBlob, #SignalBlob. + * #CallbackBlob, #SignalBlob. */ typedef struct { guint16 blob_type; /* 1 */ @@ -442,22 +442,22 @@ typedef struct { /** * FunctionBlob: * @blob_Type: #BLOB_TYPE_FUNCTION - * @symbol: The symbol which can be used to obtain the function pointer with + * @symbol: The symbol which can be used to obtain the function pointer with * dlsym(). * @deprecated: The function is deprecated. - * @setter: The function is a setter for a property. Language bindings may - * prefer to not bind individual setters and rely on the generic + * @setter: The function is a setter for a property. Language bindings may + * prefer to not bind individual setters and rely on the generic * g_object_set(). - * @getter: The function is a getter for a property. Language bindings may - * prefer to not bind individual getters and rely on the generic + * @getter: The function is a getter for a property. Language bindings may + * prefer to not bind individual getters and rely on the generic * g_object_get(). - * @constructor:The function acts as a constructor for the object it is contained + * @constructor:The function acts as a constructor for the object it is contained * in. * @wraps_vfunc: The function is a simple wrapper for a virtual function. - * @index: Index of the property that this function is a setter or getter of + * @index: Index of the property that this function is a setter or getter of * in the array of properties of the containing interface, or index * of the virtual function that this function wraps. - * @signature: Offset of the SignatureBlob describing the parameter types and the + * @signature: Offset of the SignatureBlob describing the parameter types and the * return value type. * @is_static: The function is a "static method"; in other words it's a pure * function whose name is conceptually scoped to the object. @@ -487,7 +487,7 @@ typedef struct { /** * CallbackBlob: - * @signature: Offset of the #SignatureBlob describing the parameter types and the + * @signature: Offset of the #SignatureBlob describing the parameter types and the * return value type. */ typedef struct { @@ -505,36 +505,36 @@ typedef struct { * @pointer: Whether this type represents an indirection * @tag: A #GITypeTag * @interface: Index of the directory entry for the interface. - * + * * If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1. */ typedef struct { guint8 pointer :1; guint8 reserved :2; - guint8 tag :5; + guint8 tag :5; guint8 reserved2; - guint16 interface; + guint16 interface; } InterfaceTypeBlob; /** * ArrayTypeBlob: - * @zero_terminated: Indicates that the array must be terminated by a suitable #NULL - * value. - * @has_length: Indicates that length points to a parameter specifying the length - * of the array. If both has_length and zero_terminated are set, the - * convention is to pass -1 for the length if the array is - * zero-terminated. - * @length: The index of the parameter which is used to pass the length of the - * array. The parameter must be an integer type and have the same - * direction as this one. + * @zero_terminated: Indicates that the array must be terminated by a suitable #NULL + * value. + * @has_length: Indicates that length points to a parameter specifying the length + * of the array. If both has_length and zero_terminated are set, the + * convention is to pass -1 for the length if the array is + * zero-terminated. + * @length: The index of the parameter which is used to pass the length of the + * array. The parameter must be an integer type and have the same + * direction as this one. * @type: The type of the array elements. - * + * * Arrays are passed by reference, thus is_pointer is always 1. */ typedef struct { guint16 pointer :1; guint16 reserved :2; - guint16 tag :5; + guint16 tag :5; guint16 zero_terminated :1; guint16 has_length :1; @@ -553,12 +553,12 @@ typedef struct { * ParamTypeBlob: * @n_types: The number of parameter types to follow. * @type: Describes the type of the list elements. - * + * */ typedef struct { guint8 pointer :1; guint8 reserved :2; - guint8 tag :5; + guint8 tag :5; guint8 reserved2; guint16 n_types; @@ -574,7 +574,7 @@ typedef struct { typedef struct { guint8 pointer :1; guint8 reserved :2; - guint8 tag :5; + guint8 tag :5; guint8 reserved2; guint16 n_domains; @@ -584,7 +584,7 @@ typedef struct { /** * ErrorDomainBlob: - * @get_quark: The symbol name of the function which must be called to obtain the + * @get_quark: The symbol name of the function which must be called to obtain the * GQuark for the error domain. * @error_codes: Index of the InterfaceBlob describing the enumeration which lists * the possible error codes. @@ -594,7 +594,7 @@ typedef struct { guint16 deprecated : 1; guint16 reserved :15; - + guint32 name; guint32 get_quark; @@ -607,7 +607,7 @@ typedef struct { * @deprecated: Whether this value is deprecated * @value: The numerical value * @name: Name of blob - * + * * Values commonly occur in enums and flags. */ typedef struct { @@ -633,7 +633,7 @@ typedef struct { typedef struct { guint32 name; - guint8 readable :1; + guint8 readable :1; guint8 writable :1; guint8 has_embedded_type :1; guint8 reserved :5; @@ -652,11 +652,11 @@ typedef struct { * @gtype_init: The symbol name of the get_type() function which registers the type. */ typedef struct { - guint16 blob_type; - guint16 deprecated : 1; + guint16 blob_type; + guint16 deprecated : 1; guint16 unregistered : 1; guint16 reserved :14; - guint32 name; + guint32 name; guint32 gtype_name; guint32 gtype_init; @@ -672,10 +672,10 @@ typedef struct { * @size: The size of the struct in bytes. * @gtype_name: String name of the associated #GType * @gtype_init: String naming the symbol which gets the runtime #GType - * @n_fields: + * @n_fields: * @n_functions: The lengths of the arrays. - * @fields: An array of n_fields FieldBlobs. - * @functions: An array of n_functions FunctionBlobs. The described functions + * @fields: An array of n_fields FieldBlobs. + * @functions: An array of n_functions FunctionBlobs. The described functions * should be considered as methods of the struct. */ typedef struct { @@ -684,7 +684,7 @@ typedef struct { guint16 deprecated : 1; guint16 unregistered : 1; guint16 is_gtype_struct : 1; - guint16 alignment : 6; + guint16 alignment : 6; guint16 reserved : 7; guint32 name; @@ -702,7 +702,7 @@ typedef struct { #if 0 /* variable-length parts of the blob */ - FieldBlob fields[]; + FieldBlob fields[]; FunctionBlob methods[]; #endif } StructBlob; @@ -720,12 +720,12 @@ typedef struct { * discriminator of a discriminated union is located. * The value 0xFFFF indicates that the discriminator offset * is unknown. - * @discriminator_type: Type of the discriminator + * @discriminator_type: Type of the discriminator * @discriminator_values: On discriminator value per field * @fields: Array of FieldBlobs describing the alternative branches of the union */ typedef struct { - guint16 blob_type; + guint16 blob_type; guint16 deprecated : 1; guint16 unregistered : 1; guint16 discriminated : 1; @@ -744,12 +744,12 @@ typedef struct { guint32 reserved2; guint32 reserved3; - gint32 discriminator_offset; + gint32 discriminator_offset; SimpleTypeBlob discriminator_type; #if 0 - FieldBlob fields[]; - FunctionBlob functions[]; + FieldBlob fields[]; + FunctionBlob functions[]; ConstantBlob discriminator_values[] #endif } UnionBlob; @@ -762,17 +762,17 @@ typedef struct { * @gtype_name: String name of the associated #GType * @gtype_init: String naming the symbol which gets the runtime #GType * @n_values: The lengths of the values arrays. - * @values: Describes the enum values. + * @values: Describes the enum values. */ typedef struct { guint16 blob_type; - guint16 deprecated : 1; + guint16 deprecated : 1; guint16 unregistered : 1; guint16 storage_type : 5; guint16 reserved : 9; - guint32 name; + guint32 name; guint32 gtype_name; guint32 gtype_init; @@ -782,15 +782,15 @@ typedef struct { guint32 reserved3; - ValueBlob values[]; + ValueBlob values[]; } EnumBlob; /** * PropertyBlob: - * @name: The name of the property. + * @name: The name of the property. * @readable: - * @writable: - * @construct: + * @writable: + * @construct: * @construct_only: The ParamFlags used when registering the property. * @type: Describes the type of the property. */ @@ -823,7 +823,7 @@ typedef struct { * @true_stops_emit: Whether the signal has true-stops-emit semantics * @class_closure: The index of the class closure in the list of virtual functions * of the object or interface on which the signal is defined. - * @signature: Offset of the SignatureBlob describing the parameter types and the + * @signature: Offset of the SignatureBlob describing the parameter types and the * return value type. */ typedef struct { @@ -852,19 +852,19 @@ typedef struct { * VFuncBlob: * @name: The name of the virtual function. * @must_chain_up: If set, every implementation of this virtual function must - * chain up to the implementation of the parent class. + * chain up to the implementation of the parent class. * @must_be_implemented: If set, every derived class must override this virtual function. * @must_not_be_implemented: If set, derived class must not override this virtual function. * @class_closure: Set if this virtual function is the class closure of a signal. - * @signal: The index of the signal in the list of signals of the object or + * @signal: The index of the signal in the list of signals of the object or * interface to which this virtual function belongs. * @struct_offset: The offset of the function pointer in the class struct. The value * 0xFFFF indicates that the struct offset is unknown. * @invoker: If a method invoker for this virtual exists, this is the offset in the * class structure of the method. If no method is known, this value will be 0x3ff. - * @signature: - * Offset of the SignatureBlob describing the parameter types and the - * return value type. + * @signature: + * Offset of the SignatureBlob describing the parameter types and the + * return value type. */ typedef struct { guint32 name; @@ -889,19 +889,19 @@ typedef struct { * @blob_type: #BLOB_TYPE_OBJECT * @gtype_name: String name of the associated #GType * @gtype_init: String naming the symbol which gets the runtime #GType - * @parent: The directory index of the parent type. This is only set for + * @parent: The directory index of the parent type. This is only set for * objects. If an object does not have a parent, it is zero. * @n_interfaces: - * @n_fields: + * @n_fields: * @n_properties: * @n_methods: * @n_signals: * @n_vfuncs: - * @n_constants: The lengths of the arrays.Up to 16bits of padding may be inserted + * @n_constants: The lengths of the arrays.Up to 16bits of padding may be inserted * between the arrays to ensure that they start on a 32bit boundary. - * @interfaces: An array of indices of directory entries for the implemented + * @interfaces: An array of indices of directory entries for the implemented * interfaces. - * @fields: Describes the fields. + * @fields: Describes the fields. * @methods: Describes the methods, constructors, setters and getters. * @properties: Describes the properties. * @signals: Describes the signals. @@ -934,7 +934,7 @@ typedef struct { guint32 reserved4; guint16 interfaces[]; - + #if 0 /* variable-length parts of the blob */ FieldBlob fields[]; @@ -965,10 +965,10 @@ typedef struct { * @constants: Describes the constants. */ typedef struct { - guint16 blob_type; + guint16 blob_type; guint16 deprecated : 1; guint16 reserved :15; - guint32 name; + guint32 name; guint32 gtype_name; guint32 gtype_init; @@ -979,14 +979,14 @@ typedef struct { guint16 n_methods; guint16 n_signals; guint16 n_vfuncs; - guint16 n_constants; + guint16 n_constants; guint32 reserved2; guint32 reserved3; guint16 prerequisites[]; -#if 0 +#if 0 /* variable-length parts of the blob */ PropertyBlob properties[]; FunctionBlob methods[]; @@ -1005,9 +1005,9 @@ typedef struct { */ typedef struct { guint16 blob_type; - guint16 deprecated : 1; + guint16 deprecated : 1; guint16 reserved :15; - guint32 name; + guint32 name; SimpleTypeBlob type; |