1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2000-2001 Red Hat, Inc.
3 * Copyright (C) 2005 Imendio AB
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * MT safe with regards to reference counting.
36 #include "gvaluetypes.h"
37 #include "gtype-private.h"
42 * @short_description: Functions as first-class objects
45 * A #GClosure represents a callback supplied by the programmer. It
46 * will generally comprise a function of some kind and a marshaller
47 * used to call it. It is the reponsibility of the marshaller to
48 * convert the arguments for the invocation from #GValue<!-- -->s into
49 * a suitable form, perform the callback on the converted arguments,
50 * and transform the return value back into a #GValue.
52 * In the case of C programs, a closure usually just holds a pointer
53 * to a function and maybe a data argument, and the marshaller
54 * converts between #GValue<!-- --> and native C types. The GObject
55 * library provides the #GCClosure type for this purpose. Bindings for
56 * other languages need marshallers which convert between #GValue<!--
57 * -->s and suitable representations in the runtime of the language in
58 * order to use functions written in that languages as callbacks.
60 * Within GObject, closures play an important role in the
61 * implementation of signals. When a signal is registered, the
62 * @c_marshaller argument to g_signal_new() specifies the default C
63 * marshaller for any closure which is connected to this
64 * signal. GObject provides a number of C marshallers for this
65 * purpose, see the g_cclosure_marshal_*() functions. Additional C
66 * marshallers can be generated with the <link
67 * linkend="glib-genmarshal">glib-genmarshal</link> utility. Closures
68 * can be explicitly connected to signals with
69 * g_signal_connect_closure(), but it usually more convenient to let
70 * GObject create a closure automatically by using one of the
71 * g_signal_connect_*() functions which take a callback function/user
74 * Using closures has a number of important advantages over a simple
75 * callback function/data pointer combination:
78 * Closures allow the callee to get the types of the callback parameters,
79 * which means that language bindings don't have to write individual glue
80 * for each callback type.
83 * The reference counting of #GClosure makes it easy to handle reentrancy
84 * right; if a callback is removed while it is being invoked, the closure
85 * and its parameters won't be freed until the invocation finishes.
88 * g_closure_invalidate() and invalidation notifiers allow callbacks to be
89 * automatically removed when the objects they point to go away.
94 #define CLOSURE_MAX_REF_COUNT ((1 << 15) - 1)
95 #define CLOSURE_MAX_N_GUARDS ((1 << 1) - 1)
96 #define CLOSURE_MAX_N_FNOTIFIERS ((1 << 2) - 1)
97 #define CLOSURE_MAX_N_INOTIFIERS ((1 << 8) - 1)
98 #define CLOSURE_N_MFUNCS(cl) (((cl)->n_guards << 1L))
99 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
100 #define CLOSURE_N_NOTIFIERS(cl) (CLOSURE_N_MFUNCS (cl) + \
101 (cl)->n_fnotifiers + \
109 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW) \
111 ClosureInt *cunion = (ClosureInt*) _closure; \
112 gint new_int, old_int, success; \
116 tmp.vint = old_int = cunion->vint; \
117 _SET_OLD tmp.closure._field; \
118 tmp.closure._field _OP _value; \
119 _SET_NEW tmp.closure._field; \
120 new_int = tmp.vint; \
121 success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int); \
123 while (!success && _must_set); \
126 #define SWAP(_closure, _field, _value, _oldv) CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =, (void) )
127 #define SET(_closure, _field, _value) CHANGE_FIELD (_closure, _field, =, _value, TRUE, (void), (void) )
128 #define INC(_closure, _field) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), (void) )
129 #define INC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, +=, 1, TRUE, (void), *(_newv) = )
130 #define DEC(_closure, _field) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), (void) )
131 #define DEC_ASSIGN(_closure, _field, _newv) CHANGE_FIELD (_closure, _field, -=, 1, TRUE, (void), *(_newv) = )
133 #if 0 /* for non-thread-safe closures */
134 #define SWAP(cl,f,v,o) (void) (*(o) = cl->f, cl->f = v)
135 #define SET(cl,f,v) (void) (cl->f = v)
136 #define INC(cl,f) (void) (cl->f += 1)
137 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
138 #define DEC(cl,f) (void) (cl->f -= 1)
139 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
150 /* --- functions --- */
152 * g_closure_new_simple:
153 * @sizeof_closure: the size of the structure to allocate, must be at least
154 * <literal>sizeof (GClosure)</literal>
155 * @data: data to store in the @data field of the newly allocated #GClosure
157 * Allocates a struct of the given size and initializes the initial
158 * part as a #GClosure. This function is mainly useful when
159 * implementing new types of closures.
162 * typedef struct _MyClosure MyClosure;
166 * // extra data goes here
170 * my_closure_finalize (gpointer notify_data,
173 * MyClosure *my_closure = (MyClosure *)closure;
175 * // free extra data here
178 * MyClosure *my_closure_new (gpointer data)
181 * MyClosure *my_closure;
183 * closure = g_closure_new_simple (sizeof (MyClosure), data);
184 * my_closure = (MyClosure *) closure;
186 * // initialize extra data here
188 * g_closure_add_finalize_notifier (closure, notify_data,
189 * my_closure_finalize);
194 * Returns: (transfer full): a newly allocated #GClosure
197 g_closure_new_simple (guint sizeof_closure,
200 GRealClosure *real_closure;
203 g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
204 sizeof_closure = sizeof_closure + sizeof (GRealClosure) - sizeof (GClosure);
206 real_closure = g_malloc0 (sizeof_closure);
207 closure = &real_closure->closure;
208 SET (closure, ref_count, 1);
209 SET (closure, floating, TRUE);
210 closure->data = data;
216 closure_invoke_notifiers (GClosure *closure,
220 * n_guards n_guards n_fnotif. n_inotifiers
221 * ->[[pre_guards][post_guards][fnotifiers][inotifiers]]
223 * CLOSURE_N_MFUNCS(cl) = n_guards + n_guards;
224 * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
226 * constrains/catches:
227 * - closure->notifiers may be reloacted during callback
228 * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
229 * - i.e. callbacks can be removed/added during invocation
230 * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
231 * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
232 * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
233 * + none of the callbacks can cause recursion
234 * + closure->n_inotifiers is const 0 during FNOTIFY
238 GClosureNotifyData *ndata;
241 while (closure->n_fnotifiers)
244 DEC_ASSIGN (closure, n_fnotifiers, &n);
246 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
247 closure->marshal = (GClosureMarshal) ndata->notify;
248 closure->data = ndata->data;
249 ndata->notify (ndata->data, closure);
251 closure->marshal = NULL;
252 closure->data = NULL;
255 SET (closure, in_inotify, TRUE);
256 while (closure->n_inotifiers)
259 DEC_ASSIGN (closure, n_inotifiers, &n);
261 ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
262 closure->marshal = (GClosureMarshal) ndata->notify;
263 closure->data = ndata->data;
264 ndata->notify (ndata->data, closure);
266 closure->marshal = NULL;
267 closure->data = NULL;
268 SET (closure, in_inotify, FALSE);
271 i = closure->n_guards;
275 ndata = closure->notifiers + offs + i;
276 ndata->notify (ndata->data, closure);
280 i = closure->n_guards;
284 ndata = closure->notifiers + offs + i;
285 ndata->notify (ndata->data, closure);
292 * g_closure_set_meta_marshal: (skip)
293 * @closure: a #GClosure
294 * @marshal_data: context-dependent data to pass to @meta_marshal
295 * @meta_marshal: a #GClosureMarshal function
297 * Sets the meta marshaller of @closure. A meta marshaller wraps
298 * @closure->marshal and modifies the way it is called in some
299 * fashion. The most common use of this facility is for C callbacks.
300 * The same marshallers (generated by <link
301 * linkend="glib-genmarshal">glib-genmarshal</link>) are used
302 * everywhere, but the way that we get the callback function
303 * differs. In most cases we want to use @closure->callback, but in
304 * other cases we want to use some different technique to retrieve the
307 * For example, class closures for signals (see
308 * g_signal_type_cclosure_new()) retrieve the callback function from a
309 * fixed offset in the class structure. The meta marshaller retrieves
310 * the right callback and passes it to the marshaller as the
311 * @marshal_data argument.
314 g_closure_set_meta_marshal (GClosure *closure,
315 gpointer marshal_data,
316 GClosureMarshal meta_marshal)
318 GRealClosure *real_closure;
320 g_return_if_fail (closure != NULL);
321 g_return_if_fail (meta_marshal != NULL);
322 g_return_if_fail (closure->is_invalid == FALSE);
323 g_return_if_fail (closure->in_marshal == FALSE);
325 real_closure = G_REAL_CLOSURE (closure);
327 g_return_if_fail (real_closure->meta_marshal == NULL);
329 real_closure->meta_marshal = meta_marshal;
330 real_closure->meta_marshal_data = marshal_data;
334 * g_closure_add_marshal_guards: (skip)
335 * @closure: a #GClosure
336 * @pre_marshal_data: data to pass to @pre_marshal_notify
337 * @pre_marshal_notify: a function to call before the closure callback
338 * @post_marshal_data: data to pass to @post_marshal_notify
339 * @post_marshal_notify: a function to call after the closure callback
341 * Adds a pair of notifiers which get invoked before and after the
342 * closure callback, respectively. This is typically used to protect
343 * the extra arguments for the duration of the callback. See
344 * g_object_watch_closure() for an example of marshal guards.
347 g_closure_add_marshal_guards (GClosure *closure,
348 gpointer pre_marshal_data,
349 GClosureNotify pre_marshal_notify,
350 gpointer post_marshal_data,
351 GClosureNotify post_marshal_notify)
355 g_return_if_fail (closure != NULL);
356 g_return_if_fail (pre_marshal_notify != NULL);
357 g_return_if_fail (post_marshal_notify != NULL);
358 g_return_if_fail (closure->is_invalid == FALSE);
359 g_return_if_fail (closure->in_marshal == FALSE);
360 g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
362 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
363 if (closure->n_inotifiers)
364 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
365 closure->n_fnotifiers +
366 closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
367 closure->n_fnotifiers + 0)];
368 if (closure->n_inotifiers > 1)
369 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
370 closure->n_fnotifiers +
371 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
372 closure->n_fnotifiers + 1)];
373 if (closure->n_fnotifiers)
374 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
375 closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
376 if (closure->n_fnotifiers > 1)
377 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
378 closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
379 if (closure->n_guards)
380 closure->notifiers[(closure->n_guards +
381 closure->n_guards + 1)] = closure->notifiers[closure->n_guards];
382 i = closure->n_guards;
383 closure->notifiers[i].data = pre_marshal_data;
384 closure->notifiers[i].notify = pre_marshal_notify;
385 closure->notifiers[i + 1].data = post_marshal_data;
386 closure->notifiers[i + 1].notify = post_marshal_notify;
387 INC (closure, n_guards);
391 * g_closure_add_finalize_notifier: (skip)
392 * @closure: a #GClosure
393 * @notify_data: data to pass to @notify_func
394 * @notify_func: the callback function to register
396 * Registers a finalization notifier which will be called when the
397 * reference count of @closure goes down to 0. Multiple finalization
398 * notifiers on a single closure are invoked in unspecified order. If
399 * a single call to g_closure_unref() results in the closure being
400 * both invalidated and finalized, then the invalidate notifiers will
401 * be run before the finalize notifiers.
404 g_closure_add_finalize_notifier (GClosure *closure,
405 gpointer notify_data,
406 GClosureNotify notify_func)
410 g_return_if_fail (closure != NULL);
411 g_return_if_fail (notify_func != NULL);
412 g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
414 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
415 if (closure->n_inotifiers)
416 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
417 closure->n_fnotifiers +
418 closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
419 closure->n_fnotifiers + 0)];
420 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
421 closure->notifiers[i].data = notify_data;
422 closure->notifiers[i].notify = notify_func;
423 INC (closure, n_fnotifiers);
427 * g_closure_add_invalidate_notifier: (skip)
428 * @closure: a #GClosure
429 * @notify_data: data to pass to @notify_func
430 * @notify_func: the callback function to register
432 * Registers an invalidation notifier which will be called when the
433 * @closure is invalidated with g_closure_invalidate(). Invalidation
434 * notifiers are invoked before finalization notifiers, in an
438 g_closure_add_invalidate_notifier (GClosure *closure,
439 gpointer notify_data,
440 GClosureNotify notify_func)
444 g_return_if_fail (closure != NULL);
445 g_return_if_fail (notify_func != NULL);
446 g_return_if_fail (closure->is_invalid == FALSE);
447 g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
449 closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
450 i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
451 closure->notifiers[i].data = notify_data;
452 closure->notifiers[i].notify = notify_func;
453 INC (closure, n_inotifiers);
456 static inline gboolean
457 closure_try_remove_inotify (GClosure *closure,
458 gpointer notify_data,
459 GClosureNotify notify_func)
461 GClosureNotifyData *ndata, *nlast;
463 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
464 for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
465 if (ndata->notify == notify_func && ndata->data == notify_data)
467 DEC (closure, n_inotifiers);
476 static inline gboolean
477 closure_try_remove_fnotify (GClosure *closure,
478 gpointer notify_data,
479 GClosureNotify notify_func)
481 GClosureNotifyData *ndata, *nlast;
483 nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
484 for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
485 if (ndata->notify == notify_func && ndata->data == notify_data)
487 DEC (closure, n_fnotifiers);
490 if (closure->n_inotifiers)
491 closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
492 closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
493 closure->n_fnotifiers +
494 closure->n_inotifiers)];
502 * @closure: #GClosure to increment the reference count on
504 * Increments the reference count on a closure to force it staying
505 * alive while the caller holds a pointer to it.
507 * Returns: (transfer none): The @closure passed in, for convenience
510 g_closure_ref (GClosure *closure)
513 g_return_val_if_fail (closure != NULL, NULL);
514 g_return_val_if_fail (closure->ref_count > 0, NULL);
515 g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
517 INC_ASSIGN (closure, ref_count, &new_ref_count);
518 g_return_val_if_fail (new_ref_count > 1, NULL);
524 * g_closure_invalidate:
525 * @closure: GClosure to invalidate
527 * Sets a flag on the closure to indicate that its calling
528 * environment has become invalid, and thus causes any future
529 * invocations of g_closure_invoke() on this @closure to be
530 * ignored. Also, invalidation notifiers installed on the closure will
531 * be called at this point. Note that unless you are holding a
532 * reference to the closure yourself, the invalidation notifiers may
533 * unref the closure and cause it to be destroyed, so if you need to
534 * access the closure after calling g_closure_invalidate(), make sure
535 * that you've previously called g_closure_ref().
537 * Note that g_closure_invalidate() will also be called when the
538 * reference count of a closure drops to zero (unless it has already
539 * been invalidated before).
542 g_closure_invalidate (GClosure *closure)
544 g_return_if_fail (closure != NULL);
546 if (!closure->is_invalid)
548 gboolean was_invalid;
549 g_closure_ref (closure); /* preserve floating flag */
550 SWAP (closure, is_invalid, TRUE, &was_invalid);
551 /* invalidate only once */
553 closure_invoke_notifiers (closure, INOTIFY);
554 g_closure_unref (closure);
560 * @closure: #GClosure to decrement the reference count on
562 * Decrements the reference count of a closure after it was previously
563 * incremented by the same caller. If no other callers are using the
564 * closure, then the closure will be destroyed and freed.
567 g_closure_unref (GClosure *closure)
571 g_return_if_fail (closure != NULL);
572 g_return_if_fail (closure->ref_count > 0);
574 if (closure->ref_count == 1) /* last unref, invalidate first */
575 g_closure_invalidate (closure);
577 DEC_ASSIGN (closure, ref_count, &new_ref_count);
579 if (new_ref_count == 0)
581 closure_invoke_notifiers (closure, FNOTIFY);
582 g_free (closure->notifiers);
583 g_free (G_REAL_CLOSURE (closure));
589 * @closure: #GClosure to decrement the initial reference count on, if it's
592 * Takes over the initial ownership of a closure. Each closure is
593 * initially created in a <firstterm>floating</firstterm> state, which
594 * means that the initial reference count is not owned by any caller.
595 * g_closure_sink() checks to see if the object is still floating, and
596 * if so, unsets the floating state and decreases the reference
597 * count. If the closure is not floating, g_closure_sink() does
598 * nothing. The reason for the existence of the floating state is to
599 * prevent cumbersome code sequences like:
601 * closure = g_cclosure_new (cb_func, cb_data);
602 * g_source_set_closure (source, closure);
603 * g_closure_unref (closure); // XXX GObject doesn't really need this
605 * Because g_source_set_closure() (and similar functions) take ownership of the
606 * initial reference count, if it is unowned, we instead can write:
608 * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
611 * Generally, this function is used together with g_closure_ref(). Ane example
612 * of storing a closure for later notification looks like:
614 * static GClosure *notify_closure = NULL;
616 * foo_notify_set_closure (GClosure *closure)
618 * if (notify_closure)
619 * g_closure_unref (notify_closure);
620 * notify_closure = closure;
621 * if (notify_closure)
623 * g_closure_ref (notify_closure);
624 * g_closure_sink (notify_closure);
629 * Because g_closure_sink() may decrement the reference count of a closure
630 * (if it hasn't been called on @closure yet) just like g_closure_unref(),
631 * g_closure_ref() should be called prior to this function.
634 g_closure_sink (GClosure *closure)
636 g_return_if_fail (closure != NULL);
637 g_return_if_fail (closure->ref_count > 0);
639 /* floating is basically a kludge to avoid creating closures
640 * with a ref_count of 0. so the initial ref_count a closure has
641 * is unowned. with invoking g_closure_sink() code may
642 * indicate that it takes over that intiial ref_count.
644 if (closure->floating)
646 gboolean was_floating;
647 SWAP (closure, floating, FALSE, &was_floating);
648 /* unref floating flag only once */
650 g_closure_unref (closure);
655 * g_closure_remove_invalidate_notifier: (skip)
656 * @closure: a #GClosure
657 * @notify_data: data which was passed to g_closure_add_invalidate_notifier()
658 * when registering @notify_func
659 * @notify_func: the callback function to remove
661 * Removes an invalidation notifier.
663 * Notice that notifiers are automatically removed after they are run.
666 g_closure_remove_invalidate_notifier (GClosure *closure,
667 gpointer notify_data,
668 GClosureNotify notify_func)
670 g_return_if_fail (closure != NULL);
671 g_return_if_fail (notify_func != NULL);
673 if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while it's called */
674 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
675 closure->data == notify_data)
676 closure->marshal = NULL;
677 else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
678 g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
679 notify_func, notify_data);
683 * g_closure_remove_finalize_notifier: (skip)
684 * @closure: a #GClosure
685 * @notify_data: data which was passed to g_closure_add_finalize_notifier()
686 * when registering @notify_func
687 * @notify_func: the callback function to remove
689 * Removes a finalization notifier.
691 * Notice that notifiers are automatically removed after they are run.
694 g_closure_remove_finalize_notifier (GClosure *closure,
695 gpointer notify_data,
696 GClosureNotify notify_func)
698 g_return_if_fail (closure != NULL);
699 g_return_if_fail (notify_func != NULL);
701 if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while it's called */
702 ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
703 closure->data == notify_data)
704 closure->marshal = NULL;
705 else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
706 g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
707 notify_func, notify_data);
712 * @closure: a #GClosure
713 * @return_value: (allow-none): a #GValue to store the return
714 * value. May be %NULL if the callback of @closure
715 * doesn't return a value.
716 * @n_param_values: the length of the @param_values array
717 * @param_values: (array length=n_param_values): an array of
718 * #GValue<!-- -->s holding the arguments on which to
719 * invoke the callback of @closure
720 * @invocation_hint: (allow-none): a context-dependent invocation hint
722 * Invokes the closure, i.e. executes the callback represented by the @closure.
725 g_closure_invoke (GClosure *closure,
726 GValue /*out*/ *return_value,
727 guint n_param_values,
728 const GValue *param_values,
729 gpointer invocation_hint)
731 GRealClosure *real_closure;
733 g_return_if_fail (closure != NULL);
735 real_closure = G_REAL_CLOSURE (closure);
737 g_closure_ref (closure); /* preserve floating flag */
738 if (!closure->is_invalid)
740 GClosureMarshal marshal;
741 gpointer marshal_data;
742 gboolean in_marshal = closure->in_marshal;
744 g_return_if_fail (closure->marshal || real_closure->meta_marshal);
746 SET (closure, in_marshal, TRUE);
747 if (real_closure->meta_marshal)
749 marshal_data = real_closure->meta_marshal_data;
750 marshal = real_closure->meta_marshal;
755 marshal = closure->marshal;
758 closure_invoke_notifiers (closure, PRE_NOTIFY);
761 n_param_values, param_values,
765 closure_invoke_notifiers (closure, POST_NOTIFY);
766 SET (closure, in_marshal, in_marshal);
768 g_closure_unref (closure);
772 * g_closure_set_marshal: (skip)
773 * @closure: a #GClosure
774 * @marshal: a #GClosureMarshal function
776 * Sets the marshaller of @closure. The <literal>marshal_data</literal>
777 * of @marshal provides a way for a meta marshaller to provide additional
778 * information to the marshaller. (See g_closure_set_meta_marshal().) For
779 * GObject's C predefined marshallers (the g_cclosure_marshal_*()
780 * functions), what it provides is a callback function to use instead of
781 * @closure->callback.
784 g_closure_set_marshal (GClosure *closure,
785 GClosureMarshal marshal)
787 g_return_if_fail (closure != NULL);
788 g_return_if_fail (marshal != NULL);
790 if (closure->marshal && closure->marshal != marshal)
791 g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
792 closure->marshal, marshal);
794 closure->marshal = marshal;
798 * g_cclosure_new: (skip)
799 * @callback_func: the function to invoke
800 * @user_data: user data to pass to @callback_func
801 * @destroy_data: destroy notify to be called when @user_data is no longer used
803 * Creates a new closure which invokes @callback_func with @user_data as
804 * the last parameter.
806 * Returns: a new #GCClosure
809 g_cclosure_new (GCallback callback_func,
811 GClosureNotify destroy_data)
815 g_return_val_if_fail (callback_func != NULL, NULL);
817 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
819 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
820 ((GCClosure*) closure)->callback = (gpointer) callback_func;
826 * g_cclosure_new_swap: (skip)
827 * @callback_func: the function to invoke
828 * @user_data: user data to pass to @callback_func
829 * @destroy_data: destroy notify to be called when @user_data is no longer used
831 * Creates a new closure which invokes @callback_func with @user_data as
832 * the first parameter.
834 * Returns: (transfer full): a new #GCClosure
837 g_cclosure_new_swap (GCallback callback_func,
839 GClosureNotify destroy_data)
843 g_return_val_if_fail (callback_func != NULL, NULL);
845 closure = g_closure_new_simple (sizeof (GCClosure), user_data);
847 g_closure_add_finalize_notifier (closure, user_data, destroy_data);
848 ((GCClosure*) closure)->callback = (gpointer) callback_func;
849 SET (closure, derivative_flag, TRUE);
855 g_type_class_meta_marshal (GClosure *closure,
856 GValue /*out*/ *return_value,
857 guint n_param_values,
858 const GValue *param_values,
859 gpointer invocation_hint,
860 gpointer marshal_data)
864 /* GType itype = (GType) closure->data; */
865 guint offset = GPOINTER_TO_UINT (marshal_data);
867 class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
868 callback = G_STRUCT_MEMBER (gpointer, class, offset);
870 closure->marshal (closure,
872 n_param_values, param_values,
878 g_type_iface_meta_marshal (GClosure *closure,
879 GValue /*out*/ *return_value,
880 guint n_param_values,
881 const GValue *param_values,
882 gpointer invocation_hint,
883 gpointer marshal_data)
887 GType itype = (GType) closure->data;
888 guint offset = GPOINTER_TO_UINT (marshal_data);
890 class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
891 callback = G_STRUCT_MEMBER (gpointer, class, offset);
893 closure->marshal (closure,
895 n_param_values, param_values,
901 * g_signal_type_cclosure_new:
902 * @itype: the #GType identifier of an interface or classed type
903 * @struct_offset: the offset of the member function of @itype's class
904 * structure which is to be invoked by the new closure
906 * Creates a new closure which invokes the function found at the offset
907 * @struct_offset in the class structure of the interface or classed type
908 * identified by @itype.
910 * Returns: a new #GCClosure
913 g_signal_type_cclosure_new (GType itype,
918 g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
919 g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
921 closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
922 if (G_TYPE_IS_INTERFACE (itype))
923 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
925 g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
932 value_to_ffi_type (const GValue *gvalue,
935 gboolean *tmpval_used)
937 ffi_type *rettype = NULL;
938 GType type = g_type_fundamental (G_VALUE_TYPE (gvalue));
939 g_assert (type != G_TYPE_INVALID);
943 g_assert (tmpval_used != NULL);
944 *tmpval_used = FALSE;
952 rettype = &ffi_type_sint;
953 *value = (gpointer)&(gvalue->data[0].v_int);
956 /* enums are stored in v_long even though they are integers, which makes
957 * marshalling through libffi somewhat complicated. They need to be
958 * marshalled as signed ints, but we need to use a temporary int sized
959 * value to pass to libffi otherwise it'll pull the wrong value on
960 * BE machines with 32-bit integers when treating v_long as 32-bit int.
962 g_assert (enum_tmpval != NULL);
963 rettype = &ffi_type_sint;
964 *enum_tmpval = g_value_get_enum (gvalue);
965 *value = enum_tmpval;
971 rettype = &ffi_type_uint;
972 *value = (gpointer)&(gvalue->data[0].v_uint);
979 case G_TYPE_INTERFACE:
981 rettype = &ffi_type_pointer;
982 *value = (gpointer)&(gvalue->data[0].v_pointer);
985 rettype = &ffi_type_float;
986 *value = (gpointer)&(gvalue->data[0].v_float);
989 rettype = &ffi_type_double;
990 *value = (gpointer)&(gvalue->data[0].v_double);
993 rettype = &ffi_type_slong;
994 *value = (gpointer)&(gvalue->data[0].v_long);
997 rettype = &ffi_type_ulong;
998 *value = (gpointer)&(gvalue->data[0].v_ulong);
1001 rettype = &ffi_type_sint64;
1002 *value = (gpointer)&(gvalue->data[0].v_int64);
1005 rettype = &ffi_type_uint64;
1006 *value = (gpointer)&(gvalue->data[0].v_uint64);
1009 rettype = &ffi_type_pointer;
1011 g_warning ("value_to_ffi_type: Unsupported fundamental type: %s", g_type_name (type));
1018 value_from_ffi_type (GValue *gvalue, gpointer *value)
1020 ffi_arg *int_val = (ffi_arg*) value;
1022 switch (g_type_fundamental (G_VALUE_TYPE (gvalue)))
1025 g_value_set_int (gvalue, (gint) *int_val);
1028 g_value_set_float (gvalue, *(gfloat*)value);
1031 g_value_set_double (gvalue, *(gdouble*)value);
1033 case G_TYPE_BOOLEAN:
1034 g_value_set_boolean (gvalue, (gboolean) *int_val);
1037 g_value_set_string (gvalue, *(gchar**)value);
1040 g_value_set_schar (gvalue, (gint8) *int_val);
1043 g_value_set_uchar (gvalue, (guchar) *int_val);
1046 g_value_set_uint (gvalue, (guint) *int_val);
1048 case G_TYPE_POINTER:
1049 g_value_set_pointer (gvalue, *(gpointer*)value);
1052 g_value_set_long (gvalue, (glong) *int_val);
1055 g_value_set_ulong (gvalue, (gulong) *int_val);
1058 g_value_set_int64 (gvalue, (gint64) *int_val);
1061 g_value_set_uint64 (gvalue, (guint64) *int_val);
1064 g_value_set_boxed (gvalue, *(gpointer*)value);
1067 g_value_set_enum (gvalue, (gint) *int_val);
1070 g_value_set_flags (gvalue, (guint) *int_val);
1073 g_value_set_param (gvalue, *(gpointer*)value);
1076 g_value_set_object (gvalue, *(gpointer*)value);
1079 g_warning ("value_from_ffi_type: Unsupported fundamental type: %s",
1080 g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue))));
1085 * g_cclosure_marshal_generic:
1086 * @closure: A #GClosure.
1087 * @return_gvalue: A #GValue to store the return value. May be %NULL
1088 * if the callback of closure doesn't return a value.
1089 * @n_param_values: The length of the @param_values array.
1090 * @param_values: An array of #GValue<!-- -->s holding the arguments
1091 * on which to invoke the callback of closure.
1092 * @invocation_hint: The invocation hint given as the last argument to
1093 * g_closure_invoke().
1094 * @marshal_data: Additional data specified when registering the
1095 * marshaller, see g_closure_set_marshal() and
1096 * g_closure_set_meta_marshal()
1098 * A generic marshaller function implemented via <ulink
1099 * url="http://sourceware.org/libffi/">libffi</ulink>.
1104 g_cclosure_marshal_generic (GClosure *closure,
1105 GValue *return_gvalue,
1106 guint n_param_values,
1107 const GValue *param_values,
1108 gpointer invocation_hint,
1109 gpointer marshal_data)
1118 GCClosure *cc = (GCClosure*) closure;
1120 gboolean tmpval_used = FALSE;
1122 enum_tmpval = g_alloca (sizeof (gint));
1123 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1125 rtype = value_to_ffi_type (return_gvalue, &rvalue, enum_tmpval, &tmpval_used);
1129 rtype = &ffi_type_void;
1132 rvalue = g_alloca (MAX (rtype->size, sizeof (ffi_arg)));
1134 n_args = n_param_values + 1;
1135 atypes = g_alloca (sizeof (ffi_type *) * n_args);
1136 args = g_alloca (sizeof (gpointer) * n_args);
1139 enum_tmpval = g_alloca (sizeof (gint));
1141 if (G_CCLOSURE_SWAP_DATA (closure))
1143 atypes[n_args-1] = value_to_ffi_type (param_values + 0,
1147 atypes[0] = &ffi_type_pointer;
1148 args[0] = &closure->data;
1152 atypes[0] = value_to_ffi_type (param_values + 0,
1156 atypes[n_args-1] = &ffi_type_pointer;
1157 args[n_args-1] = &closure->data;
1160 for (i = 1; i < n_args - 1; i++)
1163 enum_tmpval = g_alloca (sizeof (gint));
1165 atypes[i] = value_to_ffi_type (param_values + i,
1171 if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, n_args, rtype, atypes) != FFI_OK)
1174 ffi_call (&cif, marshal_data ? marshal_data : cc->callback, rvalue, args);
1176 if (return_gvalue && G_VALUE_TYPE (return_gvalue))
1177 value_from_ffi_type (return_gvalue, rvalue);
1181 * g_cclosure_marshal_VOID__VOID:
1182 * @closure: the #GClosure to which the marshaller belongs
1183 * @return_value: ignored
1184 * @n_param_values: 1
1185 * @param_values: a #GValue array holding only the instance
1186 * @invocation_hint: the invocation hint given as the last argument
1187 * to g_closure_invoke()
1188 * @marshal_data: additional data specified when registering the marshaller
1190 * A marshaller for a #GCClosure with a callback of type
1191 * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
1195 * g_cclosure_marshal_VOID__BOOLEAN:
1196 * @closure: the #GClosure to which the marshaller belongs
1197 * @return_value: ignored
1198 * @n_param_values: 2
1199 * @param_values: a #GValue array holding the instance and the #gboolean parameter
1200 * @invocation_hint: the invocation hint given as the last argument
1201 * to g_closure_invoke()
1202 * @marshal_data: additional data specified when registering the marshaller
1204 * A marshaller for a #GCClosure with a callback of type
1205 * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
1209 * g_cclosure_marshal_VOID__CHAR:
1210 * @closure: the #GClosure to which the marshaller belongs
1211 * @return_value: ignored
1212 * @n_param_values: 2
1213 * @param_values: a #GValue array holding the instance and the #gchar parameter
1214 * @invocation_hint: the invocation hint given as the last argument
1215 * to g_closure_invoke()
1216 * @marshal_data: additional data specified when registering the marshaller
1218 * A marshaller for a #GCClosure with a callback of type
1219 * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
1223 * g_cclosure_marshal_VOID__UCHAR:
1224 * @closure: the #GClosure to which the marshaller belongs
1225 * @return_value: ignored
1226 * @n_param_values: 2
1227 * @param_values: a #GValue array holding the instance and the #guchar parameter
1228 * @invocation_hint: the invocation hint given as the last argument
1229 * to g_closure_invoke()
1230 * @marshal_data: additional data specified when registering the marshaller
1232 * A marshaller for a #GCClosure with a callback of type
1233 * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
1237 * g_cclosure_marshal_VOID__INT:
1238 * @closure: the #GClosure to which the marshaller belongs
1239 * @return_value: ignored
1240 * @n_param_values: 2
1241 * @param_values: a #GValue array holding the instance and the #gint parameter
1242 * @invocation_hint: the invocation hint given as the last argument
1243 * to g_closure_invoke()
1244 * @marshal_data: additional data specified when registering the marshaller
1246 * A marshaller for a #GCClosure with a callback of type
1247 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
1251 * g_cclosure_marshal_VOID__UINT:
1252 * @closure: the #GClosure to which the marshaller belongs
1253 * @return_value: ignored
1254 * @n_param_values: 2
1255 * @param_values: a #GValue array holding the instance and the #guint parameter
1256 * @invocation_hint: the invocation hint given as the last argument
1257 * to g_closure_invoke()
1258 * @marshal_data: additional data specified when registering the marshaller
1260 * A marshaller for a #GCClosure with a callback of type
1261 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
1265 * g_cclosure_marshal_VOID__LONG:
1266 * @closure: the #GClosure to which the marshaller belongs
1267 * @return_value: ignored
1268 * @n_param_values: 2
1269 * @param_values: a #GValue array holding the instance and the #glong parameter
1270 * @invocation_hint: the invocation hint given as the last argument
1271 * to g_closure_invoke()
1272 * @marshal_data: additional data specified when registering the marshaller
1274 * A marshaller for a #GCClosure with a callback of type
1275 * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1279 * g_cclosure_marshal_VOID__ULONG:
1280 * @closure: the #GClosure to which the marshaller belongs
1281 * @return_value: ignored
1282 * @n_param_values: 2
1283 * @param_values: a #GValue array holding the instance and the #gulong parameter
1284 * @invocation_hint: the invocation hint given as the last argument
1285 * to g_closure_invoke()
1286 * @marshal_data: additional data specified when registering the marshaller
1288 * A marshaller for a #GCClosure with a callback of type
1289 * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1293 * g_cclosure_marshal_VOID__ENUM:
1294 * @closure: the #GClosure to which the marshaller belongs
1295 * @return_value: ignored
1296 * @n_param_values: 2
1297 * @param_values: a #GValue array holding the instance and the enumeration parameter
1298 * @invocation_hint: the invocation hint given as the last argument
1299 * to g_closure_invoke()
1300 * @marshal_data: additional data specified when registering the marshaller
1302 * A marshaller for a #GCClosure with a callback of type
1303 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1307 * g_cclosure_marshal_VOID__FLAGS:
1308 * @closure: the #GClosure to which the marshaller belongs
1309 * @return_value: ignored
1310 * @n_param_values: 2
1311 * @param_values: a #GValue array holding the instance and the flags parameter
1312 * @invocation_hint: the invocation hint given as the last argument
1313 * to g_closure_invoke()
1314 * @marshal_data: additional data specified when registering the marshaller
1316 * A marshaller for a #GCClosure with a callback of type
1317 * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1321 * g_cclosure_marshal_VOID__FLOAT:
1322 * @closure: the #GClosure to which the marshaller belongs
1323 * @return_value: ignored
1324 * @n_param_values: 2
1325 * @param_values: a #GValue array holding the instance and the #gfloat parameter
1326 * @invocation_hint: the invocation hint given as the last argument
1327 * to g_closure_invoke()
1328 * @marshal_data: additional data specified when registering the marshaller
1330 * A marshaller for a #GCClosure with a callback of type
1331 * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1335 * g_cclosure_marshal_VOID__DOUBLE:
1336 * @closure: the #GClosure to which the marshaller belongs
1337 * @return_value: ignored
1338 * @n_param_values: 2
1339 * @param_values: a #GValue array holding the instance and the #gdouble parameter
1340 * @invocation_hint: the invocation hint given as the last argument
1341 * to g_closure_invoke()
1342 * @marshal_data: additional data specified when registering the marshaller
1344 * A marshaller for a #GCClosure with a callback of type
1345 * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1349 * g_cclosure_marshal_VOID__STRING:
1350 * @closure: the #GClosure to which the marshaller belongs
1351 * @return_value: ignored
1352 * @n_param_values: 2
1353 * @param_values: a #GValue array holding the instance and the #gchar* parameter
1354 * @invocation_hint: the invocation hint given as the last argument
1355 * to g_closure_invoke()
1356 * @marshal_data: additional data specified when registering the marshaller
1358 * A marshaller for a #GCClosure with a callback of type
1359 * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1363 * g_cclosure_marshal_VOID__PARAM:
1364 * @closure: the #GClosure to which the marshaller belongs
1365 * @return_value: ignored
1366 * @n_param_values: 2
1367 * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1368 * @invocation_hint: the invocation hint given as the last argument
1369 * to g_closure_invoke()
1370 * @marshal_data: additional data specified when registering the marshaller
1372 * A marshaller for a #GCClosure with a callback of type
1373 * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1377 * g_cclosure_marshal_VOID__BOXED:
1378 * @closure: the #GClosure to which the marshaller belongs
1379 * @return_value: ignored
1380 * @n_param_values: 2
1381 * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1382 * @invocation_hint: the invocation hint given as the last argument
1383 * to g_closure_invoke()
1384 * @marshal_data: additional data specified when registering the marshaller
1386 * A marshaller for a #GCClosure with a callback of type
1387 * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1391 * g_cclosure_marshal_VOID__POINTER:
1392 * @closure: the #GClosure to which the marshaller belongs
1393 * @return_value: ignored
1394 * @n_param_values: 2
1395 * @param_values: a #GValue array holding the instance and the #gpointer parameter
1396 * @invocation_hint: the invocation hint given as the last argument
1397 * to g_closure_invoke()
1398 * @marshal_data: additional data specified when registering the marshaller
1400 * A marshaller for a #GCClosure with a callback of type
1401 * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1405 * g_cclosure_marshal_VOID__OBJECT:
1406 * @closure: the #GClosure to which the marshaller belongs
1407 * @return_value: ignored
1408 * @n_param_values: 2
1409 * @param_values: a #GValue array holding the instance and the #GObject* parameter
1410 * @invocation_hint: the invocation hint given as the last argument
1411 * to g_closure_invoke()
1412 * @marshal_data: additional data specified when registering the marshaller
1414 * A marshaller for a #GCClosure with a callback of type
1415 * <literal>void (*callback) (gpointer instance, GObject *arg1, gpointer user_data)</literal>.
1419 * g_cclosure_marshal_VOID__VARIANT:
1420 * @closure: the #GClosure to which the marshaller belongs
1421 * @return_value: ignored
1422 * @n_param_values: 2
1423 * @param_values: a #GValue array holding the instance and the #GVariant* parameter
1424 * @invocation_hint: the invocation hint given as the last argument
1425 * to g_closure_invoke()
1426 * @marshal_data: additional data specified when registering the marshaller
1428 * A marshaller for a #GCClosure with a callback of type
1429 * <literal>void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data)</literal>.
1435 * g_cclosure_marshal_VOID__UINT_POINTER:
1436 * @closure: the #GClosure to which the marshaller belongs
1437 * @return_value: ignored
1438 * @n_param_values: 3
1439 * @param_values: a #GValue array holding instance, arg1 and arg2
1440 * @invocation_hint: the invocation hint given as the last argument
1441 * to g_closure_invoke()
1442 * @marshal_data: additional data specified when registering the marshaller
1444 * A marshaller for a #GCClosure with a callback of type
1445 * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1449 * g_cclosure_marshal_BOOLEAN__FLAGS:
1450 * @closure: the #GClosure to which the marshaller belongs
1451 * @return_value: a #GValue which can store the returned #gboolean
1452 * @n_param_values: 2
1453 * @param_values: a #GValue array holding instance and arg1
1454 * @invocation_hint: the invocation hint given as the last argument
1455 * to g_closure_invoke()
1456 * @marshal_data: additional data specified when registering the marshaller
1458 * A marshaller for a #GCClosure with a callback of type
1459 * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1460 * denotes a flags type.
1464 * g_cclosure_marshal_BOOL__FLAGS:
1466 * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1469 * g_cclosure_marshal_STRING__OBJECT_POINTER:
1470 * @closure: the #GClosure to which the marshaller belongs
1471 * @return_value: a #GValue, which can store the returned string
1472 * @n_param_values: 3
1473 * @param_values: a #GValue array holding instance, arg1 and arg2
1474 * @invocation_hint: the invocation hint given as the last argument
1475 * to g_closure_invoke()
1476 * @marshal_data: additional data specified when registering the marshaller
1478 * A marshaller for a #GCClosure with a callback of type
1479 * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1482 * g_cclosure_marshal_BOOLEAN__OBJECT_BOXED_BOXED:
1483 * @closure: the #GClosure to which the marshaller belongs
1484 * @return_value: a #GValue, which can store the returned string
1485 * @n_param_values: 3
1486 * @param_values: a #GValue array holding instance, arg1 and arg2
1487 * @invocation_hint: the invocation hint given as the last argument
1488 * to g_closure_invoke()
1489 * @marshal_data: additional data specified when registering the marshaller
1491 * A marshaller for a #GCClosure with a callback of type
1492 * <literal>gboolean (*callback) (gpointer instance, GBoxed *arg1, GBoxed *arg2, gpointer user_data)</literal>.