Disable array auto-detection for out-annotated parameters
authorOwen Taylor <otaylor@src.gnome.org>
Tue, 16 Dec 2008 04:20:50 +0000 (04:20 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 16 Dec 2008 04:20:50 +0000 (04:20 +0000)
If we have a parameter annotated as (out), then having a ctype of
'char **' (or similar) doesn't necessarily indicate an array.

* giscanner/transformer.py: Skip array-detection logic for
  (out)-annotated parameters.
* tests/scanner/annotation.h tests/scanner/annotation.c
  tests/scanner/annotation-1.0-expected.gir
  tests/scanner/annotation-1.0-expected.tgir: Add a test for
  an (out) string parameter.

http://bugzilla.gnome.org/show_bug.cgi?id=563934

svn path=/trunk/; revision=994

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 389c82008eca4261c1cd19c7a6bb9206e1d06426..812f6459a1ed83c4fe4dcd949f20f0a72dcf475e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-12-12  Owen Taylor  <otaylor@redhat.com>
+
+       Disable array auto-detection for out-annotated parameters (#563934)
+
+       If we have a parameter annotated as (out), then having a ctype of
+       'char **' (or similar) doesn't necessarily indicate an array.
+
+       * giscanner/transformer.py: Skip array-detection logic for
+       (out)-annotated parameters.
+       * tests/scanner/annotation.h tests/scanner/annotation.c
+       tests/scanner/annotation-1.0-expected.gir
+       tests/scanner/annotation-1.0-expected.tgir: Add a test for
+       an (out) string parameter.
+
 2008-12-12  Johan Dahlin  <jdahlin@async.com.br>
 
        * giscanner/dumper.py (DumpCompiler._link): Pass in
index f9807eab2141e1628bbc4cd3d7e2c2289b7f6281..bba44f7de5e87a8919e870837e3ad72f18686459 100644 (file)
@@ -462,7 +462,8 @@ class Transformer(object):
             rettype = Map(derefed_name,
                           ctype,
                           key_type, value_type)
-        elif ((is_param and canonical_ctype in default_array_types)
+        elif ((is_param and canonical_ctype in default_array_types
+               and not 'out' in options)
               or ('array' in options)):
             if canonical_ctype[-1] == '*':
                 derefed_name = canonical_ctype[:-1]
index 745bbc3f4fe7858510d65d170537cd447b439045..88dcdc6adde8151eb87a8a2aeefbf0b4adb8d61f 100644 (file)
           </parameter>
         </parameters>
       </method>
+      <method name="string_out" c:identifier="annotation_object_string_out">
+        <return-value transfer-ownership="none">
+          <type name="boolean" c:type="gboolean"/>
+        </return-value>
+        <parameters>
+          <parameter name="str_out" direction="out" transfer-ownership="full">
+            <type name="utf8" c:type="char**"/>
+          </parameter>
+        </parameters>
+      </method>
       <method name="do_not_use"
               c:identifier="annotation_object_do_not_use"
               deprecated="Use annotation_object_create_object() instead."
index 53df582eb7872dd1d1105a775475ce78b73c78f9..4fe10bd6020926b16f7e50796cce184bd432b046 100644 (file)
           </parameter>
         </parameters>
       </method>
+      <method name="string_out" c:identifier="annotation_object_string_out">
+        <return-value transfer-ownership="none">
+          <type name="boolean"/>
+        </return-value>
+        <parameters>
+          <parameter name="str_out" transfer-ownership="full" direction="out">
+            <type name="utf8"/>
+          </parameter>
+        </parameters>
+      </method>
       <method name="do_not_use" c:identifier="annotation_object_do_not_use" deprecated="1">
         <return-value transfer-ownership="full">
           <type name="GObject.Object"/>
index 420a927cc61da45ac33be517f56b9188e83a546b..cbb69b7275374114cf727cfa256161bbd41ba93e 100644 (file)
@@ -291,6 +291,22 @@ annotation_object_parse_args(AnnotationObject *object,
 
 }
 
+/**
+ * annotation_object_string_out:
+ * @object: a #AnnotationObject
+ * @str_out: (out) (transfer full): string return value
+ *
+ * Test returning a string as an out parameter
+ *
+ * Returns: some boolean
+ **/
+gboolean
+annotation_object_string_out(AnnotationObject *object,
+                             char            **str_out)
+{
+
+}
+
 /**
  * annotation_object_allow_none:
  * @object: a #GObject
index d6d609162b459902e4fa520cfeee46d396cd89c5..1e83ca23aa2996bdfbef753ca2be5b166ff930ba 100644 (file)
@@ -73,6 +73,8 @@ void     annotation_object_compute_sum_nz(AnnotationObject *object,
 void     annotation_object_parse_args   (AnnotationObject *object,
                                          int              *argc,
                                          char           ***argv);
+gboolean annotation_object_string_out   (AnnotationObject *object,
+                                         char            **str_out);
 
 GObject* annotation_object_do_not_use   (AnnotationObject *object);