diff options
author | David Zeuthen <davidz@redhat.com> | 2010-06-15 11:01:37 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2010-06-24 11:53:18 -0400 |
commit | 11cfe386c37ced44a8e3efb5556bde3a43a11171 (patch) | |
tree | a01903a4e4596ca80c79abbc8d35c33dc665e526 /girepository/gibaseinfo.c | |
parent | 751ffa016e410a031028282e63f98a94cc444b7b (diff) | |
download | gobject-introspection-11cfe386c37ced44a8e3efb5556bde3a43a11171.tar.gz |
Allow attributes on parameters and return values
Any annotation where the key has a dot in the name will go into the
attribute list. For example
* @arg: (foo.bar baz): some arg
the parameter @arg will get the attribute with key foo.bar and value
baz. This also works for.
* Returns: (foo.bar2 baz2): the return value
Also add tests for this new feature.
See https://bugzilla.gnome.org/show_bug.cgi?id=571548
Signed-off-by: David Zeuthen <davidz@redhat.com>
Diffstat (limited to 'girepository/gibaseinfo.c')
-rw-r--r-- | girepository/gibaseinfo.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index c8444a5e..81b936d8 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -475,7 +475,7 @@ g_base_info_get_attribute (GIBaseInfo *info, static int cmp_attribute (const void *av, - const void *bv) + const void *bv) { const AttributeBlob *a = av; const AttributeBlob *b = bv; @@ -488,13 +488,25 @@ cmp_attribute (const void *av, return 1; } -static AttributeBlob * -find_first_attribute (GIRealInfo *rinfo) +/* + * _attribute_blob_find_first: + * @GIBaseInfo: A #GIBaseInfo. + * @blob_offset: The offset for the blob to find the first attribute for. + * + * Searches for the first #AttributeBlob for @blob_offset and returns + * it if found. + * + * Returns: A pointer to #AttributeBlob or %NULL if not found. + */ +AttributeBlob * +_attribute_blob_find_first (GIBaseInfo *info, + guint32 blob_offset) { + GIRealInfo *rinfo = (GIRealInfo *) info; Header *header = (Header *)rinfo->typelib->data; AttributeBlob blob, *first, *res, *previous; - blob.offset = rinfo->offset; + blob.offset = blob_offset; first = (AttributeBlob *) &rinfo->typelib->data[header->attributes]; @@ -505,7 +517,7 @@ find_first_attribute (GIRealInfo *rinfo) return NULL; previous = res - 1; - while (previous >= first && previous->offset == rinfo->offset) + while (previous >= first && previous->offset == blob_offset) { res = previous; previous = res - 1; @@ -563,7 +575,7 @@ g_base_info_iterate_attributes (GIBaseInfo *info, if (iterator->data != NULL) next = (AttributeBlob *) iterator->data; else - next = find_first_attribute (rinfo); + next = _attribute_blob_find_first (info, rinfo->offset); if (next == NULL || next->offset != rinfo->offset || next >= after) return FALSE; |