GObject Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#define G_CLOSURE_NEEDS_MARSHAL(closure) (((GClosure*) (closure))->marshal == NULL) |
#define G_CCLOSURE_SWAP_DATA(cclosure) (((GClosure*) (closure))->derivative_flag) |
struct GClosure { /*< private >*/ guint ref_count : 15; /*< private >*/ guint meta_marshal : 1; /*< private >*/ guint n_guards : 1; /*< private >*/ guint n_fnotifiers : 2; /* finalization notifiers */ /*< private >*/ guint n_inotifiers : 8; /* invalidation notifiers */ /*< private >*/ guint in_inotify : 1; /*< private >*/ guint floating : 1; /*< protected >*/ guint derivative_flag : 1; /*< public >*/ guint in_marshal : 1; /*< public >*/ guint is_invalid : 1; /*< private >*/ void (*marshal) (GClosure *closure, GValue /*out*/ *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); /*< protected >*/ gpointer data; /*< private >*/ GClosureNotifyData *notifiers; /* invariants/constrains: * - ->marshal and ->data are _invalid_ as soon as ->is_invalid==TRUE * - invocation of all inotifiers occours prior to fnotifiers * - order of inotifiers is random * inotifiers may _not_ free/invalidate parameter values (e.g. ->data) * - order of fnotifiers is random * - each notifier may only be removed before or during its invocation * - reference counting may only happen prior to fnotify invocation * (in that sense, fnotifiers are really finalization handlers) */ }; |
guint in_marshal : 1 | |
guint is_invalid : 1 | Indicates whether the closure has been invalidated by g_closure_invalidate() |
void (*GClosureMarshal) (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); |
GClosure* g_cclosure_new (GCallback callback_func, gpointer user_data, GClosureNotify destroy_data); |
GClosure* g_cclosure_new_swap (GCallback callback_func, gpointer user_data, GClosureNotify destroy_data); |
GClosure* g_cclosure_new_object_swap (GCallback callback_func, GObject *object); |
GClosure* g_closure_ref (GClosure *closure); |
Increment the reference count on a closure to force it staying alive while the caller holds a pointer to it.
closure : | GClosure to increment the reference count on |
Returns : | The closure passed in, for convenience |
void g_closure_sink (GClosure *closure); |
Take over the initial ownership of a closure. When closures are newly created, they get an initial reference count of 1, eventhough no caller has yet invoked g_closure_ref() on the closure. Code entities that store closures for notification purposes are supposed to call this function, for example like this:
static GClosure *notify_closure = NULL; void foo_notify_set_closure (GClosure *closure) { if (notify_closure) g_closure_unref (notify_closure); notify_closure = closure; if (notify_closure) { g_closure_ref (notify_closure); g_closure_sink (notify_closure); } } |
closure : | GClosure to decrement the initial reference count on, if it's still being held |
void g_closure_unref (GClosure *closure); |
Decrement the reference count of a closure after it was previously incremented by the same caller. The closure will most likely be destroyed and freed after this function returns.
closure : | GClosure to decrement the reference count on |
void g_closure_invoke (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint); |
void g_closure_invalidate (GClosure *closure); |
This function sets a flag on the closure to indicate that it's calling environment has become invalid, and thus causes any future invocations of g_closure_invoke() on this closure to be ignored. Also, invalidation notifiers installed on the closure will be called at this point, and since invalidation notifiers may unreference the closure, closure should be considered an invalidated pointer atfer this function, unles g_closure_ref() was called beforehand.
void g_closure_add_finalize_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func); |
void g_closure_add_invalidate_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func); |
void g_closure_remove_finalize_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func); |
void g_closure_remove_invalidate_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func); |
void g_closure_add_marshal_guards (GClosure *closure, gpointer pre_marshal_data, GClosureNotify pre_marshal_notify, gpointer post_marshal_data, GClosureNotify post_marshal_notify); |
void g_closure_set_meta_marshal (GClosure *closure, gpointer marshal_data, GClosureMarshal meta_marshal); |
void g_source_set_closure (GSource *source, GClosure *closure); |
Set the callback for a source as a GClosure.
If the source is not one of the standard GLib types, the closure_callback and closure_marshal fields of the GSourceFuncs structure must have been filled in with pointers to appropriate functions.
source : | the source |
closure : | a GClosure |