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 #GValues 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:
75 * - Closures allow the callee to get the types of the callback parameters,
76 * which means that language bindings don't have to write individual glue
77 * for each callback type.
79 * - The reference counting of #GClosure makes it easy to handle reentrancy
80 * right; if a callback is removed while it is being invoked, the closure
81 * and its parameters won't be freed until the invocation finishes.
83 * - g_closure_invalidate() and invalidation notifiers allow callbacks to be
84 * automatically removed when the objects they point to go away.
87 #define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
88 #define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
89 #define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
90 #define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
91 #define CLOSURE_N_MFUNCS(cl) (((cl)->n_guards << 1L))
92 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
93 #define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
94 (cl)->n_fnotifiers + \
102 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
104 ClosureInt *cunion = (ClosureInt*) _closure; \
105 gint new_int, old_int, success; \
109 tmp.vint = old_int = cunion->vint; \
110 _SET_OLD tmp.closure._field; \
111 tmp.closure._field _OP _value; \
112 _SET_NEW tmp.closure._field; \
113 new_int = tmp.vint; \
114 success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int); \
116 while (!success && _must_set); \
119 #define SWAP(_closure, _field, _value, _oldv) CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =, (void) )
120 #define SET(_closure, _field, _value) CHANGE_FIELD (_closure, _field, =, _value, TRUE, (void), (void) )
121 #define INC(_closure, _field) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), (void) )
122 #define INC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), *(_newv) = )
123 #define DEC(_closure, _field) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), (void) )
124 #define DEC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), *(_newv) = )
126 #if 0 /* for non-thread-safe closures */
127 #define SWAP(cl,f,v,o) (void) (*(o) = cl->f, cl->f = v)
128 #define SET(cl,f,v) (void) (cl->f = v)
129 #define INC(cl,f) (void) (cl->f += 1)
130 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
131 #define DEC(cl,f) (void) (cl->f -= 1)
132 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
143 /* --- functions --- */
145 * g_closure_new_simple:
146 * @sizeof_closure: the size of the structure to allocate, must be at least
147 * <literal>sizeof (GClosure)</literal>
148 * @data: data to store in the @data field of the newly allocated #GClosure
150 * Allocates a struct of the given size and initializes the initial
151 * part as a #GClosure. This function is mainly useful when
152 * implementing new types of closures.
154 * |[<!-- language="C" -->
155 * typedef struct _MyClosure MyClosure;
159 * /* extra data goes here */
163 * my_closure_finalize (gpointer notify_data,
166 * MyClosure *my_closure = (MyClosure *)closure;
168 * /* free extra data here */
171 * MyClosure *my_closure_new (gpointer data)
174 * MyClosure *my_closure;
176 * closure = g_closure_new_simple (sizeof (MyClosure), data);
177 * my_closure = (MyClosure *) closure;
179 * /* initialize extra data here */
181 * g_closure_add_finalize_notifier (closure, notify_data,
182 * my_closure_finalize);
187 * Returns: (transfer full): a newly allocated #GClosure
190 g_closure_new_simple (guint sizeof_closure,
193 GRealClosure *real_closure;
196 g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
197 sizeof_closure = sizeof_closure + sizeof (GRealClosure) - sizeof (GClosure);
199 real_closure = g_malloc0 (sizeof_closure);
200 closure = &real_closure->closure;
201 SET (closure, ref_count, 1);
202 SET (closure, floating, TRUE);
203 closure->data = data;
209 closure_invoke_notifiers (GClosure *closure,
213 * n_guards n_guards n_fnotif. n_inotifiers
214 * ->[[pre_guards][post_guards][fnotifiers][inotifiers]]
216 * CLOSURE_N_MFUNCS(cl) = n_guards + n_guards;
217 * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
219 * constrains/catches:
220 * - closure->notifiers may be reloacted during callback
221 * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
222 * - i.e. callbacks can be removed/added during invocation
223 * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
224 * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
225 * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
226 * + none of the callbacks can cause recursion
227 * + closure->n_inotifiers is const 0 during FNOTIFY
231 GClosureNotifyData *ndata;
234 while (closure->n_fnotifiers)
237 DEC_ASSIGN (closure, n_fnotifiers, &n);
239 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
240 closure->marshal = (GClosureMarshal) ndata->notify;
241 closure->data = ndata->data;
242 ndata->notify (ndata->data, closure);
244 closure->marshal = NULL;
245 closure->data = NULL;
248 SET (closure, in_inotify, TRUE);
249 while (closure->n_inotifiers)
252 DEC_ASSIGN (closure, n_inotifiers, &n);
254 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
255 closure->marshal = (GClosureMarshal) ndata->notify;
256 closure->data = ndata->data;
257 ndata->notify (ndata->data, closure);
259 closure->marshal = NULL;
260 closure->data = NULL;
261 SET (closure, in_inotify, FALSE);
264 i = closure->n_guards;
268 ndata = closure->notifiers + offs + i;
269 ndata->notify (ndata->data, closure);
273 i = closure->n_guards;
277 ndata = closure->notifiers + offs + i;
278 ndata->notify (ndata->data, closure);
285 g_closure_set_meta_va_marshal (GClosure *closure,
286 GVaClosureMarshal va_meta_marshal)
288 GRealClosure *real_closure;
290 g_return_if_fail (closure != NULL);
291 g_return_if_fail (va_meta_marshal != NULL);
292 g_return_if_fail (closure->is_invalid == FALSE);
293 g_return_if_fail (closure->in_marshal == FALSE);
295 real_closure = G_REAL_CLOSURE (closure);
297 g_return_if_fail (real_closure->meta_marshal != NULL);
299 real_closure->va_meta_marshal = va_meta_marshal;
303 * g_closure_set_meta_marshal: (skip)
304 * @closure: a #GClosure
305 * @marshal_data: context-dependent data to pass to @meta_marshal
306 * @meta_marshal: a #GClosureMarshal function
308 * Sets the meta marshaller of @closure. A meta marshaller wraps
309 * @closure->marshal and modifies the way it is called in some
310 * fashion. The most common use of this facility is for C callbacks.
311 * The same marshallers (generated by <link
312 * linkend="glib-genmarshal">glib-genmarshal</link>) are used
313 * everywhere, but the way that we get the callback function
314 * differs. In most cases we want to use @closure->callback, but in
315 * other cases we want to use some different technique to retrieve the
318 * For example, class closures for signals (see
319 * g_signal_type_cclosure_new()) retrieve the callback function from a
320 * fixed offset in the class structure. The meta marshaller retrieves
321 * the right callback and passes it to the marshaller as the
322 * @marshal_data argument.
325 g_closure_set_meta_marshal (GClosure *closure,
326 gpointer marshal_data,
327 GClosureMarshal meta_marshal)
329 GRealClosure *real_closure;
331 g_return_if_fail (closure != NULL);
332 g_return_if_fail (meta_marshal != NULL);
333 g_return_if_fail (closure->is_invalid == FALSE);
334 g_return_if_fail (closure->in_marshal == FALSE);
336 real_closure = G_REAL_CLOSURE (closure);
338 g_return_if_fail (real_closure->meta_marshal == NULL);
340 real_closure->meta_marshal = meta_marshal;
341 real_closure->meta_marshal_data = marshal_data;
345 * g_closure_add_marshal_guards: (skip)
346 * @closure: a #GClosure
347 * @pre_marshal_data: data to pass to @pre_marshal_notify
348 * @pre_marshal_notify: a function to call before the closure callback
349 * @post_marshal_data: data to pass to @post_marshal_notify
350 * @post_marshal_notify: a function to call after the closure callback
352 * Adds a pair of notifiers which get invoked before and after the
353 * closure callback, respectively. This is typically used to protect
354 * the extra arguments for the duration of the callback. See
355 * g_object_watch_closure() for an example of marshal guards.
358 g_closure_add_marshal_guards (GClosure *closure,
359 gpointer pre_marshal_data,
360 GClosureNotify pre_marshal_notify,
361 gpointer post_marshal_data,
362 GClosureNotify post_marshal_notify)
366 g_return_if_fail (closure != NULL);
367 g_return_if_fail (pre_marshal_notify != NULL);
368 g_return_if_fail (post_marshal_notify != NULL);
369 g_return_if_fail (closure->is_invalid == FALSE);
370 g_return_if_fail (closure->in_marshal == FALSE);
371 g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
373 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
374 if (closure->n_inotifiers)
375 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
376 closure->n_fnotifiers +
377 closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
378 closure->n_fnotifiers + 0)];
379 if (closure->n_inotifiers > 1)
380 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
381 closure->n_fnotifiers +
382 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
383 closure->n_fnotifiers + 1)];
384 if (closure->n_fnotifiers)
385 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
386 closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
387 if (closure->n_fnotifiers > 1)
388 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
389 closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
390 if (closure->n_guards)
391 closure->notifiers[(closure->n_guards +
392 closure->n_guards + 1)] = closure->notifiers[closure->n_guards];
393 i = closure->n_guards;
394 closure->notifiers[i].data = pre_marshal_data;
395 closure->notifiers[i].notify = pre_marshal_notify;
396 closure->notifiers[i + 1].data = post_marshal_data;
397 closure->notifiers[i + 1].notify = post_marshal_notify;
398 INC (closure, n_guards);
402 * g_closure_add_finalize_notifier: (skip)
403 * @closure: a #GClosure
404 * @notify_data: data to pass to @notify_func
405 * @notify_func: the callback function to register
407 * Registers a finalization notifier which will be called when the
408 * reference count of @closure goes down to 0. Multiple finalization
409 * notifiers on a single closure are invoked in unspecified order. If
410 * a single call to g_closure_unref() results in the closure being
411 * both invalidated and finalized, then the invalidate notifiers will
412 * be run before the finalize notifiers.
415 g_closure_add_finalize_notifier (GClosure *closure,
416 gpointer notify_data,
417 GClosureNotify notify_func)
421 g_return_if_fail (closure != NULL);
422 g_return_if_fail (notify_func != NULL);
423 g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
425 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
426 if (closure->n_inotifiers)
427 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
428 closure->n_fnotifiers +
429 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
430 closure->n_fnotifiers + 0)];
431 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
432 closure->notifiers[i].data = notify_data;
433 closure->notifiers[i].notify = notify_func;
434 INC (closure, n_fnotifiers);
438 * g_closure_add_invalidate_notifier: (skip)
439 * @closure: a #GClosure
440 * @notify_data: data to pass to @notify_func
441 * @notify_func: the callback function to register
443 * Registers an invalidation notifier which will be called when the
444 * @closure is invalidated with g_closure_invalidate(). Invalidation
445 * notifiers are invoked before finalization notifiers, in an
449 g_closure_add_invalidate_notifier (GClosure *closure,
450 gpointer notify_data,
451 GClosureNotify notify_func)
455 g_return_if_fail (closure != NULL);
456 g_return_if_fail (notify_func != NULL);
457 g_return_if_fail (closure->is_invalid == FALSE);
458 g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
460 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
461 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
462 closure->notifiers[i].data = notify_data;
463 closure->notifiers[i].notify = notify_func;
464 INC (closure, n_inotifiers);
467 static inline gboolean
468 closure_try_remove_inotify (GClosure *closure,
469 gpointer notify_data,
470 GClosureNotify notify_func)
472 GClosureNotifyData *ndata, *nlast;
474 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
475 for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
476 if (ndata->notify == notify_func && ndata->data == notify_data)
478 DEC (closure, n_inotifiers);
487 static inline gboolean
488 closure_try_remove_fnotify (GClosure *closure,
489 gpointer notify_data,
490 GClosureNotify notify_func)
492 GClosureNotifyData *ndata, *nlast;
494 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
495 for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
496 if (ndata->notify == notify_func && ndata->data == notify_data)
498 DEC (closure, n_fnotifiers);
501 if (closure->n_inotifiers)
502 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
503 closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
504 closure->n_fnotifiers +
505 closure->n_inotifiers)];
513 * @closure: #GClosure to increment the reference count on
515 * Increments the reference count on a closure to force it staying
516 * alive while the caller holds a pointer to it.
518 * Returns: (transfer none): The @closure passed in, for convenience
521 g_closure_ref (GClosure *closure)
524 g_return_val_if_fail (closure != NULL, NULL);
525 g_return_val_if_fail (closure->ref_count > 0, NULL);
526 g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
528 INC_ASSIGN (closure, ref_count, &new_ref_count);
529 g_return_val_if_fail (new_ref_count > 1, NULL);
535 * g_closure_invalidate:
536 * @closure: GClosure to invalidate
538 * Sets a flag on the closure to indicate that its calling
539 * environment has become invalid, and thus causes any future
540 * invocations of g_closure_invoke() on this @closure to be
541 * ignored. Also, invalidation notifiers installed on the closure will
542 * be called at this point. Note that unless you are holding a
543 * reference to the closure yourself, the invalidation notifiers may
544 * unref the closure and cause it to be destroyed, so if you need to
545 * access the closure after calling g_closure_invalidate(), make sure
546 * that you've previously called g_closure_ref().
548 * Note that g_closure_invalidate() will also be called when the
549 * reference count of a closure drops to zero (unless it has already
550 * been invalidated before).
553 g_closure_invalidate (GClosure *closure)
555 g_return_if_fail (closure != NULL);
557 if (!closure->is_invalid)
559 gboolean was_invalid;
560 g_closure_ref (closure); /* preserve floating flag */
561 SWAP (closure, is_invalid, TRUE, &was_invalid);
562 /* invalidate only once */
564 closure_invoke_notifiers (closure, INOTIFY);
565 g_closure_unref (closure);
571 * @closure: #GClosure to decrement the reference count on
573 * Decrements the reference count of a closure after it was previously
574 * incremented by the same caller. If no other callers are using the
575 * closure, then the closure will be destroyed and freed.
578 g_closure_unref (GClosure *closure)
582 g_return_if_fail (closure != NULL);
583 g_return_if_fail (closure->ref_count > 0);
585 if (closure->ref_count == 1) /* last unref, invalidate first */
586 g_closure_invalidate (closure);
588 DEC_ASSIGN (closure, ref_count, &new_ref_count);
590 if (new_ref_count == 0)
592 closure_invoke_notifiers (closure, FNOTIFY);
593 g_free (closure->notifiers);
594 g_free (G_REAL_CLOSURE (closure));
600 * @closure: #GClosure to decrement the initial reference count on, if it's
603 * Takes over the initial ownership of a closure. Each closure is
604 * initially created in a "floating" state, which means that the initial
605 * reference count is not owned by any caller. g_closure_sink() checks
606 * to see if the object is still floating, and if so, unsets the
607 * floating state and decreases the reference count. If the closure
608 * is not floating, g_closure_sink() does nothing. The reason for the
609 * existence of the floating state is to prevent cumbersome code
611 * |[<!-- language="C" -->
612 * closure = g_cclosure_new (cb_func, cb_data);
613 * g_source_set_closure (source, closure);
614 * g_closure_unref (closure); /* GObject doesn't really need this */
616 * Because g_source_set_closure() (and similar functions) take ownership of the
617 * initial reference count, if it is unowned, we instead can write:
618 * |[<!-- language="C" -->
619 * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
622 * Generally, this function is used together with g_closure_ref(). Ane example
623 * of storing a closure for later notification looks like:
624 * |[<!-- language="C" -->
625 * static GClosure *notify_closure = NULL;
627 * foo_notify_set_closure (GClosure *closure)
629 * if (notify_closure)
630 * g_closure_unref (notify_closure);
631 * notify_closure = closure;
632 * if (notify_closure)
634 * g_closure_ref (notify_closure);
635 * g_closure_sink (notify_closure);
640 * Because g_closure_sink() may decrement the reference count of a closure
641 * (if it hasn't been called on @closure yet) just like g_closure_unref(),
642 * g_closure_ref() should be called prior to this function.
645 g_closure_sink (GClosure *closure)
647 g_return_if_fail (closure != NULL);
648 g_return_if_fail (closure->ref_count > 0);
650 /* floating is basically a kludge to avoid creating closures
651 * with a ref_count of 0. so the initial ref_count a closure has
652 * is unowned. with invoking g_closure_sink() code may
653 * indicate that it takes over that intiial ref_count.
655 if (closure->floating)
657 gboolean was_floating;
658 SWAP (closure, floating, FALSE, &was_floating);
659 /* unref floating flag only once */
661 g_closure_unref (closure);
666 * g_closure_remove_invalidate_notifier: (skip)
667 * @closure: a #GClosure
668 * @notify_data: data which was passed to g_closure_add_invalidate_notifier()
669 * when registering @notify_func
670 * @notify_func: the callback function to remove
672 * Removes an invalidation notifier.
674 * Notice that notifiers are automatically removed after they are run.
677 g_closure_remove_invalidate_notifier (GClosure *closure,
678 gpointer notify_data,
679 GClosureNotify notify_func)
681 g_return_if_fail (closure != NULL);
682 g_return_if_fail (notify_func != NULL);
684 if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while it's called */
685 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
686 closure->data == notify_data)
687 closure->marshal = NULL;
688 else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
689 g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
690 notify_func, notify_data);
694 * g_closure_remove_finalize_notifier: (skip)
695 * @closure: a #GClosure
696 * @notify_data: data which was passed to g_closure_add_finalize_notifier()
697 * when registering @notify_func
698 * @notify_func: the callback function to remove
700 * Removes a finalization notifier.
702 * Notice that notifiers are automatically removed after they are run.
705 g_closure_remove_finalize_notifier (GClosure *closure,
706 gpointer notify_data,
707 GClosureNotify notify_func)
709 g_return_if_fail (closure != NULL);
710 g_return_if_fail (notify_func != NULL);
712 if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while it's called */
713 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
714 closure->data == notify_data)
715 closure->marshal = NULL;
716 else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
717 g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
718 notify_func, notify_data);
723 * @closure: a #GClosure
724 * @return_value: (allow-none): a #GValue to store the return
725 * value. May be %NULL if the callback of @closure
726 * doesn't return a value.
727 * @n_param_values: the length of the @param_values array
728 * @param_values: (array length=n_param_values): an array of
729 * #GValues holding the arguments on which to
730 * invoke the callback of @closure
731 * @invocation_hint: (allow-none): a context-dependent invocation hint
733 * Invokes the closure, i.e. executes the callback represented by the @closure.
736 g_closure_invoke (GClosure *closure,
737 GValue /*out*/ *return_value,
738 guint n_param_values,
739 const GValue *param_values,
740 gpointer invocation_hint)
742 GRealClosure *real_closure;
744 g_return_if_fail (closure != NULL);
746 real_closure = G_REAL_CLOSURE (closure);
748 g_closure_ref (closure); /* preserve floating flag */
749 if (!closure->is_invalid)
751 GClosureMarshal marshal;
752 gpointer marshal_data;
753 gboolean in_marshal = closure->in_marshal;
755 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
757 SET (closure, in_marshal, TRUE);
758 if (real_closure->meta_marshal)
760 marshal_data = real_closure->meta_marshal_data;
761 marshal = real_closure->meta_marshal;
766 marshal = closure->marshal;
769 closure_invoke_notifiers (closure, PRE_NOTIFY);
772 n_param_values, param_values,
776 closure_invoke_notifiers (closure, POST_NOTIFY);
777 SET (closure, in_marshal, in_marshal);
779 g_closure_unref (closure);
783 _g_closure_supports_invoke_va (GClosure *closure)
785 GRealClosure *real_closure;
787 g_return_val_if_fail (closure != NULL, FALSE);
789 real_closure = G_REAL_CLOSURE (closure);
792 real_closure->va_marshal != NULL &&
793 (real_closure->meta_marshal == NULL ||
794 real_closure->va_meta_marshal != NULL);
798 _g_closure_invoke_va (GClosure *closure,
799 GValue /*out*/ *return_value,
805 GRealClosure *real_closure;
807 g_return_if_fail (closure != NULL);
809 real_closure = G_REAL_CLOSURE (closure);
811 g_closure_ref (closure); /* preserve floating flag */
812 if (!closure->is_invalid)
814 GVaClosureMarshal marshal;
815 gpointer marshal_data;
816 gboolean in_marshal = closure->in_marshal;
818 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
820 SET (closure, in_marshal, TRUE);
821 if (real_closure->va_meta_marshal)
823 marshal_data = real_closure->meta_marshal_data;
824 marshal = real_closure->va_meta_marshal;
829 marshal = real_closure->va_marshal;
832 closure_invoke_notifiers (closure, PRE_NOTIFY);
837 n_params, param_types);
839 closure_invoke_notifiers (closure, POST_NOTIFY);
840 SET (closure, in_marshal, in_marshal);
842 g_closure_unref (closure);
847 * g_closure_set_marshal: (skip)
848 * @closure: a #GClosure
849 * @marshal: a #GClosureMarshal function
851 * Sets the marshaller of @closure. The <literal>marshal_data</literal>
852 * of @marshal provides a way for a meta marshaller to provide additional
853 * information to the marshaller. (See g_closure_set_meta_marshal().) For
854 * GObject's C predefined marshallers (the g_cclosure_marshal_*()
855 * functions), what it provides is a callback function to use instead of
856 * @closure->callback.
859 g_closure_set_marshal (GClosure *closure,
860 GClosureMarshal marshal)
862 g_return_if_fail (closure != NULL);
863 g_return_if_fail (marshal != NULL);
865 if (closure->marshal && closure->marshal != marshal)
866 g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
867 closure->marshal, marshal);
869 closure->marshal = marshal;
873 _g_closure_set_va_marshal (GClosure *closure,
874 GVaClosureMarshal marshal)
876 GRealClosure *real_closure;
878 g_return_if_fail (closure != NULL);
879 g_return_if_fail (marshal != NULL);
881 real_closure = G_REAL_CLOSURE (closure);
883 if (real_closure->va_marshal && real_closure->va_marshal != marshal)
884 g_warning ("attempt to override closure->va_marshal (%p) with new marshal (%p)",
885 real_closure->va_marshal, marshal);
887 real_closure->va_marshal = marshal;
891 * g_cclosure_new: (skip)
892 * @callback_func: the function to invoke
893 * @user_data: user data to pass to @callback_func
894 * @destroy_data: destroy notify to be called when @user_data is no longer used
896 * Creates a new closure which invokes @callback_func with @user_data as
897 * the last parameter.
899 * Returns: a new #GCClosure
902 g_cclosure_new (GCallback callback_func,
904 GClosureNotify destroy_data)
908 g_return_val_if_fail (callback_func != NULL, NULL);
910 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
912 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
913 ((GCClosure*) closure)->callback = (gpointer) callback_func;
919 * g_cclosure_new_swap: (skip)
920 * @callback_func: the function to invoke
921 * @user_data: user data to pass to @callback_func
922 * @destroy_data: destroy notify to be called when @user_data is no longer used
924 * Creates a new closure which invokes @callback_func with @user_data as
925 * the first parameter.
927 * Returns: (transfer full): a new #GCClosure
930 g_cclosure_new_swap (GCallback callback_func,
932 GClosureNotify destroy_data)
936 g_return_val_if_fail (callback_func != NULL, NULL);
938 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
940 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
941 ((GCClosure*) closure)->callback = (gpointer) callback_func;
942 SET (closure, derivative_flag, TRUE);
948 g_type_class_meta_marshal (GClosure *closure,
949 GValue /*out*/ *return_value,
950 guint n_param_values,
951 const GValue *param_values,
952 gpointer invocation_hint,
953 gpointer marshal_data)
957 /* GType itype = (GType) closure->data; */
958 guint offset = GPOINTER_TO_UINT (marshal_data);
960 class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
961 callback = G_STRUCT_MEMBER (gpointer, class, offset);
963 closure->marshal (closure,
965 n_param_values, param_values,
971 g_type_class_meta_marshalv (GClosure *closure,
972 GValue *return_value,
975 gpointer marshal_data,
979 GRealClosure *real_closure;
982 /* GType itype = (GType) closure->data; */
983 guint offset = GPOINTER_TO_UINT (marshal_data);
985 real_closure = G_REAL_CLOSURE (closure);
987 class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
988 callback = G_STRUCT_MEMBER (gpointer, class, offset);
990 real_closure->va_marshal (closure,
999 g_type_iface_meta_marshal (GClosure *closure,
1000 GValue /*out*/ *return_value,
1001 guint n_param_values,
1002 const GValue *param_values,
1003 gpointer invocation_hint,
1004 gpointer marshal_data)
1008 GType itype = (GType) closure->data;
1009 guint offset = GPOINTER_TO_UINT (marshal_data);
1011 class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
1012 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1014 closure->marshal (closure,
1016 n_param_values, param_values,
1022 _g_closure_is_void (GClosure *closure,
1025 GRealClosure *real_closure;
1031 if (closure->is_invalid)
1034 real_closure = G_REAL_CLOSURE (closure);
1036 if (real_closure->meta_marshal == g_type_iface_meta_marshal)
1038 itype = (GType) closure->data;
1039 offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
1041 class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
1042 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1043 return callback == NULL;
1045 else if (real_closure->meta_marshal == g_type_class_meta_marshal)
1047 offset = GPOINTER_TO_UINT (real_closure->meta_marshal_data);
1049 class = G_TYPE_INSTANCE_GET_CLASS (instance, itype, GTypeClass);
1050 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1051 return callback == NULL;
1058 g_type_iface_meta_marshalv (GClosure *closure,
1059 GValue *return_value,
1062 gpointer marshal_data,
1066 GRealClosure *real_closure;
1069 GType itype = (GType) closure->data;
1070 guint offset = GPOINTER_TO_UINT (marshal_data);
1072 real_closure = G_REAL_CLOSURE (closure);
1074 class = G_TYPE_INSTANCE_GET_INTERFACE (instance, itype, GTypeClass);
1075 callback = G_STRUCT_MEMBER (gpointer, class, offset);
1077 real_closure->va_marshal (closure,
1086 * g_signal_type_cclosure_new:
1087 * @itype: the #GType identifier of an interface or classed type
1088 * @struct_offset: the offset of the member function of @itype's class
1089 * structure which is to be invoked by the new closure
1091 * Creates a new closure which invokes the function found at the offset
1092 * @struct_offset in the class structure of the interface or classed type
1093 * identified by @itype.
1095 * Returns: a new #GCClosure
1098 g_signal_type_cclosure_new (GType itype,
1099 guint struct_offset)
1103 g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
1104 g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
1106 closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
1107 if (G_TYPE_IS_INTERFACE (itype))
1109 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
1110 g_closure_set_meta_va_marshal (closure, g_type_iface_meta_marshalv);
1114 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
1115 g_closure_set_meta_va_marshal (closure, g_type_class_meta_marshalv);
1122 value_to_ffi_type (const GValue *gvalue,
1125 gboolean *tmpval_used)
1127 ffi_type *rettype = NULL;
1128 GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
1129 g_assert (type != G_TYPE_INVALID);
1133 g_assert (tmpval_used != NULL);
1134 *tmpval_used = FALSE;
1139 case G_TYPE_BOOLEAN:
1142 rettype = &ffi_type_sint;
1143 *value = (gpointer)&(gvalue->data[0].v_int);
1146 /* enums are stored in v_long even though they are integers, which makes
1147 * marshalling through libffi somewhat complicated. They need to be
1148 * marshalled as signed ints, but we need to use a temporary int sized
1149 * value to pass to libffi otherwise it'll pull the wrong value on
1150 * BE machines with 32-bit integers when treating v_long as 32-bit int.
1152 g_assert (enum_tmpval != NULL);
1153 rettype = &ffi_type_sint;
1154 *enum_tmpval = g_value_get_enum (gvalue);
1155 *value = enum_tmpval;
1156 *tmpval_used = TRUE;
1161 rettype = &ffi_type_uint;
1162 *value = (gpointer)&(gvalue->data[0].v_uint);
1168 case G_TYPE_POINTER:
1169 case G_TYPE_INTERFACE:
1170 case G_TYPE_VARIANT:
1171 rettype = &ffi_type_pointer;
1172 *value = (gpointer)&(gvalue->data[0].v_pointer);
1175 rettype = &ffi_type_float;
1176 *value = (gpointer)&(gvalue->data[0].v_float);
1179 rettype = &ffi_type_double;
1180 *value = (gpointer)&(gvalue->data[0].v_double);
1183 rettype = &ffi_type_slong;
1184 *value = (gpointer)&(gvalue->data[0].v_long);
1187 rettype = &ffi_type_ulong;
1188 *value = (gpointer)&(gvalue->data[0].v_ulong);
1191 rettype = &ffi_type_sint64;
1192 *value = (gpointer)&(gvalue->data[0].v_int64);
1195 rettype = &ffi_type_uint64;
1196 *value = (gpointer)&(gvalue->data[0].v_uint64);
1199 rettype = &ffi_type_pointer;
1201 g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1208 value_from_ffi_type (GValue *gvalue, gpointer *value)
1210 ffi_arg *int_val = (ffi_arg*) value;
1212 switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
1215 g_value_set_int (gvalue, (gint) *int_val);
1218 g_value_set_float (gvalue, *(gfloat*)value);
1221 g_value_set_double (gvalue, *(gdouble*)value);
1223 case G_TYPE_BOOLEAN:
1224 g_value_set_boolean (gvalue, (gboolean) *int_val);
1227 g_value_take_string (gvalue, *(gchar**)value);
1230 g_value_set_schar (gvalue, (gint8) *int_val);
1233 g_value_set_uchar (gvalue, (guchar) *int_val);
1236 g_value_set_uint (gvalue, (guint) *int_val);
1238 case G_TYPE_POINTER:
1239 g_value_set_pointer (gvalue, *(gpointer*)value);
1242 g_value_set_long (gvalue, (glong) *int_val);
1245 g_value_set_ulong (gvalue, (gulong) *int_val);
1248 g_value_set_int64 (gvalue, (gint64) *int_val);
1251 g_value_set_uint64 (gvalue, (guint64) *int_val);
1254 g_value_take_boxed (gvalue, *(gpointer*)value);
1257 g_value_set_enum (gvalue, (gint) *int_val);
1260 g_value_set_flags (gvalue, (guint) *int_val);
1263 g_value_take_param (gvalue, *(gpointer*)value);
1266 g_value_take_object (gvalue, *(gpointer*)value);
1268 case G_TYPE_VARIANT:
1269 g_value_take_variant (gvalue, *(gpointer*)value);
1272 g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
1273 g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
1290 va_to_ffi_type (GType gtype,
1292 va_arg_storage *storage)
1294 ffi_type *rettype = NULL;
1295 GType type = g_type_fundamental (gtype);
1296 g_assert (type != G_TYPE_INVALID);
1300 case G_TYPE_BOOLEAN:
1304 rettype = &ffi_type_sint;
1305 storage->_gint = va_arg (*va, gint);
1310 rettype = &ffi_type_uint;
1311 storage->_guint = va_arg (*va, guint);
1317 case G_TYPE_POINTER:
1318 case G_TYPE_INTERFACE:
1319 case G_TYPE_VARIANT:
1320 rettype = &ffi_type_pointer;
1321 storage->_gpointer = va_arg (*va, gpointer);
1324 /* Float args are passed as doubles in varargs */
1325 rettype = &ffi_type_float;
1326 storage->_float = (float)va_arg (*va, double);
1329 rettype = &ffi_type_double;
1330 storage->_double = va_arg (*va, double);
1333 rettype = &ffi_type_slong;
1334 storage->_glong = va_arg (*va, glong);
1337 rettype = &ffi_type_ulong;
1338 storage->_gulong = va_arg (*va, gulong);
1341 rettype = &ffi_type_sint64;
1342 storage->_gint64 = va_arg (*va, gint64);
1345 rettype = &ffi_type_uint64;
1346 storage->_guint64 = va_arg (*va, guint64);
1349 rettype = &ffi_type_pointer;
1350 storage->_guint64 = 0;
1351 g_warning ("va_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1358 * g_cclosure_marshal_generic:
1359 * @closure: A #GClosure.
1360 * @return_gvalue: A #GValue to store the return value. May be %NULL
1361 * if the callback of closure doesn't return a value.
1362 * @n_param_values: The length of the @param_values array.
1363 * @param_values: An array of #GValues holding the arguments
1364 * on which to invoke the callback of closure.
1365 * @invocation_hint: The invocation hint given as the last argument to
1366 * g_closure_invoke().
1367 * @marshal_data: Additional data specified when registering the
1368 * marshaller, see g_closure_set_marshal() and
1369 * g_closure_set_meta_marshal()
1371 * A generic marshaller function implemented via
1372 * [libffi](http://sourceware.org/libffi/).
1377 g_cclosure_marshal_generic (GClosure *closure,
1378 GValue *return_gvalue,
1379 guint n_param_values,
1380 const GValue *param_values,
1381 gpointer invocation_hint,
1382 gpointer marshal_data)
1391 GCClosure *cc = (GCClosure*) closure;
1393 gboolean tmpval_used = FALSE;
1395 enum_tmpval = g_alloca (sizeof (gint));
1396 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1398 rtype = value_to_ffi_type (return_gvalue, &rvalue, enum_tmpval, &tmpval_used);
1402 rtype = &ffi_type_void;
1405 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1407 n_args = n_param_values + 1;
1408 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1409 args = g_alloca (sizeof (gpointer) * n_args);
1412 enum_tmpval = g_alloca (sizeof (gint));
1414 if (G_CCLOSURE_SWAP_DATA (closure))
1416 atypes[n_args-1] = value_to_ffi_type (param_values + 0,
1420 atypes[0] = &ffi_type_pointer;
1421 args[0] = &closure->data;
1425 atypes[0] = value_to_ffi_type (param_values + 0,
1429 atypes[n_args-1] = &ffi_type_pointer;
1430 args[n_args-1] = &closure->data;
1433 for (i = 1; i < n_args - 1; i++)
1436 enum_tmpval = g_alloca (sizeof (gint));
1438 atypes[i] = value_to_ffi_type (param_values + i,
1444 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1447 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1449 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1450 value_from_ffi_type (return_gvalue, rvalue);
1454 g_cclosure_marshal_generic_va (GClosure *closure,
1455 GValue *return_value,
1458 gpointer marshal_data,
1467 va_arg_storage *storage;
1470 GCClosure *cc = (GCClosure*) closure;
1472 gboolean tmpval_used = FALSE;
1475 enum_tmpval = g_alloca (sizeof (gint));
1476 if (return_value && G_VALUE_TYPE (return_value))
1478 rtype = value_to_ffi_type (return_value, &rvalue, enum_tmpval, &tmpval_used);
1482 rtype = &ffi_type_void;
1485 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1487 n_args = n_params + 2;
1488 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1489 args = g_alloca (sizeof (gpointer) * n_args);
1490 storage = g_alloca (sizeof (va_arg_storage) * n_params);
1493 enum_tmpval = g_alloca (sizeof (gint));
1495 if (G_CCLOSURE_SWAP_DATA (closure))
1497 atypes[n_args-1] = &ffi_type_pointer;
1498 args[n_args-1] = &instance;
1499 atypes[0] = &ffi_type_pointer;
1500 args[0] = &closure->data;
1504 atypes[0] = &ffi_type_pointer;
1505 args[0] = &instance;
1506 atypes[n_args-1] = &ffi_type_pointer;
1507 args[n_args-1] = &closure->data;
1510 G_VA_COPY (args_copy, args_list);
1512 /* Box non-primitive arguments */
1513 for (i = 0; i < n_params; i++)
1515 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1516 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1518 atypes[i+1] = va_to_ffi_type (type,
1521 args[i+1] = &storage[i];
1523 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1525 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1526 storage[i]._gpointer = g_strdup (storage[i]._gpointer);
1527 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1528 storage[i]._gpointer = g_param_spec_ref (storage[i]._gpointer);
1529 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1530 storage[i]._gpointer = g_boxed_copy (type, storage[i]._gpointer);
1531 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1532 storage[i]._gpointer = g_variant_ref_sink (storage[i]._gpointer);
1534 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1535 storage[i]._gpointer = g_object_ref (storage[i]._gpointer);
1540 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1543 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1545 /* Unbox non-primitive arguments */
1546 for (i = 0; i < n_params; i++)
1548 GType type = param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE;
1549 GType fundamental = G_TYPE_FUNDAMENTAL (type);
1551 if ((param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE) == 0)
1553 if (fundamental == G_TYPE_STRING && storage[i]._gpointer != NULL)
1554 g_free (storage[i]._gpointer);
1555 else if (fundamental == G_TYPE_PARAM && storage[i]._gpointer != NULL)
1556 g_param_spec_unref (storage[i]._gpointer);
1557 else if (fundamental == G_TYPE_BOXED && storage[i]._gpointer != NULL)
1558 g_boxed_free (type, storage[i]._gpointer);
1559 else if (fundamental == G_TYPE_VARIANT && storage[i]._gpointer != NULL)
1560 g_variant_unref (storage[i]._gpointer);
1562 if (fundamental == G_TYPE_OBJECT && storage[i]._gpointer != NULL)
1563 g_object_unref (storage[i]._gpointer);
1566 if (return_value && G_VALUE_TYPE (return_value))
1567 value_from_ffi_type (return_value, rvalue);
1571 * g_cclosure_marshal_VOID__VOID:
1572 * @closure: the #GClosure to which the marshaller belongs
1573 * @return_value: ignored
1574 * @n_param_values: 1
1575 * @param_values: a #GValue array holding only the instance
1576 * @invocation_hint: the invocation hint given as the last argument
1577 * to g_closure_invoke()
1578 * @marshal_data: additional data specified when registering the marshaller
1580 * A marshaller for a #GCClosure with a callback of type
1581 * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
1585 * g_cclosure_marshal_VOID__BOOLEAN:
1586 * @closure: the #GClosure to which the marshaller belongs
1587 * @return_value: ignored
1588 * @n_param_values: 2
1589 * @param_values: a #GValue array holding the instance and the #gboolean parameter
1590 * @invocation_hint: the invocation hint given as the last argument
1591 * to g_closure_invoke()
1592 * @marshal_data: additional data specified when registering the marshaller
1594 * A marshaller for a #GCClosure with a callback of type
1595 * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
1599 * g_cclosure_marshal_VOID__CHAR:
1600 * @closure: the #GClosure to which the marshaller belongs
1601 * @return_value: ignored
1602 * @n_param_values: 2
1603 * @param_values: a #GValue array holding the instance and the #gchar parameter
1604 * @invocation_hint: the invocation hint given as the last argument
1605 * to g_closure_invoke()
1606 * @marshal_data: additional data specified when registering the marshaller
1608 * A marshaller for a #GCClosure with a callback of type
1609 * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
1613 * g_cclosure_marshal_VOID__UCHAR:
1614 * @closure: the #GClosure to which the marshaller belongs
1615 * @return_value: ignored
1616 * @n_param_values: 2
1617 * @param_values: a #GValue array holding the instance and the #guchar parameter
1618 * @invocation_hint: the invocation hint given as the last argument
1619 * to g_closure_invoke()
1620 * @marshal_data: additional data specified when registering the marshaller
1622 * A marshaller for a #GCClosure with a callback of type
1623 * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
1627 * g_cclosure_marshal_VOID__INT:
1628 * @closure: the #GClosure to which the marshaller belongs
1629 * @return_value: ignored
1630 * @n_param_values: 2
1631 * @param_values: a #GValue array holding the instance and the #gint parameter
1632 * @invocation_hint: the invocation hint given as the last argument
1633 * to g_closure_invoke()
1634 * @marshal_data: additional data specified when registering the marshaller
1636 * A marshaller for a #GCClosure with a callback of type
1637 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
1641 * g_cclosure_marshal_VOID__UINT:
1642 * @closure: the #GClosure to which the marshaller belongs
1643 * @return_value: ignored
1644 * @n_param_values: 2
1645 * @param_values: a #GValue array holding the instance and the #guint parameter
1646 * @invocation_hint: the invocation hint given as the last argument
1647 * to g_closure_invoke()
1648 * @marshal_data: additional data specified when registering the marshaller
1650 * A marshaller for a #GCClosure with a callback of type
1651 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
1655 * g_cclosure_marshal_VOID__LONG:
1656 * @closure: the #GClosure to which the marshaller belongs
1657 * @return_value: ignored
1658 * @n_param_values: 2
1659 * @param_values: a #GValue array holding the instance and the #glong parameter
1660 * @invocation_hint: the invocation hint given as the last argument
1661 * to g_closure_invoke()
1662 * @marshal_data: additional data specified when registering the marshaller
1664 * A marshaller for a #GCClosure with a callback of type
1665 * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1669 * g_cclosure_marshal_VOID__ULONG:
1670 * @closure: the #GClosure to which the marshaller belongs
1671 * @return_value: ignored
1672 * @n_param_values: 2
1673 * @param_values: a #GValue array holding the instance and the #gulong parameter
1674 * @invocation_hint: the invocation hint given as the last argument
1675 * to g_closure_invoke()
1676 * @marshal_data: additional data specified when registering the marshaller
1678 * A marshaller for a #GCClosure with a callback of type
1679 * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1683 * g_cclosure_marshal_VOID__ENUM:
1684 * @closure: the #GClosure to which the marshaller belongs
1685 * @return_value: ignored
1686 * @n_param_values: 2
1687 * @param_values: a #GValue array holding the instance and the enumeration parameter
1688 * @invocation_hint: the invocation hint given as the last argument
1689 * to g_closure_invoke()
1690 * @marshal_data: additional data specified when registering the marshaller
1692 * A marshaller for a #GCClosure with a callback of type
1693 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1697 * g_cclosure_marshal_VOID__FLAGS:
1698 * @closure: the #GClosure to which the marshaller belongs
1699 * @return_value: ignored
1700 * @n_param_values: 2
1701 * @param_values: a #GValue array holding the instance and the flags parameter
1702 * @invocation_hint: the invocation hint given as the last argument
1703 * to g_closure_invoke()
1704 * @marshal_data: additional data specified when registering the marshaller
1706 * A marshaller for a #GCClosure with a callback of type
1707 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1711 * g_cclosure_marshal_VOID__FLOAT:
1712 * @closure: the #GClosure to which the marshaller belongs
1713 * @return_value: ignored
1714 * @n_param_values: 2
1715 * @param_values: a #GValue array holding the instance and the #gfloat parameter
1716 * @invocation_hint: the invocation hint given as the last argument
1717 * to g_closure_invoke()
1718 * @marshal_data: additional data specified when registering the marshaller
1720 * A marshaller for a #GCClosure with a callback of type
1721 * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1725 * g_cclosure_marshal_VOID__DOUBLE:
1726 * @closure: the #GClosure to which the marshaller belongs
1727 * @return_value: ignored
1728 * @n_param_values: 2
1729 * @param_values: a #GValue array holding the instance and the #gdouble parameter
1730 * @invocation_hint: the invocation hint given as the last argument
1731 * to g_closure_invoke()
1732 * @marshal_data: additional data specified when registering the marshaller
1734 * A marshaller for a #GCClosure with a callback of type
1735 * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1739 * g_cclosure_marshal_VOID__STRING:
1740 * @closure: the #GClosure to which the marshaller belongs
1741 * @return_value: ignored
1742 * @n_param_values: 2
1743 * @param_values: a #GValue array holding the instance and the #gchar* parameter
1744 * @invocation_hint: the invocation hint given as the last argument
1745 * to g_closure_invoke()
1746 * @marshal_data: additional data specified when registering the marshaller
1748 * A marshaller for a #GCClosure with a callback of type
1749 * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1753 * g_cclosure_marshal_VOID__PARAM:
1754 * @closure: the #GClosure to which the marshaller belongs
1755 * @return_value: ignored
1756 * @n_param_values: 2
1757 * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1758 * @invocation_hint: the invocation hint given as the last argument
1759 * to g_closure_invoke()
1760 * @marshal_data: additional data specified when registering the marshaller
1762 * A marshaller for a #GCClosure with a callback of type
1763 * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1767 * g_cclosure_marshal_VOID__BOXED:
1768 * @closure: the #GClosure to which the marshaller belongs
1769 * @return_value: ignored
1770 * @n_param_values: 2
1771 * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1772 * @invocation_hint: the invocation hint given as the last argument
1773 * to g_closure_invoke()
1774 * @marshal_data: additional data specified when registering the marshaller
1776 * A marshaller for a #GCClosure with a callback of type
1777 * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1781 * g_cclosure_marshal_VOID__POINTER:
1782 * @closure: the #GClosure to which the marshaller belongs
1783 * @return_value: ignored
1784 * @n_param_values: 2
1785 * @param_values: a #GValue array holding the instance and the #gpointer parameter
1786 * @invocation_hint: the invocation hint given as the last argument
1787 * to g_closure_invoke()
1788 * @marshal_data: additional data specified when registering the marshaller
1790 * A marshaller for a #GCClosure with a callback of type
1791 * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1795 * g_cclosure_marshal_VOID__OBJECT:
1796 * @closure: the #GClosure to which the marshaller belongs
1797 * @return_value: ignored
1798 * @n_param_values: 2
1799 * @param_values: a #GValue array holding the instance and the #GObject* parameter
1800 * @invocation_hint: the invocation hint given as the last argument
1801 * to g_closure_invoke()
1802 * @marshal_data: additional data specified when registering the marshaller
1804 * A marshaller for a #GCClosure with a callback of type
1805 * <literal>void (*callback) (gpointer instance, GObject *arg1, gpointer user_data)</literal>.
1809 * g_cclosure_marshal_VOID__VARIANT:
1810 * @closure: the #GClosure to which the marshaller belongs
1811 * @return_value: ignored
1812 * @n_param_values: 2
1813 * @param_values: a #GValue array holding the instance and the #GVariant* parameter
1814 * @invocation_hint: the invocation hint given as the last argument
1815 * to g_closure_invoke()
1816 * @marshal_data: additional data specified when registering the marshaller
1818 * A marshaller for a #GCClosure with a callback of type
1819 * <literal>void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data)</literal>.
1825 * g_cclosure_marshal_VOID__UINT_POINTER:
1826 * @closure: the #GClosure to which the marshaller belongs
1827 * @return_value: ignored
1828 * @n_param_values: 3
1829 * @param_values: a #GValue array holding instance, arg1 and arg2
1830 * @invocation_hint: the invocation hint given as the last argument
1831 * to g_closure_invoke()
1832 * @marshal_data: additional data specified when registering the marshaller
1834 * A marshaller for a #GCClosure with a callback of type
1835 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1839 * g_cclosure_marshal_BOOLEAN__FLAGS:
1840 * @closure: the #GClosure to which the marshaller belongs
1841 * @return_value: a #GValue which can store the returned #gboolean
1842 * @n_param_values: 2
1843 * @param_values: a #GValue array holding instance and arg1
1844 * @invocation_hint: the invocation hint given as the last argument
1845 * to g_closure_invoke()
1846 * @marshal_data: additional data specified when registering the marshaller
1848 * A marshaller for a #GCClosure with a callback of type
1849 * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1850 * denotes a flags type.
1854 * g_cclosure_marshal_BOOL__FLAGS:
1856 * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1859 * g_cclosure_marshal_STRING__OBJECT_POINTER:
1860 * @closure: the #GClosure to which the marshaller belongs
1861 * @return_value: a #GValue, which can store the returned string
1862 * @n_param_values: 3
1863 * @param_values: a #GValue array holding instance, arg1 and arg2
1864 * @invocation_hint: the invocation hint given as the last argument
1865 * to g_closure_invoke()
1866 * @marshal_data: additional data specified when registering the marshaller
1868 * A marshaller for a #GCClosure with a callback of type
1869 * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1872 * g_cclosure_marshal_BOOLEAN__OBJECT_BOXED_BOXED:
1873 * @closure: the #GClosure to which the marshaller belongs
1874 * @return_value: a #GValue, which can store the returned string
1875 * @n_param_values: 3
1876 * @param_values: a #GValue array holding instance, arg1 and arg2
1877 * @invocation_hint: the invocation hint given as the last argument
1878 * to g_closure_invoke()
1879 * @marshal_data: additional data specified when registering the marshaller
1881 * A marshaller for a #GCClosure with a callback of type
1882 * <literal>gboolean (*callback) (gpointer instance, GBoxed *arg1, GBoxed *arg2, gpointer user_data)</literal>.