[gobject-introspection] [everything] Add some "torture" test functions with baroque signatures



commit 7bac4ad4fed830ca387566122de80f49329f7411
Author: Colin Walters <walters verbum org>
Date:   Thu Mar 4 09:32:16 2010 -0500

    [everything] Add some "torture" test functions with baroque signatures
    
    We didn't have good coverage of say in arguments after out.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=611809

 gir/Everything-1.0-expected.gir |  145 +++++++++++++++++++++++++++++++++++++++
 gir/everything.c                |  142 ++++++++++++++++++++++++++++++++++++++
 gir/everything.h                |   40 +++++++++++
 3 files changed, 327 insertions(+), 0 deletions(-)
---
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index 9453090..d886979 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -164,6 +164,59 @@ and/or use gtk-doc annotations.  -->
           <type name="int" c:type="int"/>
         </return-value>
       </method>
+      <method name="torture_signature_0"
+              c:identifier="test_obj_torture_signature_0">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="x" transfer-ownership="none">
+            <type name="int" c:type="int"/>
+          </parameter>
+          <parameter name="y" direction="out" transfer-ownership="full">
+            <type name="double" c:type="double*"/>
+          </parameter>
+          <parameter name="z" direction="out" transfer-ownership="full">
+            <type name="int" c:type="int*"/>
+          </parameter>
+          <parameter name="foo" transfer-ownership="none">
+            <type name="utf8" c:type="char*"/>
+          </parameter>
+          <parameter name="q" direction="out" transfer-ownership="full">
+            <type name="int" c:type="int*"/>
+          </parameter>
+          <parameter name="m" transfer-ownership="none">
+            <type name="uint" c:type="guint"/>
+          </parameter>
+        </parameters>
+      </method>
+      <method name="torture_signature_1"
+              c:identifier="test_obj_torture_signature_1"
+              throws="1">
+        <return-value transfer-ownership="none">
+          <type name="boolean" c:type="gboolean"/>
+        </return-value>
+        <parameters>
+          <parameter name="x" transfer-ownership="none">
+            <type name="int" c:type="int"/>
+          </parameter>
+          <parameter name="y" direction="out" transfer-ownership="full">
+            <type name="double" c:type="double*"/>
+          </parameter>
+          <parameter name="z" direction="out" transfer-ownership="full">
+            <type name="int" c:type="int*"/>
+          </parameter>
+          <parameter name="foo" transfer-ownership="none">
+            <type name="utf8" c:type="char*"/>
+          </parameter>
+          <parameter name="q" direction="out" transfer-ownership="full">
+            <type name="int" c:type="int*"/>
+          </parameter>
+          <parameter name="m" transfer-ownership="none">
+            <type name="uint" c:type="guint"/>
+          </parameter>
+        </parameters>
+      </method>
       <method name="do_matrix"
               c:identifier="test_obj_do_matrix"
               doc="This method is virtual.  Notably its name differs from the virtual
@@ -1379,6 +1432,98 @@ call and can be released on return.">
         </parameter>
       </parameters>
     </function>
+    <function name="test_torture_signature_0"
+              c:identifier="test_torture_signature_0">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="x" transfer-ownership="none">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="y" direction="out" transfer-ownership="full">
+          <type name="double" c:type="double*"/>
+        </parameter>
+        <parameter name="z" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="foo" transfer-ownership="none">
+          <type name="utf8" c:type="char*"/>
+        </parameter>
+        <parameter name="q" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="m" transfer-ownership="none">
+          <type name="uint" c:type="guint"/>
+        </parameter>
+      </parameters>
+    </function>
+    <function name="test_torture_signature_1"
+              c:identifier="test_torture_signature_1"
+              throws="1">
+      <return-value transfer-ownership="none">
+        <type name="boolean" c:type="gboolean"/>
+      </return-value>
+      <parameters>
+        <parameter name="x" transfer-ownership="none">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="y" direction="out" transfer-ownership="full">
+          <type name="double" c:type="double*"/>
+        </parameter>
+        <parameter name="z" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="foo" transfer-ownership="none">
+          <type name="utf8" c:type="char*"/>
+        </parameter>
+        <parameter name="q" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="m" transfer-ownership="none">
+          <type name="uint" c:type="guint"/>
+        </parameter>
+      </parameters>
+    </function>
+    <function name="test_torture_signature_2"
+              c:identifier="test_torture_signature_2">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="x" transfer-ownership="none">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="callback"
+                   transfer-ownership="none"
+                   scope="notified"
+                   closure="2"
+                   destroy="3">
+          <type name="TestCallbackUserData" c:type="TestCallbackUserData"/>
+        </parameter>
+        <parameter name="user_data" transfer-ownership="none">
+          <type name="any" c:type="gpointer"/>
+        </parameter>
+        <parameter name="notify" transfer-ownership="none" scope="call">
+          <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
+        </parameter>
+        <parameter name="y" direction="out" transfer-ownership="full">
+          <type name="double" c:type="double*"/>
+        </parameter>
+        <parameter name="z" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="foo" transfer-ownership="none">
+          <type name="utf8" c:type="char*"/>
+        </parameter>
+        <parameter name="q" direction="out" transfer-ownership="full">
+          <type name="int" c:type="int*"/>
+        </parameter>
+        <parameter name="m" transfer-ownership="none">
+          <type name="uint" c:type="guint"/>
+        </parameter>
+      </parameters>
+    </function>
     <function name="test_uint" c:identifier="test_uint">
       <return-value transfer-ownership="none">
         <type name="uint" c:type="guint"/>
diff --git a/gir/everything.c b/gir/everything.c
index 6c394e8..6796088 100644
--- a/gir/everything.c
+++ b/gir/everything.c
@@ -1,5 +1,6 @@
 #include <string.h>
 #include "everything.h"
+#include <gio/gio.h>
 
 /* basic types */
 gboolean test_boolean (gboolean in)
@@ -1482,6 +1483,63 @@ test_obj_static_method (int x)
 }
 
 /**
+ * test_obj_torture_signature_0:
+ * @obj: A #TestObj
+ * @x:
+ * @y: (out):
+ * @z: (out):
+ * @foo:
+ * @q: (out):
+ * @m:
+ *
+ */
+void
+test_obj_torture_signature_0 (TestObj    *obj,
+                              int         x,
+                              double     *y,
+                              int        *z,
+                              const char *foo,
+                              int        *q,
+                              guint       m)
+{
+  *y = x;
+  *z = x * 2;
+  *q = g_utf8_strlen (foo, -1) + m;
+}
+
+/**
+ * test_obj_torture_signature_1:
+ * @obj: A #TestObj
+ * @x:
+ * @y: (out):
+ * @z: (out):
+ * @foo:
+ * @q: (out):
+ * @m:
+ * @error: A #GError
+ *
+ * This function throws an error if m is odd.
+ */
+gboolean
+test_obj_torture_signature_1 (TestObj   *obj,
+                              int        x,
+                              double     *y,
+                              int        *z,
+                              const char *foo,
+                              int        *q,
+                              guint       m,
+                              GError    **error)
+{
+  *y = x;
+  *z = x * 2;
+  *q = g_utf8_strlen (foo, -1) + m;
+  if (m % 2 == 0)
+      return TRUE;
+  g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
+  return FALSE;
+}
+
+/**
  * test_obj_do_matrix:
  * @obj: A #TestObj
  * @somestr: Meaningless string
@@ -1812,3 +1870,87 @@ test_wi_802_1x_static_method (int x)
 {
   return 2*x;
 }
+
+/**
+ * test_torture_signature_0:
+ * @x:
+ * @y: (out):
+ * @z: (out):
+ * @foo:
+ * @q: (out):
+ * @m:
+ *
+ */
+void
+test_torture_signature_0 (int         x,
+                          double     *y,
+                          int        *z,
+                          const char *foo,
+                          int        *q,
+                          guint       m)
+{
+  *y = x;
+  *z = x * 2;
+  *q = g_utf8_strlen (foo, -1) + m;
+}
+
+/**
+ * test_torture_signature_1:
+ * @x:
+ * @y: (out):
+ * @z: (out):
+ * @foo:
+ * @q: (out):
+ * @m:
+ * @error: A #GError
+ *
+ * This function throws an error if m is odd.
+ */
+gboolean
+test_torture_signature_1 (int         x,
+                          double     *y,
+                          int        *z,
+                          const char *foo,
+                          int        *q,
+                          guint       m,
+                          GError    **error)
+{
+  *y = x;
+  *z = x * 2;
+  *q = g_utf8_strlen (foo, -1) + m;
+  if (m % 2 == 0)
+      return TRUE;
+  g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
+  return FALSE;
+}
+
+/**
+ * test_torture_signature_2:
+ * @x:
+ * @callback:
+ * @user_data:
+ * @notify:
+ * @y: (out):
+ * @z: (out):
+ * @foo:
+ * @q: (out):
+ * @m:
+ *
+ */
+void
+test_torture_signature_2 (int                   x,
+                          TestCallbackUserData  callback,
+                          gpointer              user_data,
+                          GDestroyNotify        notify,
+                          double               *y,
+                          int                  *z,
+                          const char           *foo,
+                          int                  *q,
+                          guint                 m)
+{
+  *y = x;
+  *z = x * 2;
+  *q = g_utf8_strlen (foo, -1) + m;  
+  notify (user_data);
+}
+
diff --git a/gir/everything.h b/gir/everything.h
index 84e2fe2..be4f6c6 100644
--- a/gir/everything.h
+++ b/gir/everything.h
@@ -257,6 +257,22 @@ void       test_obj_set_bare (TestObj *obj, GObject *bare);
 int        test_obj_instance_method (TestObj *obj);
 double     test_obj_static_method (int x);
 
+void test_obj_torture_signature_0 (TestObj    *obj,
+                                   int        x,
+                                   double     *y,
+                                   int        *z,
+                                   const char *foo,
+                                   int        *q,
+                                   guint       m);
+gboolean test_obj_torture_signature_1 (TestObj    *obj,
+                                       int        x,
+                                       double     *y,
+                                       int        *z,
+                                       const char *foo,
+                                       int        *q,
+                                       guint       m,
+                                       GError    **error);
+
 /* virtual */
 int        test_obj_do_matrix (TestObj *obj, const char *somestr);
 
@@ -340,4 +356,28 @@ gboolean     test_wi_802_1x_get_testbool (TestWi8021x *obj);
 void         test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean v);
 int          test_wi_802_1x_static_method (int x);
 
+/* Function signature torture tests */
+void test_torture_signature_0 (int        x,
+                               double     *y,
+                               int        *z,
+                               const char *foo,
+                               int        *q,
+                               guint       m);
+gboolean test_torture_signature_1 (int        x,
+                                   double     *y,
+                                   int        *z,
+                                   const char *foo,
+                                   int        *q,
+                                   guint       m,
+                                   GError    **error);
+void test_torture_signature_2 (int                  x,
+                               TestCallbackUserData  callback,
+                               gpointer              user_data,
+                               GDestroyNotify        notify,
+                               double               *y,
+                               int                  *z,
+                               const char           *foo,
+                               int                  *q,
+                               guint                 m);
+
 #endif /* __GITESTTYPES_H__ */



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