Bug 561617 – Return value array annotations
authorJohan Dahlin <jdahlin@async.com.br>
Fri, 21 Nov 2008 02:53:28 +0000 (02:53 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Fri, 21 Nov 2008 02:53:28 +0000 (02:53 +0000)
2008-11-21  Johan Dahlin  <jdahlin@async.com.br>

    Bug 561617 – Return value array annotations

    * giscanner/transformer.py:
    * tests/scanner/annotation.c (annotation_return_array):
    * tests/scanner/annotation.h:
    Add support for (array) for return value annotations as well.

svn path=/trunk/; revision=957

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 fc817a6..0966256 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-11-21  Johan Dahlin  <jdahlin@async.com.br>
+
+       Bug 561617 – Return value array annotations
+
+       * giscanner/transformer.py:
+       * tests/scanner/annotation.c (annotation_return_array):
+       * tests/scanner/annotation.h:
+       Add support for (array) for return value annotations as well.
+
 2008-11-20  Johan Bilien  <jobi@via.ecp.fr>
 
        * tests/everything/everything.[ch]: add a test function which calls a
index c60ec62..70a0849 100644 (file)
@@ -249,7 +249,7 @@ class Transformer(object):
         raise ValueError("Unmatched length parameter name %r"\
                              % (target_name, ))
 
-    def _pair_annotations(self, params):
+    def _pair_annotations(self, params, return_):
         names = {}
         for param in params:
             if param.name in names:
@@ -259,6 +259,9 @@ class Transformer(object):
             if isinstance(param.type, Array):
                 self._pair_array(params, param)
 
+        if isinstance(return_.type, Array):
+            self._pair_array(params, return_)
+
     # We take the annotations from the parser as strings; here we
     # want to split them into components, so:
     # (transfer full) -> {'transfer' : [ 'full' ]}
@@ -275,9 +278,9 @@ class Transformer(object):
         directives = symbol.directives()
         parameters = list(self._create_parameters(
             symbol.base_type, directives))
-        self._pair_annotations(parameters)
         return_ = self._create_return(symbol.base_type.base_type,
                                       directives.get('return', {}))
+        self._pair_annotations(parameters, return_)
         name = self._strip_namespace_func(symbol.ident)
         func = Function(name, return_, parameters, symbol.ident)
         self._parse_deprecated(func, directives)
@@ -595,6 +598,8 @@ class Transformer(object):
             if option in ('transfer', 'transfer-inferred',
                           'element-type', 'out'):
                 pass
+            elif option.startswith(('element-type', 'array')):
+                pass
             else:
                 print 'Unhandled return type annotation option: %r' % (
                     option, )
index 286759c..d3582a1 100644 (file)
         </parameter>
       </parameters>
     </function>
+    <function name="return_array" c:identifier="annotation_return_array">
+      <return-value transfer-ownership="none">
+        <array length="0" c:type="char**">
+          <type name="utf8"/>
+        </array>
+      </return-value>
+      <parameters>
+        <parameter name="length" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+      </parameters>
+    </function>
   </namespace>
 </repository>
index 251d0bc..449286e 100644 (file)
         </parameter>
       </parameters>
     </function>
+    <function name="return_array" c:identifier="annotation_return_array">
+      <return-value transfer-ownership="none">
+        <array length="0" zero-terminated="1">
+          <type name="utf8"/>
+        </array>
+      </return-value>
+      <parameters>
+        <parameter name="length" transfer-ownership="full" direction="out">
+          <type name="int"/>
+        </parameter>
+      </parameters>
+    </function>
   </namespace>
 </repository>
index fafb2a4..b19b540 100644 (file)
@@ -338,5 +338,17 @@ annotation_init (int *argc, char ***argv)
 
 }
 
+/**
+ * annotation_return_array:
+ * @length: (out): Number of return values
+ *
+ * Return value: (array length=length zero-terminated=1): The return value
+ **/
+char **
+annotation_return_array (int *length)
+{
+  return NULL;
+}
+
 
 static char backslash_parsing_tester_2 = '\\';
index d79c309..0eecce0 100644 (file)
@@ -78,5 +78,6 @@ GObject* annotation_object_do_not_use   (AnnotationObject *object);
 
 
 void     annotation_init (int *argc, char ***argv);
+char **  annotation_return_array (int *length);
 
 #endif /* __ANNOTATION_OBJECT_H__ */