![]() | ![]() | ![]() | GObject Reference Manual | ![]() |
---|
Closures — Functions as first-class objects
#include <gobject.h> #define G_CLOSURE_NEEDS_MARSHAL (closure) #define G_CLOSURE_N_NOTIFIERS (cl) #define G_CCLOSURE_SWAP_DATA (cclosure) #define G_CALLBACK (f) void (*GCallback) (void); struct GClosure; #define G_TYPE_CLOSURE struct GCClosure; void (*GClosureMarshal) (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data); void (*GClosureNotify) (gpointer data, GClosure *closure); struct GClosureNotifyData; 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 (GCallback callback_func, GObject *object); GClosure* g_cclosure_new_object_swap (GCallback callback_func, GObject *object); GClosure* g_closure_new_object (guint sizeof_closure, GObject *object); GClosure* g_closure_ref (GClosure *closure); void g_closure_sink (GClosure *closure); void g_closure_unref (GClosure *closure); 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); 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); GClosure* g_closure_new_simple (guint sizeof_closure, gpointer data); void g_closure_set_marshal (GClosure *closure, GClosureMarshal marshal); 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); #define G_TYPE_IO_CHANNEL #define G_TYPE_IO_CONDITION
#define G_CLOSURE_NEEDS_MARSHAL(closure) (((GClosure*) (closure))->marshal == NULL)
closure : |
#define G_CCLOSURE_SWAP_DATA(cclosure) (((GClosure*) (closure))->derivative_flag)
cclosure : |
struct GClosure { };
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);
closure : | |
return_value : | |
n_param_values : | |
param_values : | |
invocation_hint : | |
marshal_data : |
GClosure* g_cclosure_new (GCallback callback_func, gpointer user_data, GClosureNotify destroy_data);
callback_func : | |
user_data : | |
destroy_data : | |
Returns : |
GClosure* g_cclosure_new_swap (GCallback callback_func, gpointer user_data, GClosureNotify destroy_data);
callback_func : | |
user_data : | |
destroy_data : | |
Returns : |
GClosure* g_cclosure_new_object (GCallback callback_func, GObject *object);
callback_func : | |
object : | |
Returns : |
GClosure* g_cclosure_new_object_swap (GCallback callback_func, GObject *object);
callback_func : | |
object : | |
Returns : |
GClosure* g_closure_new_object (guint sizeof_closure, GObject *object);
sizeof_closure : | |
object : | |
Returns : |
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);
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);
closure : | |
return_value : | |
n_param_values : | |
param_values : | |
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.
closure : | GClosure to invalidate |
void g_closure_add_finalize_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func);
closure : | |
notify_data : | |
notify_func : |
void g_closure_add_invalidate_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func);
closure : | |
notify_data : | |
notify_func : |
void g_closure_remove_finalize_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func);
closure : | |
notify_data : | |
notify_func : |
void g_closure_remove_invalidate_notifier (GClosure *closure, gpointer notify_data, GClosureNotify notify_func);
closure : | |
notify_data : | |
notify_func : |
GClosure* g_closure_new_simple (guint sizeof_closure, gpointer data);
sizeof_closure : | |
data : | |
Returns : |
void g_closure_set_marshal (GClosure *closure, GClosureMarshal marshal);
closure : | |
marshal : |
void g_closure_add_marshal_guards (GClosure *closure, gpointer pre_marshal_data, GClosureNotify pre_marshal_notify, gpointer post_marshal_data, GClosureNotify post_marshal_notify);
closure : | |
pre_marshal_data : | |
pre_marshal_notify : | |
post_marshal_data : | |
post_marshal_notify : |
void g_closure_set_meta_marshal (GClosure *closure, gpointer marshal_data, GClosureMarshal meta_marshal);
closure : | |
marshal_data : | |
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 |
#define G_TYPE_IO_CONDITION (g_io_condition_get_type ())
The GType for GIOCondition.
<< Signals | Value arrays >> |