From b3c410dee1b3d3e72ad1e76c7dc597a07482137d Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 15 Dec 2000 07:05:10 +0000 Subject: [PATCH] use g_signal_newc 2000-12-15 Havoc Pennington * gobject.c (g_object_do_class_init): use g_signal_newc * gsignal.c (g_signal_newc): convenience function for signals created from C (g_signal_new_valist): added (g_signal_new): removed --- gobject/ChangeLog | 9 ++++++++ gobject/gobject.c | 34 +++++++++++++++---------------- gobject/gsignal.c | 52 ++++++++++++++++++++++++++++++++++------------- gobject/gsignal.h | 27 ++++++++++++++++-------- 4 files changed, 81 insertions(+), 41 deletions(-) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index c420b14f9..d5c18324a 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,12 @@ +2000-12-15 Havoc Pennington + + * gobject.c (g_object_do_class_init): use g_signal_newc + + * gsignal.c (g_signal_newc): convenience function for signals + created from C + (g_signal_new_valist): added + (g_signal_new): removed + Fri Dec 15 04:40:23 2000 Tim Janik * gparam.[hc]: add an instance member value_type so the default diff --git a/gobject/gobject.c b/gobject/gobject.c index cc70c0911..6a8bc0b5c 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -299,25 +299,23 @@ g_object_do_class_init (GObjectClass *class) "and a data pointer", G_PARAM_WRITABLE)); gobject_signals[PROPERTIES_CHANGED] = - g_signal_new ("properties_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, - g_signal_type_cclosure_new (G_TYPE_FROM_CLASS (class), - G_STRUCT_OFFSET (GObjectClass, properties_changed)), - NULL, /* accumulator */ - g_cclosure_marshal_VOID__UINT_POINTER, - G_TYPE_NONE, - 2, G_TYPE_UINT, G_TYPE_POINTER); + g_signal_newc ("properties_changed", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (GObjectClass, properties_changed), + NULL, /* accumulator */ + g_cclosure_marshal_VOID__UINT_POINTER, + G_TYPE_NONE, + 2, G_TYPE_UINT, G_TYPE_POINTER); gobject_signals[NOTIFY] = - g_signal_new ("notify", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, - g_signal_type_cclosure_new (G_TYPE_FROM_CLASS (class), - G_STRUCT_OFFSET (GObjectClass, notify)), - NULL, /* accumulator */ - g_cclosure_marshal_VOID__PARAM, - G_TYPE_NONE, - 1, G_TYPE_PARAM); + g_signal_newc ("notify", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, + G_STRUCT_OFFSET (GObjectClass, notify), + NULL, /* accumulator */ + g_cclosure_marshal_VOID__PARAM, + G_TYPE_NONE, + 1, G_TYPE_PARAM); } void diff --git a/gobject/gsignal.c b/gobject/gsignal.c index dc93b5a2c..af69cc909 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -883,31 +883,26 @@ g_signal_list_ids (GType itype, } guint -g_signal_new (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - GClosure *class_closure, - GSignalAccumulator accumulator, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - ...) +g_signal_new_valist (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + va_list args) { GType *param_types; guint i; - va_list args; guint signal_id; if (n_params > 0) { param_types = g_new (GType, n_params); - va_start (args, n_params); - for (i = 0; i < n_params; i++) param_types[i] = va_arg (args, GType); - - va_end (args); } else param_types = NULL; @@ -920,6 +915,35 @@ g_signal_new (const gchar *signal_name, return signal_id; } +guint +g_signal_newc (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + guint class_offset, + GSignalAccumulator accumulator, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...) +{ + va_list args; + guint signal_id; + + g_return_val_if_fail (signal_name != NULL, 0); + + va_start (args, n_params); + + signal_id = g_signal_new_valist (signal_name, itype, signal_flags, + g_signal_type_cclosure_new (itype, + class_offset), + accumulator, c_marshaller, + return_type, n_params, args); + + va_end (args); + + return signal_id; +} + guint g_signal_newv (const gchar *signal_name, GType itype, diff --git a/gobject/gsignal.h b/gobject/gsignal.h index 971a0e5c7..748e07299 100644 --- a/gobject/gsignal.h +++ b/gobject/gsignal.h @@ -87,15 +87,6 @@ struct _GSignalQuery /* --- signals --- */ -guint g_signal_new (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - GClosure *class_closure, - GSignalAccumulator accumulator, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - ...); guint g_signal_newv (const gchar *signal_name, GType itype, GSignalFlags signal_flags, @@ -105,6 +96,24 @@ guint g_signal_newv (const gchar *signal_name, GType return_type, guint n_params, GType *param_types); +guint g_signal_new_valist (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + va_list args); +guint g_signal_newc (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + guint class_offset, + GSignalAccumulator accumulator, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...); void g_signal_emitv (const GValue *instance_and_params, guint signal_id, GQuark detail,