[gobject-introspection] scanner: Readd --warn-error to tests, fix test case



commit 33ead62f2b18f9c5a0b6a40f0e843ee515fcd853
Author: Colin Walters <walters verbum org>
Date:   Fri Sep 3 15:46:49 2010 -0400

    scanner: Readd --warn-error to tests, fix test case
    
    Commit b6fb70f9 wrongly disabled fatal warnings - in fact there
    is a way to make this test case work, and it was a bug in the
    scanner not processing virtual function annotations correctly.
    
    Add a different test case for un-named parameters that doesn't
    have a callback.

 giscanner/maintransformer.py       |    3 +-
 tests/scanner/Foo-1.0-expected.gir |   62 ++++++++++++++++++++++++++++++++---
 tests/scanner/Makefile.am          |    2 +-
 tests/scanner/foo.c                |   11 ++++++-
 tests/scanner/foo.h                |    6 +++-
 5 files changed, 74 insertions(+), 10 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 1aeb089..c638721 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -478,7 +478,7 @@ class MainTransformer(object):
             options = tag.options
         else:
             options = {}
-        if isinstance(parent, ast.Function):
+        if isinstance(parent, (ast.Function, ast.VFunction)):
             scope = options.get(OPT_SCOPE)
             if scope:
                 scope = scope.one()
@@ -919,6 +919,7 @@ method or constructor of some type."""
                 # the vfunc
                 block = self._blocks.get(method.symbol)
                 self._apply_annotations_callable(vfunc, [], block)
+                break
 
     def _pass3(self, node, chain):
         """Pass 3 is after we've loaded GType data and performed type
diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir
index 59aa9ed..105de42 100644
--- a/tests/scanner/Foo-1.0-expected.gir
+++ b/tests/scanner/Foo-1.0-expected.gir
@@ -644,14 +644,30 @@ exposed to language bindings.</doc>
           <type name="none" c:type="void"/>
         </return-value>
       </virtual-method>
-      <virtual-method name="do_baz" invoker="do_baz" introspectable="0">
+      <virtual-method name="do_baz" invoker="do_baz">
         <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
         </return-value>
         <parameters>
-          <parameter transfer-ownership="none">
+          <parameter name="callback"
+                     transfer-ownership="none"
+                     scope="call"
+                     closure="1">
             <type name="GObject.Callback" c:type="GCallback"/>
           </parameter>
+          <parameter name="data" transfer-ownership="none">
+            <type name="gpointer" c:type="gpointer"/>
+          </parameter>
+        </parameters>
+      </virtual-method>
+      <virtual-method name="do_moo" invoker="do_moo">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter transfer-ownership="none">
+            <type name="gint" c:type="int"/>
+          </parameter>
           <parameter transfer-ownership="none">
             <type name="gpointer" c:type="gpointer"/>
           </parameter>
@@ -678,6 +694,19 @@ exposed to language bindings.</doc>
           </parameter>
         </parameters>
       </method>
+      <method name="do_moo" c:identifier="foo_sub_interface_do_moo">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter transfer-ownership="none">
+            <type name="gint" c:type="int"/>
+          </parameter>
+          <parameter transfer-ownership="none">
+            <type name="gpointer" c:type="gpointer"/>
+          </parameter>
+        </parameters>
+      </method>
       <glib:signal name="destroy-event">
         <return-value transfer-ownership="none">
           <type name="none"/>
@@ -714,17 +743,17 @@ exposed to language bindings.</doc>
           </parameters>
         </callback>
       </field>
-      <field name="do_baz" introspectable="0">
-        <callback name="do_baz" introspectable="0">
+      <field name="do_moo">
+        <callback name="do_moo">
           <return-value transfer-ownership="none">
             <type name="none" c:type="void"/>
           </return-value>
           <parameters>
-            <parameter transfer-ownership="none">
+            <parameter name="self" transfer-ownership="none">
               <type name="SubInterface" c:type="FooSubInterface*"/>
             </parameter>
             <parameter transfer-ownership="none">
-              <type name="GObject.Callback" c:type="GCallback"/>
+              <type name="gint" c:type="int"/>
             </parameter>
             <parameter transfer-ownership="none">
               <type name="gpointer" c:type="gpointer"/>
@@ -732,6 +761,27 @@ exposed to language bindings.</doc>
           </parameters>
         </callback>
       </field>
+      <field name="do_baz">
+        <callback name="do_baz">
+          <return-value transfer-ownership="none">
+            <type name="none" c:type="void"/>
+          </return-value>
+          <parameters>
+            <parameter name="self" transfer-ownership="none">
+              <type name="SubInterface" c:type="FooSubInterface*"/>
+            </parameter>
+            <parameter name="callback"
+                       transfer-ownership="none"
+                       scope="call"
+                       closure="2">
+              <type name="GObject.Callback" c:type="GCallback"/>
+            </parameter>
+            <parameter name="data" transfer-ownership="none">
+              <type name="gpointer" c:type="gpointer"/>
+            </parameter>
+          </parameters>
+        </callback>
+      </field>
     </record>
     <class name="Subobject"
            c:symbol-prefix="subobject"
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 1b73d6b..5b20131 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -1,7 +1,7 @@
 include $(top_srcdir)/common.mk
 include $(top_srcdir)/Makefile.introspection
 
-INTROSPECTION_SCANNER_ARGS += --warn-all
+INTROSPECTION_SCANNER_ARGS += --warn-all --warn-error
 
 # We need to build a shared library, which can be dlopened
 # it does not work with noinst_LTLIBRARIES
diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c
index 3118be4..d84c58a 100644
--- a/tests/scanner/foo.c
+++ b/tests/scanner/foo.c
@@ -116,15 +116,24 @@ foo_sub_interface_class_init (gpointer g_class, gpointer class_data)
                   G_TYPE_NONE);
 }
 
-void foo_sub_interface_do_bar (FooSubInterface *self)
+void
+foo_sub_interface_do_bar (FooSubInterface *self)
 {
   FOO_SUBINTERFACE_GET_INTERFACE(self)->do_bar (self);
 }
 
+void
+foo_sub_interface_do_moo (FooSubInterface *self, int x, gpointer y)
+{
+  FOO_SUBINTERFACE_GET_INTERFACE(self)->do_moo (self, x, y);
+}
+
 /**
  * foo_sub_interface_do_baz:
  * @self:
  * @callback: (scope call):
+ * @user_data:
+ *
  */
 void
 foo_sub_interface_do_baz (FooSubInterface *self, GCallback callback, gpointer user_data)
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index 6b65e1e..2d11ba6 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -68,12 +68,16 @@ struct _FooSubInterfaceIface
 
   void (*do_bar) (FooSubInterface *self);
 
-  void (*do_baz) (FooSubInterface *, GCallback, gpointer);
+  /* explicitly test un-named parameters */
+  void (*do_moo) (FooSubInterface *self, int, gpointer);
+
+  void (*do_baz) (FooSubInterface *self, GCallback callback, gpointer data);
 };
 
 GType                 foo_sub_interface_get_type       (void) G_GNUC_CONST;
 
 void foo_sub_interface_do_bar (FooSubInterface *self);
+void foo_sub_interface_do_moo (FooSubInterface *self, int, gpointer);
 void foo_sub_interface_do_baz (FooSubInterface *self,
                                GCallback callback,
                                gpointer data);



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