From 86b9f6ad4a6f466e24b5e4c1c320029041c50e3b Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Wed, 5 Oct 2005 20:43:46 +0000 Subject: * glib/dbus-gvalue.c (marshal_variant): call _dbus_gvalue_marshal instead of marshal basic so we can handle recursive types in a variant * test/glib/test-dbus-glib.c: Add test for marshaling recurive types in variants * test/glib/test-service-glib.c, test-service-glib.xml (my_object_echo_variant [EchoVariant], my_object_process_variant_of_array_of_ints123 [ProcessVariantOfArrayOfInts123]): Add two test methods * python/introspect_parser.py: New module for parsing introspect data. * python/dbus_bindings.pyx: (various places): when throwing errors fix to use errormsg instead of message local variable because Pyrex can get confused with other message variables (initial patch by Robert McQueen ) (MessageIter::parse_signature_block): new method for getting the next block in a signiture. (MessageIter::append_strict): new method for appending values strictly using the passed in signature instead of guessing at the type (MessageItter:: append_dict, append_struct, append_array): use signatures to marshal children if the signature is available * python/exceptions.py (IntrospectionParserException): new exception * python/proxies.py (ProxyMethod::__call__): Marshal args with introspected signatures if available, else we fall back to the old way of doing things. (ProxyObject::_introspect_reply_handler ): parse introspection data * python/service.py (ObjectType::_reflect_on_method): Properly terminate if there are no args in the reflection data * test/python/test-client.py: add tests for talking with the GLib test server. This gives us better coverage for introspection since python to python will always generate arguments as variants. It also allows us to test the robustness of the GLib bindings and interlanguage communications. --- test/glib/test-dbus-glib.c | 27 +++++++++++++++++++++++++++ test/glib/test-service-glib.c | 41 +++++++++++++++++++++++++++++++++++++++++ test/glib/test-service-glib.xml | 9 +++++++++ 3 files changed, 77 insertions(+) (limited to 'test/glib') diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c index 368a5762..86c9f7ec 100644 --- a/test/glib/test-dbus-glib.c +++ b/test/glib/test-dbus-glib.c @@ -1138,7 +1138,34 @@ main (int argc, char **argv) g_free (g_ptr_array_index (objs, i)); g_ptr_array_free (objs, TRUE); } + + { + GValue *variant; + GArray *array; + gint i; + + g_print ("Calling ProcessVariantOfArrayOfInts123\n"); + + array = g_array_sized_new (FALSE, FALSE, sizeof(gint), 3); + i = 1; + g_array_append_val (array, i); + i++; + g_array_append_val (array, i); + i++; + g_array_append_val (array, i); + variant = g_new0 (GValue, 1); + g_value_init (variant, dbus_g_type_get_collection ("GArray", G_TYPE_INT)); + g_value_set_boxed_take_ownership (variant, array); + + if (!dbus_g_proxy_call (proxy, "ProcessVariantOfArrayOfInts123", &error, + G_TYPE_VALUE, variant, + G_TYPE_INVALID, + G_TYPE_INVALID)) + lose_gerror ("Failed to send a vairant of array of ints 1, 2 and 3!", error); + + g_value_unset (variant); + } /* Signal handling tests */ g_print ("Testing signal handling\n"); diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c index 7230fd94..06cc5957 100644 --- a/test/glib/test-service-glib.c +++ b/test/glib/test-service-glib.c @@ -97,6 +97,10 @@ gboolean my_object_emit_signal2 (MyObject *obj, GError **error); gboolean my_object_emit_frobnicate (MyObject *obj, GError **error); +gboolean my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error); + +gboolean my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error); + gboolean my_object_terminate (MyObject *obj, GError **error); void my_object_async_increment (MyObject *obj, gint32 x, DBusGMethodInvocation *context); @@ -663,6 +667,43 @@ my_object_get_value (MyObject *obj, guint *ret, GError **error) return TRUE; } +gboolean +my_object_echo_variant (MyObject *obj, GValue *variant, GValue *ret, GError **error) +{ + g_value_init (ret, G_VALUE_TYPE(variant)); + g_value_copy (variant, ret); + + return TRUE; +} + +gboolean +my_object_process_variant_of_array_of_ints123 (MyObject *obj, GValue *variant, GError **error) +{ + GArray *array; + int i; + int j; + + j = 0; + + array = (GArray *)g_value_get_boxed (variant); + + for (i = 0; i <= 2; i++) + { + j = g_array_index (array, int, i); + if (j != i + 1) + goto error; + } + + return TRUE; + +error: + *error = g_error_new (MY_OBJECT_ERROR, + MY_OBJECT_ERROR_FOO, + "Error decoding a variant of type ai (i + 1 = %i, j = %i)", + i, j + 1); + return FALSE; +} + gboolean my_object_emit_frobnicate (MyObject *obj, GError **error) { diff --git a/test/glib/test-service-glib.xml b/test/glib/test-service-glib.xml index 1fd6155c..5b589d08 100644 --- a/test/glib/test-service-glib.xml +++ b/test/glib/test-service-glib.xml @@ -128,6 +128,15 @@ + + + + + + + + + -- cgit