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
This commit is contained in:
Dan Winship 2013-06-02 19:59:23 -03:00
parent cdff4a331e
commit 1da47d5ede
5 changed files with 2 additions and 61 deletions

View File

@ -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 *

View File

@ -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,
};
/**

View File

@ -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,
};
/**

View File

@ -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 *

View File

@ -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);
}
}