1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2000-2001 Red Hat, Inc.
3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * MT safe with regards to reference counting.
35 #include "gvaluetypes.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.
93 #define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
94 #define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
95 #define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
96 #define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
97 #define CLOSURE_N_MFUNCS(cl) ((cl)->meta_marshal + \
98 ((cl)->n_guards << 1L))
99 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
100 #define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
101 (cl)->n_fnotifiers + \
109 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
111 ClosureInt *cunion = (ClosureInt*) _closure; \
112 gint new_int, old_int, success; \
116 tmp.vint = old_int = cunion->vint; \
117 _SET_OLD tmp.closure._field; \
118 tmp.closure._field _OP _value; \
119 _SET_NEW tmp.closure._field; \
120 new_int = tmp.vint; \
121 success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int); \
123 while (!success && _must_set); \
126 #define SWAP(_closure, _field, _value, _oldv) CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =, (void) )
127 #define SET(_closure, _field, _value) CHANGE_FIELD (_closure, _field, =, _value, TRUE, (void), (void) )
128 #define INC(_closure, _field) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), (void) )
129 #define INC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), *(_newv) = )
130 #define DEC(_closure, _field) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), (void) )
131 #define DEC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), *(_newv) = )
133 #if 0 /* for non-thread-safe closures */
134 #define SWAP(cl,f,v,o) (void) (*(o) = cl->f, cl->f = v)
135 #define SET(cl,f,v) (void) (cl->f = v)
136 #define INC(cl,f) (void) (cl->f += 1)
137 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
138 #define DEC(cl,f) (void) (cl->f -= 1)
139 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
150 /* --- functions --- */
152 * g_closure_new_simple:
153 * @sizeof_closure: the size of the structure to allocate, must be at least
154 * <literal>sizeof (GClosure)</literal>
155 * @data: data to store in the @data field of the newly allocated #GClosure
157 * Allocates a struct of the given size and initializes the initial
158 * part as a #GClosure. This function is mainly useful when
159 * implementing new types of closures.
162 * typedef struct _MyClosure MyClosure;
166 * // extra data goes here
170 * my_closure_finalize (gpointer notify_data,
173 * MyClosure *my_closure = (MyClosure *)closure;
175 * // free extra data here
178 * MyClosure *my_closure_new (gpointer data)
181 * MyClosure *my_closure;
183 * closure = g_closure_new_simple (sizeof (MyClosure), data);
184 * my_closure = (MyClosure *) closure;
186 * // initialize extra data here
188 * g_closure_add_finalize_notifier (closure, notify_data,
189 * my_closure_finalize);
194 * Returns: (transfer full): a newly allocated #GClosure
197 g_closure_new_simple (guint sizeof_closure,
202 g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
204 closure = g_malloc0 (sizeof_closure);
205 SET (closure, ref_count, 1);
206 SET (closure, meta_marshal, 0);
207 SET (closure, n_guards, 0);
208 SET (closure, n_fnotifiers, 0);
209 SET (closure, n_inotifiers, 0);
210 SET (closure, in_inotify, FALSE);
211 SET (closure, floating, TRUE);
212 SET (closure, derivative_flag, 0);
213 SET (closure, in_marshal, FALSE);
214 SET (closure, is_invalid, FALSE);
215 closure->marshal = NULL;
216 closure->data = data;
217 closure->notifiers = NULL;
218 memset (G_STRUCT_MEMBER_P (closure, sizeof (*closure)), 0, sizeof_closure - sizeof (*closure));
224 closure_invoke_notifiers (GClosure *closure,
228 * meta_marshal n_guards n_guards n_fnotif. n_inotifiers
229 * ->[[meta_marshal][pre_guards][post_guards][fnotifiers][inotifiers]]
231 * CLOSURE_N_MFUNCS(cl) = meta_marshal + n_guards + n_guards;
232 * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
234 * constrains/catches:
235 * - closure->notifiers may be reloacted during callback
236 * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
237 * - i.e. callbacks can be removed/added during invocation
238 * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
239 * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
240 * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
241 * + closure->meta_marshal is const for all cases
242 * + none of the callbacks can cause recursion
243 * + closure->n_inotifiers is const 0 during FNOTIFY
247 GClosureNotifyData *ndata;
250 while (closure->n_fnotifiers)
253 DEC_ASSIGN (closure, n_fnotifiers, &n);
255 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
256 closure->marshal = (GClosureMarshal) ndata->notify;
257 closure->data = ndata->data;
258 ndata->notify (ndata->data, closure);
260 closure->marshal = NULL;
261 closure->data = NULL;
264 SET (closure, in_inotify, TRUE);
265 while (closure->n_inotifiers)
268 DEC_ASSIGN (closure, n_inotifiers, &n);
270 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
271 closure->marshal = (GClosureMarshal) ndata->notify;
272 closure->data = ndata->data;
273 ndata->notify (ndata->data, closure);
275 closure->marshal = NULL;
276 closure->data = NULL;
277 SET (closure, in_inotify, FALSE);
280 i = closure->n_guards;
281 offs = closure->meta_marshal;
284 ndata = closure->notifiers + offs + i;
285 ndata->notify (ndata->data, closure);
289 i = closure->n_guards;
290 offs = closure->meta_marshal + i;
293 ndata = closure->notifiers + offs + i;
294 ndata->notify (ndata->data, closure);
301 * g_closure_set_meta_marshal: (skip)
302 * @closure: a #GClosure
303 * @marshal_data: context-dependent data to pass to @meta_marshal
304 * @meta_marshal: a #GClosureMarshal function
306 * Sets the meta marshaller of @closure. A meta marshaller wraps
307 * @closure->marshal and modifies the way it is called in some
308 * fashion. The most common use of this facility is for C callbacks.
309 * The same marshallers (generated by <link
310 * linkend="glib-genmarshal">glib-genmarshal</link>) are used
311 * everywhere, but the way that we get the callback function
312 * differs. In most cases we want to use @closure->callback, but in
313 * other cases we want to use some different technique to retrieve the
316 * For example, class closures for signals (see
317 * g_signal_type_cclosure_new()) retrieve the callback function from a
318 * fixed offset in the class structure. The meta marshaller retrieves
319 * the right callback and passes it to the marshaller as the
320 * @marshal_data argument.
323 g_closure_set_meta_marshal (GClosure *closure,
324 gpointer marshal_data,
325 GClosureMarshal meta_marshal)
327 GClosureNotifyData *notifiers;
329 g_return_if_fail (closure != NULL);
330 g_return_if_fail (meta_marshal != NULL);
331 g_return_if_fail (closure->is_invalid == FALSE);
332 g_return_if_fail (closure->in_marshal == FALSE);
333 g_return_if_fail (closure->meta_marshal == 0);
335 notifiers = closure->notifiers;
336 closure->notifiers = g_renew (GClosureNotifyData, NULL, CLOSURE_N_NOTIFIERS (closure) + 1);
339 /* usually the meta marshal will be setup right after creation, so the
340 * g_memmove() should be rare-case scenario
342 g_memmove (closure->notifiers + 1, notifiers, CLOSURE_N_NOTIFIERS (closure) * sizeof (notifiers[0]));
345 closure->notifiers[0].data = marshal_data;
346 closure->notifiers[0].notify = (GClosureNotify) meta_marshal;
347 SET (closure, meta_marshal, 1);
351 * g_closure_add_marshal_guards: (skip)
352 * @closure: a #GClosure
353 * @pre_marshal_data: data to pass to @pre_marshal_notify
354 * @pre_marshal_notify: a function to call before the closure callback
355 * @post_marshal_data: data to pass to @post_marshal_notify
356 * @post_marshal_notify: a function to call after the closure callback
358 * Adds a pair of notifiers which get invoked before and after the
359 * closure callback, respectively. This is typically used to protect
360 * the extra arguments for the duration of the callback. See
361 * g_object_watch_closure() for an example of marshal guards.
364 g_closure_add_marshal_guards (GClosure *closure,
365 gpointer pre_marshal_data,
366 GClosureNotify pre_marshal_notify,
367 gpointer post_marshal_data,
368 GClosureNotify post_marshal_notify)
372 g_return_if_fail (closure != NULL);
373 g_return_if_fail (pre_marshal_notify != NULL);
374 g_return_if_fail (post_marshal_notify != NULL);
375 g_return_if_fail (closure->is_invalid == FALSE);
376 g_return_if_fail (closure->in_marshal == FALSE);
377 g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
379 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
380 if (closure->n_inotifiers)
381 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
382 closure->n_fnotifiers +
383 closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
384 closure->n_fnotifiers + 0)];
385 if (closure->n_inotifiers > 1)
386 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
387 closure->n_fnotifiers +
388 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
389 closure->n_fnotifiers + 1)];
390 if (closure->n_fnotifiers)
391 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
392 closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
393 if (closure->n_fnotifiers > 1)
394 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
395 closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
396 if (closure->n_guards)
397 closure->notifiers[(closure->meta_marshal +
399 closure->n_guards + 1)] = closure->notifiers[closure->meta_marshal + closure->n_guards];
400 i = closure->n_guards;
401 closure->notifiers[closure->meta_marshal + i].data = pre_marshal_data;
402 closure->notifiers[closure->meta_marshal + i].notify = pre_marshal_notify;
403 closure->notifiers[closure->meta_marshal + i + 1].data = post_marshal_data;
404 closure->notifiers[closure->meta_marshal + i + 1].notify = post_marshal_notify;
405 INC (closure, n_guards);
409 * g_closure_add_finalize_notifier: (skip)
410 * @closure: a #GClosure
411 * @notify_data: data to pass to @notify_func
412 * @notify_func: the callback function to register
414 * Registers a finalization notifier which will be called when the
415 * reference count of @closure goes down to 0. Multiple finalization
416 * notifiers on a single closure are invoked in unspecified order. If
417 * a single call to g_closure_unref() results in the closure being
418 * both invalidated and finalized, then the invalidate notifiers will
419 * be run before the finalize notifiers.
422 g_closure_add_finalize_notifier (GClosure *closure,
423 gpointer notify_data,
424 GClosureNotify notify_func)
428 g_return_if_fail (closure != NULL);
429 g_return_if_fail (notify_func != NULL);
430 g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
432 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
433 if (closure->n_inotifiers)
434 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
435 closure->n_fnotifiers +
436 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
437 closure->n_fnotifiers + 0)];
438 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
439 closure->notifiers[i].data = notify_data;
440 closure->notifiers[i].notify = notify_func;
441 INC (closure, n_fnotifiers);
445 * g_closure_add_invalidate_notifier: (skip)
446 * @closure: a #GClosure
447 * @notify_data: data to pass to @notify_func
448 * @notify_func: the callback function to register
450 * Registers an invalidation notifier which will be called when the
451 * @closure is invalidated with g_closure_invalidate(). Invalidation
452 * notifiers are invoked before finalization notifiers, in an
456 g_closure_add_invalidate_notifier (GClosure *closure,
457 gpointer notify_data,
458 GClosureNotify notify_func)
462 g_return_if_fail (closure != NULL);
463 g_return_if_fail (notify_func != NULL);
464 g_return_if_fail (closure->is_invalid == FALSE);
465 g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
467 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
468 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
469 closure->notifiers[i].data = notify_data;
470 closure->notifiers[i].notify = notify_func;
471 INC (closure, n_inotifiers);
474 static inline gboolean
475 closure_try_remove_inotify (GClosure *closure,
476 gpointer notify_data,
477 GClosureNotify notify_func)
479 GClosureNotifyData *ndata, *nlast;
481 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
482 for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
483 if (ndata->notify == notify_func && ndata->data == notify_data)
485 DEC (closure, n_inotifiers);
494 static inline gboolean
495 closure_try_remove_fnotify (GClosure *closure,
496 gpointer notify_data,
497 GClosureNotify notify_func)
499 GClosureNotifyData *ndata, *nlast;
501 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
502 for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
503 if (ndata->notify == notify_func && ndata->data == notify_data)
505 DEC (closure, n_fnotifiers);
508 if (closure->n_inotifiers)
509 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
510 closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
511 closure->n_fnotifiers +
512 closure->n_inotifiers)];
520 * @closure: #GClosure to increment the reference count on
522 * Increments the reference count on a closure to force it staying
523 * alive while the caller holds a pointer to it.
525 * Returns: (transfer none): The @closure passed in, for convenience
528 g_closure_ref (GClosure *closure)
531 g_return_val_if_fail (closure != NULL, NULL);
532 g_return_val_if_fail (closure->ref_count > 0, NULL);
533 g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
535 INC_ASSIGN (closure, ref_count, &new_ref_count);
536 g_return_val_if_fail (new_ref_count > 1, NULL);
542 * g_closure_invalidate:
543 * @closure: GClosure to invalidate
545 * Sets a flag on the closure to indicate that its calling
546 * environment has become invalid, and thus causes any future
547 * invocations of g_closure_invoke() on this @closure to be
548 * ignored. Also, invalidation notifiers installed on the closure will
549 * be called at this point. Note that unless you are holding a
550 * reference to the closure yourself, the invalidation notifiers may
551 * unref the closure and cause it to be destroyed, so if you need to
552 * access the closure after calling g_closure_invalidate(), make sure
553 * that you've previously called g_closure_ref().
555 * Note that g_closure_invalidate() will also be called when the
556 * reference count of a closure drops to zero (unless it has already
557 * been invalidated before).
560 g_closure_invalidate (GClosure *closure)
562 g_return_if_fail (closure != NULL);
564 if (!closure->is_invalid)
566 gboolean was_invalid;
567 g_closure_ref (closure); /* preserve floating flag */
568 SWAP (closure, is_invalid, TRUE, &was_invalid);
569 /* invalidate only once */
571 closure_invoke_notifiers (closure, INOTIFY);
572 g_closure_unref (closure);
578 * @closure: #GClosure to decrement the reference count on
580 * Decrements the reference count of a closure after it was previously
581 * incremented by the same caller. If no other callers are using the
582 * closure, then the closure will be destroyed and freed.
585 g_closure_unref (GClosure *closure)
589 g_return_if_fail (closure != NULL);
590 g_return_if_fail (closure->ref_count > 0);
592 if (closure->ref_count == 1) /* last unref, invalidate first */
593 g_closure_invalidate (closure);
595 DEC_ASSIGN (closure, ref_count, &new_ref_count);
597 if (new_ref_count == 0)
599 closure_invoke_notifiers (closure, FNOTIFY);
600 g_free (closure->notifiers);
607 * @closure: #GClosure to decrement the initial reference count on, if it's
610 * Takes over the initial ownership of a closure. Each closure is
611 * initially created in a <firstterm>floating</firstterm> state, which
612 * means that the initial reference count is not owned by any caller.
613 * g_closure_sink() checks to see if the object is still floating, and
614 * if so, unsets the floating state and decreases the reference
615 * count. If the closure is not floating, g_closure_sink() does
616 * nothing. The reason for the existance of the floating state is to
617 * prevent cumbersome code sequences like:
619 * closure = g_cclosure_new (cb_func, cb_data);
620 * g_source_set_closure (source, closure);
621 * g_closure_unref (closure); // XXX GObject doesn't really need this
623 * Because g_source_set_closure() (and similar functions) take ownership of the
624 * initial reference count, if it is unowned, we instead can write:
626 * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
629 * Generally, this function is used together with g_closure_ref(). Ane example
630 * of storing a closure for later notification looks like:
632 * static GClosure *notify_closure = NULL;
634 * foo_notify_set_closure (GClosure *closure)
636 * if (notify_closure)
637 * g_closure_unref (notify_closure);
638 * notify_closure = closure;
639 * if (notify_closure)
641 * g_closure_ref (notify_closure);
642 * g_closure_sink (notify_closure);
647 * Because g_closure_sink() may decrement the reference count of a closure
648 * (if it hasn't been called on @closure yet) just like g_closure_unref(),
649 * g_closure_ref() should be called prior to this function.
652 g_closure_sink (GClosure *closure)
654 g_return_if_fail (closure != NULL);
655 g_return_if_fail (closure->ref_count > 0);
657 /* floating is basically a kludge to avoid creating closures
658 * with a ref_count of 0. so the intial ref_count a closure has
659 * is unowned. with invoking g_closure_sink() code may
660 * indicate that it takes over that intiial ref_count.
662 if (closure->floating)
664 gboolean was_floating;
665 SWAP (closure, floating, FALSE, &was_floating);
666 /* unref floating flag only once */
668 g_closure_unref (closure);
673 * g_closure_remove_invalidate_notifier: (skip)
674 * @closure: a #GClosure
675 * @notify_data: data which was passed to g_closure_add_invalidate_notifier()
676 * when registering @notify_func
677 * @notify_func: the callback function to remove
679 * Removes an invalidation notifier.
681 * Notice that notifiers are automatically removed after they are run.
684 g_closure_remove_invalidate_notifier (GClosure *closure,
685 gpointer notify_data,
686 GClosureNotify notify_func)
688 g_return_if_fail (closure != NULL);
689 g_return_if_fail (notify_func != NULL);
691 if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while it's called */
692 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
693 closure->data == notify_data)
694 closure->marshal = NULL;
695 else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
696 g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
697 notify_func, notify_data);
701 * g_closure_remove_finalize_notifier: (skip)
702 * @closure: a #GClosure
703 * @notify_data: data which was passed to g_closure_add_finalize_notifier()
704 * when registering @notify_func
705 * @notify_func: the callback function to remove
707 * Removes a finalization notifier.
709 * Notice that notifiers are automatically removed after they are run.
712 g_closure_remove_finalize_notifier (GClosure *closure,
713 gpointer notify_data,
714 GClosureNotify notify_func)
716 g_return_if_fail (closure != NULL);
717 g_return_if_fail (notify_func != NULL);
719 if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while it's called */
720 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
721 closure->data == notify_data)
722 closure->marshal = NULL;
723 else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
724 g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
725 notify_func, notify_data);
730 * @closure: a #GClosure
731 * @return_value: a #GValue to store the return value. May be %NULL if the
732 * callback of @closure doesn't return a value.
733 * @n_param_values: the length of the @param_values array
734 * @param_values: (array length=n_param_values): an array of
735 * #GValue<!-- -->s holding the arguments on which to
736 * invoke the callback of @closure
737 * @invocation_hint: a context-dependent invocation hint
739 * Invokes the closure, i.e. executes the callback represented by the @closure.
742 g_closure_invoke (GClosure *closure,
743 GValue /*out*/ *return_value,
744 guint n_param_values,
745 const GValue *param_values,
746 gpointer invocation_hint)
748 g_return_if_fail (closure != NULL);
750 g_closure_ref (closure); /* preserve floating flag */
751 if (!closure->is_invalid)
753 GClosureMarshal marshal;
754 gpointer marshal_data;
755 gboolean in_marshal = closure->in_marshal;
757 g_return_if_fail (closure->marshal || closure->meta_marshal);
759 SET (closure, in_marshal, TRUE);
760 if (closure->meta_marshal)
762 marshal_data = closure->notifiers[0].data;
763 marshal = (GClosureMarshal) closure->notifiers[0].notify;
768 marshal = closure->marshal;
771 closure_invoke_notifiers (closure, PRE_NOTIFY);
774 n_param_values, param_values,
778 closure_invoke_notifiers (closure, POST_NOTIFY);
779 SET (closure, in_marshal, in_marshal);
781 g_closure_unref (closure);
785 * g_closure_set_marshal: (skip)
786 * @closure: a #GClosure
787 * @marshal: a #GClosureMarshal function
789 * Sets the marshaller of @closure. The <literal>marshal_data</literal>
790 * of @marshal provides a way for a meta marshaller to provide additional
791 * information to the marshaller. (See g_closure_set_meta_marshal().) For
792 * GObject's C predefined marshallers (the g_cclosure_marshal_*()
793 * functions), what it provides is a callback function to use instead of
794 * @closure->callback.
797 g_closure_set_marshal (GClosure *closure,
798 GClosureMarshal marshal)
800 g_return_if_fail (closure != NULL);
801 g_return_if_fail (marshal != NULL);
803 if (closure->marshal && closure->marshal != marshal)
804 g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
805 closure->marshal, marshal);
807 closure->marshal = marshal;
811 * g_cclosure_new: (skip)
812 * @callback_func: the function to invoke
813 * @user_data: user data to pass to @callback_func
814 * @destroy_data: destroy notify to be called when @user_data is no longer used
816 * Creates a new closure which invokes @callback_func with @user_data as
817 * the last parameter.
819 * Returns: a new #GCClosure
822 g_cclosure_new (GCallback callback_func,
824 GClosureNotify destroy_data)
828 g_return_val_if_fail (callback_func != NULL, NULL);
830 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
832 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
833 ((GCClosure*) closure)->callback = (gpointer) callback_func;
839 * g_cclosure_new_swap: (skip)
840 * @callback_func: the function to invoke
841 * @user_data: user data to pass to @callback_func
842 * @destroy_data: destroy notify to be called when @user_data is no longer used
844 * Creates a new closure which invokes @callback_func with @user_data as
845 * the first parameter.
847 * Returns: (transfer full): a new #GCClosure
850 g_cclosure_new_swap (GCallback callback_func,
852 GClosureNotify destroy_data)
856 g_return_val_if_fail (callback_func != NULL, NULL);
858 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
860 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
861 ((GCClosure*) closure)->callback = (gpointer) callback_func;
862 SET (closure, derivative_flag, TRUE);
868 g_type_class_meta_marshal (GClosure *closure,
869 GValue /*out*/ *return_value,
870 guint n_param_values,
871 const GValue *param_values,
872 gpointer invocation_hint,
873 gpointer marshal_data)
877 /* GType itype = (GType) closure->data; */
878 guint offset = GPOINTER_TO_UINT (marshal_data);
880 class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
881 callback = G_STRUCT_MEMBER (gpointer, class, offset);
883 closure->marshal (closure,
885 n_param_values, param_values,
891 g_type_iface_meta_marshal (GClosure *closure,
892 GValue /*out*/ *return_value,
893 guint n_param_values,
894 const GValue *param_values,
895 gpointer invocation_hint,
896 gpointer marshal_data)
900 GType itype = (GType) closure->data;
901 guint offset = GPOINTER_TO_UINT (marshal_data);
903 class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
904 callback = G_STRUCT_MEMBER (gpointer, class, offset);
906 closure->marshal (closure,
908 n_param_values, param_values,
914 * g_signal_type_cclosure_new:
915 * @itype: the #GType identifier of an interface or classed type
916 * @struct_offset: the offset of the member function of @itype's class
917 * structure which is to be invoked by the new closure
919 * Creates a new closure which invokes the function found at the offset
920 * @struct_offset in the class structure of the interface or classed type
921 * identified by @itype.
923 * Returns: a new #GCClosure
926 g_signal_type_cclosure_new (GType itype,
931 g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
932 g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
934 closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
935 if (G_TYPE_IS_INTERFACE (itype))
936 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
938 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
945 value_to_ffi_type (const GValue *gvalue, gpointer *value)
947 ffi_type *rettype = NULL;
948 GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
949 g_assert (type != G_TYPE_INVALID);
956 rettype = &ffi_type_sint;
957 *value = (gpointer)&(gvalue->data[0].v_int);
962 rettype = &ffi_type_uint;
963 *value = (gpointer)&(gvalue->data[0].v_uint);
969 case G_TYPE_INTERFACE:
971 rettype = &ffi_type_pointer;
972 *value = (gpointer)&(gvalue->data[0].v_pointer);
975 rettype = &ffi_type_float;
976 *value = (gpointer)&(gvalue->data[0].v_float);
979 rettype = &ffi_type_double;
980 *value = (gpointer)&(gvalue->data[0].v_double);
983 rettype = &ffi_type_slong;
984 *value = (gpointer)&(gvalue->data[0].v_long);
987 rettype = &ffi_type_ulong;
988 *value = (gpointer)&(gvalue->data[0].v_ulong);
991 rettype = &ffi_type_sint64;
992 *value = (gpointer)&(gvalue->data[0].v_int64);
995 rettype = &ffi_type_uint64;
996 *value = (gpointer)&(gvalue->data[0].v_uint64);
999 rettype = &ffi_type_pointer;
1001 g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1008 value_from_ffi_type (GValue *gvalue, gpointer *value)
1010 switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
1013 g_value_set_int (gvalue, *(gint*)value);
1016 g_value_set_float (gvalue, *(gfloat*)value);
1019 g_value_set_double (gvalue, *(gdouble*)value);
1021 case G_TYPE_BOOLEAN:
1022 g_value_set_boolean (gvalue, *(gboolean*)value);
1025 g_value_set_string (gvalue, *(gchar**)value);
1028 g_value_set_char (gvalue, *(gchar*)value);
1031 g_value_set_uchar (gvalue, *(guchar*)value);
1034 g_value_set_uint (gvalue, *(guint*)value);
1036 case G_TYPE_POINTER:
1037 g_value_set_pointer (gvalue, *(gpointer*)value);
1040 g_value_set_long (gvalue, *(glong*)value);
1043 g_value_set_ulong (gvalue, *(gulong*)value);
1046 g_value_set_int64 (gvalue, *(gint64*)value);
1049 g_value_set_uint64 (gvalue, *(guint64*)value);
1052 g_value_set_boxed (gvalue, *(gpointer*)value);
1055 g_value_set_flags (gvalue, *(guint*)value);
1058 g_value_set_object (gvalue, *(gpointer*)value);
1061 g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
1062 g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
1067 * g_cclosure_marshal_generic:
1068 * @closure: A #GClosure.
1069 * @return_gvalue: A #GValue to store the return value. May be %NULL
1070 * if the callback of closure doesn't return a value.
1071 * @n_param_values: The length of the @param_values array.
1072 * @param_values: An array of #GValue<!-- -->s holding the arguments
1073 * on which to invoke the callback of closure.
1074 * @invocation_hint: The invocation hint given as the last argument to
1075 * g_closure_invoke().
1076 * @marshal_data: Additional data specified when registering the
1077 * marshaller, see g_closure_set_marshal() and
1078 * g_closure_set_meta_marshal()
1080 * A generic marshaller function implemented via <ulink
1081 * url="http://sourceware.org/libffi/">libffi</ulink>.
1086 g_cclosure_marshal_generic (GClosure *closure,
1087 GValue *return_gvalue,
1088 guint n_param_values,
1089 const GValue *param_values,
1090 gpointer invocation_hint,
1091 gpointer marshal_data)
1100 GCClosure *cc = (GCClosure*) closure;
1102 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1104 rtype = value_to_ffi_type (return_gvalue, &rvalue);
1108 rtype = &ffi_type_void;
1111 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1113 n_args = n_param_values + 1;
1114 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1115 args = g_alloca (sizeof (gpointer) * n_args);
1117 if (G_CCLOSURE_SWAP_DATA (closure))
1119 atypes[n_args-1] = value_to_ffi_type (param_values + 0,
1121 atypes[0] = &ffi_type_pointer;
1122 args[0] = &closure->data;
1126 atypes[0] = value_to_ffi_type (param_values + 0, &args[0]);
1127 atypes[n_args-1] = &ffi_type_pointer;
1128 args[n_args-1] = &closure->data;
1131 for (i = 1; i < n_args - 1; i++)
1132 atypes[i] = value_to_ffi_type (param_values + i, &args[i]);
1134 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1137 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1139 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1140 value_from_ffi_type (return_gvalue, rvalue);
1144 * g_cclosure_marshal_VOID__VOID:
1145 * @closure: the #GClosure to which the marshaller belongs
1146 * @return_value: ignored
1147 * @n_param_values: 1
1148 * @param_values: a #GValue array holding only the instance
1149 * @invocation_hint: the invocation hint given as the last argument
1150 * to g_closure_invoke()
1151 * @marshal_data: additional data specified when registering the marshaller
1153 * A marshaller for a #GCClosure with a callback of type
1154 * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
1158 * g_cclosure_marshal_VOID__BOOLEAN:
1159 * @closure: the #GClosure to which the marshaller belongs
1160 * @return_value: ignored
1161 * @n_param_values: 2
1162 * @param_values: a #GValue array holding the instance and the #gboolean parameter
1163 * @invocation_hint: the invocation hint given as the last argument
1164 * to g_closure_invoke()
1165 * @marshal_data: additional data specified when registering the marshaller
1167 * A marshaller for a #GCClosure with a callback of type
1168 * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
1172 * g_cclosure_marshal_VOID__CHAR:
1173 * @closure: the #GClosure to which the marshaller belongs
1174 * @return_value: ignored
1175 * @n_param_values: 2
1176 * @param_values: a #GValue array holding the instance and the #gchar parameter
1177 * @invocation_hint: the invocation hint given as the last argument
1178 * to g_closure_invoke()
1179 * @marshal_data: additional data specified when registering the marshaller
1181 * A marshaller for a #GCClosure with a callback of type
1182 * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
1186 * g_cclosure_marshal_VOID__UCHAR:
1187 * @closure: the #GClosure to which the marshaller belongs
1188 * @return_value: ignored
1189 * @n_param_values: 2
1190 * @param_values: a #GValue array holding the instance and the #guchar parameter
1191 * @invocation_hint: the invocation hint given as the last argument
1192 * to g_closure_invoke()
1193 * @marshal_data: additional data specified when registering the marshaller
1195 * A marshaller for a #GCClosure with a callback of type
1196 * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
1200 * g_cclosure_marshal_VOID__INT:
1201 * @closure: the #GClosure to which the marshaller belongs
1202 * @return_value: ignored
1203 * @n_param_values: 2
1204 * @param_values: a #GValue array holding the instance and the #gint parameter
1205 * @invocation_hint: the invocation hint given as the last argument
1206 * to g_closure_invoke()
1207 * @marshal_data: additional data specified when registering the marshaller
1209 * A marshaller for a #GCClosure with a callback of type
1210 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
1214 * g_cclosure_marshal_VOID__UINT:
1215 * @closure: the #GClosure to which the marshaller belongs
1216 * @return_value: ignored
1217 * @n_param_values: 2
1218 * @param_values: a #GValue array holding the instance and the #guint parameter
1219 * @invocation_hint: the invocation hint given as the last argument
1220 * to g_closure_invoke()
1221 * @marshal_data: additional data specified when registering the marshaller
1223 * A marshaller for a #GCClosure with a callback of type
1224 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
1228 * g_cclosure_marshal_VOID__LONG:
1229 * @closure: the #GClosure to which the marshaller belongs
1230 * @return_value: ignored
1231 * @n_param_values: 2
1232 * @param_values: a #GValue array holding the instance and the #glong parameter
1233 * @invocation_hint: the invocation hint given as the last argument
1234 * to g_closure_invoke()
1235 * @marshal_data: additional data specified when registering the marshaller
1237 * A marshaller for a #GCClosure with a callback of type
1238 * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1242 * g_cclosure_marshal_VOID__ULONG:
1243 * @closure: the #GClosure to which the marshaller belongs
1244 * @return_value: ignored
1245 * @n_param_values: 2
1246 * @param_values: a #GValue array holding the instance and the #gulong parameter
1247 * @invocation_hint: the invocation hint given as the last argument
1248 * to g_closure_invoke()
1249 * @marshal_data: additional data specified when registering the marshaller
1251 * A marshaller for a #GCClosure with a callback of type
1252 * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1256 * g_cclosure_marshal_VOID__ENUM:
1257 * @closure: the #GClosure to which the marshaller belongs
1258 * @return_value: ignored
1259 * @n_param_values: 2
1260 * @param_values: a #GValue array holding the instance and the enumeration parameter
1261 * @invocation_hint: the invocation hint given as the last argument
1262 * to g_closure_invoke()
1263 * @marshal_data: additional data specified when registering the marshaller
1265 * A marshaller for a #GCClosure with a callback of type
1266 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1270 * g_cclosure_marshal_VOID__FLAGS:
1271 * @closure: the #GClosure to which the marshaller belongs
1272 * @return_value: ignored
1273 * @n_param_values: 2
1274 * @param_values: a #GValue array holding the instance and the flags parameter
1275 * @invocation_hint: the invocation hint given as the last argument
1276 * to g_closure_invoke()
1277 * @marshal_data: additional data specified when registering the marshaller
1279 * A marshaller for a #GCClosure with a callback of type
1280 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1284 * g_cclosure_marshal_VOID__FLOAT:
1285 * @closure: the #GClosure to which the marshaller belongs
1286 * @return_value: ignored
1287 * @n_param_values: 2
1288 * @param_values: a #GValue array holding the instance and the #gfloat parameter
1289 * @invocation_hint: the invocation hint given as the last argument
1290 * to g_closure_invoke()
1291 * @marshal_data: additional data specified when registering the marshaller
1293 * A marshaller for a #GCClosure with a callback of type
1294 * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1298 * g_cclosure_marshal_VOID__DOUBLE:
1299 * @closure: the #GClosure to which the marshaller belongs
1300 * @return_value: ignored
1301 * @n_param_values: 2
1302 * @param_values: a #GValue array holding the instance and the #gdouble parameter
1303 * @invocation_hint: the invocation hint given as the last argument
1304 * to g_closure_invoke()
1305 * @marshal_data: additional data specified when registering the marshaller
1307 * A marshaller for a #GCClosure with a callback of type
1308 * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1312 * g_cclosure_marshal_VOID__STRING:
1313 * @closure: the #GClosure to which the marshaller belongs
1314 * @return_value: ignored
1315 * @n_param_values: 2
1316 * @param_values: a #GValue array holding the instance and the #gchar* parameter
1317 * @invocation_hint: the invocation hint given as the last argument
1318 * to g_closure_invoke()
1319 * @marshal_data: additional data specified when registering the marshaller
1321 * A marshaller for a #GCClosure with a callback of type
1322 * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1326 * g_cclosure_marshal_VOID__PARAM:
1327 * @closure: the #GClosure to which the marshaller belongs
1328 * @return_value: ignored
1329 * @n_param_values: 2
1330 * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1331 * @invocation_hint: the invocation hint given as the last argument
1332 * to g_closure_invoke()
1333 * @marshal_data: additional data specified when registering the marshaller
1335 * A marshaller for a #GCClosure with a callback of type
1336 * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1340 * g_cclosure_marshal_VOID__BOXED:
1341 * @closure: the #GClosure to which the marshaller belongs
1342 * @return_value: ignored
1343 * @n_param_values: 2
1344 * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1345 * @invocation_hint: the invocation hint given as the last argument
1346 * to g_closure_invoke()
1347 * @marshal_data: additional data specified when registering the marshaller
1349 * A marshaller for a #GCClosure with a callback of type
1350 * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1354 * g_cclosure_marshal_VOID__POINTER:
1355 * @closure: the #GClosure to which the marshaller belongs
1356 * @return_value: ignored
1357 * @n_param_values: 2
1358 * @param_values: a #GValue array holding the instance and the #gpointer parameter
1359 * @invocation_hint: the invocation hint given as the last argument
1360 * to g_closure_invoke()
1361 * @marshal_data: additional data specified when registering the marshaller
1363 * A marshaller for a #GCClosure with a callback of type
1364 * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1368 * g_cclosure_marshal_VOID__OBJECT:
1369 * @closure: the #GClosure to which the marshaller belongs
1370 * @return_value: ignored
1371 * @n_param_values: 2
1372 * @param_values: a #GValue array holding the instance and the #GObject* parameter
1373 * @invocation_hint: the invocation hint given as the last argument
1374 * to g_closure_invoke()
1375 * @marshal_data: additional data specified when registering the marshaller
1377 * A marshaller for a #GCClosure with a callback of type
1378 * <literal>void (*callback) (gpointer instance, GObject *arg1, gpointer user_data)</literal>.
1382 * g_cclosure_marshal_VOID__VARIANT:
1383 * @closure: the #GClosure to which the marshaller belongs
1384 * @return_value: ignored
1385 * @n_param_values: 2
1386 * @param_values: a #GValue array holding the instance and the #GVariant* parameter
1387 * @invocation_hint: the invocation hint given as the last argument
1388 * to g_closure_invoke()
1389 * @marshal_data: additional data specified when registering the marshaller
1391 * A marshaller for a #GCClosure with a callback of type
1392 * <literal>void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data)</literal>.
1398 * g_cclosure_marshal_VOID__UINT_POINTER:
1399 * @closure: the #GClosure to which the marshaller belongs
1400 * @return_value: ignored
1401 * @n_param_values: 3
1402 * @param_values: a #GValue array holding instance, arg1 and arg2
1403 * @invocation_hint: the invocation hint given as the last argument
1404 * to g_closure_invoke()
1405 * @marshal_data: additional data specified when registering the marshaller
1407 * A marshaller for a #GCClosure with a callback of type
1408 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1412 * g_cclosure_marshal_BOOLEAN__FLAGS:
1413 * @closure: the #GClosure to which the marshaller belongs
1414 * @return_value: a #GValue which can store the returned #gboolean
1415 * @n_param_values: 2
1416 * @param_values: a #GValue array holding instance and arg1
1417 * @invocation_hint: the invocation hint given as the last argument
1418 * to g_closure_invoke()
1419 * @marshal_data: additional data specified when registering the marshaller
1421 * A marshaller for a #GCClosure with a callback of type
1422 * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1423 * denotes a flags type.
1427 * g_cclosure_marshal_BOOL__FLAGS:
1429 * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1432 * g_cclosure_marshal_STRING__OBJECT_POINTER:
1433 * @closure: the #GClosure to which the marshaller belongs
1434 * @return_value: a #GValue, which can store the returned string
1435 * @n_param_values: 3
1436 * @param_values: a #GValue array holding instance, arg1 and arg2
1437 * @invocation_hint: the invocation hint given as the last argument
1438 * to g_closure_invoke()
1439 * @marshal_data: additional data specified when registering the marshaller
1441 * A marshaller for a #GCClosure with a callback of type
1442 * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1445 * g_cclosure_marshal_BOOLEAN__OBJECT_BOXED_BOXED:
1446 * @closure: the #GClosure to which the marshaller belongs
1447 * @return_value: a #GValue, which can store the returned string
1448 * @n_param_values: 3
1449 * @param_values: a #GValue array holding instance, arg1 and arg2
1450 * @invocation_hint: the invocation hint given as the last argument
1451 * to g_closure_invoke()
1452 * @marshal_data: additional data specified when registering the marshaller
1454 * A marshaller for a #GCClosure with a callback of type
1455 * <literal>gboolean (*callback) (gpointer instance, GBoxed *arg1, GBoxed *arg2, gpointer user_data)</literal>.