From 02df69822504cfef706d4d1863c53fb2ffe69957 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 17 Jun 2011 14:53:09 +0100 Subject: [PATCH 4/5] MyObject: register marshallers so individual tests don't have to These marshallers are actually dual-use: they're used to call certain methods on MyObject, and also to bind to its signals. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38406 --- test/core/Makefile.am | 4 +++- test/core/my-object.c | 12 ++++++++++++ test/core/my-object.h | 1 + test/core/test-dbus-glib.c | 11 ++++------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/test/core/Makefile.am b/test/core/Makefile.am index 164e3d8..0604ecb 100644 --- a/test/core/Makefile.am +++ b/test/core/Makefile.am @@ -70,7 +70,9 @@ test_registrations_SOURCES = \ registrations.c test_dbus_glib_SOURCES= \ - my-object-marshal.c \ + my-object.c \ + my-object.h \ + my-object-marshal.c \ test-dbus-glib.c test_dbus_glib_LDADD= $(tool_ldadd) diff --git a/test/core/my-object.c b/test/core/my-object.c index 0ff5562..426f056 100644 --- a/test/core/my-object.c +++ b/test/core/my-object.c @@ -10,6 +10,16 @@ static gboolean my_object_throw_error_under_score (MyObject *obj, #include "test-service-glib-glue.h" +void +my_object_register_marshallers (void) +{ + dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_INT_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); + + dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_BOXED, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); +} + /* Properties */ enum { @@ -125,6 +135,8 @@ my_object_class_init (MyObjectClass *mobject_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (mobject_class); + my_object_register_marshallers (); + dbus_g_object_type_install_info (MY_TYPE_OBJECT, &dbus_glib_my_object_object_info); diff --git a/test/core/my-object.h b/test/core/my-object.h index 3657aa0..0fcfee2 100644 --- a/test/core/my-object.h +++ b/test/core/my-object.h @@ -7,6 +7,7 @@ typedef struct MyObject MyObject; typedef struct MyObjectClass MyObjectClass; +void my_object_register_marshallers (void); GType my_object_get_type (void); struct MyObject diff --git a/test/core/test-dbus-glib.c b/test/core/test-dbus-glib.c index be3e8d9..9125338 100644 --- a/test/core/test-dbus-glib.c +++ b/test/core/test-dbus-glib.c @@ -10,9 +10,10 @@ #include #include #include -#include "my-object-marshal.h" +#include "my-object.h" + +GMainLoop *loop = NULL; -static GMainLoop *loop = NULL; static const char *await_terminating_service = NULL; static int n_times_foo_received = 0; static int n_times_frobnicate_received = 0; @@ -1719,11 +1720,7 @@ main (int argc, char **argv) if (proxy == NULL) lose_gerror ("Failed to create proxy for name owner", error); - dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_INT_STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); - - dbus_g_object_register_marshaller (my_object_marshal_VOID__STRING_BOXED, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + my_object_register_marshallers (); dbus_g_proxy_add_signal (proxy, "Sig0", G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal (proxy, "Sig1", G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); -- 1.7.5.4