gobject-introspection r103 - in trunk: . tests/invoke
- From: robtaylor svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r103 - in trunk: . tests/invoke
- Date: Mon, 4 Feb 2008 17:09:02 +0000 (GMT)
Author: robtaylor
Date: Mon Feb 4 17:09:02 2008
New Revision: 103
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=103&view=rev
Log:
2008-02-04 Rob Taylor <rob taylor codethink co uk>
* tests/invoke/invoke.c: (main):
* tests/invoke/testfns.c: (test6), (test7):
* tests/invoke/testfns.xml:
Add tests for invokation with a GList argument.
Also tests caller-owns return values.
Modified:
trunk/ChangeLog
trunk/tests/invoke/invoke.c
trunk/tests/invoke/testfns.c
trunk/tests/invoke/testfns.xml
Modified: trunk/tests/invoke/invoke.c
==============================================================================
--- trunk/tests/invoke/invoke.c (original)
+++ trunk/tests/invoke/invoke.c Mon Feb 4 17:09:02 2008
@@ -142,11 +142,66 @@
g_assert (len == strlen (blurb));
g_base_info_unref (info);
+
+ /* test GList*/
+ g_print ("Test 6");
+ info = g_irepository_find_by_name (rep, "test", "test6");
+ g_assert (g_base_info_get_type (info) == GI_INFO_TYPE_FUNCTION);
+ function = (GIFunctionInfo *)info;
+
+ {
+ GList *list = NULL;
+ list = g_list_prepend (list, GINT_TO_POINTER(1));
+ list = g_list_prepend (list, GINT_TO_POINTER(2));
+ retval.v_int = 0;
+ in_args[0].v_pointer = out_args[0].v_pointer = list;
+ if (!g_function_info_invoke (function, in_args, 1, NULL, 0, &retval, &error))
+ g_print ("Invokation of %s failed: %s\n",
+ g_base_info_get_name (info),
+ error->message);
+
+ g_print("returned %d", retval.v_int);
+ g_assert (retval.v_int == 2);
+ g_list_free (list);
+ }
+
+ g_base_info_unref (info);
+ g_clear_error (&error);
+
+ /* test GList more, transfer ownership*/
+ g_print ("Test 7");
+ info = g_irepository_find_by_name (rep, "test", "test7");
+ g_assert (g_base_info_get_type (info) == GI_INFO_TYPE_FUNCTION);
+ function = (GIFunctionInfo *)info;
+
+ {
+ GList *list = NULL;
+ list = g_list_prepend (list, g_strdup("there..."));
+ list = g_list_prepend (list, g_strdup("Hey "));
+ retval.v_pointer = NULL;
+ in_args[0].v_pointer = out_args[0].v_pointer = list;
+ if (!g_function_info_invoke (function, in_args, 1, NULL, 0, &retval, &error))
+ g_print ("Invokation of %s failed: %s\n",
+ g_base_info_get_name (info),
+ error->message);
+
+ g_print("returned %s", retval.v_pointer);
+ g_assert (strcmp(retval.v_pointer, "Hey there...")==0);
+ g_list_foreach (list, (GFunc) g_free, NULL);
+ g_list_free (list);
+ g_assert (g_callable_info_get_caller_owns ((GICallableInfo *)function) ==
+ GI_TRANSFER_EVERYTHING);
+ g_free (retval.v_pointer);
+ }
+
+ g_base_info_unref (info);
+ g_clear_error (&error);
+
/* test error handling */
#if 0
- /* test6 is not implemented */
- info = g_irepository_find_by_name (rep, "test", "test6");
+ /* "broken" is in the metadata but not in the .so*/
+ info = g_irepository_find_by_name (rep, "test", "broken");
g_assert (g_base_info_get_type (info) == GI_INFO_TYPE_FUNCTION);
function = (GIFunctionInfo *)info;
Modified: trunk/tests/invoke/testfns.c
==============================================================================
--- trunk/tests/invoke/testfns.c (original)
+++ trunk/tests/invoke/testfns.c Mon Feb 4 17:09:02 2008
@@ -28,3 +28,20 @@
*blurb = g_strdup ("hey there");
*len = strlen (*blurb);
}
+
+gint test6 (GList *list)
+{
+ return g_list_length(list);
+}
+
+char *test7 (GList *list)
+{
+ GList *lp;
+ GString *string = g_string_new("");
+
+ for (lp=list; lp ; lp=lp->next)
+ {
+ g_string_append(string, (const char *)lp->data);
+ }
+ return g_string_free (string, FALSE);
+}
Modified: trunk/tests/invoke/testfns.xml
==============================================================================
--- trunk/tests/invoke/testfns.xml (original)
+++ trunk/tests/invoke/testfns.xml Mon Feb 4 17:09:02 2008
@@ -40,6 +40,21 @@
</function>
<function name="test6" symbol="test6">
+ <return-type type="gint"/>
+ <parameters>
+ <parameter name="list" type="GList<gint>*" direction="in"/>
+ </parameters>
+ </function>
+
+
+ <function name="test7" symbol="test7">
+ <return-type type="utf8" transfer="full"/>
+ <parameters>
+ <parameter name="list" type="GList<utf8>*" direction="in"/>
+ </parameters>
+ </function>
+
+ <function name="broken" symbol="broken">
<return-type type="void"/>
</function>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]