From 1da47d5ede3384105c035638fb4eb533d8989e20 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sun, 2 Jun 2013 19:59:23 -0300 Subject: [PATCH] gsourceclosure: use g_cclosure_marshal_generic For the glib-defined source types, and any source type that defines a closure callback but not a closure marshal, use g_cclosure_marshal_generic. And then remove all the other remaining source closure marshals. https://bugzilla.gnome.org/show_bug.cgi?id=701511 --- gio/gasynchelper.c | 25 ------------------------- gio/gcancellable.c | 1 - gio/gpollableutils.c | 1 - gio/gsocket.c | 1 - gobject/gsourceclosure.c | 35 ++--------------------------------- 5 files changed, 2 insertions(+), 61 deletions(-) diff --git a/gio/gasynchelper.c b/gio/gasynchelper.c index ab8bd2c1d..d75111b4e 100644 --- a/gio/gasynchelper.c +++ b/gio/gasynchelper.c @@ -109,37 +109,12 @@ fd_source_closure_callback (int fd, return result; } -static void -fd_source_closure_marshal (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) -{ - GFDSourceFunc callback; - GCClosure *cc = (GCClosure*) closure; - gboolean v_return; - - g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 0); - - callback = (GFDSourceFunc) (marshal_data ? marshal_data : cc->callback); - - v_return = callback (g_value_get_int (param_values), - g_value_get_flags (param_values + 1), - closure->data); - - g_value_set_boolean (return_value, v_return); -} - static GSourceFuncs fd_source_funcs = { fd_source_prepare, fd_source_check, fd_source_dispatch, fd_source_finalize, (GSourceFunc)fd_source_closure_callback, - (GSourceDummyMarshal)fd_source_closure_marshal, }; GSource * diff --git a/gio/gcancellable.c b/gio/gcancellable.c index 4e7a44951..3186ea68c 100644 --- a/gio/gcancellable.c +++ b/gio/gcancellable.c @@ -713,7 +713,6 @@ static GSourceFuncs cancellable_source_funcs = cancellable_source_dispatch, cancellable_source_finalize, (GSourceFunc)cancellable_source_closure_callback, - (GSourceDummyMarshal)g_cclosure_marshal_generic, }; /** diff --git a/gio/gpollableutils.c b/gio/gpollableutils.c index d3510345c..1aa4fd061 100644 --- a/gio/gpollableutils.c +++ b/gio/gpollableutils.c @@ -105,7 +105,6 @@ static GSourceFuncs pollable_source_funcs = pollable_source_dispatch, pollable_source_finalize, (GSourceFunc)pollable_source_closure_callback, - (GSourceDummyMarshal)g_cclosure_marshal_generic, }; /** diff --git a/gio/gsocket.c b/gio/gsocket.c index de6739052..20f4b301b 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -3231,7 +3231,6 @@ static GSourceFuncs socket_source_funcs = socket_source_dispatch, socket_source_finalize, (GSourceFunc)socket_source_closure_callback, - (GSourceDummyMarshal)g_cclosure_marshal_generic, }; static GSource * diff --git a/gobject/gsourceclosure.c b/gobject/gsourceclosure.c index 16f34ee6c..f5425f215 100644 --- a/gobject/gsourceclosure.c +++ b/gobject/gsourceclosure.c @@ -48,31 +48,6 @@ g_io_condition_get_type (void) return etype; } -/* We need to hand-write this marshaler, since it doesn't have an - * instance object. - */ -static void -source_closure_marshal_BOOLEAN__VOID (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) -{ - GSourceFunc callback; - GCClosure *cc = (GCClosure*) closure; - gboolean v_return; - - g_return_if_fail (return_value != NULL); - g_return_if_fail (n_param_values == 0); - - callback = (GSourceFunc) (marshal_data ? marshal_data : cc->callback); - - v_return = callback (closure->data); - - g_value_set_boolean (return_value, v_return); -} - static gboolean io_watch_closure_callback (GIOChannel *channel, GIOCondition condition, @@ -188,16 +163,10 @@ g_source_set_closure (GSource *source, if (G_CLOSURE_NEEDS_MARSHAL (closure)) { GClosureMarshal marshal = (GClosureMarshal)source->source_funcs->closure_marshal; - if (!marshal) - { - if (source->source_funcs == &g_idle_funcs || - source->source_funcs == &g_timeout_funcs) - marshal = source_closure_marshal_BOOLEAN__VOID; - else if (source->source_funcs == &g_io_watch_funcs) - marshal = g_cclosure_marshal_BOOLEAN__FLAGS; - } if (marshal) g_closure_set_marshal (closure, marshal); + else + g_closure_set_marshal (closure, g_cclosure_marshal_generic); } }