summaryrefslogtreecommitdiffstats
path: root/test/glib
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2005-07-11 16:12:50 +0000
committerColin Walters <walters@verbum.org>2005-07-11 16:12:50 +0000
commit622cc8af6181d7e3d839ec0bdfad376648863844 (patch)
treed1c77dc4245d50c4749fd0eff18c7dcaf6115c6c /test/glib
parent8c095eea8fbe2f8c219bdb2aebcf61e4e3993f53 (diff)
2005-07-11 Colin Walters <walters@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.
Diffstat (limited to 'test/glib')
-rw-r--r--test/glib/test-dbus-glib.c45
-rw-r--r--test/glib/test-service-glib.c28
-rw-r--r--test/glib/test-service-glib.xml5
3 files changed, 78 insertions, 0 deletions
diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c
index 786235de..962db15e 100644
--- a/test/glib/test-dbus-glib.c
+++ b/test/glib/test-dbus-glib.c
@@ -885,6 +885,51 @@ main (int argc, char **argv)
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;
diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c
index e44310f3..b0043e80 100644
--- a/test/glib/test-service-glib.c
+++ b/test/glib/test-service-glib.c
@@ -80,6 +80,8 @@ gboolean my_object_many_uppercase (MyObject *obj, const char * const *in, char *
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 @@ my_object_str_hash_len (MyObject *obj, GHashTable *table, guint *len, GError **e
}
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;
diff --git a/test/glib/test-service-glib.xml b/test/glib/test-service-glib.xml
index 4ea2b2bb..f63beada 100644
--- a/test/glib/test-service-glib.xml
+++ b/test/glib/test-service-glib.xml
@@ -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>