[gobject-introspection] Add tests for vfuncs with callbacks as arguments



commit 61c9950f5096499e5a19c7b0aebb0c22f4b2fd87
Author: Tomeu Vizoso <tomeu vizoso collabora com>
Date:   Tue Feb 21 15:28:14 2012 +0100

    Add tests for vfuncs with callbacks as arguments
    
    https://bugzilla.gnome.org/show_bug.cgi?id=663052
    
    Signed-off-by: Martin Pitt <martinpitt gnome org>

 tests/gimarshallingtests.c |   29 +++++++++++++++++++++++++++++
 tests/gimarshallingtests.h |   11 +++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 7afe543..e42233f 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -3772,6 +3772,35 @@ gi_marshalling_tests_object_real_method_with_default_implementation (GIMarshalli
     g_object_set_property (G_OBJECT (self), "int", &val);
 }
 
+/**
+ * gi_marshalling_tests_object_vfunc_with_callback:
+ * @callback: (scope call) (closure callback_data):
+ * @callback_data: (allow-none):
+ *
+ * Virtual: vfunc_with_callback
+ */
+void
+gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
+                                                 GIMarshallingTestsCallbackIntInt callback,
+                                                 void *callback_data)
+{
+
+}
+
+static int
+_callback (int val, void *user_data)
+{
+    g_assert(user_data == 0xdeadbeef);
+    return val;
+}
+
+void
+gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object)
+{
+    GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (object)->vfunc_with_callback (object,
+                                                                         _callback,
+                                                                         (void *) 0xdeadbeef);
+}
 
 /**
  * gi_marshalling_tests_object_none_return:
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 0c88920..6fa1b08 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -679,6 +679,8 @@ void gi_marshalling_tests_union_method (GIMarshallingTestsUnion *union_);
 typedef struct _GIMarshallingTestsObjectClass GIMarshallingTestsObjectClass;
 typedef struct _GIMarshallingTestsObject GIMarshallingTestsObject;
 
+typedef int (* GIMarshallingTestsCallbackIntInt) (int val, void *user_data);
+
 struct _GIMarshallingTestsObjectClass
 {
 	GObjectClass parent_class;
@@ -707,6 +709,10 @@ struct _GIMarshallingTestsObjectClass
      */
     void (* method_deep_hierarchy) (GIMarshallingTestsObject *self, gint8 in);
 
+    void (* vfunc_with_callback) (GIMarshallingTestsObject *self,
+                                  GIMarshallingTestsCallbackIntInt callback,
+                                  void *callback_data);
+
     /**
      * GIMarshallingTestsObjectClass::vfunc_return_value_only:
      */
@@ -791,6 +797,11 @@ void gi_marshalling_tests_object_inout_same (GIMarshallingTestsObject **object);
 void gi_marshalling_tests_object_int8_in (GIMarshallingTestsObject *object, gint8 in);
 void gi_marshalling_tests_object_int8_out (GIMarshallingTestsObject *object, gint8 *out);
 
+void gi_marshalling_tests_object_vfunc_with_callback (GIMarshallingTestsObject *object,
+                                                      GIMarshallingTestsCallbackIntInt callback,
+                                                      void *callback_data);
+void gi_marshalling_tests_object_call_vfunc_with_callback (GIMarshallingTestsObject *object);
+
 #define GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT             (gi_marshalling_tests_sub_object_get_type ())
 #define GI_MARSHALLING_TESTS_SUB_OBJECT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT, GIMarshallingTestsSubObject))
 #define GI_MARSHALLING_TESTS_SUB_OBJECT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GI_MARSHALLING_TESTS_TYPE_SUB_OBJECT, GIMarshallingTestsSubObjectClass))



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