From bfcbfe7f09abff87728f9d14fa4be48a649aaee1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 4 May 2013 11:03:40 -0400 Subject: [PATCH] Use g_cclosure_marshal_generic() when GLib version is sufficient For applications that use GLib 2.30 or later in combination with dbus-glib (such as NetworkManager), this allows them to simply stop calling dbus_g_object_register_marshaller(). In the future when dbus-glib hard requires GLib 2.30, we can deprecate the API. https://bugs.freedesktop.org/show_bug.cgi?id=64214 --- dbus/dbus-gobject.c | 7 ++++++- test/core/my-object.c | 5 +++++ 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index 9889836..26cf1ca 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -2965,6 +2965,9 @@ _dbus_gobject_lookup_marshaller (GType rettype, guint n_params, const GType *param_types) { +#if GLIB_CHECK_VERSION(2,30,0) + return g_cclosure_marshal_generic; +#else GClosureMarshal ret; DBusGFuncSignature sig; GType *params; @@ -3034,6 +3037,7 @@ _dbus_gobject_lookup_marshaller (GType rettype, g_free (params); return ret; +#endif } /** @@ -3046,7 +3050,8 @@ _dbus_gobject_lookup_marshaller (GType rettype, * giving its return type and a list of parameter types, * followed by %G_TYPE_INVALID. * - * This function will not be needed once GLib includes libffi. + * This function is not necessary if your application is using GLib + * 2.30 or later. */ void dbus_g_object_register_marshaller (GClosureMarshal marshaller, diff --git a/test/core/my-object.c b/test/core/my-object.c index e31dca3..5bedf36 100644 --- a/test/core/my-object.c +++ b/test/core/my-object.c @@ -10,11 +10,16 @@ void my_object_register_marshallers (void) { + /* Don't register marshallers if we don't need to; this will test + * the g_cclosure_marshal_generic() case. + */ +#if !GLIB_CHECK_VERSION(2,30,0) 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); +#endif } /* Properties */ -- 1.7.1