summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2010-05-03 19:15:54 +0200
committerTomeu Vizoso <tomeu@sugarlabs.org>2010-05-03 19:15:54 +0200
commitffc28a47400e06b39e05be4f7e4c8dccef4bd8ea (patch)
treef35d65e071d9ec47231d1bee26130a5b5f39165b
parent87291e08b0fd34b62e1ad9811c174108b38311a9 (diff)
downloadgobject-introspection-ffc28a47400e06b39e05be4f7e4c8dccef4bd8ea.tar.gz
Add some tests to Everything for testing callbacks as constructor args
-rw-r--r--gir/Everything-1.0-expected.gir48
-rw-r--r--gir/everything.c47
-rw-r--r--gir/everything.h6
3 files changed, 101 insertions, 0 deletions
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index ff854394..24c9ff94 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -169,6 +169,26 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</constructor>
+ <constructor name="new_callback" c:identifier="test_obj_new_callback">
+ <return-value transfer-ownership="full">
+ <type name="TestObj" c:type="TestObj*"/>
+ </return-value>
+ <parameters>
+ <parameter name="callback"
+ transfer-ownership="none"
+ scope="notified"
+ closure="1"
+ destroy="2">
+ <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>
+ </parameters>
+ </constructor>
<function name="static_method" c:identifier="test_obj_static_method">
<return-value transfer-ownership="none">
<type name="double" c:type="double"/>
@@ -179,6 +199,20 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</function>
+ <function name="static_method_callback"
+ c:identifier="test_obj_static_method_callback">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="callback"
+ transfer-ownership="none"
+ allow-none="1"
+ scope="call">
+ <type name="TestCallback" c:type="TestCallback"/>
+ </parameter>
+ </parameters>
+ </function>
<virtual-method name="matrix" invoker="do_matrix">
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
@@ -272,6 +306,20 @@ case.">
</parameter>
</parameters>
</method>
+ <method name="instance_method_callback"
+ c:identifier="test_obj_instance_method_callback">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="callback"
+ transfer-ownership="none"
+ allow-none="1"
+ scope="call">
+ <type name="TestCallback" c:type="TestCallback"/>
+ </parameter>
+ </parameters>
+ </method>
<property name="bare" writable="1">
<type name="GObject.Object" c:type="GObject"/>
</property>
diff --git a/gir/everything.c b/gir/everything.c
index b4cfc759..169d05cf 100644
--- a/gir/everything.c
+++ b/gir/everything.c
@@ -2004,6 +2004,53 @@ test_async_ready_callback (GAsyncReadyCallback callback)
g_simple_async_result_complete_in_idle (result);
}
+/**
+ * test_obj_instance_method_callback:
+ * @callback: (scope call) (allow-none):
+ *
+ **/
+void
+test_obj_instance_method_callback (TestObj *obj, TestCallback callback)
+{
+ if (callback != NULL)
+ callback();
+}
+
+/**
+ * test_obj_static_method_callback:
+ * @callback: (scope call) (allow-none):
+ *
+ **/
+void
+test_obj_static_method_callback (TestCallback callback)
+{
+ if (callback != NULL)
+ callback();
+}
+
+/**
+ * test_obj_new_callback:
+ * @callback: (scope notified):
+ *
+ **/
+TestObj *
+test_obj_new_callback (TestCallbackUserData callback, gpointer user_data,
+ GDestroyNotify notify)
+{
+ CallbackInfo *info;
+
+ callback(user_data);
+
+ info = g_slice_new(CallbackInfo);
+ info->callback = callback;
+ info->notify = notify;
+ info->user_data = user_data;
+
+ notified_callbacks = g_slist_prepend(notified_callbacks, info);
+
+ return g_object_new (TEST_TYPE_OBJ, NULL);
+}
+
/* interface */
static void
diff --git a/gir/everything.h b/gir/everything.h
index 63b2ec1e..8afe8fa2 100644
--- a/gir/everything.h
+++ b/gir/everything.h
@@ -352,6 +352,12 @@ int test_callback_infinite (TestCallbackUserData callback,
void test_async_ready_callback (GAsyncReadyCallback callback);
+void test_obj_instance_method_callback (TestObj *obj, TestCallback callback);
+void test_obj_static_method_callback (TestCallback callback);
+TestObj *test_obj_new_callback (TestCallbackUserData callback,
+ gpointer user_data,
+ GDestroyNotify notify);
+
/* interface */
#define TEST_TYPE_INTERFACE (test_interface_get_type ())
#define TEST_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_INTERFACE, TestInterface))