Add _g_closure_is_void to check for NULL vfuncs

https://bugzilla.gnome.org/show_bug.cgi?id=661140
This commit is contained in:
Alexander Larsson 2012-02-28 15:48:20 +01:00
parent 57051905f9
commit 1c4f0ca483
2 changed files with 38 additions and 0 deletions

View File

@ -1025,6 +1025,42 @@ g_type_iface_meta_marshal (GClosure *closure,
callback); callback);
} }
gboolean
_g_closure_is_void (GClosure *closure,
gpointer instance)
{
GRealClosure *real_closure;
GTypeClass *class;
gpointer callback;
GType itype;
guint offset;
if (closure->is_invalid)
return TRUE;
real_closure = G_REAL_CLOSURE (closure);
if (real_closure->meta_marshal == g_type_iface_meta_marshal)
{
itype = (GType) closure->data;
offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
callback = G_STRUCT_MEMBER (gpointer, class, offset);
return callback == NULL;
}
else if (real_closure->meta_marshal == g_type_class_meta_marshal)
{
offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
callback = G_STRUCT_MEMBER (gpointer, class, offset);
return callback == NULL;
}
return FALSE;
}
static void static void
g_type_iface_meta_marshalv (GClosure *closure, g_type_iface_meta_marshalv (GClosure *closure,
GValue *return_value, GValue *return_value,

View File

@ -60,6 +60,8 @@ void _g_type_boxed_init (GType type,
GBoxedCopyFunc copy_func, GBoxedCopyFunc copy_func,
GBoxedFreeFunc free_func); GBoxedFreeFunc free_func);
gboolean _g_closure_is_void (GClosure *closure,
gpointer instance);
gboolean _g_closure_supports_invoke_va (GClosure *closure); gboolean _g_closure_supports_invoke_va (GClosure *closure);
void _g_closure_set_va_marshal (GClosure *closure, void _g_closure_set_va_marshal (GClosure *closure,
GVaClosureMarshal marshal); GVaClosureMarshal marshal);