Bug 560708 – Fix zero-termination defaults for arrays with length=
authorColin Walters <walters@src.gnome.org>
Thu, 13 Nov 2008 23:17:57 +0000 (23:17 +0000)
committerColin Walters <walters@src.gnome.org>
Thu, 13 Nov 2008 23:17:57 +0000 (23:17 +0000)
svn path=/trunk/; revision=921

ChangeLog
giscanner/transformer.py
tests/scanner/annotation-1.0-expected.gir
tests/scanner/annotation-1.0-expected.tgir
tests/scanner/annotation.c
tests/scanner/annotation.h

index dfdd1b5..4025b3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index fbf82ff..36b02f7 100644 (file)
@@ -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)
index 1a859b3..33fb370 100644 (file)
         <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </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*">
index a2c0146..9a50dd9 100644 (file)
         </parameters>
       </method>
       <method name="compute_sum_n" c:identifier="annotation_object_compute_sum_n">
+        <return-value transfer-ownership="none">
+          <type name="none"/>
+        </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>
index ef521a2..e4c44e1 100644 (file)
@@ -241,6 +241,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
index 3eb9fcb..23a5c6b 100644 (file)
@@ -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);