[glib/signal-performance: 6/10] Add _g_closure_is_void to check for NULL vfuncs
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/signal-performance: 6/10] Add _g_closure_is_void to check for NULL vfuncs
- Date: Fri, 2 Mar 2012 16:13:55 +0000 (UTC)
commit 1c4f0ca48332f2e550b5e5e17365c43912958cee
Author: Alexander Larsson <alexl redhat com>
Date: Tue Feb 28 15:48:20 2012 +0100
Add _g_closure_is_void to check for NULL vfuncs
https://bugzilla.gnome.org/show_bug.cgi?id=661140
gobject/gclosure.c | 36 ++++++++++++++++++++++++++++++++++++
gobject/gtype-private.h | 2 ++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gobject/gclosure.c b/gobject/gclosure.c
index bf79754..4cee41c 100644
--- a/gobject/gclosure.c
+++ b/gobject/gclosure.c
@@ -1025,6 +1025,42 @@ g_type_iface_meta_marshal (GClosure *closure,
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
g_type_iface_meta_marshalv (GClosure *closure,
GValue *return_value,
diff --git a/gobject/gtype-private.h b/gobject/gtype-private.h
index 9cbea77..04a252b 100644
--- a/gobject/gtype-private.h
+++ b/gobject/gtype-private.h
@@ -60,6 +60,8 @@ void _g_type_boxed_init (GType type,
GBoxedCopyFunc copy_func,
GBoxedFreeFunc free_func);
+gboolean _g_closure_is_void (GClosure *closure,
+ gpointer instance);
gboolean _g_closure_supports_invoke_va (GClosure *closure);
void _g_closure_set_va_marshal (GClosure *closure,
GVaClosureMarshal marshal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]