dbus/test/glib test-service-glib.xml, 1.13, 1.14 test-service-glib.c,
1.23, 1.24 test-dbus-glib.c, 1.30, 1.31
Colin Walters
walters at freedesktop.org
Mon Jul 25 04:04:25 EST 2005
Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv32645/test/glib
Modified Files:
test-service-glib.xml test-service-glib.c test-dbus-glib.c
Log Message:
2005-07-24 Colin Walters <walters at verbum.org>
* glib/dbus-gvalue.c (signature_iter_to_g_type_array): Don't require
typedata; recursive arrays won't have it.
* test/glib/test-dbus-glib.c:
* test/glib/test-service-glib.c:
* test/glib/test-service-glib.xml: Add recursive arrays tests.
Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- test-service-glib.xml 11 Jul 2005 16:12:49 -0000 1.13
+++ test-service-glib.xml 24 Jul 2005 18:04:23 -0000 1.14
@@ -90,6 +90,11 @@
<arg type="a{ss}" direction="out"/>
</method>
+ <method name="RecArrays">
+ <arg type="aas" name="val" direction="in"/>
+ <arg type="aau" direction="out"/>
+ </method>
+
<method name="Objpath">
<arg type="o" direction="in"/>
<arg type="o" direction="out">
Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- test-service-glib.c 11 Jul 2005 16:12:49 -0000 1.23
+++ test-service-glib.c 24 Jul 2005 18:04:23 -0000 1.24
@@ -69,6 +69,8 @@
gboolean my_object_many_stringify (MyObject *obj, GHashTable *vals, GHashTable **ret, GError **error);
+gboolean my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error);
+
gboolean my_object_objpath (MyObject *obj, const char *in, const char **arg1, GError **error);
gboolean my_object_get_objs (MyObject *obj, GPtrArray **objs, GError **error);
@@ -459,6 +461,105 @@
}
gboolean
+my_object_rec_arrays (MyObject *obj, GPtrArray *in, GPtrArray **ret, GError **error)
+{
+ guint i;
+ char **strs;
+ GArray *ints;
+ guint v_UINT;
+
+ if (in->len != 2)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid array len");
+ return FALSE;
+ }
+
+ strs = g_ptr_array_index (in, 0);
+ if (!*strs || strcmp (*strs, "foo"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 0");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "bar"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 1");
+ return FALSE;
+ }
+ strs++;
+ if (*strs)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string array len in pos 0");
+ return FALSE;
+ }
+ strs = g_ptr_array_index (in, 1);
+ if (!*strs || strcmp (*strs, "baz"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 0");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "whee"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 1");
+ return FALSE;
+ }
+ strs++;
+ if (!*strs || strcmp (*strs, "moo"))
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string 2");
+ return FALSE;
+ }
+ strs++;
+ if (*strs)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid string array len in pos 1");
+ return FALSE;
+ }
+
+ *ret = g_ptr_array_new ();
+
+ ints = g_array_new (TRUE, TRUE, sizeof (guint));
+ v_UINT = 10;
+ g_array_append_val (ints, v_UINT);
+ v_UINT = 42;
+ g_array_append_val (ints, v_UINT);
+ v_UINT = 27;
+ g_array_append_val (ints, v_UINT);
+ g_ptr_array_add (*ret, ints);
+
+ ints = g_array_new (TRUE, TRUE, sizeof (guint));
+ v_UINT = 30;
+ g_array_append_val (ints, v_UINT);
+ g_ptr_array_add (*ret, ints);
+ return TRUE;
+}
+
+gboolean
my_object_objpath (MyObject *obj, const char *incoming, const char **outgoing, GError **error)
{
if (strcmp (incoming, "/org/freedesktop/DBus/Tests/MyTestObject"))
Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- test-dbus-glib.c 11 Jul 2005 16:12:49 -0000 1.30
+++ test-dbus-glib.c 24 Jul 2005 18:04:23 -0000 1.31
@@ -974,6 +974,57 @@
}
{
+ GPtrArray *in_array;
+ GPtrArray *out_array;
+ char **strs;
+ GArray *uints;
+
+ in_array = g_ptr_array_new ();
+
+ strs = g_new0 (char *, 3);
+ strs[0] = "foo";
+ strs[1] = "bar";
+ strs[2] = NULL;
+ g_ptr_array_add (in_array, strs);
+
+ strs = g_new0 (char *, 4);
+ strs[0] = "baz";
+ strs[1] = "whee";
+ strs[2] = "moo";
+ strs[3] = NULL;
+ g_ptr_array_add (in_array, strs);
+
+ out_array = NULL;
+ g_print ("Calling RecArrays\n");
+ if (!dbus_g_proxy_call (proxy, "RecArrays", &error,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRV), in_array,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray",
+ dbus_g_type_get_collection ("GPtrArray",
+ G_TYPE_UINT)), &out_array,
+ G_TYPE_INVALID))
+ lose_gerror ("Failed to complete RecArrays call", error);
+ g_free (g_ptr_array_index (in_array, 0));
+ g_free (g_ptr_array_index (in_array, 1));
+
+ g_assert (out_array);
+ g_assert (out_array->len == 2);
+ uints = g_ptr_array_index (out_array, 0);
+ g_assert (uints);
+ g_assert (uints->len == 3);
+ g_assert (g_array_index (uints, guint, 0) == 10);
+ g_assert (g_array_index (uints, guint, 1) == 42);
+ g_assert (g_array_index (uints, guint, 2) == 27);
+ g_array_free (uints, TRUE);
+ uints = g_ptr_array_index (out_array, 1);
+ g_assert (uints);
+ g_assert (uints->len == 1);
+ g_assert (g_array_index (uints, guint, 0) == 30);
+ g_array_free (uints, TRUE);
+ g_ptr_array_free (out_array, TRUE);
+ }
+
+ {
guint val;
char *ret_path;
DBusGProxy *ret_proxy;
More information about the dbus-commit
mailing list