1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2000-2001 Red Hat, Inc.
3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * MT safe with regards to reference counting.
36 #include "gvaluetypes.h"
37 #include "gtype-private.h"
42 * @short_description: Functions as first-class objects
45 * A #GClosure represents a callback supplied by the programmer. It
46 * will generally comprise a function of some kind and a marshaller
47 * used to call it. It is the reponsibility of the marshaller to
48 * convert the arguments for the invocation from #GValue<!-- -->s into
49 * a suitable form, perform the callback on the converted arguments,
50 * and transform the return value back into a #GValue.
52 * In the case of C programs, a closure usually just holds a pointer
53 * to a function and maybe a data argument, and the marshaller
54 * converts between #GValue<!-- --> and native C types. The GObject
55 * library provides the #GCClosure type for this purpose. Bindings for
56 * other languages need marshallers which convert between #GValue<!--
57 * -->s and suitable representations in the runtime of the language in
58 * order to use functions written in that languages as callbacks.
60 * Within GObject, closures play an important role in the
61 * implementation of signals. When a signal is registered, the
62 * @c_marshaller argument to g_signal_new() specifies the default C
63 * marshaller for any closure which is connected to this
64 * signal. GObject provides a number of C marshallers for this
65 * purpose, see the g_cclosure_marshal_*() functions. Additional C
66 * marshallers can be generated with the <link
67 * linkend="glib-genmarshal">glib-genmarshal</link> utility. Closures
68 * can be explicitly connected to signals with
69 * g_signal_connect_closure(), but it usually more convenient to let
70 * GObject create a closure automatically by using one of the
71 * g_signal_connect_*() functions which take a callback function/user
74 * Using closures has a number of important advantages over a simple
75 * callback function/data pointer combination:
78 * Closures allow the callee to get the types of the callback parameters,
79 * which means that language bindings don't have to write individual glue
80 * for each callback type.
83 * The reference counting of #GClosure makes it easy to handle reentrancy
84 * right; if a callback is removed while it is being invoked, the closure
85 * and its parameters won't be freed until the invocation finishes.
88 * g_closure_invalidate() and invalidation notifiers allow callbacks to be
89 * automatically removed when the objects they point to go away.
94 #define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
95 #define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
96 #define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
97 #define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
98 #define CLOSURE_N_MFUNCS(cl) (((cl)->n_guards << 1L))
99 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
100 #define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
101 (cl)->n_fnotifiers + \
109 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
111 ClosureInt *cunion = (ClosureInt*) _closure; \
112 gint new_int, old_int, success; \
116 tmp.vint = old_int = cunion->vint; \
117 _SET_OLD tmp.closure._field; \
118 tmp.closure._field _OP _value; \
119 _SET_NEW tmp.closure._field; \
120 new_int = tmp.vint; \
121 success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int); \
123 while (!success && _must_set); \
126 #define SWAP(_closure, _field, _value, _oldv) CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =, (void) )
127 #define SET(_closure, _field, _value) CHANGE_FIELD (_closure, _field, =, _value, TRUE, (void), (void) )
128 #define INC(_closure, _field) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), (void) )
129 #define INC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), *(_newv) = )
130 #define DEC(_closure, _field) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), (void) )
131 #define DEC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), *(_newv) = )
133 #if 0 /* for non-thread-safe closures */
134 #define SWAP(cl,f,v,o) (void) (*(o) = cl->f, cl->f = v)
135 #define SET(cl,f,v) (void) (cl->f = v)
136 #define INC(cl,f) (void) (cl->f += 1)
137 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
138 #define DEC(cl,f) (void) (cl->f -= 1)
139 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
150 /* --- functions --- */
152 * g_closure_new_simple:
153 * @sizeof_closure: the size of the structure to allocate, must be at least
154 * <literal>sizeof (GClosure)</literal>
155 * @data: data to store in the @data field of the newly allocated #GClosure
157 * Allocates a struct of the given size and initializes the initial
158 * part as a #GClosure. This function is mainly useful when
159 * implementing new types of closures.
162 * typedef struct _MyClosure MyClosure;
166 * // extra data goes here
170 * my_closure_finalize (gpointer notify_data,
173 * MyClosure *my_closure = (MyClosure *)closure;
175 * // free extra data here
178 * MyClosure *my_closure_new (gpointer data)
181 * MyClosure *my_closure;
183 * closure = g_closure_new_simple (sizeof (MyClosure), data);
184 * my_closure = (MyClosure *) closure;
186 * // initialize extra data here
188 * g_closure_add_finalize_notifier (closure, notify_data,
189 * my_closure_finalize);
194 * Returns: (transfer full): a newly allocated #GClosure
197 g_closure_new_simple (guint sizeof_closure,
200 GRealClosure *real_closure;
203 g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
204 sizeof_closure = sizeof_closure + sizeof (GRealClosure) - sizeof (GClosure);
206 real_closure = g_malloc0 (sizeof_closure);
207 closure = &real_closure->closure;
208 SET (closure, ref_count, 1);
209 SET (closure, floating, TRUE);
210 closure->data = data;
216 closure_invoke_notifiers (GClosure *closure,
220 * n_guards n_guards n_fnotif. n_inotifiers
221 * ->[[pre_guards][post_guards][fnotifiers][inotifiers]]
223 * CLOSURE_N_MFUNCS(cl) = n_guards + n_guards;
224 * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
226 * constrains/catches:
227 * - closure->notifiers may be reloacted during callback
228 * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
229 * - i.e. callbacks can be removed/added during invocation
230 * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
231 * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
232 * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
233 * + none of the callbacks can cause recursion
234 * + closure->n_inotifiers is const 0 during FNOTIFY
238 GClosureNotifyData *ndata;
241 while (closure->n_fnotifiers)
244 DEC_ASSIGN (closure, n_fnotifiers, &n);
246 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
247 closure->marshal = (GClosureMarshal) ndata->notify;
248 closure->data = ndata->data;
249 ndata->notify (ndata->data, closure);
251 closure->marshal = NULL;
252 closure->data = NULL;
255 SET (closure, in_inotify, TRUE);
256 while (closure->n_inotifiers)
259 DEC_ASSIGN (closure, n_inotifiers, &n);
261 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
262 closure->marshal = (GClosureMarshal) ndata->notify;
263 closure->data = ndata->data;
264 ndata->notify (ndata->data, closure);
266 closure->marshal = NULL;
267 closure->data = NULL;
268 SET (closure, in_inotify, FALSE);
271 i = closure->n_guards;
275 ndata = closure->notifiers + offs + i;
276 ndata->notify (ndata->data, closure);
280 i = closure->n_guards;
284 ndata = closure->notifiers + offs + i;
285 ndata->notify (ndata->data, closure);
292 g_closure_set_meta_va_marshal (GClosure *closure,
293 GVaClosureMarshal va_meta_marshal)
295 GRealClosure *real_closure;
297 g_return_if_fail (closure != NULL);
298 g_return_if_fail (va_meta_marshal != NULL);
299 g_return_if_fail (closure->is_invalid == FALSE);
300 g_return_if_fail (closure->in_marshal == FALSE);
302 real_closure = G_REAL_CLOSURE (closure);
304 g_return_if_fail (real_closure->meta_marshal != NULL);
306 real_closure->va_meta_marshal = va_meta_marshal;
310 * g_closure_set_meta_marshal: (skip)
311 * @closure: a #GClosure
312 * @marshal_data: context-dependent data to pass to @meta_marshal
313 * @meta_marshal: a #GClosureMarshal function
315 * Sets the meta marshaller of @closure. A meta marshaller wraps
316 * @closure->marshal and modifies the way it is called in some
317 * fashion. The most common use of this facility is for C callbacks.
318 * The same marshallers (generated by <link
319 * linkend="glib-genmarshal">glib-genmarshal</link>) are used
320 * everywhere, but the way that we get the callback function
321 * differs. In most cases we want to use @closure->callback, but in
322 * other cases we want to use some different technique to retrieve the
325 * For example, class closures for signals (see
326 * g_signal_type_cclosure_new()) retrieve the callback function from a
327 * fixed offset in the class structure. The meta marshaller retrieves
328 * the right callback and passes it to the marshaller as the
329 * @marshal_data argument.
332 g_closure_set_meta_marshal (GClosure *closure,
333 gpointer marshal_data,
334 GClosureMarshal meta_marshal)
336 GRealClosure *real_closure;
338 g_return_if_fail (closure != NULL);
339 g_return_if_fail (meta_marshal != NULL);
340 g_return_if_fail (closure->is_invalid == FALSE);
341 g_return_if_fail (closure->in_marshal == FALSE);
343 real_closure = G_REAL_CLOSURE (closure);
345 g_return_if_fail (real_closure->meta_marshal == NULL);
347 real_closure->meta_marshal = meta_marshal;
348 real_closure->meta_marshal_data = marshal_data;
352 * g_closure_add_marshal_guards: (skip)
353 * @closure: a #GClosure
354 * @pre_marshal_data: data to pass to @pre_marshal_notify
355 * @pre_marshal_notify: a function to call before the closure callback
356 * @post_marshal_data: data to pass to @post_marshal_notify
357 * @post_marshal_notify: a function to call after the closure callback
359 * Adds a pair of notifiers which get invoked before and after the
360 * closure callback, respectively. This is typically used to protect
361 * the extra arguments for the duration of the callback. See
362 * g_object_watch_closure() for an example of marshal guards.
365 g_closure_add_marshal_guards (GClosure *closure,
366 gpointer pre_marshal_data,
367 GClosureNotify pre_marshal_notify,
368 gpointer post_marshal_data,
369 GClosureNotify post_marshal_notify)
373 g_return_if_fail (closure != NULL);
374 g_return_if_fail (pre_marshal_notify != NULL);
375 g_return_if_fail (post_marshal_notify != NULL);
376 g_return_if_fail (closure->is_invalid == FALSE);
377 g_return_if_fail (closure->in_marshal == FALSE);
378 g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
380 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
381 if (closure->n_inotifiers)
382 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
383 closure->n_fnotifiers +
384 closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
385 closure->n_fnotifiers + 0)];
386 if (closure->n_inotifiers > 1)
387 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
388 closure->n_fnotifiers +
389 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
390 closure->n_fnotifiers + 1)];
391 if (closure->n_fnotifiers)
392 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
393 closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
394 if (closure->n_fnotifiers > 1)
395 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
396 closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
397 if (closure->n_guards)
398 closure->notifiers[(closure->n_guards +
399 closure->n_guards + 1)] = closure->notifiers[closure->n_guards];
400 i = closure->n_guards;
401 closure->notifiers[i].data = pre_marshal_data;
402 closure->notifiers[i].notify = pre_marshal_notify;
403 closure->notifiers[i + 1].data = post_marshal_data;
404 closure->notifiers[i + 1].notify = post_marshal_notify;
405 INC (closure, n_guards);
409 * g_closure_add_finalize_notifier: (skip)
410 * @closure: a #GClosure
411 * @notify_data: data to pass to @notify_func
412 * @notify_func: the callback function to register
414 * Registers a finalization notifier which will be called when the
415 * reference count of @closure goes down to 0. Multiple finalization
416 * notifiers on a single closure are invoked in unspecified order. If
417 * a single call to g_closure_unref() results in the closure being
418 * both invalidated and finalized, then the invalidate notifiers will
419 * be run before the finalize notifiers.
422 g_closure_add_finalize_notifier (GClosure *closure,
423 gpointer notify_data,
424 GClosureNotify notify_func)
428 g_return_if_fail (closure != NULL);
429 g_return_if_fail (notify_func != NULL);
430 g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
432 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
433 if (closure->n_inotifiers)
434 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
435 closure->n_fnotifiers +
436 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
437 closure->n_fnotifiers + 0)];
438 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
439 closure->notifiers[i].data = notify_data;
440 closure->notifiers[i].notify = notify_func;
441 INC (closure, n_fnotifiers);
445 * g_closure_add_invalidate_notifier: (skip)
446 * @closure: a #GClosure
447 * @notify_data: data to pass to @notify_func
448 * @notify_func: the callback function to register
450 * Registers an invalidation notifier which will be called when the
451 * @closure is invalidated with g_closure_invalidate(). Invalidation
452 * notifiers are invoked before finalization notifiers, in an
456 g_closure_add_invalidate_notifier (GClosure *closure,
457 gpointer notify_data,
458 GClosureNotify notify_func)
462 g_return_if_fail (closure != NULL);
463 g_return_if_fail (notify_func != NULL);
464 g_return_if_fail (closure->is_invalid == FALSE);
465 g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
467 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
468 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
469 closure->notifiers[i].data = notify_data;
470 closure->notifiers[i].notify = notify_func;
471 INC (closure, n_inotifiers);
474 static inline gboolean
475 closure_try_remove_inotify (GClosure *closure,
476 gpointer notify_data,
477 GClosureNotify notify_func)
479 GClosureNotifyData *ndata, *nlast;
481 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
482 for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
483 if (ndata->notify == notify_func && ndata->data == notify_data)
485 DEC (closure, n_inotifiers);
494 static inline gboolean
495 closure_try_remove_fnotify (GClosure *closure,
496 gpointer notify_data,
497 GClosureNotify notify_func)
499 GClosureNotifyData *ndata, *nlast;
501 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
502 for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
503 if (ndata->notify == notify_func && ndata->data == notify_data)
505 DEC (closure, n_fnotifiers);
508 if (closure->n_inotifiers)
509 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
510 closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
511 closure->n_fnotifiers +
512 closure->n_inotifiers)];
520 * @closure: #GClosure to increment the reference count on
522 * Increments the reference count on a closure to force it staying
523 * alive while the caller holds a pointer to it.
525 * Returns: (transfer none): The @closure passed in, for convenience
528 g_closure_ref (GClosure *closure)
531 g_return_val_if_fail (closure != NULL, NULL);
532 g_return_val_if_fail (closure->ref_count > 0, NULL);
533 g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
535 INC_ASSIGN (closure, ref_count, &new_ref_count);
536 g_return_val_if_fail (new_ref_count > 1, NULL);
542 * g_closure_invalidate:
543 * @closure: GClosure to invalidate
545 * Sets a flag on the closure to indicate that its calling
546 * environment has become invalid, and thus causes any future
547 * invocations of g_closure_invoke() on this @closure to be
548 * ignored. Also, invalidation notifiers installed on the closure will
549 * be called at this point. Note that unless you are holding a
550 * reference to the closure yourself, the invalidation notifiers may
551 * unref the closure and cause it to be destroyed, so if you need to
552 * access the closure after calling g_closure_invalidate(), make sure
553 * that you've previously called g_closure_ref().
555 * Note that g_closure_invalidate() will also be called when the
556 * reference count of a closure drops to zero (unless it has already
557 * been invalidated before).
560 g_closure_invalidate (GClosure *closure)
562 g_return_if_fail (closure != NULL);
564 if (!closure->is_invalid)
566 gboolean was_invalid;
567 g_closure_ref (closure); /* preserve floating flag */
568 SWAP (closure, is_invalid, TRUE, &was_invalid);
569 /* invalidate only once */
571 closure_invoke_notifiers (closure, INOTIFY);
572 g_closure_unref (closure);
578 * @closure: #GClosure to decrement the reference count on
580 * Decrements the reference count of a closure after it was previously
581 * incremented by the same caller. If no other callers are using the
582 * closure, then the closure will be destroyed and freed.
585 g_closure_unref (GClosure *closure)
589 g_return_if_fail (closure != NULL);
590 g_return_if_fail (closure->ref_count > 0);
592 if (closure->ref_count == 1) /* last unref, invalidate first */
593 g_closure_invalidate (closure);
595 DEC_ASSIGN (closure, ref_count, &new_ref_count);
597 if (new_ref_count == 0)
599 closure_invoke_notifiers (closure, FNOTIFY);
600 g_free (closure->notifiers);
601 g_free (G_REAL_CLOSURE (closure));
607 * @closure: #GClosure to decrement the initial reference count on, if it's
610 * Takes over the initial ownership of a closure. Each closure is
611 * initially created in a <firstterm>floating</firstterm> state, which
612 * means that the initial reference count is not owned by any caller.
613 * g_closure_sink() checks to see if the object is still floating, and
614 * if so, unsets the floating state and decreases the reference
615 * count. If the closure is not floating, g_closure_sink() does
616 * nothing. The reason for the existence of the floating state is to
617 * prevent cumbersome code sequences like:
619 * closure = g_cclosure_new (cb_func, cb_data);
620 * g_source_set_closure (source, closure);
621 * g_closure_unref (closure); // XXX GObject doesn't really need this
623 * Because g_source_set_closure() (and similar functions) take ownership of the
624 * initial reference count, if it is unowned, we instead can write:
626 * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
629 * Generally, this function is used together with g_closure_ref(). Ane example
630 * of storing a closure for later notification looks like:
632 * static GClosure *notify_closure = NULL;
634 * foo_notify_set_closure (GClosure *closure)
636 * if (notify_closure)
637 * g_closure_unref (notify_closure);
638 * notify_closure = closure;
639 * if (notify_closure)
641 * g_closure_ref (notify_closure);
642 * g_closure_sink (notify_closure);
647 * Because g_closure_sink() may decrement the reference count of a closure
648 * (if it hasn't been called on @closure yet) just like g_closure_unref(),
649 * g_closure_ref() should be called prior to this function.
652 g_closure_sink (GClosure *closure)
654 g_return_if_fail (closure != NULL);
655 g_return_if_fail (closure->ref_count > 0);
657 /* floating is basically a kludge to avoid creating closures
658 * with a ref_count of 0. so the initial ref_count a closure has
659 * is unowned. with invoking g_closure_sink() code may
660 * indicate that it takes over that intiial ref_count.
662 if (closure->floating)
664 gboolean was_floating;
665 SWAP (closure, floating, FALSE, &was_floating);
666 /* unref floating flag only once */
668 g_closure_unref (closure);
673 * g_closure_remove_invalidate_notifier: (skip)
674 * @closure: a #GClosure
675 * @notify_data: data which was passed to g_closure_add_invalidate_notifier()
676 * when registering @notify_func
677 * @notify_func: the callback function to remove
679 * Removes an invalidation notifier.
681 * Notice that notifiers are automatically removed after they are run.
684 g_closure_remove_invalidate_notifier (GClosure *closure,
685 gpointer notify_data,
686 GClosureNotify notify_func)
688 g_return_if_fail (closure != NULL);
689 g_return_if_fail (notify_func != NULL);
691 if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while it's called */
692 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
693 closure->data == notify_data)
694 closure->marshal = NULL;
695 else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
696 g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
697 notify_func, notify_data);
701 * g_closure_remove_finalize_notifier: (skip)
702 * @closure: a #GClosure
703 * @notify_data: data which was passed to g_closure_add_finalize_notifier()
704 * when registering @notify_func
705 * @notify_func: the callback function to remove
707 * Removes a finalization notifier.
709 * Notice that notifiers are automatically removed after they are run.
712 g_closure_remove_finalize_notifier (GClosure *closure,
713 gpointer notify_data,
714 GClosureNotify notify_func)
716 g_return_if_fail (closure != NULL);
717 g_return_if_fail (notify_func != NULL);
719 if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while it's called */
720 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
721 closure->data == notify_data)
722 closure->marshal = NULL;
723 else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
724 g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
725 notify_func, notify_data);
730 * @closure: a #GClosure
731 * @return_value: (allow-none): a #GValue to store the return
732 * value. May be %NULL if the callback of @closure
733 * doesn't return a value.
734 * @n_param_values: the length of the @param_values array
735 * @param_values: (array length=n_param_values): an array of
736 * #GValue<!-- -->s holding the arguments on which to
737 * invoke the callback of @closure
738 * @invocation_hint: (allow-none): a context-dependent invocation hint
740 * Invokes the closure, i.e. executes the callback represented by the @closure.
743 g_closure_invoke (GClosure *closure,
744 GValue /*out*/ *return_value,
745 guint n_param_values,
746 const GValue *param_values,
747 gpointer invocation_hint)
749 GRealClosure *real_closure;
751 g_return_if_fail (closure != NULL);
753 real_closure = G_REAL_CLOSURE (closure);
755 g_closure_ref (closure); /* preserve floating flag */
756 if (!closure->is_invalid)
758 GClosureMarshal marshal;
759 gpointer marshal_data;
760 gboolean in_marshal = closure->in_marshal;
762 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
764 SET (closure, in_marshal, TRUE);
765 if (real_closure->meta_marshal)
767 marshal_data = real_closure->meta_marshal_data;
768 marshal = real_closure->meta_marshal;
773 marshal = closure->marshal;
776 closure_invoke_notifiers (closure, PRE_NOTIFY);
779 n_param_values, param_values,
783 closure_invoke_notifiers (closure, POST_NOTIFY);
784 SET (closure, in_marshal, in_marshal);
786 g_closure_unref (closure);
790 _g_closure_supports_invoke_va (GClosure *closure)
792 GRealClosure *real_closure;
794 g_return_val_if_fail (closure != NULL, FALSE);
796 real_closure = G_REAL_CLOSURE (closure);
799 real_closure->va_marshal != NULL &&
800 (real_closure->meta_marshal == NULL ||
801 real_closure->va_meta_marshal != NULL);
805 _g_closure_invoke_va (GClosure *closure,
806 GValue /*out*/ *return_value,
812 GRealClosure *real_closure;
814 g_return_if_fail (closure != NULL);
816 real_closure = G_REAL_CLOSURE (closure);
818 g_closure_ref (closure); /* preserve floating flag */
819 if (!closure->is_invalid)
821 GVaClosureMarshal marshal;
822 gpointer marshal_data;
823 gboolean in_marshal = closure->in_marshal;
825 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
827 SET (closure, in_marshal, TRUE);
828 if (real_closure->va_meta_marshal)
830 marshal_data = real_closure->meta_marshal_data;
831 marshal = real_closure->va_meta_marshal;
836 marshal = real_closure->va_marshal;
839 closure_invoke_notifiers (closure, PRE_NOTIFY);
844 n_params, param_types);
846 closure_invoke_notifiers (closure, POST_NOTIFY);
847 SET (closure, in_marshal, in_marshal);
849 g_closure_unref (closure);
854 * g_closure_set_marshal: (skip)
855 * @closure: a #GClosure
856 * @marshal: a #GClosureMarshal function
858 * Sets the marshaller of @closure. The <literal>marshal_data</literal>
859 * of @marshal provides a way for a meta marshaller to provide additional
860 * information to the marshaller. (See g_closure_set_meta_marshal().) For
861 * GObject's C predefined marshallers (the g_cclosure_marshal_*()
862 * functions), what it provides is a callback function to use instead of
863 * @closure->callback.
866 g_closure_set_marshal (GClosure *closure,
867 GClosureMarshal marshal)
869 g_return_if_fail (closure != NULL);
870 g_return_if_fail (marshal != NULL);
872 if (closure->marshal && closure->marshal != marshal)
873 g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
874 closure->marshal, marshal);
876 closure->marshal = marshal;
880 _g_closure_set_va_marshal (GClosure *closure,
881 GVaClosureMarshal marshal)
883 GRealClosure *real_closure;
885 g_return_if_fail (closure != NULL);
886 g_return_if_fail (marshal != NULL);
888 real_closure = G_REAL_CLOSURE (closure);
890 if (real_closure->va_marshal && real_closure->va_marshal != marshal)
891 g_warning ("attempt to override closure->va_marshal (%p) with new marshal (%p)",
892 real_closure->va_marshal, marshal);
894 real_closure->va_marshal = marshal;
898 * g_cclosure_new: (skip)
899 * @callback_func: the function to invoke
900 * @user_data: user data to pass to @callback_func
901 * @destroy_data: destroy notify to be called when @user_data is no longer used
903 * Creates a new closure which invokes @callback_func with @user_data as
904 * the last parameter.
906 * Returns: a new #GCClosure
909 g_cclosure_new (GCallback callback_func,
911 GClosureNotify destroy_data)
915 g_return_val_if_fail (callback_func != NULL, NULL);
917 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
919 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
920 ((GCClosure*) closure)->callback = (gpointer) callback_func;
926 * g_cclosure_new_swap: (skip)
927 * @callback_func: the function to invoke
928 * @user_data: user data to pass to @callback_func
929 * @destroy_data: destroy notify to be called when @user_data is no longer used
931 * Creates a new closure which invokes @callback_func with @user_data as
932 * the first parameter.
934 * Returns: (transfer full): a new #GCClosure
937 g_cclosure_new_swap (GCallback callback_func,
939 GClosureNotify destroy_data)
943 g_return_val_if_fail (callback_func != NULL, NULL);
945 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
947 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
948 ((GCClosure*) closure)->callback = (gpointer) callback_func;
949 SET (closure, derivative_flag, TRUE);
955 g_type_class_meta_marshal (GClosure *closure,
956 GValue /*out*/ *return_value,
957 guint n_param_values,
958 const GValue *param_values,
959 gpointer invocation_hint,
960 gpointer marshal_data)
964 /* GType itype = (GType) closure->data; */
965 guint offset = GPOINTER_TO_UINT (marshal_data);
967 class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
968 callback = G_STRUCT_MEMBER (gpointer, class, offset);
970 closure->marshal (closure,
972 n_param_values, param_values,
978 g_type_class_meta_marshalv (GClosure *closure,
979 GValue *return_value,
982 gpointer marshal_data,
986 GRealClosure *real_closure;
989 /* GType itype = (GType) closure->data; */
990 guint offset = GPOINTER_TO_UINT (marshal_data);
992 real_closure = G_REAL_CLOSURE (closure);
994 class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
995 callback = G_STRUCT_MEMBER (gpointer, class, offset);
997 real_closure->va_marshal (closure,
1006 g_type_iface_meta_marshal (GClosure *closure,
1007 GValue /*out*/ *return_value,
1008 guint n_param_values,
1009 const GValue *param_values,
1010 gpointer invocation_hint,
1011 gpointer marshal_data)
1015 GType itype = (GType) closure->data;
1016 guint offset = GPOINTER_TO_UINT (marshal_data);
1018 class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
1019 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1021 closure->marshal (closure,
1023 n_param_values, param_values,
1029 g_type_iface_meta_marshalv (GClosure *closure,
1030 GValue *return_value,
1033 gpointer marshal_data,
1037 GRealClosure *real_closure;
1040 GType itype = (GType) closure->data;
1041 guint offset = GPOINTER_TO_UINT (marshal_data);
1043 real_closure = G_REAL_CLOSURE (closure);
1045 class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
1046 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1048 real_closure->va_marshal (closure,
1057 * g_signal_type_cclosure_new:
1058 * @itype: the #GType identifier of an interface or classed type
1059 * @struct_offset: the offset of the member function of @itype's class
1060 * structure which is to be invoked by the new closure
1062 * Creates a new closure which invokes the function found at the offset
1063 * @struct_offset in the class structure of the interface or classed type
1064 * identified by @itype.
1066 * Returns: a new #GCClosure
1069 g_signal_type_cclosure_new (GType itype,
1070 guint struct_offset)
1074 g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
1075 g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
1077 closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
1078 if (G_TYPE_IS_INTERFACE (itype))
1080 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
1081 g_closure_set_meta_va_marshal (closure, g_type_iface_meta_marshalv);
1085 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
1086 g_closure_set_meta_va_marshal (closure, g_type_class_meta_marshalv);
1093 value_to_ffi_type (const GValue *gvalue,
1096 gboolean *tmpval_used)
1098 ffi_type *rettype = NULL;
1099 GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
1100 g_assert (type != G_TYPE_INVALID);
1104 g_assert (tmpval_used != NULL);
1105 *tmpval_used = FALSE;
1110 case G_TYPE_BOOLEAN:
1113 rettype = &ffi_type_sint;
1114 *value = (gpointer)&(gvalue->data[0].v_int);
1117 /* enums are stored in v_long even though they are integers, which makes
1118 * marshalling through libffi somewhat complicated. They need to be
1119 * marshalled as signed ints, but we need to use a temporary int sized
1120 * value to pass to libffi otherwise it'll pull the wrong value on
1121 * BE machines with 32-bit integers when treating v_long as 32-bit int.
1123 g_assert (enum_tmpval != NULL);
1124 rettype = &ffi_type_sint;
1125 *enum_tmpval = g_value_get_enum (gvalue);
1126 *value = enum_tmpval;
1127 *tmpval_used = TRUE;
1132 rettype = &ffi_type_uint;
1133 *value = (gpointer)&(gvalue->data[0].v_uint);
1139 case G_TYPE_POINTER:
1140 case G_TYPE_INTERFACE:
1141 case G_TYPE_VARIANT:
1142 rettype = &ffi_type_pointer;
1143 *value = (gpointer)&(gvalue->data[0].v_pointer);
1146 rettype = &ffi_type_float;
1147 *value = (gpointer)&(gvalue->data[0].v_float);
1150 rettype = &ffi_type_double;
1151 *value = (gpointer)&(gvalue->data[0].v_double);
1154 rettype = &ffi_type_slong;
1155 *value = (gpointer)&(gvalue->data[0].v_long);
1158 rettype = &ffi_type_ulong;
1159 *value = (gpointer)&(gvalue->data[0].v_ulong);
1162 rettype = &ffi_type_sint64;
1163 *value = (gpointer)&(gvalue->data[0].v_int64);
1166 rettype = &ffi_type_uint64;
1167 *value = (gpointer)&(gvalue->data[0].v_uint64);
1170 rettype = &ffi_type_pointer;
1172 g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1179 value_from_ffi_type (GValue *gvalue, gpointer *value)
1181 ffi_arg *int_val = (ffi_arg*) value;
1183 switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
1186 g_value_set_int (gvalue, (gint) *int_val);
1189 g_value_set_float (gvalue, *(gfloat*)value);
1192 g_value_set_double (gvalue, *(gdouble*)value);
1194 case G_TYPE_BOOLEAN:
1195 g_value_set_boolean (gvalue, (gboolean) *int_val);
1198 g_value_set_string (gvalue, *(gchar**)value);
1201 g_value_set_schar (gvalue, (gint8) *int_val);
1204 g_value_set_uchar (gvalue, (guchar) *int_val);
1207 g_value_set_uint (gvalue, (guint) *int_val);
1209 case G_TYPE_POINTER:
1210 g_value_set_pointer (gvalue, *(gpointer*)value);
1213 g_value_set_long (gvalue, (glong) *int_val);
1216 g_value_set_ulong (gvalue, (gulong) *int_val);
1219 g_value_set_int64 (gvalue, (gint64) *int_val);
1222 g_value_set_uint64 (gvalue, (guint64) *int_val);
1225 g_value_set_boxed (gvalue, *(gpointer*)value);
1228 g_value_set_enum (gvalue, (gint) *int_val);
1231 g_value_set_flags (gvalue, (guint) *int_val);
1234 g_value_set_param (gvalue, *(gpointer*)value);
1237 g_value_set_object (gvalue, *(gpointer*)value);
1240 g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
1241 g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
1258 va_to_ffi_type (GType gtype,
1260 va_arg_storage *storage)
1262 ffi_type *rettype = NULL;
1263 GType type = g_type_fundamental (gtype);
1264 g_assert (type != G_TYPE_INVALID);
1268 case G_TYPE_BOOLEAN:
1272 rettype = &ffi_type_sint;
1273 storage->_gint = va_arg (*va, gint);
1278 rettype = &ffi_type_uint;
1279 storage->_guint = va_arg (*va, guint);
1285 case G_TYPE_POINTER:
1286 case G_TYPE_INTERFACE:
1287 case G_TYPE_VARIANT:
1288 rettype = &ffi_type_pointer;
1289 storage->_gpointer = va_arg (*va, gpointer);
1292 /* Float args are passed as doubles in varargs */
1293 rettype = &ffi_type_float;
1294 storage->_float = (float)va_arg (*va, double);
1297 rettype = &ffi_type_double;
1298 storage->_double = va_arg (*va, double);
1301 rettype = &ffi_type_slong;
1302 storage->_glong = va_arg (*va, glong);
1305 rettype = &ffi_type_ulong;
1306 storage->_gulong = va_arg (*va, gulong);
1309 rettype = &ffi_type_sint64;
1310 storage->_gint64 = va_arg (*va, gint64);
1313 rettype = &ffi_type_uint64;
1314 storage->_guint64 = va_arg (*va, guint64);
1317 rettype = &ffi_type_pointer;
1318 storage->_guint64 = 0;
1319 g_warning ("va_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1326 * g_cclosure_marshal_generic:
1327 * @closure: A #GClosure.
1328 * @return_gvalue: A #GValue to store the return value. May be %NULL
1329 * if the callback of closure doesn't return a value.
1330 * @n_param_values: The length of the @param_values array.
1331 * @param_values: An array of #GValue<!-- -->s holding the arguments
1332 * on which to invoke the callback of closure.
1333 * @invocation_hint: The invocation hint given as the last argument to
1334 * g_closure_invoke().
1335 * @marshal_data: Additional data specified when registering the
1336 * marshaller, see g_closure_set_marshal() and
1337 * g_closure_set_meta_marshal()
1339 * A generic marshaller function implemented via <ulink
1340 * url="http://sourceware.org/libffi/">libffi</ulink>.
1345 g_cclosure_marshal_generic (GClosure *closure,
1346 GValue *return_gvalue,
1347 guint n_param_values,
1348 const GValue *param_values,
1349 gpointer invocation_hint,
1350 gpointer marshal_data)
1359 GCClosure *cc = (GCClosure*) closure;
1361 gboolean tmpval_used = FALSE;
1363 enum_tmpval = g_alloca (sizeof (gint));
1364 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1366 rtype = value_to_ffi_type (return_gvalue, &rvalue, enum_tmpval, &tmpval_used);
1370 rtype = &ffi_type_void;
1373 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1375 n_args = n_param_values + 1;
1376 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1377 args = g_alloca (sizeof (gpointer) * n_args);
1380 enum_tmpval = g_alloca (sizeof (gint));
1382 if (G_CCLOSURE_SWAP_DATA (closure))
1384 atypes[n_args-1] = value_to_ffi_type (param_values + 0,
1388 atypes[0] = &ffi_type_pointer;
1389 args[0] = &closure->data;
1393 atypes[0] = value_to_ffi_type (param_values + 0,
1397 atypes[n_args-1] = &ffi_type_pointer;
1398 args[n_args-1] = &closure->data;
1401 for (i = 1; i < n_args - 1; i++)
1404 enum_tmpval = g_alloca (sizeof (gint));
1406 atypes[i] = value_to_ffi_type (param_values + i,
1412 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1415 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1417 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1418 value_from_ffi_type (return_gvalue, rvalue);
1422 g_cclosure_marshal_generic_va (GClosure *closure,
1423 GValue *return_value,
1426 gpointer marshal_data,
1435 va_arg_storage *storage;
1438 GCClosure *cc = (GCClosure*) closure;
1440 gboolean tmpval_used = FALSE;
1443 enum_tmpval = g_alloca (sizeof (gint));
1444 if (return_value && G_VALUE_TYPE (return_value))
1446 rtype = value_to_ffi_type (return_value, &rvalue, enum_tmpval, &tmpval_used);
1450 rtype = &ffi_type_void;
1453 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1455 n_args = n_params + 2;
1456 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1457 args = g_alloca (sizeof (gpointer) * n_args);
1458 storage = g_alloca (sizeof (va_arg_storage) * n_params);
1461 enum_tmpval = g_alloca (sizeof (gint));
1463 if (G_CCLOSURE_SWAP_DATA (closure))
1465 atypes[n_args-1] = &ffi_type_pointer;
1466 args[n_args-1] = &instance;
1467 atypes[0] = &ffi_type_pointer;
1468 args[0] = &closure->data;
1472 atypes[0] = &ffi_type_pointer;
1473 args[0] = &instance;
1474 atypes[n_args-1] = &ffi_type_pointer;
1475 args[n_args-1] = &closure->data;
1478 va_copy (args_copy, args_list);
1480 /* Box non-primitive arguments */
1481 for (i = 0; i < n_params; i++)
1483 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1484 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1486 atypes[i+1] = va_to_ffi_type (type,
1489 args[i+1] = &storage[i];
1491 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1493 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1494 storage[i]._gpointer = g_strdup (storage[i]._gpointer);
1495 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1496 storage[i]._gpointer = g_param_spec_ref (storage[i]._gpointer);
1497 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1498 storage[i]._gpointer = g_boxed_copy (type, storage[i]._gpointer);
1499 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1500 storage[i]._gpointer = g_variant_ref_sink (storage[i]._gpointer);
1502 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1503 storage[i]._gpointer = g_object_ref (storage[i]._gpointer);
1508 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1511 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1513 /* Unbox non-primitive arguments */
1514 for (i = 0; i < n_params; i++)
1516 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1517 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1519 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1521 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1522 g_free (storage[i]._gpointer);
1523 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1524 g_param_spec_unref (storage[i]._gpointer);
1525 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1526 g_boxed_free (type, storage[i]._gpointer);
1527 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1528 g_variant_unref (storage[i]._gpointer);
1530 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1531 g_object_unref (storage[i]._gpointer);
1534 if (return_value && G_VALUE_TYPE (return_value))
1535 value_from_ffi_type (return_value, rvalue);
1539 * g_cclosure_marshal_VOID__VOID:
1540 * @closure: the #GClosure to which the marshaller belongs
1541 * @return_value: ignored
1542 * @n_param_values: 1
1543 * @param_values: a #GValue array holding only the instance
1544 * @invocation_hint: the invocation hint given as the last argument
1545 * to g_closure_invoke()
1546 * @marshal_data: additional data specified when registering the marshaller
1548 * A marshaller for a #GCClosure with a callback of type
1549 * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
1553 * g_cclosure_marshal_VOID__BOOLEAN:
1554 * @closure: the #GClosure to which the marshaller belongs
1555 * @return_value: ignored
1556 * @n_param_values: 2
1557 * @param_values: a #GValue array holding the instance and the #gboolean parameter
1558 * @invocation_hint: the invocation hint given as the last argument
1559 * to g_closure_invoke()
1560 * @marshal_data: additional data specified when registering the marshaller
1562 * A marshaller for a #GCClosure with a callback of type
1563 * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
1567 * g_cclosure_marshal_VOID__CHAR:
1568 * @closure: the #GClosure to which the marshaller belongs
1569 * @return_value: ignored
1570 * @n_param_values: 2
1571 * @param_values: a #GValue array holding the instance and the #gchar parameter
1572 * @invocation_hint: the invocation hint given as the last argument
1573 * to g_closure_invoke()
1574 * @marshal_data: additional data specified when registering the marshaller
1576 * A marshaller for a #GCClosure with a callback of type
1577 * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
1581 * g_cclosure_marshal_VOID__UCHAR:
1582 * @closure: the #GClosure to which the marshaller belongs
1583 * @return_value: ignored
1584 * @n_param_values: 2
1585 * @param_values: a #GValue array holding the instance and the #guchar parameter
1586 * @invocation_hint: the invocation hint given as the last argument
1587 * to g_closure_invoke()
1588 * @marshal_data: additional data specified when registering the marshaller
1590 * A marshaller for a #GCClosure with a callback of type
1591 * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
1595 * g_cclosure_marshal_VOID__INT:
1596 * @closure: the #GClosure to which the marshaller belongs
1597 * @return_value: ignored
1598 * @n_param_values: 2
1599 * @param_values: a #GValue array holding the instance and the #gint parameter
1600 * @invocation_hint: the invocation hint given as the last argument
1601 * to g_closure_invoke()
1602 * @marshal_data: additional data specified when registering the marshaller
1604 * A marshaller for a #GCClosure with a callback of type
1605 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
1609 * g_cclosure_marshal_VOID__UINT:
1610 * @closure: the #GClosure to which the marshaller belongs
1611 * @return_value: ignored
1612 * @n_param_values: 2
1613 * @param_values: a #GValue array holding the instance and the #guint parameter
1614 * @invocation_hint: the invocation hint given as the last argument
1615 * to g_closure_invoke()
1616 * @marshal_data: additional data specified when registering the marshaller
1618 * A marshaller for a #GCClosure with a callback of type
1619 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
1623 * g_cclosure_marshal_VOID__LONG:
1624 * @closure: the #GClosure to which the marshaller belongs
1625 * @return_value: ignored
1626 * @n_param_values: 2
1627 * @param_values: a #GValue array holding the instance and the #glong parameter
1628 * @invocation_hint: the invocation hint given as the last argument
1629 * to g_closure_invoke()
1630 * @marshal_data: additional data specified when registering the marshaller
1632 * A marshaller for a #GCClosure with a callback of type
1633 * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1637 * g_cclosure_marshal_VOID__ULONG:
1638 * @closure: the #GClosure to which the marshaller belongs
1639 * @return_value: ignored
1640 * @n_param_values: 2
1641 * @param_values: a #GValue array holding the instance and the #gulong parameter
1642 * @invocation_hint: the invocation hint given as the last argument
1643 * to g_closure_invoke()
1644 * @marshal_data: additional data specified when registering the marshaller
1646 * A marshaller for a #GCClosure with a callback of type
1647 * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1651 * g_cclosure_marshal_VOID__ENUM:
1652 * @closure: the #GClosure to which the marshaller belongs
1653 * @return_value: ignored
1654 * @n_param_values: 2
1655 * @param_values: a #GValue array holding the instance and the enumeration parameter
1656 * @invocation_hint: the invocation hint given as the last argument
1657 * to g_closure_invoke()
1658 * @marshal_data: additional data specified when registering the marshaller
1660 * A marshaller for a #GCClosure with a callback of type
1661 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1665 * g_cclosure_marshal_VOID__FLAGS:
1666 * @closure: the #GClosure to which the marshaller belongs
1667 * @return_value: ignored
1668 * @n_param_values: 2
1669 * @param_values: a #GValue array holding the instance and the flags parameter
1670 * @invocation_hint: the invocation hint given as the last argument
1671 * to g_closure_invoke()
1672 * @marshal_data: additional data specified when registering the marshaller
1674 * A marshaller for a #GCClosure with a callback of type
1675 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1679 * g_cclosure_marshal_VOID__FLOAT:
1680 * @closure: the #GClosure to which the marshaller belongs
1681 * @return_value: ignored
1682 * @n_param_values: 2
1683 * @param_values: a #GValue array holding the instance and the #gfloat parameter
1684 * @invocation_hint: the invocation hint given as the last argument
1685 * to g_closure_invoke()
1686 * @marshal_data: additional data specified when registering the marshaller
1688 * A marshaller for a #GCClosure with a callback of type
1689 * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1693 * g_cclosure_marshal_VOID__DOUBLE:
1694 * @closure: the #GClosure to which the marshaller belongs
1695 * @return_value: ignored
1696 * @n_param_values: 2
1697 * @param_values: a #GValue array holding the instance and the #gdouble parameter
1698 * @invocation_hint: the invocation hint given as the last argument
1699 * to g_closure_invoke()
1700 * @marshal_data: additional data specified when registering the marshaller
1702 * A marshaller for a #GCClosure with a callback of type
1703 * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1707 * g_cclosure_marshal_VOID__STRING:
1708 * @closure: the #GClosure to which the marshaller belongs
1709 * @return_value: ignored
1710 * @n_param_values: 2
1711 * @param_values: a #GValue array holding the instance and the #gchar* parameter
1712 * @invocation_hint: the invocation hint given as the last argument
1713 * to g_closure_invoke()
1714 * @marshal_data: additional data specified when registering the marshaller
1716 * A marshaller for a #GCClosure with a callback of type
1717 * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1721 * g_cclosure_marshal_VOID__PARAM:
1722 * @closure: the #GClosure to which the marshaller belongs
1723 * @return_value: ignored
1724 * @n_param_values: 2
1725 * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1726 * @invocation_hint: the invocation hint given as the last argument
1727 * to g_closure_invoke()
1728 * @marshal_data: additional data specified when registering the marshaller
1730 * A marshaller for a #GCClosure with a callback of type
1731 * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1735 * g_cclosure_marshal_VOID__BOXED:
1736 * @closure: the #GClosure to which the marshaller belongs
1737 * @return_value: ignored
1738 * @n_param_values: 2
1739 * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1740 * @invocation_hint: the invocation hint given as the last argument
1741 * to g_closure_invoke()
1742 * @marshal_data: additional data specified when registering the marshaller
1744 * A marshaller for a #GCClosure with a callback of type
1745 * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1749 * g_cclosure_marshal_VOID__POINTER:
1750 * @closure: the #GClosure to which the marshaller belongs
1751 * @return_value: ignored
1752 * @n_param_values: 2
1753 * @param_values: a #GValue array holding the instance and the #gpointer parameter
1754 * @invocation_hint: the invocation hint given as the last argument
1755 * to g_closure_invoke()
1756 * @marshal_data: additional data specified when registering the marshaller
1758 * A marshaller for a #GCClosure with a callback of type
1759 * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1763 * g_cclosure_marshal_VOID__OBJECT:
1764 * @closure: the #GClosure to which the marshaller belongs
1765 * @return_value: ignored
1766 * @n_param_values: 2
1767 * @param_values: a #GValue array holding the instance and the #GObject* parameter
1768 * @invocation_hint: the invocation hint given as the last argument
1769 * to g_closure_invoke()
1770 * @marshal_data: additional data specified when registering the marshaller
1772 * A marshaller for a #GCClosure with a callback of type
1773 * <literal>void (*callback) (gpointer instance, GObject *arg1, gpointer user_data)</literal>.
1777 * g_cclosure_marshal_VOID__VARIANT:
1778 * @closure: the #GClosure to which the marshaller belongs
1779 * @return_value: ignored
1780 * @n_param_values: 2
1781 * @param_values: a #GValue array holding the instance and the #GVariant* parameter
1782 * @invocation_hint: the invocation hint given as the last argument
1783 * to g_closure_invoke()
1784 * @marshal_data: additional data specified when registering the marshaller
1786 * A marshaller for a #GCClosure with a callback of type
1787 * <literal>void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data)</literal>.
1793 * g_cclosure_marshal_VOID__UINT_POINTER:
1794 * @closure: the #GClosure to which the marshaller belongs
1795 * @return_value: ignored
1796 * @n_param_values: 3
1797 * @param_values: a #GValue array holding instance, arg1 and arg2
1798 * @invocation_hint: the invocation hint given as the last argument
1799 * to g_closure_invoke()
1800 * @marshal_data: additional data specified when registering the marshaller
1802 * A marshaller for a #GCClosure with a callback of type
1803 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1807 * g_cclosure_marshal_BOOLEAN__FLAGS:
1808 * @closure: the #GClosure to which the marshaller belongs
1809 * @return_value: a #GValue which can store the returned #gboolean
1810 * @n_param_values: 2
1811 * @param_values: a #GValue array holding instance and arg1
1812 * @invocation_hint: the invocation hint given as the last argument
1813 * to g_closure_invoke()
1814 * @marshal_data: additional data specified when registering the marshaller
1816 * A marshaller for a #GCClosure with a callback of type
1817 * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1818 * denotes a flags type.
1822 * g_cclosure_marshal_BOOL__FLAGS:
1824 * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1827 * g_cclosure_marshal_STRING__OBJECT_POINTER:
1828 * @closure: the #GClosure to which the marshaller belongs
1829 * @return_value: a #GValue, which can store the returned string
1830 * @n_param_values: 3
1831 * @param_values: a #GValue array holding instance, arg1 and arg2
1832 * @invocation_hint: the invocation hint given as the last argument
1833 * to g_closure_invoke()
1834 * @marshal_data: additional data specified when registering the marshaller
1836 * A marshaller for a #GCClosure with a callback of type
1837 * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1840 * g_cclosure_marshal_BOOLEAN__OBJECT_BOXED_BOXED:
1841 * @closure: the #GClosure to which the marshaller belongs
1842 * @return_value: a #GValue, which can store the returned string
1843 * @n_param_values: 3
1844 * @param_values: a #GValue array holding instance, arg1 and arg2
1845 * @invocation_hint: the invocation hint given as the last argument
1846 * to g_closure_invoke()
1847 * @marshal_data: additional data specified when registering the marshaller
1849 * A marshaller for a #GCClosure with a callback of type
1850 * <literal>gboolean (*callback) (gpointer instance, GBoxed *arg1, GBoxed *arg2, gpointer user_data)</literal>.