#include <signal.h>
#include "gsignal.h"
+#include "gtype-private.h"
#include "gbsearcharray.h"
#include "gvaluecollector.h"
#include "gvaluetypes.h"
-#include "gboxed.h"
#include "gobject.h"
#include "genums.h"
-#include "gobjectalias.h"
+#include "gobject_trace.h"
/**
}
void
-g_signal_init (void)
+_g_signal_init (void)
{
SIGNAL_LOCK ();
if (!g_n_signal_nodes)
* g_signal_parse_name:
* @detailed_signal: a string of the form "signal-name::detail".
* @itype: The interface/instance type that introduced "signal-name".
- * @signal_id_p: Location to store the signal id.
- * @detail_p: Location to store the detail quark.
+ * @signal_id_p: (out): Location to store the signal id.
+ * @detail_p: (out): Location to store the detail quark.
* @force_detail_quark: %TRUE forces creation of a #GQuark for the detail.
*
* Internal function to parse a signal name into its @signal_id
* created. Further information about the signals can be acquired through
* g_signal_query().
*
- * Returns: Newly allocated array of signal IDs.
+ * Returns: (array length=n_ids): Newly allocated array of signal IDs.
*/
guint*
g_signal_list_ids (GType itype,
*
* Returns: the signal name, or %NULL if the signal number was invalid.
*/
-G_CONST_RETURN gchar*
+const gchar *
g_signal_name (guint signal_id)
{
SignalNode *node;
/**
* g_signal_query:
* @signal_id: The signal id of the signal to query information for.
- * @query: A user provided structure that is filled in with constant
- * values upon success.
+ * @query: (out caller-allocates): A user provided structure that is
+ * filled in with constant values upon success.
*
* Queries the signal system for in-depth information about a
* specific signal. This function will fill in a user-provided
* not associate a class method slot with this signal.
* @accumulator: the accumulator for this signal; may be %NULL.
* @accu_data: user data for the @accumulator.
- * @c_marshaller: the function to translate arrays of parameter values to
- * signal emissions into C language callback invocations.
+ * @c_marshaller: (allow-none): the function to translate arrays of parameter
+ * values to signal emissions into C language callback invocations or %NULL.
* @return_type: the type of return value, or #G_TYPE_NONE for a signal
* without a return value.
* @n_params: the number of parameter types to follow.
* <code>super_class->signal_handler = my_signal_handler</code>. Instead they
* will have to use g_signal_override_class_handler().
*
+ * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as
+ * the marshaller for this signal.
+ *
* Returns: the signal id
*/
guint
/* optimize NOP emissions with NULL class handlers */
if (signal_id && G_TYPE_IS_INSTANTIATABLE (itype) && return_type == G_TYPE_NONE &&
- class_offset && class_offset < MAX_TEST_CLASS_OFFSET)
+ class_offset && class_offset < MAX_TEST_CLASS_OFFSET &&
+ ~signal_flags & G_SIGNAL_MUST_COLLECT)
{
SignalNode *node;
* not associate a class method with this signal.
* @accumulator: the accumulator for this signal; may be %NULL.
* @accu_data: user data for the @accumulator.
- * @c_marshaller: the function to translate arrays of parameter values to
- * signal emissions into C language callback invocations.
+ * @c_marshaller: (allow-none): the function to translate arrays of parameter
+ * values to signal emissions into C language callback invocations or %NULL.
* @return_type: the type of return value, or #G_TYPE_NONE for a signal
* without a return value.
* @n_params: the number of parameter types to follow.
*
* See g_signal_new() for information about signal names.
*
+ * If c_marshaller is %NULL @g_cclosure_marshal_generic will be used as
+ * the marshaller for this signal.
+ *
* Returns: the signal id
*
* Since: 2.18
* @signal_flags: a combination of #GSignalFlags specifying detail of when
* the default handler is to be invoked. You should at least specify
* %G_SIGNAL_RUN_FIRST or %G_SIGNAL_RUN_LAST
- * @class_closure: The closure to invoke on signal emission; may be %NULL
- * @accumulator: the accumulator for this signal; may be %NULL
+ * @class_closure: (allow-none): The closure to invoke on signal emission;
+ * may be %NULL
+ * @accumulator: (allow-none): the accumulator for this signal; may be %NULL
* @accu_data: user data for the @accumulator
- * @c_marshaller: the function to translate arrays of parameter values to
- * signal emissions into C language callback invocations
+ * @c_marshaller: (allow-none): the function to translate arrays of
+ * parameter values to signal emissions into C language callback
+ * invocations or %NULL
* @return_type: the type of return value, or #G_TYPE_NONE for a signal
* without a return value
* @n_params: the length of @param_types
- * @param_types: an array of types, one for each parameter
+ * @param_types: (array length=n_params): an array of types, one for
+ * each parameter
*
* Creates a new signal. (This is usually done in the class initializer.)
*
* See g_signal_new() for details on allowed signal names.
*
+ * If c_marshaller is %NULL @g_cclosure_marshal_generic will be used as
+ * the marshaller for this signal.
+ *
* Returns: the signal id
*/
guint
node->name = g_intern_string (name);
key.quark = g_quark_from_string (name);
g_signal_key_bsa = g_bsearch_array_insert (g_signal_key_bsa, &g_signal_key_bconfig, &key);
+
+ TRACE(GOBJECT_SIGNAL_NEW(signal_id, name, itype));
}
node->destroyed = FALSE;
node->test_class_offset = 0;
}
else
node->accumulator = NULL;
+ if (c_marshaller == NULL)
+ c_marshaller = g_cclosure_marshal_generic;
node->c_marshaller = c_marshaller;
node->emission_hooks = NULL;
if (class_closure)
signal_add_class_closure (node, 0, class_closure);
- else if (G_TYPE_IS_INSTANTIATABLE (itype) && return_type == G_TYPE_NONE)
+ else if (G_TYPE_IS_INSTANTIATABLE (itype) &&
+ return_type == G_TYPE_NONE &&
+ ~signal_flags & G_SIGNAL_MUST_COLLECT)
{
/* optimize NOP emissions */
node->test_class_offset = TEST_CLASS_MAGIC;
* @class_closure: The closure to invoke on signal emission; may be %NULL.
* @accumulator: the accumulator for this signal; may be %NULL.
* @accu_data: user data for the @accumulator.
- * @c_marshaller: the function to translate arrays of parameter values to
- * signal emissions into C language callback invocations.
+ * @c_marshaller: (allow-none): the function to translate arrays of parameter
+ * values to signal emissions into C language callback invocations or %NULL.
* @return_type: the type of return value, or #G_TYPE_NONE for a signal
* without a return value.
* @n_params: the number of parameter types in @args.
*
* See g_signal_new() for details on allowed signal names.
*
+ * If c_marshaller is %NULL, g_cclosure_marshal_generic() will be used as
+ * the marshaller for this signal.
+ *
* Returns: the signal id
*/
guint
/**
* g_signal_chain_from_overridden:
- * @instance_and_params: the argument list of the signal emission. The first
- * element in the array is a #GValue for the instance the signal is being
- * emitted on. The rest are any arguments to be passed to the signal.
+ * @instance_and_params: (array) the argument list of the signal emission.
+ * The first element in the array is a #GValue for the instance the signal
+ * is being emitted on. The rest are any arguments to be passed to the signal.
* @return_value: Location for the return value.
*
* Calls the original class closure of a signal. This function should only
g_free (error);
/* we purposely leak the value here, it might not be
- * in a sane state if an error condition occured
+ * in a sane state if an error condition occurred
*/
}
}
*
* Returns the invocation hint of the innermost signal emission of instance.
*
- * Returns: the invocation hint of the innermost signal emission.
+ * Returns: (transfer none): the invocation hint of the innermost signal emission.
*/
GSignalInvocationHint*
g_signal_get_invocation_hint (gpointer instance)
* and/or @data the handler has to match.
* @signal_id: Signal the handler has to be connected to.
* @detail: Signal detail the handler has to be connected to.
- * @closure: The closure the handler will invoke.
+ * @closure: (allow-none): The closure the handler will invoke.
* @func: The C closure callback of the handler (useless for non-C closures).
* @data: The closure data of the handler's closure.
*
* and/or @data the handlers have to match.
* @signal_id: Signal the handlers have to be connected to.
* @detail: Signal detail the handlers have to be connected to.
- * @closure: The closure the handlers will invoke.
+ * @closure: (allow-none): The closure the handlers will invoke.
* @func: The C closure callback of the handlers (useless for non-C closures).
* @data: The closure data of the handlers' closures.
*
* and/or @data the handlers have to match.
* @signal_id: Signal the handlers have to be connected to.
* @detail: Signal detail the handlers have to be connected to.
- * @closure: The closure the handlers will invoke.
+ * @closure: (allow-none): The closure the handlers will invoke.
* @func: The C closure callback of the handlers (useless for non-C closures).
* @data: The closure data of the handlers' closures.
*
* and/or @data the handlers have to match.
* @signal_id: Signal the handlers have to be connected to.
* @detail: Signal detail the handlers have to be connected to.
- * @closure: The closure the handlers will invoke.
+ * @closure: (allow-none): The closure the handlers will invoke.
* @func: The C closure callback of the handlers (useless for non-C closures).
* @data: The closure data of the handlers' closures.
*
/**
* g_signal_emitv:
- * @instance_and_params: argument list for the signal emission. The first
- * element in the array is a #GValue for the instance the signal is
- * being emitted on. The rest are any arguments to be passed to the
- * signal.
+ * @instance_and_params: (array): argument list for the signal emission.
+ * The first element in the array is a #GValue for the instance the signal
+ * is being emitted on. The rest are any arguments to be passed to the signal.
* @signal_id: the signal id
* @detail: the detail
* @return_value: Location to store the return value of the signal emission.
GValue *param_values;
SignalNode *node;
guint i, n_params;
-
+
g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
g_return_if_fail (signal_id > 0);
SIGNAL_LOCK ();
}
SIGNAL_UNLOCK ();
+
instance_and_params->g_type = 0;
g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (instance));
g_value_set_instance (instance_and_params, instance);
g_free (error);
/* we purposely leak the value here, it might not be
- * in a sane state if an error condition occured
+ * in a sane state if an error condition occurred
*/
}
}
G_BREAKPOINT ();
}
#endif /* G_ENABLE_DEBUG */
-
+
+ TRACE(GOBJECT_SIGNAL_EMIT(node->signal_id, detail, instance, G_TYPE_FROM_INSTANCE (instance)));
+
SIGNAL_LOCK ();
signal_id = node->signal_id;
if (node->flags & G_SIGNAL_NO_RECURSE)
SIGNAL_UNLOCK ();
if (accumulator)
g_value_unset (&accu);
-
+
+ TRACE(GOBJECT_SIGNAL_EMIT_END(node->signal_id, detail, instance, G_TYPE_FROM_INSTANCE (instance)));
+
return return_value_altered;
}
* boolean values. The behavior that this accumulator gives is
* that a return of %TRUE stops the signal emission: no further
* callbacks will be invoked, while a return of %FALSE allows
- * the emission to coninue. The idea here is that a %TRUE return
+ * the emission to continue. The idea here is that a %TRUE return
* indicates that the callback <emphasis>handled</emphasis> the signal,
* and no further handling is needed.
*
return continue_emission;
}
-/* --- compile standard marshallers --- */
-#include "gmarshal.c"
-
-#define __G_SIGNAL_C__
-#include "gobjectaliasdef.c"
+/**
+ * g_signal_accumulator_first_wins:
+ * @ihint: standard #GSignalAccumulator parameter
+ * @return_accu: standard #GSignalAccumulator parameter
+ * @handler_return: standard #GSignalAccumulator parameter
+ * @dummy: standard #GSignalAccumulator parameter
+ *
+ * A predefined #GSignalAccumulator for signals intended to be used as a
+ * hook for application code to provide a particular value. Usually
+ * only one such value is desired and multiple handlers for the same
+ * signal don't make much sense (except for the case of the default
+ * handler defined in the class structure, in which case you will
+ * usually want the signal connection to override the class handler).
+ *
+ * This accumulator will use the return value from the first signal
+ * handler that is run as the return value for the signal and not run
+ * any further handlers (ie: the first handler "wins").
+ *
+ * Returns: standard #GSignalAccumulator result
+ *
+ * Since: 2.28
+ **/
+gboolean
+g_signal_accumulator_first_wins (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ g_value_copy (handler_return, return_accu);
+ return FALSE;
+}