gobject-introspection r957 - in trunk: . giscanner tests/scanner



Author: johan
Date: Fri Nov 21 02:53:28 2008
New Revision: 957
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=957&view=rev

Log:
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.



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

Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py	(original)
+++ trunk/giscanner/transformer.py	Fri Nov 21 02:53:28 2008
@@ -249,7 +249,7 @@
         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 @@
             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 @@
         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 @@
             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, )

Modified: trunk/tests/scanner/annotation-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.gir	(original)
+++ trunk/tests/scanner/annotation-1.0-expected.gir	Fri Nov 21 02:53:28 2008
@@ -267,5 +267,17 @@
         </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>

Modified: trunk/tests/scanner/annotation-1.0-expected.tgir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.tgir	(original)
+++ trunk/tests/scanner/annotation-1.0-expected.tgir	Fri Nov 21 02:53:28 2008
@@ -250,5 +250,17 @@
         </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>

Modified: trunk/tests/scanner/annotation.c
==============================================================================
--- trunk/tests/scanner/annotation.c	(original)
+++ trunk/tests/scanner/annotation.c	Fri Nov 21 02:53:28 2008
@@ -338,5 +338,17 @@
 
 }
 
+/**
+ * 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 = '\\';

Modified: trunk/tests/scanner/annotation.h
==============================================================================
--- trunk/tests/scanner/annotation.h	(original)
+++ trunk/tests/scanner/annotation.h	Fri Nov 21 02:53:28 2008
@@ -78,5 +78,6 @@
 
 
 void     annotation_init (int *argc, char ***argv);
+char **  annotation_return_array (int *length);
 
 #endif /* __ANNOTATION_OBJECT_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]