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, see <http://www.gnu.org/licenses/>.
20 * MT safe with regards to reference counting.
34 #include "gvaluetypes.h"
35 #include "gtype-private.h"
40 * @short_description: Functions as first-class objects
43 * A #GClosure represents a callback supplied by the programmer. It
44 * will generally comprise a function of some kind and a marshaller
45 * used to call it. It is the reponsibility of the marshaller to
46 * convert the arguments for the invocation from #GValue<!-- -->s into
47 * a suitable form, perform the callback on the converted arguments,
48 * and transform the return value back into a #GValue.
50 * In the case of C programs, a closure usually just holds a pointer
51 * to a function and maybe a data argument, and the marshaller
52 * converts between #GValue<!-- --> and native C types. The GObject
53 * library provides the #GCClosure type for this purpose. Bindings for
54 * other languages need marshallers which convert between #GValue<!--
55 * -->s and suitable representations in the runtime of the language in
56 * order to use functions written in that languages as callbacks.
58 * Within GObject, closures play an important role in the
59 * implementation of signals. When a signal is registered, the
60 * @c_marshaller argument to g_signal_new() specifies the default C
61 * marshaller for any closure which is connected to this
62 * signal. GObject provides a number of C marshallers for this
63 * purpose, see the g_cclosure_marshal_*() functions. Additional C
64 * marshallers can be generated with the <link
65 * linkend="glib-genmarshal">glib-genmarshal</link> utility. Closures
66 * can be explicitly connected to signals with
67 * g_signal_connect_closure(), but it usually more convenient to let
68 * GObject create a closure automatically by using one of the
69 * g_signal_connect_*() functions which take a callback function/user
72 * Using closures has a number of important advantages over a simple
73 * callback function/data pointer combination:
76 * Closures allow the callee to get the types of the callback parameters,
77 * which means that language bindings don't have to write individual glue
78 * for each callback type.
81 * The reference counting of #GClosure makes it easy to handle reentrancy
82 * right; if a callback is removed while it is being invoked, the closure
83 * and its parameters won't be freed until the invocation finishes.
86 * g_closure_invalidate() and invalidation notifiers allow callbacks to be
87 * automatically removed when the objects they point to go away.
92 #define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
93 #define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
94 #define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
95 #define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
96 #define CLOSURE_N_MFUNCS(cl) (((cl)->n_guards << 1L))
97 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
98 #define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
99 (cl)->n_fnotifiers + \
107 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
109 ClosureInt *cunion = (ClosureInt*) _closure; \
110 gint new_int, old_int, success; \
114 tmp.vint = old_int = cunion->vint; \
115 _SET_OLD tmp.closure._field; \
116 tmp.closure._field _OP _value; \
117 _SET_NEW tmp.closure._field; \
118 new_int = tmp.vint; \
119 success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int); \
121 while (!success && _must_set); \
124 #define SWAP(_closure, _field, _value, _oldv) CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =, (void) )
125 #define SET(_closure, _field, _value) CHANGE_FIELD (_closure, _field, =, _value, TRUE, (void), (void) )
126 #define INC(_closure, _field) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), (void) )
127 #define INC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), *(_newv) = )
128 #define DEC(_closure, _field) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), (void) )
129 #define DEC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), *(_newv) = )
131 #if 0 /* for non-thread-safe closures */
132 #define SWAP(cl,f,v,o) (void) (*(o) = cl->f, cl->f = v)
133 #define SET(cl,f,v) (void) (cl->f = v)
134 #define INC(cl,f) (void) (cl->f += 1)
135 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
136 #define DEC(cl,f) (void) (cl->f -= 1)
137 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
148 /* --- functions --- */
150 * g_closure_new_simple:
151 * @sizeof_closure: the size of the structure to allocate, must be at least
152 * <literal>sizeof (GClosure)</literal>
153 * @data: data to store in the @data field of the newly allocated #GClosure
155 * Allocates a struct of the given size and initializes the initial
156 * part as a #GClosure. This function is mainly useful when
157 * implementing new types of closures.
160 * typedef struct _MyClosure MyClosure;
164 * // extra data goes here
168 * my_closure_finalize (gpointer notify_data,
171 * MyClosure *my_closure = (MyClosure *)closure;
173 * // free extra data here
176 * MyClosure *my_closure_new (gpointer data)
179 * MyClosure *my_closure;
181 * closure = g_closure_new_simple (sizeof (MyClosure), data);
182 * my_closure = (MyClosure *) closure;
184 * // initialize extra data here
186 * g_closure_add_finalize_notifier (closure, notify_data,
187 * my_closure_finalize);
192 * Returns: (transfer full): a newly allocated #GClosure
195 g_closure_new_simple (guint sizeof_closure,
198 GRealClosure *real_closure;
201 g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
202 sizeof_closure = sizeof_closure + sizeof (GRealClosure) - sizeof (GClosure);
204 real_closure = g_malloc0 (sizeof_closure);
205 closure = &real_closure->closure;
206 SET (closure, ref_count, 1);
207 SET (closure, floating, TRUE);
208 closure->data = data;
214 closure_invoke_notifiers (GClosure *closure,
218 * n_guards n_guards n_fnotif. n_inotifiers
219 * ->[[pre_guards][post_guards][fnotifiers][inotifiers]]
221 * CLOSURE_N_MFUNCS(cl) = n_guards + n_guards;
222 * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
224 * constrains/catches:
225 * - closure->notifiers may be reloacted during callback
226 * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
227 * - i.e. callbacks can be removed/added during invocation
228 * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
229 * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
230 * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
231 * + none of the callbacks can cause recursion
232 * + closure->n_inotifiers is const 0 during FNOTIFY
236 GClosureNotifyData *ndata;
239 while (closure->n_fnotifiers)
242 DEC_ASSIGN (closure, n_fnotifiers, &n);
244 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
245 closure->marshal = (GClosureMarshal) ndata->notify;
246 closure->data = ndata->data;
247 ndata->notify (ndata->data, closure);
249 closure->marshal = NULL;
250 closure->data = NULL;
253 SET (closure, in_inotify, TRUE);
254 while (closure->n_inotifiers)
257 DEC_ASSIGN (closure, n_inotifiers, &n);
259 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
260 closure->marshal = (GClosureMarshal) ndata->notify;
261 closure->data = ndata->data;
262 ndata->notify (ndata->data, closure);
264 closure->marshal = NULL;
265 closure->data = NULL;
266 SET (closure, in_inotify, FALSE);
269 i = closure->n_guards;
273 ndata = closure->notifiers + offs + i;
274 ndata->notify (ndata->data, closure);
278 i = closure->n_guards;
282 ndata = closure->notifiers + offs + i;
283 ndata->notify (ndata->data, closure);
290 g_closure_set_meta_va_marshal (GClosure *closure,
291 GVaClosureMarshal va_meta_marshal)
293 GRealClosure *real_closure;
295 g_return_if_fail (closure != NULL);
296 g_return_if_fail (va_meta_marshal != NULL);
297 g_return_if_fail (closure->is_invalid == FALSE);
298 g_return_if_fail (closure->in_marshal == FALSE);
300 real_closure = G_REAL_CLOSURE (closure);
302 g_return_if_fail (real_closure->meta_marshal != NULL);
304 real_closure->va_meta_marshal = va_meta_marshal;
308 * g_closure_set_meta_marshal: (skip)
309 * @closure: a #GClosure
310 * @marshal_data: context-dependent data to pass to @meta_marshal
311 * @meta_marshal: a #GClosureMarshal function
313 * Sets the meta marshaller of @closure. A meta marshaller wraps
314 * @closure->marshal and modifies the way it is called in some
315 * fashion. The most common use of this facility is for C callbacks.
316 * The same marshallers (generated by <link
317 * linkend="glib-genmarshal">glib-genmarshal</link>) are used
318 * everywhere, but the way that we get the callback function
319 * differs. In most cases we want to use @closure->callback, but in
320 * other cases we want to use some different technique to retrieve the
323 * For example, class closures for signals (see
324 * g_signal_type_cclosure_new()) retrieve the callback function from a
325 * fixed offset in the class structure. The meta marshaller retrieves
326 * the right callback and passes it to the marshaller as the
327 * @marshal_data argument.
330 g_closure_set_meta_marshal (GClosure *closure,
331 gpointer marshal_data,
332 GClosureMarshal meta_marshal)
334 GRealClosure *real_closure;
336 g_return_if_fail (closure != NULL);
337 g_return_if_fail (meta_marshal != NULL);
338 g_return_if_fail (closure->is_invalid == FALSE);
339 g_return_if_fail (closure->in_marshal == FALSE);
341 real_closure = G_REAL_CLOSURE (closure);
343 g_return_if_fail (real_closure->meta_marshal == NULL);
345 real_closure->meta_marshal = meta_marshal;
346 real_closure->meta_marshal_data = marshal_data;
350 * g_closure_add_marshal_guards: (skip)
351 * @closure: a #GClosure
352 * @pre_marshal_data: data to pass to @pre_marshal_notify
353 * @pre_marshal_notify: a function to call before the closure callback
354 * @post_marshal_data: data to pass to @post_marshal_notify
355 * @post_marshal_notify: a function to call after the closure callback
357 * Adds a pair of notifiers which get invoked before and after the
358 * closure callback, respectively. This is typically used to protect
359 * the extra arguments for the duration of the callback. See
360 * g_object_watch_closure() for an example of marshal guards.
363 g_closure_add_marshal_guards (GClosure *closure,
364 gpointer pre_marshal_data,
365 GClosureNotify pre_marshal_notify,
366 gpointer post_marshal_data,
367 GClosureNotify post_marshal_notify)
371 g_return_if_fail (closure != NULL);
372 g_return_if_fail (pre_marshal_notify != NULL);
373 g_return_if_fail (post_marshal_notify != NULL);
374 g_return_if_fail (closure->is_invalid == FALSE);
375 g_return_if_fail (closure->in_marshal == FALSE);
376 g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
378 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
379 if (closure->n_inotifiers)
380 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
381 closure->n_fnotifiers +
382 closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
383 closure->n_fnotifiers + 0)];
384 if (closure->n_inotifiers > 1)
385 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
386 closure->n_fnotifiers +
387 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
388 closure->n_fnotifiers + 1)];
389 if (closure->n_fnotifiers)
390 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
391 closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
392 if (closure->n_fnotifiers > 1)
393 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
394 closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
395 if (closure->n_guards)
396 closure->notifiers[(closure->n_guards +
397 closure->n_guards + 1)] = closure->notifiers[closure->n_guards];
398 i = closure->n_guards;
399 closure->notifiers[i].data = pre_marshal_data;
400 closure->notifiers[i].notify = pre_marshal_notify;
401 closure->notifiers[i + 1].data = post_marshal_data;
402 closure->notifiers[i + 1].notify = post_marshal_notify;
403 INC (closure, n_guards);
407 * g_closure_add_finalize_notifier: (skip)
408 * @closure: a #GClosure
409 * @notify_data: data to pass to @notify_func
410 * @notify_func: the callback function to register
412 * Registers a finalization notifier which will be called when the
413 * reference count of @closure goes down to 0. Multiple finalization
414 * notifiers on a single closure are invoked in unspecified order. If
415 * a single call to g_closure_unref() results in the closure being
416 * both invalidated and finalized, then the invalidate notifiers will
417 * be run before the finalize notifiers.
420 g_closure_add_finalize_notifier (GClosure *closure,
421 gpointer notify_data,
422 GClosureNotify notify_func)
426 g_return_if_fail (closure != NULL);
427 g_return_if_fail (notify_func != NULL);
428 g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
430 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
431 if (closure->n_inotifiers)
432 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
433 closure->n_fnotifiers +
434 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
435 closure->n_fnotifiers + 0)];
436 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
437 closure->notifiers[i].data = notify_data;
438 closure->notifiers[i].notify = notify_func;
439 INC (closure, n_fnotifiers);
443 * g_closure_add_invalidate_notifier: (skip)
444 * @closure: a #GClosure
445 * @notify_data: data to pass to @notify_func
446 * @notify_func: the callback function to register
448 * Registers an invalidation notifier which will be called when the
449 * @closure is invalidated with g_closure_invalidate(). Invalidation
450 * notifiers are invoked before finalization notifiers, in an
454 g_closure_add_invalidate_notifier (GClosure *closure,
455 gpointer notify_data,
456 GClosureNotify notify_func)
460 g_return_if_fail (closure != NULL);
461 g_return_if_fail (notify_func != NULL);
462 g_return_if_fail (closure->is_invalid == FALSE);
463 g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
465 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
466 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
467 closure->notifiers[i].data = notify_data;
468 closure->notifiers[i].notify = notify_func;
469 INC (closure, n_inotifiers);
472 static inline gboolean
473 closure_try_remove_inotify (GClosure *closure,
474 gpointer notify_data,
475 GClosureNotify notify_func)
477 GClosureNotifyData *ndata, *nlast;
479 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
480 for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
481 if (ndata->notify == notify_func && ndata->data == notify_data)
483 DEC (closure, n_inotifiers);
492 static inline gboolean
493 closure_try_remove_fnotify (GClosure *closure,
494 gpointer notify_data,
495 GClosureNotify notify_func)
497 GClosureNotifyData *ndata, *nlast;
499 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
500 for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
501 if (ndata->notify == notify_func && ndata->data == notify_data)
503 DEC (closure, n_fnotifiers);
506 if (closure->n_inotifiers)
507 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
508 closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
509 closure->n_fnotifiers +
510 closure->n_inotifiers)];
518 * @closure: #GClosure to increment the reference count on
520 * Increments the reference count on a closure to force it staying
521 * alive while the caller holds a pointer to it.
523 * Returns: (transfer none): The @closure passed in, for convenience
526 g_closure_ref (GClosure *closure)
529 g_return_val_if_fail (closure != NULL, NULL);
530 g_return_val_if_fail (closure->ref_count > 0, NULL);
531 g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
533 INC_ASSIGN (closure, ref_count, &new_ref_count);
534 g_return_val_if_fail (new_ref_count > 1, NULL);
540 * g_closure_invalidate:
541 * @closure: GClosure to invalidate
543 * Sets a flag on the closure to indicate that its calling
544 * environment has become invalid, and thus causes any future
545 * invocations of g_closure_invoke() on this @closure to be
546 * ignored. Also, invalidation notifiers installed on the closure will
547 * be called at this point. Note that unless you are holding a
548 * reference to the closure yourself, the invalidation notifiers may
549 * unref the closure and cause it to be destroyed, so if you need to
550 * access the closure after calling g_closure_invalidate(), make sure
551 * that you've previously called g_closure_ref().
553 * Note that g_closure_invalidate() will also be called when the
554 * reference count of a closure drops to zero (unless it has already
555 * been invalidated before).
558 g_closure_invalidate (GClosure *closure)
560 g_return_if_fail (closure != NULL);
562 if (!closure->is_invalid)
564 gboolean was_invalid;
565 g_closure_ref (closure); /* preserve floating flag */
566 SWAP (closure, is_invalid, TRUE, &was_invalid);
567 /* invalidate only once */
569 closure_invoke_notifiers (closure, INOTIFY);
570 g_closure_unref (closure);
576 * @closure: #GClosure to decrement the reference count on
578 * Decrements the reference count of a closure after it was previously
579 * incremented by the same caller. If no other callers are using the
580 * closure, then the closure will be destroyed and freed.
583 g_closure_unref (GClosure *closure)
587 g_return_if_fail (closure != NULL);
588 g_return_if_fail (closure->ref_count > 0);
590 if (closure->ref_count == 1) /* last unref, invalidate first */
591 g_closure_invalidate (closure);
593 DEC_ASSIGN (closure, ref_count, &new_ref_count);
595 if (new_ref_count == 0)
597 closure_invoke_notifiers (closure, FNOTIFY);
598 g_free (closure->notifiers);
599 g_free (G_REAL_CLOSURE (closure));
605 * @closure: #GClosure to decrement the initial reference count on, if it's
608 * Takes over the initial ownership of a closure. Each closure is
609 * initially created in a <firstterm>floating</firstterm> state, which
610 * means that the initial reference count is not owned by any caller.
611 * g_closure_sink() checks to see if the object is still floating, and
612 * if so, unsets the floating state and decreases the reference
613 * count. If the closure is not floating, g_closure_sink() does
614 * nothing. The reason for the existence of the floating state is to
615 * prevent cumbersome code sequences like:
617 * closure = g_cclosure_new (cb_func, cb_data);
618 * g_source_set_closure (source, closure);
619 * g_closure_unref (closure); // XXX GObject doesn't really need this
621 * Because g_source_set_closure() (and similar functions) take ownership of the
622 * initial reference count, if it is unowned, we instead can write:
624 * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
627 * Generally, this function is used together with g_closure_ref(). Ane example
628 * of storing a closure for later notification looks like:
630 * static GClosure *notify_closure = NULL;
632 * foo_notify_set_closure (GClosure *closure)
634 * if (notify_closure)
635 * g_closure_unref (notify_closure);
636 * notify_closure = closure;
637 * if (notify_closure)
639 * g_closure_ref (notify_closure);
640 * g_closure_sink (notify_closure);
645 * Because g_closure_sink() may decrement the reference count of a closure
646 * (if it hasn't been called on @closure yet) just like g_closure_unref(),
647 * g_closure_ref() should be called prior to this function.
650 g_closure_sink (GClosure *closure)
652 g_return_if_fail (closure != NULL);
653 g_return_if_fail (closure->ref_count > 0);
655 /* floating is basically a kludge to avoid creating closures
656 * with a ref_count of 0. so the initial ref_count a closure has
657 * is unowned. with invoking g_closure_sink() code may
658 * indicate that it takes over that intiial ref_count.
660 if (closure->floating)
662 gboolean was_floating;
663 SWAP (closure, floating, FALSE, &was_floating);
664 /* unref floating flag only once */
666 g_closure_unref (closure);
671 * g_closure_remove_invalidate_notifier: (skip)
672 * @closure: a #GClosure
673 * @notify_data: data which was passed to g_closure_add_invalidate_notifier()
674 * when registering @notify_func
675 * @notify_func: the callback function to remove
677 * Removes an invalidation notifier.
679 * Notice that notifiers are automatically removed after they are run.
682 g_closure_remove_invalidate_notifier (GClosure *closure,
683 gpointer notify_data,
684 GClosureNotify notify_func)
686 g_return_if_fail (closure != NULL);
687 g_return_if_fail (notify_func != NULL);
689 if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while it's called */
690 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
691 closure->data == notify_data)
692 closure->marshal = NULL;
693 else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
694 g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
695 notify_func, notify_data);
699 * g_closure_remove_finalize_notifier: (skip)
700 * @closure: a #GClosure
701 * @notify_data: data which was passed to g_closure_add_finalize_notifier()
702 * when registering @notify_func
703 * @notify_func: the callback function to remove
705 * Removes a finalization notifier.
707 * Notice that notifiers are automatically removed after they are run.
710 g_closure_remove_finalize_notifier (GClosure *closure,
711 gpointer notify_data,
712 GClosureNotify notify_func)
714 g_return_if_fail (closure != NULL);
715 g_return_if_fail (notify_func != NULL);
717 if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while it's called */
718 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
719 closure->data == notify_data)
720 closure->marshal = NULL;
721 else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
722 g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
723 notify_func, notify_data);
728 * @closure: a #GClosure
729 * @return_value: (allow-none): a #GValue to store the return
730 * value. May be %NULL if the callback of @closure
731 * doesn't return a value.
732 * @n_param_values: the length of the @param_values array
733 * @param_values: (array length=n_param_values): an array of
734 * #GValue<!-- -->s holding the arguments on which to
735 * invoke the callback of @closure
736 * @invocation_hint: (allow-none): a context-dependent invocation hint
738 * Invokes the closure, i.e. executes the callback represented by the @closure.
741 g_closure_invoke (GClosure *closure,
742 GValue /*out*/ *return_value,
743 guint n_param_values,
744 const GValue *param_values,
745 gpointer invocation_hint)
747 GRealClosure *real_closure;
749 g_return_if_fail (closure != NULL);
751 real_closure = G_REAL_CLOSURE (closure);
753 g_closure_ref (closure); /* preserve floating flag */
754 if (!closure->is_invalid)
756 GClosureMarshal marshal;
757 gpointer marshal_data;
758 gboolean in_marshal = closure->in_marshal;
760 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
762 SET (closure, in_marshal, TRUE);
763 if (real_closure->meta_marshal)
765 marshal_data = real_closure->meta_marshal_data;
766 marshal = real_closure->meta_marshal;
771 marshal = closure->marshal;
774 closure_invoke_notifiers (closure, PRE_NOTIFY);
777 n_param_values, param_values,
781 closure_invoke_notifiers (closure, POST_NOTIFY);
782 SET (closure, in_marshal, in_marshal);
784 g_closure_unref (closure);
788 _g_closure_supports_invoke_va (GClosure *closure)
790 GRealClosure *real_closure;
792 g_return_val_if_fail (closure != NULL, FALSE);
794 real_closure = G_REAL_CLOSURE (closure);
797 real_closure->va_marshal != NULL &&
798 (real_closure->meta_marshal == NULL ||
799 real_closure->va_meta_marshal != NULL);
803 _g_closure_invoke_va (GClosure *closure,
804 GValue /*out*/ *return_value,
810 GRealClosure *real_closure;
812 g_return_if_fail (closure != NULL);
814 real_closure = G_REAL_CLOSURE (closure);
816 g_closure_ref (closure); /* preserve floating flag */
817 if (!closure->is_invalid)
819 GVaClosureMarshal marshal;
820 gpointer marshal_data;
821 gboolean in_marshal = closure->in_marshal;
823 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
825 SET (closure, in_marshal, TRUE);
826 if (real_closure->va_meta_marshal)
828 marshal_data = real_closure->meta_marshal_data;
829 marshal = real_closure->va_meta_marshal;
834 marshal = real_closure->va_marshal;
837 closure_invoke_notifiers (closure, PRE_NOTIFY);
842 n_params, param_types);
844 closure_invoke_notifiers (closure, POST_NOTIFY);
845 SET (closure, in_marshal, in_marshal);
847 g_closure_unref (closure);
852 * g_closure_set_marshal: (skip)
853 * @closure: a #GClosure
854 * @marshal: a #GClosureMarshal function
856 * Sets the marshaller of @closure. The <literal>marshal_data</literal>
857 * of @marshal provides a way for a meta marshaller to provide additional
858 * information to the marshaller. (See g_closure_set_meta_marshal().) For
859 * GObject's C predefined marshallers (the g_cclosure_marshal_*()
860 * functions), what it provides is a callback function to use instead of
861 * @closure->callback.
864 g_closure_set_marshal (GClosure *closure,
865 GClosureMarshal marshal)
867 g_return_if_fail (closure != NULL);
868 g_return_if_fail (marshal != NULL);
870 if (closure->marshal && closure->marshal != marshal)
871 g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
872 closure->marshal, marshal);
874 closure->marshal = marshal;
878 _g_closure_set_va_marshal (GClosure *closure,
879 GVaClosureMarshal marshal)
881 GRealClosure *real_closure;
883 g_return_if_fail (closure != NULL);
884 g_return_if_fail (marshal != NULL);
886 real_closure = G_REAL_CLOSURE (closure);
888 if (real_closure->va_marshal && real_closure->va_marshal != marshal)
889 g_warning ("attempt to override closure->va_marshal (%p) with new marshal (%p)",
890 real_closure->va_marshal, marshal);
892 real_closure->va_marshal = marshal;
896 * g_cclosure_new: (skip)
897 * @callback_func: the function to invoke
898 * @user_data: user data to pass to @callback_func
899 * @destroy_data: destroy notify to be called when @user_data is no longer used
901 * Creates a new closure which invokes @callback_func with @user_data as
902 * the last parameter.
904 * Returns: a new #GCClosure
907 g_cclosure_new (GCallback callback_func,
909 GClosureNotify destroy_data)
913 g_return_val_if_fail (callback_func != NULL, NULL);
915 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
917 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
918 ((GCClosure*) closure)->callback = (gpointer) callback_func;
924 * g_cclosure_new_swap: (skip)
925 * @callback_func: the function to invoke
926 * @user_data: user data to pass to @callback_func
927 * @destroy_data: destroy notify to be called when @user_data is no longer used
929 * Creates a new closure which invokes @callback_func with @user_data as
930 * the first parameter.
932 * Returns: (transfer full): a new #GCClosure
935 g_cclosure_new_swap (GCallback callback_func,
937 GClosureNotify destroy_data)
941 g_return_val_if_fail (callback_func != NULL, NULL);
943 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
945 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
946 ((GCClosure*) closure)->callback = (gpointer) callback_func;
947 SET (closure, derivative_flag, TRUE);
953 g_type_class_meta_marshal (GClosure *closure,
954 GValue /*out*/ *return_value,
955 guint n_param_values,
956 const GValue *param_values,
957 gpointer invocation_hint,
958 gpointer marshal_data)
962 /* GType itype = (GType) closure->data; */
963 guint offset = GPOINTER_TO_UINT (marshal_data);
965 class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
966 callback = G_STRUCT_MEMBER (gpointer, class, offset);
968 closure->marshal (closure,
970 n_param_values, param_values,
976 g_type_class_meta_marshalv (GClosure *closure,
977 GValue *return_value,
980 gpointer marshal_data,
984 GRealClosure *real_closure;
987 /* GType itype = (GType) closure->data; */
988 guint offset = GPOINTER_TO_UINT (marshal_data);
990 real_closure = G_REAL_CLOSURE (closure);
992 class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
993 callback = G_STRUCT_MEMBER (gpointer, class, offset);
995 real_closure->va_marshal (closure,
1004 g_type_iface_meta_marshal (GClosure *closure,
1005 GValue /*out*/ *return_value,
1006 guint n_param_values,
1007 const GValue *param_values,
1008 gpointer invocation_hint,
1009 gpointer marshal_data)
1013 GType itype = (GType) closure->data;
1014 guint offset = GPOINTER_TO_UINT (marshal_data);
1016 class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
1017 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1019 closure->marshal (closure,
1021 n_param_values, param_values,
1027 _g_closure_is_void (GClosure *closure,
1030 GRealClosure *real_closure;
1036 if (closure->is_invalid)
1039 real_closure = G_REAL_CLOSURE (closure);
1041 if (real_closure->meta_marshal == g_type_iface_meta_marshal)
1043 itype = (GType) closure->data;
1044 offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
1046 class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
1047 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1048 return callback == NULL;
1050 else if (real_closure->meta_marshal == g_type_class_meta_marshal)
1052 offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
1054 class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
1055 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1056 return callback == NULL;
1063 g_type_iface_meta_marshalv (GClosure *closure,
1064 GValue *return_value,
1067 gpointer marshal_data,
1071 GRealClosure *real_closure;
1074 GType itype = (GType) closure->data;
1075 guint offset = GPOINTER_TO_UINT (marshal_data);
1077 real_closure = G_REAL_CLOSURE (closure);
1079 class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
1080 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1082 real_closure->va_marshal (closure,
1091 * g_signal_type_cclosure_new:
1092 * @itype: the #GType identifier of an interface or classed type
1093 * @struct_offset: the offset of the member function of @itype's class
1094 * structure which is to be invoked by the new closure
1096 * Creates a new closure which invokes the function found at the offset
1097 * @struct_offset in the class structure of the interface or classed type
1098 * identified by @itype.
1100 * Returns: a new #GCClosure
1103 g_signal_type_cclosure_new (GType itype,
1104 guint struct_offset)
1108 g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
1109 g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
1111 closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
1112 if (G_TYPE_IS_INTERFACE (itype))
1114 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
1115 g_closure_set_meta_va_marshal (closure, g_type_iface_meta_marshalv);
1119 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
1120 g_closure_set_meta_va_marshal (closure, g_type_class_meta_marshalv);
1127 value_to_ffi_type (const GValue *gvalue,
1130 gboolean *tmpval_used)
1132 ffi_type *rettype = NULL;
1133 GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
1134 g_assert (type != G_TYPE_INVALID);
1138 g_assert (tmpval_used != NULL);
1139 *tmpval_used = FALSE;
1144 case G_TYPE_BOOLEAN:
1147 rettype = &ffi_type_sint;
1148 *value = (gpointer)&(gvalue->data[0].v_int);
1151 /* enums are stored in v_long even though they are integers, which makes
1152 * marshalling through libffi somewhat complicated. They need to be
1153 * marshalled as signed ints, but we need to use a temporary int sized
1154 * value to pass to libffi otherwise it'll pull the wrong value on
1155 * BE machines with 32-bit integers when treating v_long as 32-bit int.
1157 g_assert (enum_tmpval != NULL);
1158 rettype = &ffi_type_sint;
1159 *enum_tmpval = g_value_get_enum (gvalue);
1160 *value = enum_tmpval;
1161 *tmpval_used = TRUE;
1166 rettype = &ffi_type_uint;
1167 *value = (gpointer)&(gvalue->data[0].v_uint);
1173 case G_TYPE_POINTER:
1174 case G_TYPE_INTERFACE:
1175 case G_TYPE_VARIANT:
1176 rettype = &ffi_type_pointer;
1177 *value = (gpointer)&(gvalue->data[0].v_pointer);
1180 rettype = &ffi_type_float;
1181 *value = (gpointer)&(gvalue->data[0].v_float);
1184 rettype = &ffi_type_double;
1185 *value = (gpointer)&(gvalue->data[0].v_double);
1188 rettype = &ffi_type_slong;
1189 *value = (gpointer)&(gvalue->data[0].v_long);
1192 rettype = &ffi_type_ulong;
1193 *value = (gpointer)&(gvalue->data[0].v_ulong);
1196 rettype = &ffi_type_sint64;
1197 *value = (gpointer)&(gvalue->data[0].v_int64);
1200 rettype = &ffi_type_uint64;
1201 *value = (gpointer)&(gvalue->data[0].v_uint64);
1204 rettype = &ffi_type_pointer;
1206 g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1213 value_from_ffi_type (GValue *gvalue, gpointer *value)
1215 ffi_arg *int_val = (ffi_arg*) value;
1217 switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
1220 g_value_set_int (gvalue, (gint) *int_val);
1223 g_value_set_float (gvalue, *(gfloat*)value);
1226 g_value_set_double (gvalue, *(gdouble*)value);
1228 case G_TYPE_BOOLEAN:
1229 g_value_set_boolean (gvalue, (gboolean) *int_val);
1232 g_value_take_string (gvalue, *(gchar**)value);
1235 g_value_set_schar (gvalue, (gint8) *int_val);
1238 g_value_set_uchar (gvalue, (guchar) *int_val);
1241 g_value_set_uint (gvalue, (guint) *int_val);
1243 case G_TYPE_POINTER:
1244 g_value_set_pointer (gvalue, *(gpointer*)value);
1247 g_value_set_long (gvalue, (glong) *int_val);
1250 g_value_set_ulong (gvalue, (gulong) *int_val);
1253 g_value_set_int64 (gvalue, (gint64) *int_val);
1256 g_value_set_uint64 (gvalue, (guint64) *int_val);
1259 g_value_take_boxed (gvalue, *(gpointer*)value);
1262 g_value_set_enum (gvalue, (gint) *int_val);
1265 g_value_set_flags (gvalue, (guint) *int_val);
1268 g_value_take_param (gvalue, *(gpointer*)value);
1271 g_value_take_object (gvalue, *(gpointer*)value);
1273 case G_TYPE_VARIANT:
1274 g_value_take_variant (gvalue, *(gpointer*)value);
1277 g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
1278 g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
1295 va_to_ffi_type (GType gtype,
1297 va_arg_storage *storage)
1299 ffi_type *rettype = NULL;
1300 GType type = g_type_fundamental (gtype);
1301 g_assert (type != G_TYPE_INVALID);
1305 case G_TYPE_BOOLEAN:
1309 rettype = &ffi_type_sint;
1310 storage->_gint = va_arg (*va, gint);
1315 rettype = &ffi_type_uint;
1316 storage->_guint = va_arg (*va, guint);
1322 case G_TYPE_POINTER:
1323 case G_TYPE_INTERFACE:
1324 case G_TYPE_VARIANT:
1325 rettype = &ffi_type_pointer;
1326 storage->_gpointer = va_arg (*va, gpointer);
1329 /* Float args are passed as doubles in varargs */
1330 rettype = &ffi_type_float;
1331 storage->_float = (float)va_arg (*va, double);
1334 rettype = &ffi_type_double;
1335 storage->_double = va_arg (*va, double);
1338 rettype = &ffi_type_slong;
1339 storage->_glong = va_arg (*va, glong);
1342 rettype = &ffi_type_ulong;
1343 storage->_gulong = va_arg (*va, gulong);
1346 rettype = &ffi_type_sint64;
1347 storage->_gint64 = va_arg (*va, gint64);
1350 rettype = &ffi_type_uint64;
1351 storage->_guint64 = va_arg (*va, guint64);
1354 rettype = &ffi_type_pointer;
1355 storage->_guint64 = 0;
1356 g_warning ("va_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1363 * g_cclosure_marshal_generic:
1364 * @closure: A #GClosure.
1365 * @return_gvalue: A #GValue to store the return value. May be %NULL
1366 * if the callback of closure doesn't return a value.
1367 * @n_param_values: The length of the @param_values array.
1368 * @param_values: An array of #GValue<!-- -->s holding the arguments
1369 * on which to invoke the callback of closure.
1370 * @invocation_hint: The invocation hint given as the last argument to
1371 * g_closure_invoke().
1372 * @marshal_data: Additional data specified when registering the
1373 * marshaller, see g_closure_set_marshal() and
1374 * g_closure_set_meta_marshal()
1376 * A generic marshaller function implemented via <ulink
1377 * url="http://sourceware.org/libffi/">libffi</ulink>.
1382 g_cclosure_marshal_generic (GClosure *closure,
1383 GValue *return_gvalue,
1384 guint n_param_values,
1385 const GValue *param_values,
1386 gpointer invocation_hint,
1387 gpointer marshal_data)
1396 GCClosure *cc = (GCClosure*) closure;
1398 gboolean tmpval_used = FALSE;
1400 enum_tmpval = g_alloca (sizeof (gint));
1401 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1403 rtype = value_to_ffi_type (return_gvalue, &rvalue, enum_tmpval, &tmpval_used);
1407 rtype = &ffi_type_void;
1410 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1412 n_args = n_param_values + 1;
1413 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1414 args = g_alloca (sizeof (gpointer) * n_args);
1417 enum_tmpval = g_alloca (sizeof (gint));
1419 if (G_CCLOSURE_SWAP_DATA (closure))
1421 atypes[n_args-1] = value_to_ffi_type (param_values + 0,
1425 atypes[0] = &ffi_type_pointer;
1426 args[0] = &closure->data;
1430 atypes[0] = value_to_ffi_type (param_values + 0,
1434 atypes[n_args-1] = &ffi_type_pointer;
1435 args[n_args-1] = &closure->data;
1438 for (i = 1; i < n_args - 1; i++)
1441 enum_tmpval = g_alloca (sizeof (gint));
1443 atypes[i] = value_to_ffi_type (param_values + i,
1449 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1452 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1454 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1455 value_from_ffi_type (return_gvalue, rvalue);
1459 g_cclosure_marshal_generic_va (GClosure *closure,
1460 GValue *return_value,
1463 gpointer marshal_data,
1472 va_arg_storage *storage;
1475 GCClosure *cc = (GCClosure*) closure;
1477 gboolean tmpval_used = FALSE;
1480 enum_tmpval = g_alloca (sizeof (gint));
1481 if (return_value && G_VALUE_TYPE (return_value))
1483 rtype = value_to_ffi_type (return_value, &rvalue, enum_tmpval, &tmpval_used);
1487 rtype = &ffi_type_void;
1490 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1492 n_args = n_params + 2;
1493 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1494 args = g_alloca (sizeof (gpointer) * n_args);
1495 storage = g_alloca (sizeof (va_arg_storage) * n_params);
1498 enum_tmpval = g_alloca (sizeof (gint));
1500 if (G_CCLOSURE_SWAP_DATA (closure))
1502 atypes[n_args-1] = &ffi_type_pointer;
1503 args[n_args-1] = &instance;
1504 atypes[0] = &ffi_type_pointer;
1505 args[0] = &closure->data;
1509 atypes[0] = &ffi_type_pointer;
1510 args[0] = &instance;
1511 atypes[n_args-1] = &ffi_type_pointer;
1512 args[n_args-1] = &closure->data;
1515 G_VA_COPY (args_copy, args_list);
1517 /* Box non-primitive arguments */
1518 for (i = 0; i < n_params; i++)
1520 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1521 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1523 atypes[i+1] = va_to_ffi_type (type,
1526 args[i+1] = &storage[i];
1528 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1530 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1531 storage[i]._gpointer = g_strdup (storage[i]._gpointer);
1532 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1533 storage[i]._gpointer = g_param_spec_ref (storage[i]._gpointer);
1534 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1535 storage[i]._gpointer = g_boxed_copy (type, storage[i]._gpointer);
1536 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1537 storage[i]._gpointer = g_variant_ref_sink (storage[i]._gpointer);
1539 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1540 storage[i]._gpointer = g_object_ref (storage[i]._gpointer);
1545 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1548 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1550 /* Unbox non-primitive arguments */
1551 for (i = 0; i < n_params; i++)
1553 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1554 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1556 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1558 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1559 g_free (storage[i]._gpointer);
1560 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1561 g_param_spec_unref (storage[i]._gpointer);
1562 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1563 g_boxed_free (type, storage[i]._gpointer);
1564 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1565 g_variant_unref (storage[i]._gpointer);
1567 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1568 g_object_unref (storage[i]._gpointer);
1571 if (return_value && G_VALUE_TYPE (return_value))
1572 value_from_ffi_type (return_value, rvalue);
1576 * g_cclosure_marshal_VOID__VOID:
1577 * @closure: the #GClosure to which the marshaller belongs
1578 * @return_value: ignored
1579 * @n_param_values: 1
1580 * @param_values: a #GValue array holding only the instance
1581 * @invocation_hint: the invocation hint given as the last argument
1582 * to g_closure_invoke()
1583 * @marshal_data: additional data specified when registering the marshaller
1585 * A marshaller for a #GCClosure with a callback of type
1586 * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
1590 * g_cclosure_marshal_VOID__BOOLEAN:
1591 * @closure: the #GClosure to which the marshaller belongs
1592 * @return_value: ignored
1593 * @n_param_values: 2
1594 * @param_values: a #GValue array holding the instance and the #gboolean parameter
1595 * @invocation_hint: the invocation hint given as the last argument
1596 * to g_closure_invoke()
1597 * @marshal_data: additional data specified when registering the marshaller
1599 * A marshaller for a #GCClosure with a callback of type
1600 * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
1604 * g_cclosure_marshal_VOID__CHAR:
1605 * @closure: the #GClosure to which the marshaller belongs
1606 * @return_value: ignored
1607 * @n_param_values: 2
1608 * @param_values: a #GValue array holding the instance and the #gchar parameter
1609 * @invocation_hint: the invocation hint given as the last argument
1610 * to g_closure_invoke()
1611 * @marshal_data: additional data specified when registering the marshaller
1613 * A marshaller for a #GCClosure with a callback of type
1614 * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
1618 * g_cclosure_marshal_VOID__UCHAR:
1619 * @closure: the #GClosure to which the marshaller belongs
1620 * @return_value: ignored
1621 * @n_param_values: 2
1622 * @param_values: a #GValue array holding the instance and the #guchar parameter
1623 * @invocation_hint: the invocation hint given as the last argument
1624 * to g_closure_invoke()
1625 * @marshal_data: additional data specified when registering the marshaller
1627 * A marshaller for a #GCClosure with a callback of type
1628 * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
1632 * g_cclosure_marshal_VOID__INT:
1633 * @closure: the #GClosure to which the marshaller belongs
1634 * @return_value: ignored
1635 * @n_param_values: 2
1636 * @param_values: a #GValue array holding the instance and the #gint parameter
1637 * @invocation_hint: the invocation hint given as the last argument
1638 * to g_closure_invoke()
1639 * @marshal_data: additional data specified when registering the marshaller
1641 * A marshaller for a #GCClosure with a callback of type
1642 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
1646 * g_cclosure_marshal_VOID__UINT:
1647 * @closure: the #GClosure to which the marshaller belongs
1648 * @return_value: ignored
1649 * @n_param_values: 2
1650 * @param_values: a #GValue array holding the instance and the #guint parameter
1651 * @invocation_hint: the invocation hint given as the last argument
1652 * to g_closure_invoke()
1653 * @marshal_data: additional data specified when registering the marshaller
1655 * A marshaller for a #GCClosure with a callback of type
1656 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
1660 * g_cclosure_marshal_VOID__LONG:
1661 * @closure: the #GClosure to which the marshaller belongs
1662 * @return_value: ignored
1663 * @n_param_values: 2
1664 * @param_values: a #GValue array holding the instance and the #glong parameter
1665 * @invocation_hint: the invocation hint given as the last argument
1666 * to g_closure_invoke()
1667 * @marshal_data: additional data specified when registering the marshaller
1669 * A marshaller for a #GCClosure with a callback of type
1670 * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1674 * g_cclosure_marshal_VOID__ULONG:
1675 * @closure: the #GClosure to which the marshaller belongs
1676 * @return_value: ignored
1677 * @n_param_values: 2
1678 * @param_values: a #GValue array holding the instance and the #gulong parameter
1679 * @invocation_hint: the invocation hint given as the last argument
1680 * to g_closure_invoke()
1681 * @marshal_data: additional data specified when registering the marshaller
1683 * A marshaller for a #GCClosure with a callback of type
1684 * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1688 * g_cclosure_marshal_VOID__ENUM:
1689 * @closure: the #GClosure to which the marshaller belongs
1690 * @return_value: ignored
1691 * @n_param_values: 2
1692 * @param_values: a #GValue array holding the instance and the enumeration parameter
1693 * @invocation_hint: the invocation hint given as the last argument
1694 * to g_closure_invoke()
1695 * @marshal_data: additional data specified when registering the marshaller
1697 * A marshaller for a #GCClosure with a callback of type
1698 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1702 * g_cclosure_marshal_VOID__FLAGS:
1703 * @closure: the #GClosure to which the marshaller belongs
1704 * @return_value: ignored
1705 * @n_param_values: 2
1706 * @param_values: a #GValue array holding the instance and the flags parameter
1707 * @invocation_hint: the invocation hint given as the last argument
1708 * to g_closure_invoke()
1709 * @marshal_data: additional data specified when registering the marshaller
1711 * A marshaller for a #GCClosure with a callback of type
1712 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1716 * g_cclosure_marshal_VOID__FLOAT:
1717 * @closure: the #GClosure to which the marshaller belongs
1718 * @return_value: ignored
1719 * @n_param_values: 2
1720 * @param_values: a #GValue array holding the instance and the #gfloat parameter
1721 * @invocation_hint: the invocation hint given as the last argument
1722 * to g_closure_invoke()
1723 * @marshal_data: additional data specified when registering the marshaller
1725 * A marshaller for a #GCClosure with a callback of type
1726 * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1730 * g_cclosure_marshal_VOID__DOUBLE:
1731 * @closure: the #GClosure to which the marshaller belongs
1732 * @return_value: ignored
1733 * @n_param_values: 2
1734 * @param_values: a #GValue array holding the instance and the #gdouble parameter
1735 * @invocation_hint: the invocation hint given as the last argument
1736 * to g_closure_invoke()
1737 * @marshal_data: additional data specified when registering the marshaller
1739 * A marshaller for a #GCClosure with a callback of type
1740 * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1744 * g_cclosure_marshal_VOID__STRING:
1745 * @closure: the #GClosure to which the marshaller belongs
1746 * @return_value: ignored
1747 * @n_param_values: 2
1748 * @param_values: a #GValue array holding the instance and the #gchar* parameter
1749 * @invocation_hint: the invocation hint given as the last argument
1750 * to g_closure_invoke()
1751 * @marshal_data: additional data specified when registering the marshaller
1753 * A marshaller for a #GCClosure with a callback of type
1754 * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1758 * g_cclosure_marshal_VOID__PARAM:
1759 * @closure: the #GClosure to which the marshaller belongs
1760 * @return_value: ignored
1761 * @n_param_values: 2
1762 * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1763 * @invocation_hint: the invocation hint given as the last argument
1764 * to g_closure_invoke()
1765 * @marshal_data: additional data specified when registering the marshaller
1767 * A marshaller for a #GCClosure with a callback of type
1768 * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1772 * g_cclosure_marshal_VOID__BOXED:
1773 * @closure: the #GClosure to which the marshaller belongs
1774 * @return_value: ignored
1775 * @n_param_values: 2
1776 * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1777 * @invocation_hint: the invocation hint given as the last argument
1778 * to g_closure_invoke()
1779 * @marshal_data: additional data specified when registering the marshaller
1781 * A marshaller for a #GCClosure with a callback of type
1782 * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1786 * g_cclosure_marshal_VOID__POINTER:
1787 * @closure: the #GClosure to which the marshaller belongs
1788 * @return_value: ignored
1789 * @n_param_values: 2
1790 * @param_values: a #GValue array holding the instance and the #gpointer parameter
1791 * @invocation_hint: the invocation hint given as the last argument
1792 * to g_closure_invoke()
1793 * @marshal_data: additional data specified when registering the marshaller
1795 * A marshaller for a #GCClosure with a callback of type
1796 * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1800 * g_cclosure_marshal_VOID__OBJECT:
1801 * @closure: the #GClosure to which the marshaller belongs
1802 * @return_value: ignored
1803 * @n_param_values: 2
1804 * @param_values: a #GValue array holding the instance and the #GObject* parameter
1805 * @invocation_hint: the invocation hint given as the last argument
1806 * to g_closure_invoke()
1807 * @marshal_data: additional data specified when registering the marshaller
1809 * A marshaller for a #GCClosure with a callback of type
1810 * <literal>void (*callback) (gpointer instance, GObject *arg1, gpointer user_data)</literal>.
1814 * g_cclosure_marshal_VOID__VARIANT:
1815 * @closure: the #GClosure to which the marshaller belongs
1816 * @return_value: ignored
1817 * @n_param_values: 2
1818 * @param_values: a #GValue array holding the instance and the #GVariant* parameter
1819 * @invocation_hint: the invocation hint given as the last argument
1820 * to g_closure_invoke()
1821 * @marshal_data: additional data specified when registering the marshaller
1823 * A marshaller for a #GCClosure with a callback of type
1824 * <literal>void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data)</literal>.
1830 * g_cclosure_marshal_VOID__UINT_POINTER:
1831 * @closure: the #GClosure to which the marshaller belongs
1832 * @return_value: ignored
1833 * @n_param_values: 3
1834 * @param_values: a #GValue array holding instance, arg1 and arg2
1835 * @invocation_hint: the invocation hint given as the last argument
1836 * to g_closure_invoke()
1837 * @marshal_data: additional data specified when registering the marshaller
1839 * A marshaller for a #GCClosure with a callback of type
1840 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1844 * g_cclosure_marshal_BOOLEAN__FLAGS:
1845 * @closure: the #GClosure to which the marshaller belongs
1846 * @return_value: a #GValue which can store the returned #gboolean
1847 * @n_param_values: 2
1848 * @param_values: a #GValue array holding instance and arg1
1849 * @invocation_hint: the invocation hint given as the last argument
1850 * to g_closure_invoke()
1851 * @marshal_data: additional data specified when registering the marshaller
1853 * A marshaller for a #GCClosure with a callback of type
1854 * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1855 * denotes a flags type.
1859 * g_cclosure_marshal_BOOL__FLAGS:
1861 * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1864 * g_cclosure_marshal_STRING__OBJECT_POINTER:
1865 * @closure: the #GClosure to which the marshaller belongs
1866 * @return_value: a #GValue, which can store the returned string
1867 * @n_param_values: 3
1868 * @param_values: a #GValue array holding instance, arg1 and arg2
1869 * @invocation_hint: the invocation hint given as the last argument
1870 * to g_closure_invoke()
1871 * @marshal_data: additional data specified when registering the marshaller
1873 * A marshaller for a #GCClosure with a callback of type
1874 * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1877 * g_cclosure_marshal_BOOLEAN__OBJECT_BOXED_BOXED:
1878 * @closure: the #GClosure to which the marshaller belongs
1879 * @return_value: a #GValue, which can store the returned string
1880 * @n_param_values: 3
1881 * @param_values: a #GValue array holding instance, arg1 and arg2
1882 * @invocation_hint: the invocation hint given as the last argument
1883 * to g_closure_invoke()
1884 * @marshal_data: additional data specified when registering the marshaller
1886 * A marshaller for a #GCClosure with a callback of type
1887 * <literal>gboolean (*callback) (gpointer instance, GBoxed *arg1, GBoxed *arg2, gpointer user_data)</literal>.