Migrating docs.
[platform/upstream/glib.git] / gobject / gclosure.c
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 2000-2001 Red Hat, Inc.
3  * Copyright (C) 2005 Imendio AB
4  *
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.
9  *
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.
14  *
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.
19  */
20 /**
21  * SECTION:Closures
22  * @Short_description: Functions as first-class objects
23  * 
24  * A #GClosure represents a callback supplied by the programmer. It will generally
25  * comprise a function of some kind and a marshaller used to call it. It is the 
26  * reponsibility of the marshaller to convert the arguments for the invocation 
27  * from #GValue<!-- -->s into a suitable form, perform the callback on the 
28  * converted arguments, and transform the return value back into a #GValue.
29  * 
30  * In the case of C programs, a closure usually just holds a pointer to a function
31  * and maybe a data argument, and the marshaller converts between #GValue<!-- -->
32  * and native C types. The GObject library provides the #GCClosure type for this
33  * purpose. Bindings for other languages need marshallers which 
34  * convert between #GValue<!-- -->s and suitable representations in the runtime
35  * of the language in order to use functions written in that languages as 
36  * callbacks.
37  * 
38  * Within GObject, closures play an important role in the implementation of 
39  * signals. When a signal is registered, the @c_marshaller argument to 
40  * g_signal_new() specifies the default C marshaller for any closure which is 
41  * connected to this signal. GObject provides a number of C marshallers  
42  * for this purpose, see the g_cclosure_marshal_*() functions. Additional
43  * C marshallers can be generated with the <link linkend="glib-genmarshal"
44  * >glib-genmarshal</link> utility.
45  * Closures can be explicitly connected to signals with 
46  * g_signal_connect_closure(), but it usually more convenient to let GObject 
47  * create a closure automatically by using one of the g_signal_connect_*() 
48  * functions which take a callback function/user data pair.
49  * 
50  * Using closures has a number of important advantages over a simple
51  * callback function/data pointer combination:
52  * <itemizedlist>
53  * <listitem><para>
54  * Closures allow the callee to get the types of the callback parameters, 
55  * which means that language bindings don't have to write individual glue 
56  * for each callback type.
57  * </para></listitem>
58  * <listitem><para>
59  * The reference counting of #GClosure makes it easy to handle reentrancy 
60  * right; if a callback is removed while it is being invoked, the closure 
61  * and it's parameters won't be freed until the invocation finishes. 
62  * </para></listitem>
63  * <listitem><para>
64  * g_closure_invalidate() and invalidation notifiers allow callbacks to be
65  * automatically removed when the objects they point to go away.
66  * </para></listitem>
67  * </itemizedlist>
68  */
69
70 #include        "gclosure.h"
71
72 /*
73  * MT safe with regards to reference counting.
74  */
75
76 #include        "gvalue.h"
77 #include        "gobjectalias.h"
78 #include        <string.h>
79
80
81 #define CLOSURE_MAX_REF_COUNT           ((1 << 15) - 1)
82 #define CLOSURE_MAX_N_GUARDS            ((1 << 1) - 1)
83 #define CLOSURE_MAX_N_FNOTIFIERS        ((1 << 2) - 1)
84 #define CLOSURE_MAX_N_INOTIFIERS        ((1 << 8) - 1)
85 #define CLOSURE_N_MFUNCS(cl)            ((cl)->meta_marshal + \
86                                          ((cl)->n_guards << 1L))
87 /* same as G_CLOSURE_N_NOTIFIERS() (keep in sync) */
88 #define CLOSURE_N_NOTIFIERS(cl)         (CLOSURE_N_MFUNCS (cl) + \
89                                          (cl)->n_fnotifiers + \
90                                          (cl)->n_inotifiers)
91
92 typedef union {
93   GClosure closure;
94   volatile gint vint;
95 } ClosureInt;
96
97 #define CHANGE_FIELD(_closure, _field, _OP, _value, _must_set, _SET_OLD, _SET_NEW)      \
98 G_STMT_START {                                                                          \
99   ClosureInt *cunion = (ClosureInt*) _closure;                                          \
100   gint new_int, old_int, success;                                                       \
101   do                                                                                    \
102     {                                                                                   \
103       ClosureInt tmp;                                                                   \
104       tmp.vint = old_int = cunion->vint;                                                \
105       _SET_OLD tmp.closure._field;                                                      \
106       tmp.closure._field _OP _value;                                                    \
107       _SET_NEW tmp.closure._field;                                                      \
108       new_int = tmp.vint;                                                               \
109       success = g_atomic_int_compare_and_exchange (&cunion->vint, old_int, new_int);    \
110     }                                                                                   \
111   while (!success && _must_set);                                                        \
112 } G_STMT_END
113
114 #define SWAP(_closure, _field, _value, _oldv)   CHANGE_FIELD (_closure, _field, =, _value, TRUE, *(_oldv) =,     (void) )
115 #define SET(_closure, _field, _value)           CHANGE_FIELD (_closure, _field, =, _value, TRUE,     (void),     (void) )
116 #define INC(_closure, _field)                   CHANGE_FIELD (_closure, _field, +=,     1, TRUE,     (void),     (void) )
117 #define INC_ASSIGN(_closure, _field, _newv)     CHANGE_FIELD (_closure, _field, +=,     1, TRUE,     (void), *(_newv) = )
118 #define DEC(_closure, _field)                   CHANGE_FIELD (_closure, _field, -=,     1, TRUE,     (void),     (void) )
119 #define DEC_ASSIGN(_closure, _field, _newv)     CHANGE_FIELD (_closure, _field, -=,     1, TRUE,     (void), *(_newv) = )
120
121 #if 0   /* for non-thread-safe closures */
122 #define SWAP(cl,f,v,o)     (void) (*(o) = cl->f, cl->f = v)
123 #define SET(cl,f,v)        (void) (cl->f = v)
124 #define INC(cl,f)          (void) (cl->f += 1)
125 #define INC_ASSIGN(cl,f,n) (void) (cl->f += 1, *(n) = cl->f)
126 #define DEC(cl,f)          (void) (cl->f -= 1)
127 #define DEC_ASSIGN(cl,f,n) (void) (cl->f -= 1, *(n) = cl->f)
128 #endif
129
130 enum {
131   FNOTIFY,
132   INOTIFY,
133   PRE_NOTIFY,
134   POST_NOTIFY
135 };
136
137
138 /* --- functions --- */
139 /**
140  * g_closure_new_simple:
141  * @sizeof_closure: the size of the structure to allocate, must be at least 
142  *  <literal>sizeof (GClosure)</literal>
143  * @data: data to store in the @data field of the newly allocated #GClosure
144  * 
145  * Allocates a struct of the given size and initializes the initial part
146  * as a #GClosure. This function is mainly useful when implementing new types 
147  * of closures.
148  * 
149  * |[
150  * typedef struct _MyClosure MyClosure;
151  * struct _MyClosure 
152  * {
153  *   GClosure closure;
154  *   // extra data goes here
155  * };    
156  * 
157  * static void
158  * my_closure_finalize (gpointer  notify_data, 
159  *                      GClosure *closure)
160  * {
161  *   MyClosure *my_closure = (MyClosure *)closure;
162  * 
163  *   // free extra data here
164  * }
165  * 
166  * MyClosure *my_closure_new (gpointer data)
167  * {
168  *   GClosure *closure;
169  *   MyClosure *my_closure;
170  *   
171  *   closure = g_closure_new_simple (sizeof (MyClosure), data);
172  *   my_closure = (MyClosure *) closure;
173  * 
174  *   // initialize extra data here
175  * 
176  *   g_closure_add_finalize_notifier (closure, notify_data,
177  *                                    my_closure_finalize);
178  *   return my_closure;
179  * }
180  * ]|
181  * 
182  * Returns: a newly allocated #GClosure
183  */
184 GClosure*
185 g_closure_new_simple (guint           sizeof_closure,
186                       gpointer        data)
187 {
188   GClosure *closure;
189
190   g_return_val_if_fail (sizeof_closure >= sizeof (GClosure), NULL);
191
192   closure = g_malloc0 (sizeof_closure);
193   SET (closure, ref_count, 1);
194   SET (closure, meta_marshal, 0);
195   SET (closure, n_guards, 0);
196   SET (closure, n_fnotifiers, 0);
197   SET (closure, n_inotifiers, 0);
198   SET (closure, in_inotify, FALSE);
199   SET (closure, floating, TRUE);
200   SET (closure, derivative_flag, 0);
201   SET (closure, in_marshal, FALSE);
202   SET (closure, is_invalid, FALSE);
203   closure->marshal = NULL;
204   closure->data = data;
205   closure->notifiers = NULL;
206   memset (G_STRUCT_MEMBER_P (closure, sizeof (*closure)), 0, sizeof_closure - sizeof (*closure));
207
208   return closure;
209 }
210
211 static inline void
212 closure_invoke_notifiers (GClosure *closure,
213                           guint     notify_type)
214 {
215   /* notifier layout:
216    *     meta_marshal  n_guards    n_guards     n_fnotif.  n_inotifiers
217    * ->[[meta_marshal][pre_guards][post_guards][fnotifiers][inotifiers]]
218    *
219    * CLOSURE_N_MFUNCS(cl)    = meta_marshal + n_guards + n_guards;
220    * CLOSURE_N_NOTIFIERS(cl) = CLOSURE_N_MFUNCS(cl) + n_fnotifiers + n_inotifiers
221    *
222    * constrains/catches:
223    * - closure->notifiers may be reloacted during callback
224    * - closure->n_fnotifiers and closure->n_inotifiers may change during callback
225    * - i.e. callbacks can be removed/added during invocation
226    * - must prepare for callback removal during FNOTIFY and INOTIFY (done via ->marshal= & ->data=)
227    * - must distinguish (->marshal= & ->data=) for INOTIFY vs. FNOTIFY (via ->in_inotify)
228    * + closure->n_guards is const during PRE_NOTIFY & POST_NOTIFY
229    * + closure->meta_marshal is const for all cases
230    * + none of the callbacks can cause recursion
231    * + closure->n_inotifiers is const 0 during FNOTIFY
232    */
233   switch (notify_type)
234     {
235       GClosureNotifyData *ndata;
236       guint i, offs;
237     case FNOTIFY:
238       while (closure->n_fnotifiers)
239         {
240           guint n;
241           DEC_ASSIGN (closure, n_fnotifiers, &n);
242
243           ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + n;
244           closure->marshal = (GClosureMarshal) ndata->notify;
245           closure->data = ndata->data;
246           ndata->notify (ndata->data, closure);
247         }
248       closure->marshal = NULL;
249       closure->data = NULL;
250       break;
251     case INOTIFY:
252       SET (closure, in_inotify, TRUE);
253       while (closure->n_inotifiers)
254         {
255           guint n;
256           DEC_ASSIGN (closure, n_inotifiers, &n);
257
258           ndata = closure->notifiers + CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + n;
259           closure->marshal = (GClosureMarshal) ndata->notify;
260           closure->data = ndata->data;
261           ndata->notify (ndata->data, closure);
262         }
263       closure->marshal = NULL;
264       closure->data = NULL;
265       SET (closure, in_inotify, FALSE);
266       break;
267     case PRE_NOTIFY:
268       i = closure->n_guards;
269       offs = closure->meta_marshal;
270       while (i--)
271         {
272           ndata = closure->notifiers + offs + i;
273           ndata->notify (ndata->data, closure);
274         }
275       break;
276     case POST_NOTIFY:
277       i = closure->n_guards;
278       offs = closure->meta_marshal + i;
279       while (i--)
280         {
281           ndata = closure->notifiers + offs + i;
282           ndata->notify (ndata->data, closure);
283         }
284       break;
285     }
286 }
287
288 /**
289  * g_closure_set_meta_marshal:
290  * @closure: a #GClosure
291  * @marshal_data: context-dependent data to pass to @meta_marshal
292  * @meta_marshal: a #GClosureMarshal function
293  * 
294  * Sets the meta marshaller of @closure. 
295  * A meta marshaller wraps @closure->marshal and modifies the way it is called 
296  * in some fashion. The most common use of this facility is for C callbacks. 
297  * The same marshallers (generated by 
298  * <link linkend="glib-genmarshal">glib-genmarshal</link>) are used everywhere,
299  * but the way that we get the callback function differs. In most cases we want 
300  * to use @closure->callback, but in other cases we want to use some 
301  * different technique to retrieve the callback function.
302  * 
303  * For example, class closures for signals (see g_signal_type_cclosure_new()) 
304  * retrieve the callback function from a fixed offset in the class structure. 
305  * The meta marshaller retrieves the right callback and passes it to the 
306  * marshaller as the @marshal_data argument.
307  */
308 void
309 g_closure_set_meta_marshal (GClosure       *closure,
310                             gpointer        marshal_data,
311                             GClosureMarshal meta_marshal)
312 {
313   GClosureNotifyData *notifiers;
314
315   g_return_if_fail (closure != NULL);
316   g_return_if_fail (meta_marshal != NULL);
317   g_return_if_fail (closure->is_invalid == FALSE);
318   g_return_if_fail (closure->in_marshal == FALSE);
319   g_return_if_fail (closure->meta_marshal == 0);
320
321   notifiers = closure->notifiers;
322   closure->notifiers = g_renew (GClosureNotifyData, NULL, CLOSURE_N_NOTIFIERS (closure) + 1);
323   if (notifiers)
324     {
325       /* usually the meta marshal will be setup right after creation, so the
326        * g_memmove() should be rare-case scenario
327        */
328       g_memmove (closure->notifiers + 1, notifiers, CLOSURE_N_NOTIFIERS (closure) * sizeof (notifiers[0]));
329       g_free (notifiers);
330     }
331   closure->notifiers[0].data = marshal_data;
332   closure->notifiers[0].notify = (GClosureNotify) meta_marshal;
333   SET (closure, meta_marshal, 1);
334 }
335
336 /**
337  * g_closure_add_marshal_guards:
338  * @closure: a #GClosure
339  * @pre_marshal_data: data to pass to @pre_marshal_notify
340  * @pre_marshal_notify: a function to call before the closure callback
341  * @post_marshal_data: data to pass to @post_marshal_notify
342  * @post_marshal_notify: a function to call after the closure callback
343  * 
344  * Adds a pair of notifiers which get invoked before and after the closure 
345  * callback, respectively. This is typically used to protect the extra arguments
346  * for the duration of the callback. See g_object_watch_closure() for an
347  * example of marshal guards.
348  */
349 void
350 g_closure_add_marshal_guards (GClosure      *closure,
351                               gpointer       pre_marshal_data,
352                               GClosureNotify pre_marshal_notify,
353                               gpointer       post_marshal_data,
354                               GClosureNotify post_marshal_notify)
355 {
356   guint i;
357
358   g_return_if_fail (closure != NULL);
359   g_return_if_fail (pre_marshal_notify != NULL);
360   g_return_if_fail (post_marshal_notify != NULL);
361   g_return_if_fail (closure->is_invalid == FALSE);
362   g_return_if_fail (closure->in_marshal == FALSE);
363   g_return_if_fail (closure->n_guards < CLOSURE_MAX_N_GUARDS);
364
365   closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 2);
366   if (closure->n_inotifiers)
367     closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
368                         closure->n_fnotifiers +
369                         closure->n_inotifiers + 1)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
370                                                                           closure->n_fnotifiers + 0)];
371   if (closure->n_inotifiers > 1)
372     closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
373                         closure->n_fnotifiers +
374                         closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
375                                                                       closure->n_fnotifiers + 1)];
376   if (closure->n_fnotifiers)
377     closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
378                         closure->n_fnotifiers + 1)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 0];
379   if (closure->n_fnotifiers > 1)
380     closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
381                         closure->n_fnotifiers)] = closure->notifiers[CLOSURE_N_MFUNCS (closure) + 1];
382   if (closure->n_guards)
383     closure->notifiers[(closure->meta_marshal +
384                         closure->n_guards +
385                         closure->n_guards + 1)] = closure->notifiers[closure->meta_marshal + closure->n_guards];
386   i = closure->n_guards;
387   closure->notifiers[closure->meta_marshal + i].data = pre_marshal_data;
388   closure->notifiers[closure->meta_marshal + i].notify = pre_marshal_notify;
389   closure->notifiers[closure->meta_marshal + i + 1].data = post_marshal_data;
390   closure->notifiers[closure->meta_marshal + i + 1].notify = post_marshal_notify;
391   INC (closure, n_guards);
392 }
393
394 /**
395  * g_closure_add_finalize_notifier:
396  * @closure: a #GClosure
397  * @notify_data: data to pass to @notify_func
398  * @notify_func: the callback function to register
399  * 
400  * Registers a finalization notifier which will be called when the reference
401  * count of @closure goes down to 0. Multiple finalization notifiers on a 
402  * single closure are invoked in unspecified order. If a single call to 
403  * g_closure_unref() results in the closure being both invalidated and 
404  * finalized, then the invalidate notifiers will be run before the finalize 
405  * notifiers.
406  */
407 void
408 g_closure_add_finalize_notifier (GClosure      *closure,
409                                  gpointer       notify_data,
410                                  GClosureNotify notify_func)
411 {
412   guint i;
413
414   g_return_if_fail (closure != NULL);
415   g_return_if_fail (notify_func != NULL);
416   g_return_if_fail (closure->n_fnotifiers < CLOSURE_MAX_N_FNOTIFIERS);
417
418   closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
419   if (closure->n_inotifiers)
420     closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
421                         closure->n_fnotifiers +
422                         closure->n_inotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
423                                                                       closure->n_fnotifiers + 0)];
424   i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers;
425   closure->notifiers[i].data = notify_data;
426   closure->notifiers[i].notify = notify_func;
427   INC (closure, n_fnotifiers);
428 }
429
430 /**
431  * g_closure_add_invalidate_notifier:
432  * @closure: a #GClosure
433  * @notify_data: data to pass to @notify_func
434  * @notify_func: the callback function to register
435  * 
436  * Registers an invalidation notifier which will be called when the @closure
437  * is invalidated with g_closure_invalidate(). Invalidation notifiers are 
438  * invoked before finalization notifiers, in an unspecified order.
439  */
440 void
441 g_closure_add_invalidate_notifier (GClosure      *closure,
442                                    gpointer       notify_data,
443                                    GClosureNotify notify_func)
444 {
445   guint i;
446
447   g_return_if_fail (closure != NULL);
448   g_return_if_fail (notify_func != NULL);
449   g_return_if_fail (closure->is_invalid == FALSE);
450   g_return_if_fail (closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS);
451
452   closure->notifiers = g_renew (GClosureNotifyData, closure->notifiers, CLOSURE_N_NOTIFIERS (closure) + 1);
453   i = CLOSURE_N_MFUNCS (closure) + closure->n_fnotifiers + closure->n_inotifiers;
454   closure->notifiers[i].data = notify_data;
455   closure->notifiers[i].notify = notify_func;
456   INC (closure, n_inotifiers);
457 }
458
459 static inline gboolean
460 closure_try_remove_inotify (GClosure       *closure,
461                             gpointer       notify_data,
462                             GClosureNotify notify_func)
463 {
464   GClosureNotifyData *ndata, *nlast;
465
466   nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - 1;
467   for (ndata = nlast + 1 - closure->n_inotifiers; ndata <= nlast; ndata++)
468     if (ndata->notify == notify_func && ndata->data == notify_data)
469       {
470         DEC (closure, n_inotifiers);
471         if (ndata < nlast)
472           *ndata = *nlast;
473
474         return TRUE;
475       }
476   return FALSE;
477 }
478
479 static inline gboolean
480 closure_try_remove_fnotify (GClosure       *closure,
481                             gpointer       notify_data,
482                             GClosureNotify notify_func)
483 {
484   GClosureNotifyData *ndata, *nlast;
485
486   nlast = closure->notifiers + CLOSURE_N_NOTIFIERS (closure) - closure->n_inotifiers - 1;
487   for (ndata = nlast + 1 - closure->n_fnotifiers; ndata <= nlast; ndata++)
488     if (ndata->notify == notify_func && ndata->data == notify_data)
489       {
490         DEC (closure, n_fnotifiers);
491         if (ndata < nlast)
492           *ndata = *nlast;
493         if (closure->n_inotifiers)
494           closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
495                               closure->n_fnotifiers)] = closure->notifiers[(CLOSURE_N_MFUNCS (closure) +
496                                                                             closure->n_fnotifiers +
497                                                                             closure->n_inotifiers)];
498         return TRUE;
499       }
500   return FALSE;
501 }
502
503 /**
504  * g_closure_ref:
505  * @closure: #GClosure to increment the reference count on
506  * 
507  * Increments the reference count on a closure to force it staying
508  * alive while the caller holds a pointer to it.
509  * 
510  * Returns: The @closure passed in, for convenience
511  */
512 GClosure*
513 g_closure_ref (GClosure *closure)
514 {
515   guint new_ref_count;
516   g_return_val_if_fail (closure != NULL, NULL);
517   g_return_val_if_fail (closure->ref_count > 0, NULL);
518   g_return_val_if_fail (closure->ref_count < CLOSURE_MAX_REF_COUNT, NULL);
519
520   INC_ASSIGN (closure, ref_count, &new_ref_count);
521   g_return_val_if_fail (new_ref_count > 1, NULL);
522
523   return closure;
524 }
525
526 /**
527  * g_closure_invalidate:
528  * @closure: GClosure to invalidate
529  * 
530  * Sets a flag on the closure to indicate that it's calling environment has 
531  * become invalid, and thus causes any future invocations of g_closure_invoke() 
532  * on this @closure to be ignored. Also, invalidation notifiers installed on 
533  * the closure will be called at this point. Note that unless you are holding 
534  * a reference to the closure yourself, the invalidation notifiers may unref 
535  * the closure and cause it to be destroyed, so if you need to access the 
536  * closure after calling g_closure_invalidate(), make sure that you've 
537  * previously called g_closure_ref().
538  * 
539  * Note that g_closure_invalidate() will also be called when the reference count
540  * of a closure drops to zero (unless it has already been invalidated before).
541  */
542 void
543 g_closure_invalidate (GClosure *closure)
544 {
545   g_return_if_fail (closure != NULL);
546
547   if (!closure->is_invalid)
548     {
549       gboolean was_invalid;
550       g_closure_ref (closure);           /* preserve floating flag */
551       SWAP (closure, is_invalid, TRUE, &was_invalid);
552       /* invalidate only once */
553       if (!was_invalid)
554         closure_invoke_notifiers (closure, INOTIFY);
555       g_closure_unref (closure);
556     }
557 }
558
559 /**
560  * g_closure_unref:
561  * @closure: #GClosure to decrement the reference count on
562  * 
563  * Decrements the reference count of a closure after it was previously 
564  * incremented by the same caller. If no other callers are using the closure,
565  * then the closure will be destroyed and freed.
566  */
567 void
568 g_closure_unref (GClosure *closure)
569 {
570   guint new_ref_count;
571
572   g_return_if_fail (closure != NULL);
573   g_return_if_fail (closure->ref_count > 0);
574
575   if (closure->ref_count == 1)  /* last unref, invalidate first */
576     g_closure_invalidate (closure);
577
578   DEC_ASSIGN (closure, ref_count, &new_ref_count);
579
580   if (new_ref_count == 0)
581     {
582       closure_invoke_notifiers (closure, FNOTIFY);
583       g_free (closure->notifiers);
584       g_free (closure);
585     }
586 }
587
588 /**
589  * g_closure_sink:
590  * @closure: #GClosure to decrement the initial reference count on, if it's
591  *  still being held
592  * 
593  * Takes over the initial ownership of a closure.
594  * Each closure is initially created in a <firstterm>floating</firstterm> state, 
595  * which means that the initial reference count is not owned by any caller. 
596  * g_closure_sink() checks to see if the object is still floating, and if so, 
597  * unsets the floating state and decreases the reference count. If the closure 
598  * is not floating, g_closure_sink() does nothing. The reason for the existance 
599  * of the floating state is to prevent cumbersome code sequences like: 
600  * |[
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
604  * ]|
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: 
607  * |[
608  * g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
609  * ]|
610  * 
611  * Generally, this function is used together with g_closure_ref(). Ane example 
612  * of storing a closure for later notification looks like:
613  * |[
614  * static GClosure *notify_closure = NULL;
615  * void
616  * foo_notify_set_closure (GClosure *closure)
617  * {
618  *   if (notify_closure)
619  *     g_closure_unref (notify_closure);
620  *   notify_closure = closure;
621  *   if (notify_closure)
622  *     {
623  *       g_closure_ref (notify_closure);
624  *       g_closure_sink (notify_closure);
625  *     }
626  * }
627  * ]|
628  * 
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.
632  */
633 void
634 g_closure_sink (GClosure *closure)
635 {
636   g_return_if_fail (closure != NULL);
637   g_return_if_fail (closure->ref_count > 0);
638
639   /* floating is basically a kludge to avoid creating closures
640    * with a ref_count of 0. so the intial 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.
643    */
644   if (closure->floating)
645     {
646       gboolean was_floating;
647       SWAP (closure, floating, FALSE, &was_floating);
648       /* unref floating flag only once */
649       if (was_floating)
650         g_closure_unref (closure);
651     }
652 }
653
654 /**
655  * g_closure_remove_invalidate_notifier:
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
660  * 
661  * Removes an invalidation notifier.
662  * 
663  * 
664  * Notice that notifiers are automatically removed after they are run.
665  */
666 void
667 g_closure_remove_invalidate_notifier (GClosure      *closure,
668                                       gpointer       notify_data,
669                                       GClosureNotify notify_func)
670 {
671   g_return_if_fail (closure != NULL);
672   g_return_if_fail (notify_func != NULL);
673
674   if (closure->is_invalid && closure->in_inotify && /* account removal of notify_func() while its called */
675       ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
676       closure->data == notify_data)
677     closure->marshal = NULL;
678   else if (!closure_try_remove_inotify (closure, notify_data, notify_func))
679     g_warning (G_STRLOC ": unable to remove uninstalled invalidation notifier: %p (%p)",
680                notify_func, notify_data);
681 }
682
683 /**
684  * g_closure_remove_finalize_notifier:
685  * @closure: a #GClosure
686  * @notify_data: data which was passed to g_closure_add_finalize_notifier()
687  *  when registering @notify_func
688  * @notify_func: the callback function to remove
689  * 
690  * Removes a finalization notifier.
691  * 
692  * Notice that notifiers are automatically removed after they are run.
693  */
694 void
695 g_closure_remove_finalize_notifier (GClosure      *closure,
696                                     gpointer       notify_data,
697                                     GClosureNotify notify_func)
698 {
699   g_return_if_fail (closure != NULL);
700   g_return_if_fail (notify_func != NULL);
701
702   if (closure->is_invalid && !closure->in_inotify && /* account removal of notify_func() while its called */
703       ((gpointer) closure->marshal) == ((gpointer) notify_func) &&
704       closure->data == notify_data)
705     closure->marshal = NULL;
706   else if (!closure_try_remove_fnotify (closure, notify_data, notify_func))
707     g_warning (G_STRLOC ": unable to remove uninstalled finalization notifier: %p (%p)",
708                notify_func, notify_data);
709 }
710
711 /**
712  * g_closure_invoke:
713  * @closure: a #GClosure
714  * @return_value: a #GValue to store the return value. May be %NULL if the
715  *  callback of @closure doesn't return a value.
716  * @n_param_values: the length of the @param_values array
717  * @param_values: an array of #GValue<!-- -->s holding the arguments on
718  *  which to invoke the callback of @closure
719  * @invocation_hint: a context-dependent invocation hint
720  * 
721  * Invokes the closure, i.e. executes the callback represented by the @closure.
722  */
723 void
724 g_closure_invoke (GClosure       *closure,
725                   GValue /*out*/ *return_value,
726                   guint           n_param_values,
727                   const GValue   *param_values,
728                   gpointer        invocation_hint)
729 {
730   g_return_if_fail (closure != NULL);
731
732   g_closure_ref (closure);      /* preserve floating flag */
733   if (!closure->is_invalid)
734     {
735       GClosureMarshal marshal;
736       gpointer marshal_data;
737       gboolean in_marshal = closure->in_marshal;
738
739       g_return_if_fail (closure->marshal || closure->meta_marshal);
740
741       SET (closure, in_marshal, TRUE);
742       if (closure->meta_marshal)
743         {
744           marshal_data = closure->notifiers[0].data;
745           marshal = (GClosureMarshal) closure->notifiers[0].notify;
746         }
747       else
748         {
749           marshal_data = NULL;
750           marshal = closure->marshal;
751         }
752       if (!in_marshal)
753         closure_invoke_notifiers (closure, PRE_NOTIFY);
754       marshal (closure,
755                return_value,
756                n_param_values, param_values,
757                invocation_hint,
758                marshal_data);
759       if (!in_marshal)
760         closure_invoke_notifiers (closure, POST_NOTIFY);
761       SET (closure, in_marshal, in_marshal);
762     }
763   g_closure_unref (closure);
764 }
765
766 /**
767  * g_closure_set_marshal:
768  * @closure: a #GClosure
769  * @marshal: a #GClosureMarshal function
770  * 
771  * Sets the marshaller of @closure. The <literal>marshal_data</literal>
772  * of @marshal provides a way for a meta marshaller to provide additional
773  * information to the marshaller. (See g_closure_set_meta_marshal().) For
774  * GObject's C predefined marshallers (the g_cclosure_marshal_*()
775  * functions), what it provides is a callback function to use instead of
776  * @closure->callback.
777  */
778 void
779 g_closure_set_marshal (GClosure       *closure,
780                        GClosureMarshal marshal)
781 {
782   g_return_if_fail (closure != NULL);
783   g_return_if_fail (marshal != NULL);
784
785   if (closure->marshal && closure->marshal != marshal)
786     g_warning ("attempt to override closure->marshal (%p) with new marshal (%p)",
787                closure->marshal, marshal);
788   else
789     closure->marshal = marshal;
790 }
791
792 /**
793  * g_cclosure_new:
794  * @callback_func: the function to invoke
795  * @user_data: user data to pass to @callback_func
796  * @destroy_data: destroy notify to be called when @user_data is no longer used
797  * 
798  * Creates a new closure which invokes @callback_func with @user_data as 
799  * the last parameter. 
800  * 
801  * Returns: a new #GCClosure
802  */
803 GClosure*
804 g_cclosure_new (GCallback      callback_func,
805                 gpointer       user_data,
806                 GClosureNotify destroy_data)
807 {
808   GClosure *closure;
809   
810   g_return_val_if_fail (callback_func != NULL, NULL);
811   
812   closure = g_closure_new_simple (sizeof (GCClosure), user_data);
813   if (destroy_data)
814     g_closure_add_finalize_notifier (closure, user_data, destroy_data);
815   ((GCClosure*) closure)->callback = (gpointer) callback_func;
816   
817   return closure;
818 }
819
820 /**
821  * g_cclosure_new_swap:
822  * @callback_func: the function to invoke
823  * @user_data: user data to pass to @callback_func
824  * @destroy_data: destroy notify to be called when @user_data is no longer used
825  * 
826  * Creates a new closure which invokes @callback_func with @user_data as 
827  * the first parameter. 
828  * 
829  * Returns: a new #GCClosure
830  */
831 GClosure*
832 g_cclosure_new_swap (GCallback      callback_func,
833                      gpointer       user_data,
834                      GClosureNotify destroy_data)
835 {
836   GClosure *closure;
837   
838   g_return_val_if_fail (callback_func != NULL, NULL);
839   
840   closure = g_closure_new_simple (sizeof (GCClosure), user_data);
841   if (destroy_data)
842     g_closure_add_finalize_notifier (closure, user_data, destroy_data);
843   ((GCClosure*) closure)->callback = (gpointer) callback_func;
844   SET (closure, derivative_flag, TRUE);
845   
846   return closure;
847 }
848
849 static void
850 g_type_class_meta_marshal (GClosure       *closure,
851                            GValue /*out*/ *return_value,
852                            guint           n_param_values,
853                            const GValue   *param_values,
854                            gpointer        invocation_hint,
855                            gpointer        marshal_data)
856 {
857   GTypeClass *class;
858   gpointer callback;
859   /* GType itype = (GType) closure->data; */
860   guint offset = GPOINTER_TO_UINT (marshal_data);
861   
862   class = G_TYPE_INSTANCE_GET_CLASS (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
863   callback = G_STRUCT_MEMBER (gpointer, class, offset);
864   if (callback)
865     closure->marshal (closure,
866                       return_value,
867                       n_param_values, param_values,
868                       invocation_hint,
869                       callback);
870 }
871
872 static void
873 g_type_iface_meta_marshal (GClosure       *closure,
874                            GValue /*out*/ *return_value,
875                            guint           n_param_values,
876                            const GValue   *param_values,
877                            gpointer        invocation_hint,
878                            gpointer        marshal_data)
879 {
880   GTypeClass *class;
881   gpointer callback;
882   GType itype = (GType) closure->data;
883   guint offset = GPOINTER_TO_UINT (marshal_data);
884   
885   class = G_TYPE_INSTANCE_GET_INTERFACE (g_value_peek_pointer (param_values + 0), itype, GTypeClass);
886   callback = G_STRUCT_MEMBER (gpointer, class, offset);
887   if (callback)
888     closure->marshal (closure,
889                       return_value,
890                       n_param_values, param_values,
891                       invocation_hint,
892                       callback);
893 }
894
895 GClosure*
896 g_signal_type_cclosure_new (GType    itype,
897                             guint    struct_offset)
898 {
899   GClosure *closure;
900   
901   g_return_val_if_fail (G_TYPE_IS_CLASSED (itype) || G_TYPE_IS_INTERFACE (itype), NULL);
902   g_return_val_if_fail (struct_offset >= sizeof (GTypeClass), NULL);
903   
904   closure = g_closure_new_simple (sizeof (GClosure), (gpointer) itype);
905   if (G_TYPE_IS_INTERFACE (itype))
906     g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_iface_meta_marshal);
907   else
908     g_closure_set_meta_marshal (closure, GUINT_TO_POINTER (struct_offset), g_type_class_meta_marshal);
909   
910   return closure;
911 }
912
913
914 /**
915  * g_cclosure_marshal_VOID__VOID:
916  * @closure: the #GClosure to which the marshaller belongs
917  * @return_value: ignored
918  * @n_param_values: 1
919  * @param_values: a #GValue array holding only the instance
920  * @invocation_hint: the invocation hint given as the last argument
921  *  to g_closure_invoke()
922  * @marshal_data: additional data specified when registering the marshaller
923  * 
924  * A marshaller for a #GCClosure with a callback of type
925  * <literal>void (*callback) (gpointer instance, gpointer user_data)</literal>.
926  */
927 /**
928  * g_cclosure_marshal_VOID__BOOLEAN:
929  * @closure: the #GClosure to which the marshaller belongs
930  * @return_value: ignored
931  * @n_param_values: 2
932  * @param_values: a #GValue array holding the instance and the #gboolean parameter
933  * @invocation_hint: the invocation hint given as the last argument
934  *  to g_closure_invoke()
935  * @marshal_data: additional data specified when registering the marshaller
936  * 
937  * A marshaller for a #GCClosure with a callback of type
938  * <literal>void (*callback) (gpointer instance, gboolean arg1, gpointer user_data)</literal>.
939  */
940 /**
941  * g_cclosure_marshal_VOID__CHAR:
942  * @closure: the #GClosure to which the marshaller belongs
943  * @return_value: ignored
944  * @n_param_values: 2
945  * @param_values: a #GValue array holding the instance and the #gchar parameter
946  * @invocation_hint: the invocation hint given as the last argument
947  *  to g_closure_invoke()
948  * @marshal_data: additional data specified when registering the marshaller
949  * 
950  * A marshaller for a #GCClosure with a callback of type
951  * <literal>void (*callback) (gpointer instance, gchar arg1, gpointer user_data)</literal>.
952  */
953 /**
954  * g_cclosure_marshal_VOID__UCHAR:
955  * @closure: the #GClosure to which the marshaller belongs
956  * @return_value: ignored
957  * @n_param_values: 2
958  * @param_values: a #GValue array holding the instance and the #guchar parameter
959  * @invocation_hint: the invocation hint given as the last argument
960  *  to g_closure_invoke()
961  * @marshal_data: additional data specified when registering the marshaller
962  * 
963  * A marshaller for a #GCClosure with a callback of type
964  * <literal>void (*callback) (gpointer instance, guchar arg1, gpointer user_data)</literal>.
965  */
966 /**
967  * g_cclosure_marshal_VOID__INT:
968  * @closure: the #GClosure to which the marshaller belongs
969  * @return_value: ignored
970  * @n_param_values: 2
971  * @param_values: a #GValue array holding the instance and the #gint parameter
972  * @invocation_hint: the invocation hint given as the last argument
973  *  to g_closure_invoke()
974  * @marshal_data: additional data specified when registering the marshaller
975  * 
976  * A marshaller for a #GCClosure with a callback of type
977  * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal>.
978  */
979 /**
980  * g_cclosure_marshal_VOID__UINT:
981  * @closure: the #GClosure to which the marshaller belongs
982  * @return_value: ignored
983  * @n_param_values: 2
984  * @param_values: a #GValue array holding the instance and the #guint parameter
985  * @invocation_hint: the invocation hint given as the last argument
986  *  to g_closure_invoke()
987  * @marshal_data: additional data specified when registering the marshaller
988  * 
989  * A marshaller for a #GCClosure with a callback of type
990  * <literal>void (*callback) (gpointer instance, guint arg1, gpointer user_data)</literal>.
991  */
992 /**
993  * g_cclosure_marshal_VOID__LONG:
994  * @closure: the #GClosure to which the marshaller belongs
995  * @return_value: ignored
996  * @n_param_values: 2
997  * @param_values: a #GValue array holding the instance and the #glong parameter
998  * @invocation_hint: the invocation hint given as the last argument
999  *  to g_closure_invoke()
1000  * @marshal_data: additional data specified when registering the marshaller
1001  * 
1002  * A marshaller for a #GCClosure with a callback of type
1003  * <literal>void (*callback) (gpointer instance, glong arg1, gpointer user_data)</literal>.
1004  */
1005 /**
1006  * g_cclosure_marshal_VOID__ULONG:
1007  * @closure: the #GClosure to which the marshaller belongs
1008  * @return_value: ignored
1009  * @n_param_values: 2
1010  * @param_values: a #GValue array holding the instance and the #gulong parameter
1011  * @invocation_hint: the invocation hint given as the last argument
1012  *  to g_closure_invoke()
1013  * @marshal_data: additional data specified when registering the marshaller
1014  * 
1015  * A marshaller for a #GCClosure with a callback of type
1016  * <literal>void (*callback) (gpointer instance, gulong arg1, gpointer user_data)</literal>.
1017  */
1018 /**
1019  * g_cclosure_marshal_VOID__ENUM:
1020  * @closure: the #GClosure to which the marshaller belongs
1021  * @return_value: ignored
1022  * @n_param_values: 2
1023  * @param_values: a #GValue array holding the instance and the enumeration parameter
1024  * @invocation_hint: the invocation hint given as the last argument
1025  *  to g_closure_invoke()
1026  * @marshal_data: additional data specified when registering the marshaller
1027  * 
1028  * A marshaller for a #GCClosure with a callback of type
1029  * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes an enumeration type..
1030  */
1031 /**
1032  * g_cclosure_marshal_VOID__FLAGS:
1033  * @closure: the #GClosure to which the marshaller belongs
1034  * @return_value: ignored
1035  * @n_param_values: 2
1036  * @param_values: a #GValue array holding the instance and the flags parameter
1037  * @invocation_hint: the invocation hint given as the last argument
1038  *  to g_closure_invoke()
1039  * @marshal_data: additional data specified when registering the marshaller
1040  * 
1041  * A marshaller for a #GCClosure with a callback of type
1042  * <literal>void (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter denotes a flags type.
1043  */
1044 /**
1045  * g_cclosure_marshal_VOID__FLOAT:
1046  * @closure: the #GClosure to which the marshaller belongs
1047  * @return_value: ignored
1048  * @n_param_values: 2
1049  * @param_values: a #GValue array holding the instance and the #gfloat parameter
1050  * @invocation_hint: the invocation hint given as the last argument
1051  *  to g_closure_invoke()
1052  * @marshal_data: additional data specified when registering the marshaller
1053  * 
1054  * A marshaller for a #GCClosure with a callback of type
1055  * <literal>void (*callback) (gpointer instance, gfloat arg1, gpointer user_data)</literal>.
1056  */
1057 /**
1058  * g_cclosure_marshal_VOID__DOUBLE:
1059  * @closure: the #GClosure to which the marshaller belongs
1060  * @return_value: ignored
1061  * @n_param_values: 2
1062  * @param_values: a #GValue array holding the instance and the #gdouble parameter
1063  * @invocation_hint: the invocation hint given as the last argument
1064  *  to g_closure_invoke()
1065  * @marshal_data: additional data specified when registering the marshaller
1066  * 
1067  * A marshaller for a #GCClosure with a callback of type
1068  * <literal>void (*callback) (gpointer instance, gdouble arg1, gpointer user_data)</literal>.
1069  */
1070 /**
1071  * g_cclosure_marshal_VOID__STRING:
1072  * @closure: the #GClosure to which the marshaller belongs
1073  * @return_value: ignored
1074  * @n_param_values: 2
1075  * @param_values: a #GValue array holding the instance and the #gchar* parameter
1076  * @invocation_hint: the invocation hint given as the last argument
1077  *  to g_closure_invoke()
1078  * @marshal_data: additional data specified when registering the marshaller
1079  * 
1080  * A marshaller for a #GCClosure with a callback of type
1081  * <literal>void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data)</literal>.
1082  */
1083 /**
1084  * g_cclosure_marshal_VOID__PARAM:
1085  * @closure: the #GClosure to which the marshaller belongs
1086  * @return_value: ignored
1087  * @n_param_values: 2
1088  * @param_values: a #GValue array holding the instance and the #GParamSpec* parameter
1089  * @invocation_hint: the invocation hint given as the last argument
1090  *  to g_closure_invoke()
1091  * @marshal_data: additional data specified when registering the marshaller
1092  * 
1093  * A marshaller for a #GCClosure with a callback of type
1094  * <literal>void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data)</literal>.
1095  */
1096 /**
1097  * g_cclosure_marshal_VOID__BOXED:
1098  * @closure: the #GClosure to which the marshaller belongs
1099  * @return_value: ignored
1100  * @n_param_values: 2
1101  * @param_values: a #GValue array holding the instance and the #GBoxed* parameter
1102  * @invocation_hint: the invocation hint given as the last argument
1103  *  to g_closure_invoke()
1104  * @marshal_data: additional data specified when registering the marshaller
1105  * 
1106  * A marshaller for a #GCClosure with a callback of type
1107  * <literal>void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data)</literal>.
1108  */
1109 /**
1110  * g_cclosure_marshal_VOID__POINTER:
1111  * @closure: the #GClosure to which the marshaller belongs
1112  * @return_value: ignored
1113  * @n_param_values: 2
1114  * @param_values: a #GValue array holding the instance and the #gpointer parameter
1115  * @invocation_hint: the invocation hint given as the last argument
1116  *  to g_closure_invoke()
1117  * @marshal_data: additional data specified when registering the marshaller
1118  * 
1119  * A marshaller for a #GCClosure with a callback of type
1120  * <literal>void (*callback) (gpointer instance, gpointer arg1, gpointer user_data)</literal>.
1121  */
1122 /**
1123  * g_cclosure_marshal_VOID__OBJECT:
1124  * @closure: the #GClosure to which the marshaller belongs
1125  * @return_value: ignored
1126  * @n_param_values: 2
1127  * @param_values: a #GValue array holding the instance and the #GObject* parameter
1128  * @invocation_hint: the invocation hint given as the last argument
1129  *  to g_closure_invoke()
1130  * @marshal_data: additional data specified when registering the marshaller
1131  * 
1132  * A marshaller for a #GCClosure with a callback of type
1133  * <literal>void (*callback) (gpointer instance, GOBject *arg1, gpointer user_data)</literal>.
1134  */
1135 /**
1136  * g_cclosure_marshal_VOID__UINT_POINTER:
1137  * @closure: the #GClosure to which the marshaller belongs
1138  * @return_value: ignored
1139  * @n_param_values: 3
1140  * @param_values: a #GValue array holding instance, arg1 and arg2
1141  * @invocation_hint: the invocation hint given as the last argument
1142  *  to g_closure_invoke()
1143  * @marshal_data: additional data specified when registering the marshaller
1144  * 
1145  * A marshaller for a #GCClosure with a callback of type
1146  * <literal>void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data)</literal>.
1147  */
1148 /**
1149  * g_cclosure_marshal_BOOLEAN__FLAGS:
1150  * @closure: the #GClosure to which the marshaller belongs
1151  * @return_value: a #GValue which can store the returned #gboolean
1152  * @n_param_values: 2
1153  * @param_values: a #GValue array holding instance and arg1
1154  * @invocation_hint: the invocation hint given as the last argument
1155  *  to g_closure_invoke()
1156  * @marshal_data: additional data specified when registering the marshaller
1157  * 
1158  * A marshaller for a #GCClosure with a callback of type
1159  * <literal>gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data)</literal> where the #gint parameter
1160  * denotes a flags type.
1161  */
1162 /**
1163  * g_cclosure_marshal_BOOL__FLAGS:
1164  * 
1165  * Another name for g_cclosure_marshal_BOOLEAN__FLAGS().
1166  */
1167 /**
1168  * g_cclosure_marshal_STRING__OBJECT_POINTER:
1169  * @closure: the #GClosure to which the marshaller belongs
1170  * @return_value: a #GValue, which can store the returned string
1171  * @n_param_values: 3
1172  * @param_values: a #GValue array holding instance, arg1 and arg2
1173  * @invocation_hint: the invocation hint given as the last argument
1174  *  to g_closure_invoke()
1175  * @marshal_data: additional data specified when registering the marshaller
1176  * 
1177  * A marshaller for a #GCClosure with a callback of type
1178  * <literal>gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data)</literal>.
1179  */
1180
1181 #define __G_CLOSURE_C__
1182 #include "gobjectaliasdef.c"