From 34c298a51e621b26df5126bcbca1d5d5724381ec Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 12 Aug 2011 11:10:06 -0400 Subject: [PATCH 1/5] girepository: fix some doc comment syntax --- girepository.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/girepository.c b/girepository.c index f7f55e5a6..c5c464bd7 100644 --- a/girepository.c +++ b/girepository.c @@ -382,7 +382,7 @@ register_internal (GIRepository *repository, * form namespace-version. * * Note: The namespace must have already been loaded using a function - * such as #g_irepository_require before calling this function. + * such as g_irepository_require() before calling this function. * * Returns: (transfer full): Zero-terminated string array of versioned dependencies */ @@ -447,7 +447,7 @@ g_irepository_load_typelib (GIRepository *repository, * Check whether a particular namespace (and optionally, a specific * version thereof) is currently loaded. This function is likely to * only be useful in unusual circumstances; in order to act upon - * metadata in the namespace, you should call #g_irepository_require + * 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. * @@ -648,7 +648,7 @@ g_irepository_find_by_gtype (GIRepository *repository, * * Searches for a particular entry in a namespace. Before calling * this function for a particular namespace, you must call - * #g_irepository_require once to load the namespace, or otherwise + * g_irepository_require() once to load the namespace, or otherwise * ensure the namespace has already been loaded. * * Returns: (transfer full): #GIBaseInfo representing metadata about @name, or %NULL @@ -723,7 +723,7 @@ g_irepository_get_loaded_namespaces (GIRepository *repository) * namespace @namespace_. * * Note: The namespace must have already been loaded using a function - * such as #g_irepository_require before calling this function. + * such as g_irepository_require() before calling this function. * * Returns: Loaded version */ @@ -757,7 +757,7 @@ g_irepository_get_version (GIRepository *repository, * return %NULL. * * Note: The namespace must have already been loaded using a function - * such as #g_irepository_require before calling this function. + * such as g_irepository_require() before calling this function. * * Returns: Full path to shared library, or %NULL if none associated */ @@ -793,7 +793,7 @@ g_irepository_get_shared_library (GIRepository *repository, * starts with this prefix, as well each #GType in the library. * * Note: The namespace must have already been loaded using a function - * such as #g_irepository_require before calling this function. + * such as g_irepository_require() before calling this function. * * Returns: C namespace prefix, or %NULL if none associated */ From 6ee82c14e84eefcd9c6273fd046f22a761eabd0f Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 19 May 2011 16:12:03 -0400 Subject: [PATCH 2/5] Deprecate ErrorDomain The previous ErrorDomain blob was never actually scanned or used, and it was kind of a lame API conceptually. To keep some compatibility, rather than removing the enumeration values, rename them to _INVALID, and don't bump the typelib version. This should in theory allow a new libgirepository to read an old typelib. Based on a patch from Colin Walters https://bugzilla.gnome.org/show_bug.cgi?id=602516 --- gibaseinfo.c | 5 +-- gierrordomaininfo.c | 95 -------------------------------------------- gierrordomaininfo.h | 44 -------------------- gifieldinfo.c | 4 +- girepository.c | 2 - girepository.h | 1 - girmodule.c | 2 +- girnode.c | 70 ++------------------------------ girnode.h | 15 +------ girparser.c | 81 ++----------------------------------- girwriter.c | 40 ------------------- gitypeinfo.c | 69 -------------------------------- gitypeinfo.h | 3 -- gitypelib-internal.h | 29 ++------------ gitypelib.c | 40 ------------------- gitypes.h | 10 +---- 16 files changed, 17 insertions(+), 493 deletions(-) delete mode 100644 gierrordomaininfo.c delete mode 100644 gierrordomaininfo.h diff --git a/gibaseinfo.c b/gibaseinfo.c index 057cde729..bfb774360 100644 --- a/gibaseinfo.c +++ b/gibaseinfo.c @@ -202,7 +202,6 @@ _g_type_info_init (GIBaseInfo *info, * +----GIArgInfo * +----GICallableInfo * +----GIConstantInfo - * +----GIErrorDomainInfo * +----GIFieldInfo * +----GIPropertyInfo * +----GIRegisteredTypeInfo @@ -299,7 +298,7 @@ g_base_info_get_name (GIBaseInfo *info) case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_CONSTANT: - case GI_INFO_TYPE_ERROR_DOMAIN: + case GI_INFO_TYPE_INVALID_0: case GI_INFO_TYPE_UNION: { CommonBlob *blob = (CommonBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -421,7 +420,7 @@ g_base_info_is_deprecated (GIBaseInfo *info) case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_CONSTANT: - case GI_INFO_TYPE_ERROR_DOMAIN: + case GI_INFO_TYPE_INVALID_0: { CommonBlob *blob = (CommonBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/gierrordomaininfo.c b/gierrordomaininfo.c deleted file mode 100644 index 86e40c59b..000000000 --- a/gierrordomaininfo.c +++ /dev/null @@ -1,95 +0,0 @@ -/* GObject introspection: ErrorDomain implementation - * - * Copyright (C) 2005 Matthias Clasen - * Copyright (C) 2008,2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include -#include "girepository-private.h" -#include "gitypelib-internal.h" - -/** - * SECTION:gierrordomaininfo - * @Short_description: Struct representing an error domain - * @Title: GIErrorDomainInfo - * - * A GIErrorDomainInfo struct represents a domain of a #GError. - * An error domain is associated with a #GQuark and contains a pointer - * to an enum with all the error codes. - * - * - * Struct hierarchy - * - * GIBaseInfo - * +----GIErrorDomainInfo - * - * - */ - -/** - * g_error_domain_info_get_quark: - * @info: a #GIErrorDomainInfo - * - * Obtain a string representing the quark for this error domain. - * %NULL will be returned if the type tag is wrong or if a quark is - * missing in the typelib. - * - * Returns: the quark represented as a string or %NULL - */ -const gchar * -g_error_domain_info_get_quark (GIErrorDomainInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - ErrorDomainBlob *blob; - - g_return_val_if_fail (info != NULL, NULL); - g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); - - blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; - - return g_typelib_get_string (rinfo->typelib, blob->get_quark); -} - -/** - * g_error_domain_info_get_codes: - * @info: a #GIErrorDomainInfo - * - * Obtain the enum containing all the error codes for this error domain. - * The return value will have a #GIInfoType of %GI_INFO_TYPE_ERROR_DOMAIN - * - * Returns: (transfer full): the error domain or %NULL if type tag is wrong, - * free the struct with g_base_info_unref() when done. - */ -GIInterfaceInfo * -g_error_domain_info_get_codes (GIErrorDomainInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - ErrorDomainBlob *blob; - - g_return_val_if_fail (info != NULL, NULL); - g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); - - blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; - - return (GIInterfaceInfo *) _g_info_from_entry (rinfo->repository, - rinfo->typelib, blob->error_codes); -} - - diff --git a/gierrordomaininfo.h b/gierrordomaininfo.h deleted file mode 100644 index 9c2968bc1..000000000 --- a/gierrordomaininfo.h +++ /dev/null @@ -1,44 +0,0 @@ -/* GObject introspection: Error Domain - * - * Copyright (C) 2005 Matthias Clasen - * Copyright (C) 2008,2009 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GIERRORDOMAININFO_H__ -#define __GIERRORDOMAININFO_H__ - -#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -#define GI_IS_ERROR_DOMAIN_INFO(info) \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ERROR_DOMAIN) - -const gchar * g_error_domain_info_get_quark (GIErrorDomainInfo *info); -GIInterfaceInfo * g_error_domain_info_get_codes (GIErrorDomainInfo *info); - - -G_END_DECLS - - -#endif /* __GIERRORDOMAININFO_H__ */ - diff --git a/gifieldinfo.c b/gifieldinfo.c index 17491a80a..41976855d 100644 --- a/gifieldinfo.c +++ b/gifieldinfo.c @@ -322,7 +322,7 @@ g_field_info_get_field (GIFieldInfo *field_info, case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CONSTANT: - case GI_INFO_TYPE_ERROR_DOMAIN: + case GI_INFO_TYPE_INVALID_0: case GI_INFO_TYPE_VALUE: case GI_INFO_TYPE_SIGNAL: case GI_INFO_TYPE_PROPERTY: @@ -498,7 +498,7 @@ g_field_info_set_field (GIFieldInfo *field_info, case GI_INFO_TYPE_INTERFACE: case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CONSTANT: - case GI_INFO_TYPE_ERROR_DOMAIN: + case GI_INFO_TYPE_INVALID_0: case GI_INFO_TYPE_VALUE: case GI_INFO_TYPE_SIGNAL: case GI_INFO_TYPE_PROPERTY: diff --git a/girepository.c b/girepository.c index c5c464bd7..1afba0c80 100644 --- a/girepository.c +++ b/girepository.c @@ -1466,8 +1466,6 @@ g_info_type_to_string (GIInfoType type) return "interface"; case GI_INFO_TYPE_CONSTANT: return "constant"; - case GI_INFO_TYPE_ERROR_DOMAIN: - return "error domain"; case GI_INFO_TYPE_UNION: return "union"; case GI_INFO_TYPE_VALUE: diff --git a/girepository.h b/girepository.h index f14b1ad77..fddcf8c16 100644 --- a/girepository.h +++ b/girepository.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/girmodule.c b/girmodule.c index 49daaa620..f438a193b 100644 --- a/girmodule.c +++ b/girmodule.c @@ -415,7 +415,7 @@ _g_ir_module_build_typelib (GIrModule *module) header->field_blob_size = sizeof (FieldBlob); header->value_blob_size = sizeof (ValueBlob); header->constant_blob_size = sizeof (ConstantBlob); - header->error_domain_blob_size = sizeof (ErrorDomainBlob); + header->error_domain_blob_size = 16; /* No longer used */ header->attribute_blob_size = sizeof (AttributeBlob); header->signature_blob_size = sizeof (SignatureBlob); header->enum_blob_size = sizeof (EnumBlob); diff --git a/girnode.c b/girnode.c index a56471e52..1c51bfd4b 100644 --- a/girnode.c +++ b/girnode.c @@ -101,8 +101,6 @@ _g_ir_node_type_to_string (GIrNodeTypeId type) return "value"; case G_IR_NODE_CONSTANT: return "constant"; - case G_IR_NODE_ERROR_DOMAIN: - return "error-domain"; case G_IR_NODE_XREF: return "xref"; case G_IR_NODE_UNION: @@ -175,10 +173,6 @@ _g_ir_node_new (GIrNodeTypeId type, node = g_malloc0 (sizeof (GIrNodeConstant)); break; - case G_IR_NODE_ERROR_DOMAIN: - node = g_malloc0 (sizeof (GIrNodeErrorDomain)); - break; - case G_IR_NODE_XREF: node = g_malloc0 (sizeof (GIrNodeXRef)); break; @@ -379,16 +373,6 @@ _g_ir_node_free (GIrNode *node) } break; - case G_IR_NODE_ERROR_DOMAIN: - { - GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node; - - g_free (node->name); - g_free (domain->getquark); - g_free (domain->codes); - } - break; - case G_IR_NODE_XREF: { GIrNodeXRef *xref = (GIrNodeXRef *)node; @@ -535,10 +519,6 @@ _g_ir_node_get_size (GIrNode *node) size = sizeof (ConstantBlob); break; - case G_IR_NODE_ERROR_DOMAIN: - size = sizeof (ErrorDomainBlob); - break; - case G_IR_NODE_XREF: size = 0; break; @@ -665,16 +645,7 @@ _g_ir_node_get_full_size_internal (GIrNode *parent, size += _g_ir_node_get_full_size_internal (node, (GIrNode *)type->parameter_type2); break; case GI_TYPE_TAG_ERROR: - { - gint n; - - if (type->errors) - n = g_strv_length (type->errors); - else - n = 0; - - size += sizeof (ErrorTypeBlob) + 2 * (n + n % 2); - } + size += sizeof (ErrorTypeBlob); break; default: g_error ("Unknown type tag %d\n", type->tag); @@ -844,16 +815,6 @@ _g_ir_node_get_full_size_internal (GIrNode *parent, } break; - case G_IR_NODE_ERROR_DOMAIN: - { - GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node; - - size = sizeof (ErrorDomainBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += ALIGN_VALUE (strlen (domain->getquark) + 1, 4); - } - break; - case G_IR_NODE_XREF: { GIrNodeXRef *xref = (GIrNodeXRef *)node; @@ -935,7 +896,7 @@ _g_ir_node_can_have_member (GIrNode *node) case G_IR_NODE_ENUM: case G_IR_NODE_FLAGS: case G_IR_NODE_CONSTANT: - case G_IR_NODE_ERROR_DOMAIN: + case G_IR_NODE_INVALID_0: case G_IR_NODE_PARAM: case G_IR_NODE_TYPE: case G_IR_NODE_PROPERTY: @@ -1559,21 +1520,14 @@ _g_ir_node_build_typelib (GIrNode *node, 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) - blob->n_domains = g_strv_length (type->errors); - else - blob->n_domains = 0; + 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 (build, type->errors[i]); + *offset2 += sizeof (ErrorTypeBlob); } break; @@ -2234,22 +2188,6 @@ _g_ir_node_build_typelib (GIrNode *node, } break; - case G_IR_NODE_ERROR_DOMAIN: - { - GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node; - ErrorDomainBlob *blob = (ErrorDomainBlob *)&data[*offset]; - *offset += sizeof (ErrorDomainBlob); - - blob->blob_type = BLOB_TYPE_ERROR_DOMAIN; - blob->deprecated = domain->deprecated; - blob->reserved = 0; - blob->name = _g_ir_write_string (node->name, strings, data, offset2); - blob->get_quark = _g_ir_write_string (domain->getquark, strings, data, offset2); - blob->error_codes = find_entry (build, domain->codes); - blob->reserved2 = 0; - } - break; - case G_IR_NODE_CONSTANT: { GIrNodeConstant *constant = (GIrNodeConstant *)node; diff --git a/girnode.h b/girnode.h index 1f9102fd2..fb2616b1e 100644 --- a/girnode.h +++ b/girnode.h @@ -41,7 +41,6 @@ typedef struct _GIrNodeEnum GIrNodeEnum; typedef struct _GIrNodeBoxed GIrNodeBoxed; typedef struct _GIrNodeStruct GIrNodeStruct; typedef struct _GIrNodeConstant GIrNodeConstant; -typedef struct _GIrNodeErrorDomain GIrNodeErrorDomain; typedef struct _GIrNodeXRef GIrNodeXRef; typedef struct _GIrNodeUnion GIrNodeUnion; @@ -57,7 +56,7 @@ typedef enum G_IR_NODE_OBJECT = 7, G_IR_NODE_INTERFACE = 8, G_IR_NODE_CONSTANT = 9, - G_IR_NODE_ERROR_DOMAIN = 10, + G_IR_NODE_INVALID_0 = 10, /* DELETED - used to be ERROR_DOMAIN */ G_IR_NODE_UNION = 11, G_IR_NODE_PARAM = 12, G_IR_NODE_TYPE = 13, @@ -343,18 +342,6 @@ struct _GIrNodeUnion }; -struct _GIrNodeErrorDomain -{ - GIrNode node; - - gboolean deprecated; - - gchar *name; - gchar *getquark; - gchar *codes; -}; - - GIrNode * _g_ir_node_new (GIrNodeTypeId type, GIrModule *module); void _g_ir_node_free (GIrNode *node); diff --git a/girparser.c b/girparser.c index 02c044279..4e5527259 100644 --- a/girparser.c +++ b/girparser.c @@ -68,13 +68,12 @@ typedef enum STATE_BOXED_FIELD, STATE_STRUCT, STATE_STRUCT_FIELD, - STATE_ERRORDOMAIN, /* 25 */ - STATE_UNION, + STATE_UNION, /* 25 */ STATE_UNION_FIELD, STATE_NAMESPACE_CONSTANT, STATE_CLASS_CONSTANT, - STATE_INTERFACE_CONSTANT, /* 30 */ - STATE_ALIAS, + STATE_INTERFACE_CONSTANT, + STATE_ALIAS, /* 30 */ STATE_TYPE, STATE_ATTRIBUTE, STATE_DOC, @@ -1614,68 +1613,6 @@ start_constant (GMarkupParseContext *context, return TRUE; } -static gboolean -start_errordomain (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) -{ - const gchar *name; - const gchar *getquark; - const gchar *codes; - const gchar *deprecated; - GIrNodeErrorDomain *domain; - - if (!(strcmp (element_name, "errordomain") == 0 && - ctx->state == STATE_NAMESPACE)) - return FALSE; - - if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_ERRORDOMAIN)) - return TRUE; - - - 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"); - return FALSE; - } - else if (getquark == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "getquark"); - return FALSE; - } - else if (codes == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "codes"); - return FALSE; - } - - domain = (GIrNodeErrorDomain *) _g_ir_node_new (G_IR_NODE_ERROR_DOMAIN, - ctx->current_module); - - ((GIrNode *)domain)->name = g_strdup (name); - domain->getquark = g_strdup (getquark); - domain->codes = g_strdup (codes); - - if (deprecated) - domain->deprecated = TRUE; - else - domain->deprecated = FALSE; - - push_node (ctx, (GIrNode *) domain); - ctx->current_module->entries = - g_list_append (ctx->current_module->entries, domain); - - return TRUE; -} - static gboolean start_interface (GMarkupParseContext *context, const gchar *element_name, @@ -2788,10 +2725,6 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (start_errordomain (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; break; case 'f': @@ -3290,14 +3223,6 @@ end_element_handler (GMarkupParseContext *context, } break; - case STATE_ERRORDOMAIN: - if (require_end_element (context, ctx, "errordomain", element_name, error)) - { - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - } - break; - case STATE_INTERFACE_PROPERTY: if (strcmp ("type", element_name) == 0) break; diff --git a/girwriter.c b/girwriter.c index f6ab34ebd..2cdc9a11f 100644 --- a/girwriter.c +++ b/girwriter.c @@ -212,7 +212,6 @@ write_type_info (const gchar *namespace, Xml *file) { gint tag; - gint i; GITypeInfo *type; gboolean is_pointer; @@ -329,24 +328,8 @@ write_type_info (const gchar *namespace, } else if (tag == GI_TYPE_TAG_ERROR) { - gint n; - xml_start_element (file, "type"); xml_printf (file, " name=\"GLib.Error\""); - - n = g_type_info_get_n_error_domains (info); - if (n > 0) - { - for (i = 0; i < n; i++) - { - GIErrorDomainInfo *ed = g_type_info_get_error_domain (info, i); - xml_start_element (file, "type"); - write_type_name_attribute (namespace, (GIBaseInfo *)ed, "name", file); - xml_end_element (file, "type"); - g_base_info_unref ((GIBaseInfo *)ed); - } - } - xml_end_element (file, "type"); } else @@ -1193,25 +1176,6 @@ write_interface_info (const gchar *namespace, xml_end_element (file, "interface"); } -static void -write_error_domain_info (const gchar *namespace, - GIErrorDomainInfo *info, - Xml *file) -{ - GIBaseInfo *enum_; - const gchar *name, *quark; - - name = g_base_info_get_name ((GIBaseInfo *)info); - quark = g_error_domain_info_get_quark (info); - enum_ = (GIBaseInfo *)g_error_domain_info_get_codes (info); - xml_start_element (file, "errordomain"); - xml_printf (file, " name=\"%s\" get-quark=\"%s\"", - name, quark); - write_type_name_attribute (namespace, enum_, "codes", file); - xml_end_element (file, "errordomain"); - g_base_info_unref (enum_); -} - static void write_union_info (const gchar *namespace, GIUnionInfo *info, @@ -1411,10 +1375,6 @@ gir_writer_write (const char *filename, write_interface_info (ns, (GIInterfaceInfo *)info, xml); break; - case GI_INFO_TYPE_ERROR_DOMAIN: - write_error_domain_info (ns, (GIErrorDomainInfo *)info, xml); - break; - default: g_error ("unknown info type %d\n", g_base_info_get_type (info)); } diff --git a/gitypeinfo.c b/gitypeinfo.c index 1bc9b0a13..5864f82fe 100644 --- a/gitypeinfo.c +++ b/gitypeinfo.c @@ -340,72 +340,3 @@ g_type_info_get_array_type (GITypeInfo *info) return -1; } - -/** - * g_type_info_get_n_error_domains: - * @info: a #GITypeInfo - * - * Obtain the number of error domains for this type. The type tag - * must be a #GI_TYPE_TAG_ERROR or -1 will be returned. - * - * Returns: number of error domains or -1 - */ -gint -g_type_info_get_n_error_domains (GITypeInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - SimpleTypeBlob *type; - - g_return_val_if_fail (info != NULL, 0); - g_return_val_if_fail (GI_IS_TYPE_INFO (info), 0); - - type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) - { - ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (blob->tag == GI_TYPE_TAG_ERROR) - return blob->n_domains; - } - - return 0; -} - -/** - * g_type_info_get_error_domain: - * @info: a #GITypeInfo - * @n: index of error domain - * - * Obtain the error domains at index @n for this type. The type tag - * must be a #GI_TYPE_TAG_ERROR or -1 will be returned. - * - * Returns: (transfer full): the error domain or %NULL if type tag is wrong, - * free the struct with g_base_info_unref() when done. - */ -GIErrorDomainInfo * -g_type_info_get_error_domain (GITypeInfo *info, - gint n) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - SimpleTypeBlob *type; - - g_return_val_if_fail (info != NULL, NULL); - g_return_val_if_fail (GI_IS_TYPE_INFO (info), NULL); - - type = (SimpleTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) - { - ErrorTypeBlob *blob = (ErrorTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (blob->tag == GI_TYPE_TAG_ERROR) - return (GIErrorDomainInfo *) _g_info_from_entry (rinfo->repository, - rinfo->typelib, - blob->domains[n]); - } - - return NULL; -} - - diff --git a/gitypeinfo.h b/gitypeinfo.h index 5c4fc8351..56e7309aa 100644 --- a/gitypeinfo.h +++ b/gitypeinfo.h @@ -48,9 +48,6 @@ gint g_type_info_get_array_fixed_size(GITypeInfo *info); gboolean g_type_info_is_zero_terminated (GITypeInfo *info); GIArrayType g_type_info_get_array_type (GITypeInfo *info); -gint g_type_info_get_n_error_domains (GITypeInfo *info); -GIErrorDomainInfo *g_type_info_get_error_domain (GITypeInfo *info, - gint n); G_END_DECLS diff --git a/gitypelib-internal.h b/gitypelib-internal.h index 593c9876c..2bda8d9d0 100644 --- a/gitypelib-internal.h +++ b/gitypelib-internal.h @@ -57,7 +57,7 @@ G_BEGIN_DECLS * directory ::= list of entries * * entry ::= blob type, name, namespace, offset - * blob ::= function|callback|struct|boxed|enum|flags|object|interface|constant|errordomain|union + * blob ::= function|callback|struct|boxed|enum|flags|object|interface|constant|union * attributes ::= list of attributes, sorted by offset * attribute ::= offset, key, value * attributedata ::= string data for attributes @@ -156,7 +156,6 @@ Changes since 0.1: * @BLOB_TYPE_OBJECT: An #ObjectBlob * @BLOB_TYPE_INTERFACE: An #InterfaceBlob * @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" @@ -173,7 +172,7 @@ typedef enum { BLOB_TYPE_OBJECT, BLOB_TYPE_INTERFACE, BLOB_TYPE_CONSTANT, - BLOB_TYPE_ERROR_DOMAIN, + BLOB_TYPE_INVALID_0, /* DELETED - used to be ErrorDomain */ BLOB_TYPE_UNION } GTypelibBlobType; @@ -624,8 +623,6 @@ typedef struct { /** * ErrorTypeBlob: - * @n_domains: The number of domains to follow - * @domains: Indices of the directory entries for the error domains */ typedef struct { guint8 pointer :1; @@ -633,31 +630,11 @@ typedef struct { guint8 tag :5; guint8 reserved2; - guint16 n_domains; + guint16 n_domains; /* Must be 0 */ guint16 domains[]; } ErrorTypeBlob; -/** - * ErrorDomainBlob: - * @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. - */ -typedef struct { - guint16 blob_type; /* 10 */ - - guint16 deprecated : 1; - guint16 reserved :15; - - guint32 name; - - guint32 get_quark; - guint16 error_codes; - guint16 reserved2; -} ErrorDomainBlob; - /** * ValueBlob: * @deprecated: Whether this value is deprecated diff --git a/gitypelib.c b/gitypelib.c index 6d1333ba0..3869a6d25 100644 --- a/gitypelib.c +++ b/gitypelib.c @@ -284,7 +284,6 @@ g_typelib_check_sanity (void) CHECK_SIZE (ArrayTypeBlob, 8); CHECK_SIZE (ParamTypeBlob, 4); CHECK_SIZE (ErrorTypeBlob, 4); - CHECK_SIZE (ErrorDomainBlob, 16); CHECK_SIZE (ValueBlob, 12); CHECK_SIZE (FieldBlob, 16); CHECK_SIZE (RegisteredTypeBlob, 16); @@ -446,7 +445,6 @@ validate_header_basic (const guint8 *memory, header->field_blob_size != sizeof (FieldBlob) || header->value_blob_size != sizeof (ValueBlob) || header->constant_blob_size != sizeof (ConstantBlob) || - header->error_domain_blob_size != sizeof (ErrorDomainBlob) || header->attribute_blob_size != sizeof (AttributeBlob) || header->signature_blob_size != sizeof (SignatureBlob) || header->enum_blob_size != sizeof (EnumBlob) || @@ -607,8 +605,6 @@ validate_error_type_blob (GITypelib *typelib, { ErrorTypeBlob *blob; Header *header; - gint i; - DirEntry *entry; blob = (ErrorTypeBlob*)&typelib->data[offset]; @@ -623,30 +619,6 @@ validate_error_type_blob (GITypelib *typelib, return FALSE; } - for (i = 0; i < blob->n_domains; i++) - { - if (blob->domains[i] == 0 || blob->domains[i] > header->n_entries) - { - g_set_error (error, - G_TYPELIB_ERROR, - G_TYPELIB_ERROR_INVALID_BLOB, - "Invalid directory index %d", blob->domains[i]); - return FALSE; - } - - entry = g_typelib_get_dir_entry (typelib, blob->domains[i]); - - if (entry->blob_type != BLOB_TYPE_ERROR_DOMAIN && - (entry->local || entry->blob_type != BLOB_TYPE_INVALID)) - { - g_set_error (error, - G_TYPELIB_ERROR, - G_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); - return FALSE; - } - } - return TRUE; } @@ -1824,14 +1796,6 @@ validate_interface_blob (ValidateContext *ctx, return TRUE; } -static gboolean -validate_errordomain_blob (GITypelib *typelib, - guint32 offset, - GError **error) -{ - return TRUE; -} - static gboolean validate_union_blob (GITypelib *typelib, guint32 offset, @@ -1891,10 +1855,6 @@ validate_blob (ValidateContext *ctx, if (!validate_constant_blob (typelib, offset, error)) return FALSE; break; - case BLOB_TYPE_ERROR_DOMAIN: - if (!validate_errordomain_blob (typelib, offset, error)) - return FALSE; - break; case BLOB_TYPE_UNION: if (!validate_union_blob (typelib, offset, error)) return FALSE; diff --git a/gitypes.h b/gitypes.h index d15b121a3..cbe43168b 100644 --- a/gitypes.h +++ b/gitypes.h @@ -150,13 +150,6 @@ typedef GIBaseInfo GIArgInfo; */ typedef GIBaseInfo GITypeInfo; -/** - * GIErrorDomainInfo: - * - * Represents a #GError error domain. - */ -typedef GIBaseInfo GIErrorDomainInfo; - /** * GIUnresolvedInfo: * @@ -202,7 +195,6 @@ typedef union _GIArgument GIArgument; * @GI_INFO_TYPE_OBJECT: object, see #GIObjectInfo * @GI_INFO_TYPE_INTERFACE: interface, see #GIInterfaceInfo * @GI_INFO_TYPE_CONSTANT: contant, see #GIConstantInfo - * @GI_INFO_TYPE_ERROR_DOMAIN: error domain for a #GError, see #GIErrorDomainInfo * @GI_INFO_TYPE_UNION: union, see #GIUnionInfo * @GI_INFO_TYPE_VALUE: enum value, see #GIValueInfo * @GI_INFO_TYPE_SIGNAL: signal, see #GISignalInfo @@ -228,7 +220,7 @@ typedef enum GI_INFO_TYPE_OBJECT, GI_INFO_TYPE_INTERFACE, GI_INFO_TYPE_CONSTANT, - GI_INFO_TYPE_ERROR_DOMAIN, /* 10 */ + GI_INFO_TYPE_INVALID_0, /* 10 */ /** DELETED - used to be ERROR_DOMAIN **/ GI_INFO_TYPE_UNION, GI_INFO_TYPE_VALUE, GI_INFO_TYPE_SIGNAL, From 215d83ebb0a7f15b359e9e63fea2715113784ff7 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 19 May 2011 16:21:13 -0400 Subject: [PATCH 3/5] Switch to storing string form of error quarks Instead of storing the name of the function to call to get the error quark, store the string form of the error quark, which we derive from the introspection binary during scanning. Update EnumBlob and GIEnumInfo to include the new information. This will allow determining a back-mapping from error quark to error domain without having to dlsym() and call all the known error quark functions. Based on earlier patches from Owen Taylor and Maxim Ermilov. https://bugzilla.gnome.org/show_bug.cgi?id=602516 --- gdump.c | 83 +++++++++++++++++++++++++++++++++++--------- gienuminfo.c | 17 +++++++++ gienuminfo.h | 1 + girnode.c | 7 ++++ girnode.h | 1 + girparser.c | 4 +++ girwriter.c | 4 +++ gitypelib-internal.h | 4 ++- 8 files changed, 104 insertions(+), 17 deletions(-) diff --git a/gdump.c b/gdump.c index cb6e74197..e607f3237 100644 --- a/gdump.c +++ b/gdump.c @@ -70,6 +70,7 @@ goutput_write (GOutputStream *out, const char *str) } typedef GType (*GetTypeFunc)(void); +typedef GQuark (*ErrorQuarkFunc)(void); static GType invoke_get_type (GModule *self, const char *symbol, GError **error) @@ -97,6 +98,23 @@ invoke_get_type (GModule *self, const char *symbol, GError **error) return ret; } +static GQuark +invoke_error_quark (GModule *self, const char *symbol, GError **error) +{ + ErrorQuarkFunc sym; + + if (!g_module_symbol (self, symbol, (void**)&sym)) + { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + "Failed to find symbol '%s'", symbol); + return G_TYPE_INVALID; + } + + return sym (); +} + static void dump_properties (GType type, GOutputStream *out) { @@ -365,6 +383,13 @@ dump_type (GType type, const char *symbol, GOutputStream *out) } } +static void +dump_error_quark (GQuark quark, const char *symbol, GOutputStream *out) +{ + escaped_printf (out, " \n", + symbol, g_quark_to_string (quark)); +} + /** * g_irepository_dump: * @arg: Comma-separated pair of input and output filenames @@ -437,29 +462,55 @@ g_irepository_dump (const char *arg, GError **error) { gsize len; char *line = g_data_input_stream_read_line (in, &len, NULL, NULL); - GType type; + const char *function; if (line == NULL || *line == '\0') - { - g_free (line); - break; - } + { + g_free (line); + break; + } g_strchomp (line); - type = invoke_get_type (self, line, error); - if (type == G_TYPE_INVALID) - { - caught_error = TRUE; - g_free (line); - break; - } + if (strncmp (line, "get-type:", strlen ("get-type:")) == 0) + { + GType type; - if (g_hash_table_lookup (output_types, (gpointer) type)) - goto next; - g_hash_table_insert (output_types, (gpointer) type, (gpointer) type); + function = line + strlen ("get-type:"); + + type = invoke_get_type (self, function, error); + + if (type == G_TYPE_INVALID) + { + g_printerr ("Invalid GType function: '%s'\n", function); + caught_error = TRUE; + g_free (line); + break; + } + + if (g_hash_table_lookup (output_types, (gpointer) type)) + goto next; + g_hash_table_insert (output_types, (gpointer) type, (gpointer) type); + + dump_type (type, function, G_OUTPUT_STREAM (output)); + } + else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0) + { + GQuark quark; + function = line + strlen ("error-quark:"); + quark = invoke_error_quark (self, function, error); + + if (quark == 0) + { + g_printerr ("Invalid error quark function: '%s'\n", function); + caught_error = TRUE; + g_free (line); + break; + } + + dump_error_quark (quark, function, G_OUTPUT_STREAM (output)); + } - dump_type (type, line, G_OUTPUT_STREAM (output)); next: g_free (line); diff --git a/gienuminfo.c b/gienuminfo.c index 062f3abf2..338a46ee0 100644 --- a/gienuminfo.c +++ b/gienuminfo.c @@ -66,6 +66,23 @@ g_enum_info_get_n_values (GIEnumInfo *info) return blob->n_values; } +const gchar * +g_enum_info_get_error_domain (GIEnumInfo *info) +{ + GIRealInfo *rinfo = (GIRealInfo *)info; + EnumBlob *blob; + + g_return_val_if_fail (info != NULL, 0); + g_return_val_if_fail (GI_IS_ENUM_INFO (info), 0); + + blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset]; + + if (blob->error_domain) + return g_typelib_get_string (rinfo->typelib, blob->error_domain); + else + return NULL; +} + /** * g_enum_info_get_value: * @info: a #GIEnumInfo diff --git a/gienuminfo.h b/gienuminfo.h index 6b24fe7ef..fc0f3c842 100644 --- a/gienuminfo.h +++ b/gienuminfo.h @@ -41,6 +41,7 @@ gint g_enum_info_get_n_values (GIEnumInfo *info); GIValueInfo * g_enum_info_get_value (GIEnumInfo *info, gint n); GITypeTag g_enum_info_get_storage_type (GIEnumInfo *info); +const gchar * g_enum_info_get_error_domain (GIEnumInfo *info); gint64 g_value_info_get_value (GIValueInfo *info); diff --git a/girnode.c b/girnode.c index 1c51bfd4b..166ca30a3 100644 --- a/girnode.c +++ b/girnode.c @@ -328,6 +328,7 @@ _g_ir_node_free (GIrNode *node) g_free (node->name); g_free (enum_->gtype_name); g_free (enum_->gtype_init); + g_free (enum_->error_domain); for (l = enum_->values; l; l = l->next) _g_ir_node_free ((GIrNode *)l->data); @@ -712,6 +713,8 @@ _g_ir_node_get_full_size_internal (GIrNode *parent, size += ALIGN_VALUE (strlen (enum_->gtype_name) + 1, 4); size += ALIGN_VALUE (strlen (enum_->gtype_init) + 1, 4); } + if (enum_->error_domain) + size += ALIGN_VALUE (strlen (enum_->error_domain) + 1, 4); for (l = enum_->values; l; l = l->next) size += _g_ir_node_get_full_size_internal (node, (GIrNode *)l->data); @@ -2021,6 +2024,10 @@ _g_ir_node_build_typelib (GIrNode *node, blob->gtype_name = 0; blob->gtype_init = 0; } + if (enum_->error_domain) + blob->error_domain = _g_ir_write_string (enum_->error_domain, strings, data, offset2); + else + blob->error_domain = 0; blob->n_values = 0; blob->reserved2 = 0; diff --git a/girnode.h b/girnode.h index fb2616b1e..6e03821ba 100644 --- a/girnode.h +++ b/girnode.h @@ -285,6 +285,7 @@ struct _GIrNodeEnum gchar *gtype_name; gchar *gtype_init; + gchar *error_domain; GList *values; }; diff --git a/girparser.c b/girparser.c index 4e5527259..c9b7d6292 100644 --- a/girparser.c +++ b/girparser.c @@ -1332,6 +1332,7 @@ start_enum (GMarkupParseContext *context, const gchar *typename; const gchar *typeinit; const gchar *deprecated; + const gchar *error_domain; GIrNodeEnum *enum_; if (!((strcmp (element_name, "enumeration") == 0 && ctx->state == STATE_NAMESPACE) || @@ -1344,6 +1345,7 @@ start_enum (GMarkupParseContext *context, 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); + error_domain = find_attribute ("glib:error-domain", attribute_names, attribute_values); deprecated = find_attribute ("deprecated", attribute_names, attribute_values); if (name == NULL) @@ -1361,6 +1363,8 @@ start_enum (GMarkupParseContext *context, ((GIrNode *)enum_)->name = g_strdup (name); enum_->gtype_name = g_strdup (typename); enum_->gtype_init = g_strdup (typeinit); + enum_->error_domain = g_strdup (error_domain); + if (deprecated) enum_->deprecated = TRUE; else diff --git a/girwriter.c b/girwriter.c index 2cdc9a11f..d9f916c55 100644 --- a/girwriter.c +++ b/girwriter.c @@ -805,6 +805,7 @@ write_enum_info (const gchar *namespace, const gchar *name; const gchar *type_name; const gchar *type_init; + const gchar *error_domain; gboolean deprecated; gint i; @@ -813,6 +814,7 @@ write_enum_info (const gchar *namespace, type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); + error_domain = g_enum_info_get_error_domain (info); if (g_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_ENUM) xml_start_element (file, "enumeration"); @@ -822,6 +824,8 @@ write_enum_info (const gchar *namespace, if (type_init) xml_printf (file, " glib:type-name=\"%s\" glib:get-type=\"%s\"", type_name, type_init); + if (error_domain) + xml_printf (file, " glib:error-domain=\"%s\"", error_domain); if (deprecated) xml_printf (file, " deprecated=\"1\""); diff --git a/gitypelib-internal.h b/gitypelib-internal.h index 2bda8d9d0..49fbe4e3e 100644 --- a/gitypelib-internal.h +++ b/gitypelib-internal.h @@ -798,6 +798,8 @@ typedef struct { * (will be a signed or unsigned integral type) * @gtype_name: String name of the associated #GType * @gtype_init: String naming the symbol which gets the runtime #GType + * @error_domain: String naming the #GError domain this enum is + * associated with * @n_values: The lengths of the values arrays. * @values: Describes the enum values. */ @@ -817,7 +819,7 @@ typedef struct { guint16 n_values; guint16 reserved2; - guint32 reserved3; + guint32 error_domain; ValueBlob values[]; } EnumBlob; From ff6cada5528275d906763bf2133e937ebeea304b Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 19 May 2011 17:46:36 -0400 Subject: [PATCH 4/5] Add g_irepository_find_by_error_domain() Add a method to look up a GIEnumInfo given its associated error quark. Based on a patch from Colin Walters. https://bugzilla.gnome.org/show_bug.cgi?id=602516 --- girepository.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ girepository.h | 2 ++ gitypelib-internal.h | 3 ++ gitypelib.c | 30 ++++++++++++++++ 4 files changed, 118 insertions(+) diff --git a/girepository.c b/girepository.c index 1afba0c80..a2a778d91 100644 --- a/girepository.c +++ b/girepository.c @@ -45,6 +45,7 @@ struct _GIRepositoryPrivate GHashTable *typelibs; /* (string) namespace -> GITypelib */ GHashTable *lazy_typelibs; /* (string) namespace-version -> GITypelib */ GHashTable *info_by_gtype; /* GType -> GIBaseInfo */ + GHashTable *info_by_error_domain; /* GQuark -> GIBaseInfo */ }; G_DEFINE_TYPE (GIRepository, g_irepository, G_TYPE_OBJECT); @@ -64,6 +65,10 @@ g_irepository_init (GIRepository *repository) = g_hash_table_new_full (g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, (GDestroyNotify) g_base_info_unref); + repository->priv->info_by_error_domain + = g_hash_table_new_full (g_direct_hash, g_direct_equal, + (GDestroyNotify) NULL, + (GDestroyNotify) g_base_info_unref); } static void @@ -74,6 +79,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_hash_table_destroy (repository->priv->info_by_error_domain); (* G_OBJECT_CLASS (g_irepository_parent_class)->finalize) (G_OBJECT (repository)); } @@ -675,6 +681,83 @@ g_irepository_find_by_name (GIRepository *repository, NULL, typelib, entry->offset); } +typedef struct { + GIRepository *repository; + GQuark domain; + + GITypelib *result_typelib; + DirEntry *result; +} FindByErrorDomainData; + +static void +find_by_error_domain_foreach (gpointer key, + gpointer value, + gpointer datap) +{ + GITypelib *typelib = (GITypelib*)value; + FindByErrorDomainData *data = datap; + + if (data->result != NULL) + return; + + data->result = g_typelib_get_dir_entry_by_error_domain (typelib, data->domain); + if (data->result) + data->result_typelib = typelib; +} + +/** + * g_irepository_find_by_error_domain: + * @repository: (allow-none): A #GIRepository, may be %NULL for the default + * @domain: a #GError domain + * + * Searches for the enum type corresponding to the given #GError + * domain. Before calling this function for a particular namespace, + * you must call g_irepository_require() once to load the namespace, or + * otherwise ensure the namespace has already been loaded. + * + * Returns: (transfer full): #GIEnumInfo representing metadata about @domain's + * enum type, or %NULL + * + * Since: 1.29.17 + */ +GIEnumInfo * +g_irepository_find_by_error_domain (GIRepository *repository, + GQuark domain) +{ + FindByErrorDomainData data; + GIEnumInfo *cached; + + repository = get_repository (repository); + + cached = g_hash_table_lookup (repository->priv->info_by_error_domain, + GUINT_TO_POINTER (domain)); + + if (cached != NULL) + return g_base_info_ref ((GIBaseInfo *)cached); + + data.repository = repository; + data.domain = domain; + data.result_typelib = NULL; + data.result = NULL; + + g_hash_table_foreach (repository->priv->typelibs, find_by_error_domain_foreach, &data); + if (data.result == NULL) + g_hash_table_foreach (repository->priv->lazy_typelibs, find_by_error_domain_foreach, &data); + + if (data.result != NULL) + { + cached = _g_info_new_full (data.result->blob_type, + repository, + NULL, data.result_typelib, data.result->offset); + + g_hash_table_insert (repository->priv->info_by_error_domain, + GUINT_TO_POINTER (domain), + g_base_info_ref (cached)); + return cached; + } + return NULL; +} + static void collect_namespaces (gpointer key, gpointer value, diff --git a/girepository.h b/girepository.h index fddcf8c16..9e99f6e31 100644 --- a/girepository.h +++ b/girepository.h @@ -123,6 +123,8 @@ gint g_irepository_get_n_infos (GIRepository *repository, GIBaseInfo * g_irepository_get_info (GIRepository *repository, const gchar *namespace_, gint index); +GIEnumInfo * g_irepository_find_by_error_domain (GIRepository *repository, + GQuark domain); const gchar * g_irepository_get_typelib_path (GIRepository *repository, const gchar *namespace_); const gchar * g_irepository_get_shared_library (GIRepository *repository, diff --git a/gitypelib-internal.h b/gitypelib-internal.h index 49fbe4e3e..1dde5163b 100644 --- a/gitypelib-internal.h +++ b/gitypelib-internal.h @@ -1117,6 +1117,9 @@ DirEntry *g_typelib_get_dir_entry_by_gtype (GITypelib *typelib, gboolean fastpass, GType gtype); +DirEntry *g_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, + GQuark error_domain); + void g_typelib_check_sanity (void); #define g_typelib_get_string(typelib,offset) ((const gchar*)&(typelib->data)[(offset)]) diff --git a/gitypelib.c b/gitypelib.c index 3869a6d25..f610d4586 100644 --- a/gitypelib.c +++ b/gitypelib.c @@ -249,6 +249,36 @@ g_typelib_get_dir_entry_by_gtype (GITypelib *typelib, return NULL; } +DirEntry * +g_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, + GQuark error_domain) +{ + Header *header = (Header *)typelib->data; + guint n_entries = header->n_local_entries; + const char *domain_string = g_quark_to_string (error_domain); + DirEntry *entry; + guint i; + + for (i = 1; i <= n_entries; i++) + { + EnumBlob *blob; + const char *enum_domain_string; + + entry = g_typelib_get_dir_entry (typelib, i); + if (entry->blob_type != BLOB_TYPE_ENUM) + continue; + + blob = (EnumBlob *)(&typelib->data[entry->offset]); + if (!blob->error_domain) + continue; + + enum_domain_string = g_typelib_get_string (typelib, blob->error_domain); + if (strcmp (domain_string, enum_domain_string) == 0) + return entry; + } + return NULL; +} + void g_typelib_check_sanity (void) { From 1dcf01a490bf274edcf19eda2386a6f17dd405d2 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sat, 13 Aug 2011 10:35:13 -0300 Subject: [PATCH 5/5] Add signal flags This adds all GSignalFlags into the gir. https://bugzilla.gnome.org/show_bug.cgi?id=656457 --- gdump.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gdump.c b/gdump.c index e607f3237..aab067b6f 100644 --- a/gdump.c +++ b/gdump.c @@ -166,9 +166,33 @@ dump_signals (GType type, GOutputStream *out) sigid = sig_ids[i]; g_signal_query (sigid, &query); - escaped_printf (out, " \n", + escaped_printf (out, " \n"); + for (j = 0; j < query.n_params; j++) { escaped_printf (out, " \n",