[gobject-introspection/wip/transformer] [major] Handle va_list better



commit 18f9198940f2e07ec6366aa9e5be474ecf33855c
Author: Colin Walters <walters verbum org>
Date:   Mon Aug 16 18:26:49 2010 -0400

    [major] Handle va_list better

 giscanner/ast.py                   |    7 ++---
 giscanner/finaltransformer.py      |    4 ++-
 giscanner/testcodegen.py           |    2 +-
 tests/scanner/Foo-1.0-expected.gir |   37 ++++++++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 7b1feea..885c6db 100755
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -158,6 +158,8 @@ TYPE_GTYPE = Type(target_fundamental='GType', ctype='GType')
 TYPE_STRING = Type(target_fundamental='utf8', ctype='gchar*')
 TYPE_FILENAME = Type(target_fundamental='filename', ctype='gchar*')
 
+TYPE_VALIST = Type(target_fundamental='va_list', ctype='va_list')
+
 BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
                    TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
                    TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
@@ -166,7 +168,7 @@ BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
                    TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
 GIR_TYPES = [TYPE_NONE, TYPE_ANY]
 GIR_TYPES.extend(BASIC_GIR_TYPES)
-GIR_TYPES.extend([TYPE_STRING, TYPE_FILENAME])
+GIR_TYPES.extend([TYPE_STRING, TYPE_FILENAME, TYPE_VALIST])
 
 type_names = {}
 for typeval in GIR_TYPES:
@@ -208,9 +210,6 @@ type_names['gsize'] = TYPE_ULONG
 type_names['gssize'] = TYPE_LONG
 type_names['gconstpointer'] = TYPE_ANY
 
-# Some special C types that aren't scriptable, and we just squash
-type_names['va_list'] = TYPE_ANY
-
 # C stdio, used in GLib public headers; squash this for now here
 # until we move scanning into GLib and can (skip)
 type_names['FILE*'] = TYPE_ANY
diff --git a/giscanner/finaltransformer.py b/giscanner/finaltransformer.py
index 2e95efe..bc38dc9 100644
--- a/giscanner/finaltransformer.py
+++ b/giscanner/finaltransformer.py
@@ -75,7 +75,7 @@ class FinalTransformer(object):
             self._parameter_warning(parent, node, "Missing (transfer) annotation")
             parent.introspectable = False
        
-        if node.type.target_giname:
+        if isinstance(node, Parameter) and node.type.target_giname:
             target = self._transformer.lookup_typenode(node.type)
             if (isinstance(target, Callback)
                 and not target.create_type().target_giname in ('GLib.DestroyNotify', 'Gio.AsyncReadyCallback')
@@ -95,6 +95,8 @@ class FinalTransformer(object):
         if typeval.target_foreign:
             return True
         if typeval.target_fundamental:
+            if typeval.is_equiv(TYPE_VALIST):
+                return False
             # Mark UCHAR as not introspectable temporarily until
             # we're ready to land the typelib changes
             if typeval.is_equiv(TYPE_UNICHAR):
diff --git a/giscanner/testcodegen.py b/giscanner/testcodegen.py
index 0bb8958..6220321 100644
--- a/giscanner/testcodegen.py
+++ b/giscanner/testcodegen.py
@@ -27,7 +27,7 @@ from .codegen import CCodeGenerator
 
 INTROSPECTABLE_BASIC = filter(lambda x: x not in (TYPE_NONE, TYPE_ANY,
                                                   TYPE_LONG_LONG, TYPE_LONG_ULONG,
-                                                  TYPE_LONG_DOUBLE), GIR_TYPES)
+                                                  TYPE_LONG_DOUBLE, TYPE_VALIST), GIR_TYPES)
 
 DEFAULT_C_VALUES = {TYPE_ANY: 'NULL',
                     TYPE_STRING: '""',
diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir
index 7c7a01e..48e8173 100644
--- a/tests/scanner/Foo-1.0-expected.gir
+++ b/tests/scanner/Foo-1.0-expected.gir
@@ -810,6 +810,13 @@ exposed to language bindings.</doc>
         </parameter>
       </parameters>
     </function>
+    <function name="error_quark"
+              c:identifier="foo_error_quark"
+              introspectable="0">
+      <return-value>
+        <type name="GLib.Quark" c:type="GQuark"/>
+      </return-value>
+    </function>
     <function name="init" c:identifier="foo_init">
       <return-value transfer-ownership="none">
         <type name="gint" c:type="gint"/>
@@ -848,6 +855,36 @@ exposed to language bindings.</doc>
         </parameter>
       </parameters>
     </function>
+    <function name="some_variant"
+              c:identifier="foo_some_variant"
+              introspectable="0">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="x" transfer-ownership="none">
+          <type name="guint" c:type="guint"/>
+        </parameter>
+        <parameter name="args" transfer-ownership="none">
+          <type name="va_list" c:type="va_list"/>
+        </parameter>
+      </parameters>
+    </function>
+    <function name="some_variant_ptr"
+              c:identifier="foo_some_variant_ptr"
+              introspectable="0">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="x" transfer-ownership="none">
+          <type name="guint" c:type="guint"/>
+        </parameter>
+        <parameter name="args" transfer-ownership="none">
+          <type name="va_list" c:type="va_list*"/>
+        </parameter>
+      </parameters>
+    </function>
     <function name="test_array" c:identifier="foo_test_array">
       <return-value transfer-ownership="container">
         <array name="GLib.Array" c:type="GArray*">



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