dbus/test/glib test-service-glib.xml, 1.12, 1.13 test-service-glib.c,
1.22, 1.23 test-dbus-glib.c, 1.29, 1.30
Colin Walters
walters at freedesktop.org
Tue Jul 12 02:12:51 EST 2005
Update of /cvs/dbus/dbus/test/glib
In directory gabe:/tmp/cvs-serv19235/test/glib
Modified Files:
test-service-glib.xml test-service-glib.c test-dbus-glib.c
Log Message:
2005-07-11 Colin Walters <walters at verbum.org>
* glib/dbus-gvalue.c (struct _DBusGValue): Delete.
(dbus_g_value_types_init): Remove assertion.
(dbus_g_value_get_g_type, dbus_g_value_open)
(dbus_g_value_iterator_get_values, dbus_g_value_get_signature)
(dbus_g_value_copy, dbus_g_value_free): Delete unimplemented
functions related to DBusGValue. Now we marshal/demarshal
structures as GValueArray.
(dbus_gtype_from_signature_iter): Return G_TYPE_VALUE_ARRAY for
structures.
(signature_iter_to_g_type_array): Don't call
signature_iter_to_g_type_struct.
(signature_iter_to_g_type_struct): Delete.
(dbus_gvalue_to_signature): Delete.
(dbus_gvalue_to_signature): New function with same name as other
one; we can convert structures to signatures.
(demarshal_valuearray): New function.
(get_type_demarshaller): Use it.
(demarshal_recurse): Delete.
(marshal_proxy): New function.
(marshal_map): Warn if we can't determine signature from type.
(marshal_collection_ptrarray): Ditto.
(marshal_collection_array): Ditto.
(get_type_marshaller): Use marshal_valuearray.
(marshal_recurse): Delete.
(_dbus_gvalue_test): Add some tests.
* dbus/dbus-glib.h (struct _DBusGValueIterator):
(dbus_g_value_get_g_type, DBUS_TYPE_G_VALUE)
(dbus_g_value_open, dbus_g_value_iterator_get_value)
(dbus_g_value_iterator_get_values, dbus_g_value_iterator_recurse)
(dbus_g_value_free): Remove prototypes.
* glib/dbus-binding-tool-glib.c (dbus_g_type_get_lookup_function): Handle
G_TYPE_VALUE_ARRAY.
* glib/examples/example-service.c:
* glib/examples/example-client.c: Implement GetTuple.
* test/glib/test-dbus-glib.c:
* test/glib/test-service-glib.c:
* test/glib/test-service-glib.xml: Add structure tests.
Index: test-service-glib.xml
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- test-service-glib.xml 10 Jul 2005 22:54:18 -0000 1.12
+++ test-service-glib.xml 11 Jul 2005 16:12:49 -0000 1.13
@@ -81,6 +81,11 @@
<arg type="u" direction="out"/>
</method>
+ <method name="SendCar">
+ <arg type="(suv)" direction="in"/>
+ <arg type="(uo)" direction="out"/>
+ </method>
+
<method name="GetHash">
<arg type="a{ss}" direction="out"/>
</method>
Index: test-service-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-service-glib.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- test-service-glib.c 10 Jul 2005 22:54:18 -0000 1.22
+++ test-service-glib.c 11 Jul 2005 16:12:49 -0000 1.23
@@ -80,6 +80,8 @@
gboolean my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **error);
+gboolean my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error);
+
gboolean my_object_get_hash (MyObject *obj, GHashTable **table, GError **error);
gboolean my_object_increment_val (MyObject *obj, GError **error);
@@ -502,6 +504,32 @@
}
gboolean
+my_object_send_car (MyObject *obj, GValueArray *invals, GValueArray **outvals, GError **error)
+{
+ if (invals->n_values != 3
+ || G_VALUE_TYPE (g_value_array_get_nth (invals, 0)) != G_TYPE_STRING
+ || G_VALUE_TYPE (g_value_array_get_nth (invals, 1)) != G_TYPE_UINT
+ || G_VALUE_TYPE (g_value_array_get_nth (invals, 2)) != G_TYPE_VALUE)
+ {
+ g_set_error (error,
+ MY_OBJECT_ERROR,
+ MY_OBJECT_ERROR_FOO,
+ "invalid incoming values");
+ return FALSE;
+ }
+ *outvals = g_value_array_new (2);
+ g_value_array_append (*outvals, NULL);
+ g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), G_TYPE_UINT);
+ g_value_set_uint (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1),
+ g_value_get_uint (g_value_array_get_nth (invals, 1)) + 1);
+ g_value_array_append (*outvals, NULL);
+ g_value_init (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1), DBUS_TYPE_G_OBJECT_PATH);
+ g_value_set_boxed (g_value_array_get_nth (*outvals, (*outvals)->n_values - 1),
+ g_strdup ("/org/freedesktop/DBus/Tests/MyTestObject2"));
+ return TRUE;
+}
+
+gboolean
my_object_get_hash (MyObject *obj, GHashTable **ret, GError **error)
{
GHashTable *table;
Index: test-dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/test/glib/test-dbus-glib.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- test-dbus-glib.c 10 Jul 2005 22:54:18 -0000 1.29
+++ test-dbus-glib.c 11 Jul 2005 16:12:49 -0000 1.30
@@ -885,6 +885,51 @@
run_mainloop ();
{
+ GValueArray *vals;
+ GValueArray *vals_ret;
+ GValue *val;
+
+ vals = g_value_array_new (3);
+
+ g_value_array_append (vals, NULL);
+ g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_STRING);
+ g_value_set_string (g_value_array_get_nth (vals, 0), "foo");
+
+ g_value_array_append (vals, NULL);
+ g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_UINT);
+ g_value_set_uint (g_value_array_get_nth (vals, vals->n_values - 1), 42);
+
+ g_value_array_append (vals, NULL);
+ g_value_init (g_value_array_get_nth (vals, vals->n_values - 1), G_TYPE_VALUE);
+ val = g_new0 (GValue, 1);
+ g_value_init (val, G_TYPE_UCHAR);
+ g_value_set_uchar (val, '!');
+ g_value_set_boxed (g_value_array_get_nth (vals, vals->n_values - 1), val);
+
+ vals_ret = NULL;
+ g_print ("Calling SendCar\n");
+ if (!dbus_g_proxy_call (proxy, "SendCar", &error,
+ G_TYPE_VALUE_ARRAY, vals,
+ G_TYPE_INVALID,
+ G_TYPE_VALUE_ARRAY, &vals_ret,
+ G_TYPE_INVALID))
+ lose_gerror ("Failed to complete SendCar call", error);
+
+ g_assert (vals_ret != NULL);
+ g_assert (vals_ret->n_values == 2);
+
+ g_assert (G_VALUE_HOLDS_UINT (g_value_array_get_nth (vals_ret, 0)));
+ g_assert (g_value_get_uint (g_value_array_get_nth (vals_ret, 0)) == 43);
+
+ g_assert (G_VALUE_TYPE (g_value_array_get_nth (vals_ret, 1)) == DBUS_TYPE_G_OBJECT_PATH);
+ g_assert (!strcmp ("/org/freedesktop/DBus/Tests/MyTestObject2",
+ g_value_get_boxed (g_value_array_get_nth (vals_ret, 1))));
+
+ g_value_array_free (vals);
+ g_value_array_free (vals_ret);
+ }
+
+ {
GValue *val;
GHashTable *table;
GHashTable *ret_table;
More information about the dbus-commit
mailing list