diff options
author | Dan Winship <danw@gnome.org> | 2011-05-19 17:46:36 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-08-12 11:11:45 -0400 |
commit | c4c1de663f0c42875d5dd029d910d6c37e90ec8a (patch) | |
tree | 39237617ff1b54b1e6ebc0698f9fa4ceb311df48 /girepository/gitypelib.c | |
parent | 5fd2fa5bf5a07a66d2150740d534a398598e8dd1 (diff) | |
download | gobject-introspection-c4c1de663f0c42875d5dd029d910d6c37e90ec8a.tar.gz |
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
Diffstat (limited to 'girepository/gitypelib.c')
-rw-r--r-- | girepository/gitypelib.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 3869a6d2..f610d458 100644 --- a/girepository/gitypelib.c +++ b/girepository/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) { |