[gobject-introspection] [scanner] Element-type annotation for GArray types
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [scanner] Element-type annotation for GArray types
- Date: Thu, 27 May 2010 13:12:53 +0000 (UTC)
commit e77f99fba5fce4dd0d4810707aa1aeac2ba0fb50
Author: Johan Dahlin <johan gnome org>
Date: Thu May 27 00:08:20 2010 -0300
[scanner] Element-type annotation for GArray types
Add support for (element-type) annotations for G*Array
types.
https://bugzilla.gnome.org/show_bug.cgi?id=619545
giscanner/annotationparser.py | 17 +++++++++++++----
tests/scanner/annotation-1.0-expected.gir | 12 ++++++++++++
tests/scanner/annotation-1.0-expected.tgir | 12 ++++++++++++
tests/scanner/annotation.c | 9 +++++++++
tests/scanner/annotation.h | 3 +++
5 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index b1d4ea0..180de6b 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -647,15 +647,20 @@ class AnnotationApplier(object):
return True
return False
+ def _is_array_type(self, node):
+ if node.type.name in ['GLib.Array', 'GLib.PtrArray',
+ 'GLib.ByteArray']:
+ return True
+ if node.type.ctype in ['GArray*', 'GPtrArray*', 'GByteArray*']:
+ return True
+ return False
+
def _extract_container_type(self, parent, node, options):
has_element_type = OPT_ELEMENT_TYPE in options
has_array = OPT_ARRAY in options
if not has_array:
- has_array = \
- node.type.name in ['GLib.Array', 'GLib.PtrArray',
- 'GLib.ByteArray'] or \
- node.type.ctype in ['GArray*', 'GPtrArray*', 'GByteArray*']
+ has_array = self._is_array_type(node)
# FIXME: This is a hack :-(
if (not isinstance(node, Field) and
@@ -781,6 +786,10 @@ class AnnotationApplier(object):
node.type.ctype,
self._resolve(element_type[0]),
self._resolve(element_type[1]))
+ elif self._is_array_type(node):
+ container_type = Array(node.type.name,
+ node.type.ctype,
+ self._resolve(element_type[0]))
else:
print 'FIXME: unhandled element-type container:', node
return container_type
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index 035b32e..25216d1 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -607,6 +607,18 @@ detection, and fixing it via annotations.">
</parameter>
</parameters>
</function>
+ <function name="ptr_array" c:identifier="annotation_ptr_array">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="array" transfer-ownership="none" doc="the array">
+ <array name="GLib.PtrArray" c:type="GPtrArray*">
+ <type name="GLib.Value"/>
+ </array>
+ </parameter>
+ </parameters>
+ </function>
<function name="return_array" c:identifier="annotation_return_array">
<return-value transfer-ownership="full" doc="The return value">
<array length="0" c:type="char**">
diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir
index 3b37cf2..aafd070 100644
--- a/tests/scanner/annotation-1.0-expected.tgir
+++ b/tests/scanner/annotation-1.0-expected.tgir
@@ -440,6 +440,18 @@
</parameter>
</parameters>
</function>
+ <function name="ptr_array" c:identifier="annotation_ptr_array">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="array" transfer-ownership="none">
+ <array>
+ <type name="GLib.Value"/>
+ </array>
+ </parameter>
+ </parameters>
+ </function>
<function name="return_array" c:identifier="annotation_return_array">
<return-value transfer-ownership="full">
<array length="0">
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index fb025b9..e1376e4 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -673,4 +673,13 @@ annotation_set_source_file (const char *fname)
{
}
+/**
+ * annotation_ptr_array:
+ * @array: (element-type GLib.Value): the array
+ */
+void
+annotation_ptr_array (GPtrArray *array)
+{
+}
+
char backslash_parsing_tester_2 = '\\';
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index 798594b..0f47d22 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -149,4 +149,7 @@ struct AnnotationStruct
AnnotationObject *objects[10];
};
+void annotation_ptr_array (GPtrArray *array);
+
#endif /* __ANNOTATION_OBJECT_H__ */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]