summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2008-11-13 23:17:57 +0000
committerColin Walters <walters@src.gnome.org>2008-11-13 23:17:57 +0000
commit164e9d0571cfcabefbe5c6a8fb6abec70765ef87 (patch)
tree50d2b6ad7d3d35482658106136125c3d6fe566df
parent584a9f34af14ab88586f82c2ad98b788ca394293 (diff)
downloadgobject-introspection-164e9d0571cfcabefbe5c6a8fb6abec70765ef87.tar.gz
Bug 560708 – Fix zero-termination defaults for arrays with length=
svn path=/trunk/; revision=921
-rw-r--r--ChangeLog9
-rw-r--r--giscanner/transformer.py3
-rw-r--r--tests/scanner/annotation-1.0-expected.gir16
-rw-r--r--tests/scanner/annotation-1.0-expected.tgir15
-rw-r--r--tests/scanner/annotation.c16
-rw-r--r--tests/scanner/annotation.h3
6 files changed, 62 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dfdd1b5e..4025b3ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2008-11-13 Andreas Rottmann <a.rottmann@gmx.at>
+ Bug 560708 – Don't treat arrays that have a length specified as
+ zero-terminated by default
+
+ * giscanner/transformer.py: Default to non zero terminated for
+ arrays with length.
+ * tests/*: Update, add test for zero vs not.
+
+2008-11-13 Andreas Rottmann <a.rottmann@gmx.at>
+
Bug 557788 - Return types for constructors in generated typelib bogus
* girepository/girnode.c: Namespace-qualify XREFs; not doing so is
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index fbf82ffd..36b02f76 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -426,9 +426,12 @@ class Transformer(object):
for opt in options.get('array', [])])
if 'length' in array_opts:
rettype.length_param_name = array_opts['length']
+ rettype.zeroterminated = False
if 'fixed-size' in array_opts:
rettype.size = array_opts['fixed-size']
rettype.zeroterminated = False
+ if 'zero-terminated' in array_opts:
+ rettype.zeroterminated = array_opts['zero-terminated'] != '0'
else:
derefed_name = self.parse_ctype(ctype)
rettype = Type(derefed_name, ctype)
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index 1a859b3c..33fb370e 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -187,6 +187,22 @@
</return-value>
<parameters>
<parameter name="nums" transfer-ownership="none">
+ <array zero-terminated="0" length="2" c:type="int*">
+ <type name="int"/>
+ </array>
+ </parameter>
+ <parameter name="n_nums" transfer-ownership="none">
+ <type name="int" c:type="int"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="compute_sum_nz"
+ c:identifier="annotation_object_compute_sum_nz">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="nums" transfer-ownership="none">
<array length="2" c:type="int*">
<type name="int"/>
</array>
diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir
index a2c01465..9a50dd94 100644
--- a/tests/scanner/annotation-1.0-expected.tgir
+++ b/tests/scanner/annotation-1.0-expected.tgir
@@ -177,6 +177,21 @@
</return-value>
<parameters>
<parameter name="nums" transfer-ownership="none">
+ <array length="2">
+ <type name="int"/>
+ </array>
+ </parameter>
+ <parameter name="n_nums" transfer-ownership="none">
+ <type name="int"/>
+ </parameter>
+ </parameters>
+ </method>
+ <method name="compute_sum_nz" c:identifier="annotation_object_compute_sum_nz">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ <parameters>
+ <parameter name="nums" transfer-ownership="none">
<array length="2" zero-terminated="1">
<type name="int"/>
</array>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index ef521a23..e4c44e13 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -242,6 +242,22 @@ annotation_object_compute_sum_n(AnnotationObject *object,
}
/**
+ * annotation_object_compute_sum_nz:
+ * @object: a #AnnotationObject
+ * @nums: (array length=n_nums zero-terminated=1): Sequence of numbers
+ * @n_nums: Length of number array
+ *
+ * Test taking a zero-terminated array with length parameter
+ **/
+void
+annotation_object_compute_sum_nz(AnnotationObject *object,
+ int *nums,
+ int n_nums)
+{
+
+}
+
+/**
* annotation_object_allow_none:
* @object: a #GObject
* @somearg: (allow-none):
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index 3eb9fcb8..23a5c6b3 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -66,6 +66,9 @@ void annotation_object_compute_sum (AnnotationObject *object,
void annotation_object_compute_sum_n(AnnotationObject *object,
int *nums,
int n_nums);
+void annotation_object_compute_sum_nz(AnnotationObject *object,
+ int *nums,
+ int n_nums);
GObject* annotation_object_do_not_use (AnnotationObject *object);