+void
+g_signal_override_class_closure (guint signal_id,
+ GType instance_type,
+ GClosure *class_closure)
+{
+ SignalNode *node;
+
+ g_return_if_fail (signal_id > 0);
+ g_return_if_fail (class_closure != NULL);
+
+ SIGNAL_LOCK ();
+ node = LOOKUP_SIGNAL_NODE (signal_id);
+ if (!g_type_is_a (instance_type, node->itype))
+ g_warning ("%s: type `%s' cannot be overridden for signal id `%u'", G_STRLOC, type_debug_name (instance_type), signal_id);
+ else
+ {
+ ClassClosure *cc = signal_find_class_closure (node, instance_type);
+
+ if (cc && cc->instance_type == instance_type)
+ g_warning ("%s: type `%s' is already overridden for signal id `%u'", G_STRLOC, type_debug_name (instance_type), signal_id);
+ else
+ signal_add_class_closure (node, instance_type, class_closure);
+ }
+ SIGNAL_UNLOCK ();
+}
+
+void
+g_signal_chain_from_overridden (const GValue *instance_and_params,
+ GValue *return_value)
+{
+ GType chain_type = 0, restore_type = 0;
+ Emission *emission = NULL;
+ GClosure *closure = NULL;
+ guint n_params = 0;
+ gpointer instance;
+
+ g_return_if_fail (instance_and_params != NULL);
+ instance = g_value_peek_pointer (instance_and_params);
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE (instance));
+
+ SIGNAL_LOCK ();
+ emission = emission_find_innermost (instance);
+ if (emission)
+ {
+ SignalNode *node = LOOKUP_SIGNAL_NODE (emission->ihint.signal_id);
+
+ g_assert (node != NULL); /* paranoid */
+
+ /* we should probably do the same parameter checks as g_signal_emit() here.
+ */
+ if (emission->chain_type != G_TYPE_NONE)
+ {
+ ClassClosure *cc = signal_find_class_closure (node, emission->chain_type);
+
+ g_assert (cc != NULL); /* closure currently in call stack */
+
+ n_params = node->n_params;
+ restore_type = cc->instance_type;
+ cc = signal_find_class_closure (node, g_type_parent (cc->instance_type));
+ if (cc && cc->instance_type != restore_type)
+ {
+ closure = cc->closure;
+ chain_type = cc->instance_type;
+ }
+ }
+ else
+ g_warning ("%s: signal id `%u' cannot be chained from current emission stage for instance `%p'", G_STRLOC, node->signal_id, instance);
+ }
+ else
+ g_warning ("%s: no signal is currently being emitted for instance `%p'", G_STRLOC, instance);
+ if (closure)
+ {
+ emission->chain_type = chain_type;
+ SIGNAL_UNLOCK ();
+ g_closure_invoke (closure,
+ return_value,
+ n_params + 1,
+ instance_and_params,
+ &emission->ihint);
+ SIGNAL_LOCK ();
+ emission->chain_type = restore_type;
+ }
+ SIGNAL_UNLOCK ();
+}
+
+GSignalInvocationHint*
+g_signal_get_invocation_hint (gpointer instance)
+{
+ Emission *emission = NULL;
+
+ g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), NULL);
+
+ SIGNAL_LOCK ();
+ emission = emission_find_innermost (instance);
+ SIGNAL_UNLOCK ();
+
+ return emission ? &emission->ihint : NULL;
+}
+