CClosure

A GClosure represents a callback supplied by the programmer. It will generally comprise a function of some kind and a marshaller used to call it. It is the reponsibility of the marshaller to convert the arguments for the invocation from GValues into a suitable form, perform the callback on the converted arguments, and transform the return value back into a GValue.

In the case of C programs, a closure usually just holds a pointer to a function and maybe a data argument, and the marshaller converts between GValue and native C types. The GObject library provides the GCClosure type for this purpose. Bindings for other languages need marshallers which convert between GValues and suitable representations in the runtime of the language in order to use functions written in that languages as callbacks.

Within GObject, closures play an important role in the implementation of signals. When a signal is registered, the c_marshaller argument to g_signal_new() specifies the default C marshaller for any closure which is connected to this signal. GObject provides a number of C marshallers for this purpose, see the g_cclosure_marshal_*() functions. Additional C marshallers can be generated with the glib-genmarshal utility. Closures can be explicitly connected to signals with g_signal_connect_closure(), but it usually more convenient to let GObject create a closure automatically by using one of the g_signal_connect_*() functions which take a callback function/user data pair.

Using closures has a number of important advantages over a simple callback function/data pointer combination:

Closures allow the callee to get the types of the callback parameters, which means that language bindings don't have to write individual glue for each callback type.

The reference counting of GClosure makes it easy to handle reentrancy right; if a callback is removed while it is being invoked, the closure and its parameters won't be freed until the invocation finishes.

g_closure_invalidate() and invalidation notifiers allow callbacks to be automatically removed when the objects they point to go away.

class CClosure {}

Constructors

this
this(GCClosure* gCClosure)

Sets our main struct and passes it to the parent class

Members

Functions

getCClosureStruct
GCClosure* getCClosureStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

Static functions

marshalBOOLEAN__BOXED_BOXED
void marshalBOOLEAN__BOXED_BOXED(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)
marshalBOOLEAN__BOXED_BOXEDv
void marshalBOOLEAN__BOXED_BOXEDv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalBOOLEAN__FLAGS
void marshalBOOLEAN__FLAGS(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type gboolean (*callback) (gpointer instance, gint arg1, gpointer user_data) where the gint parameter denotes a flags type.

marshalBOOLEAN__FLAGSv
void marshalBOOLEAN__FLAGSv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, int nParams, GType* paramTypes)
marshalGeneric
void marshalGeneric(Closure closure, Value returnGvalue, GValue[] paramValues, void* invocationHint, void* marshalData)

A generic marshaller function implemented via libffi. Since 2.30

marshalGenericVa
void marshalGenericVa(Closure closure, Value returnValue, void* instanc, void* argsList, void* marshalData, GType[] paramTypes)
marshalSTRING__OBJECT_POINTER
void marshalSTRING__OBJECT_POINTER(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type gchar* (*callback) (gpointer instance, GObject *arg1, gpointer arg2, gpointer user_data).

marshalSTRING__OBJECT_POINTERv
void marshalSTRING__OBJECT_POINTERv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__BOOLEAN
void marshalVOID__BOOLEAN(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gboolean arg1, gpointer user_data).

marshalVOID__BOOLEANv
void marshalVOID__BOOLEANv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__BOXED
void marshalVOID__BOXED(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, GBoxed *arg1, gpointer user_data).

marshalVOID__BOXEDv
void marshalVOID__BOXEDv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__CHAR
void marshalVOID__CHAR(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gchar arg1, gpointer user_data).

marshalVOID__CHARv
void marshalVOID__CHARv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__DOUBLE
void marshalVOID__DOUBLE(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gdouble arg1, gpointer user_data).

marshalVOID__DOUBLEv
void marshalVOID__DOUBLEv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__ENUM
void marshalVOID__ENUM(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gint arg1, gpointer user_data) where the gint parameter denotes an enumeration type..

marshalVOID__ENUMv
void marshalVOID__ENUMv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__FLAGS
void marshalVOID__FLAGS(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gint arg1, gpointer user_data) where the gint parameter denotes a flags type.

marshalVOID__FLAGSv
void marshalVOID__FLAGSv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__FLOAT
void marshalVOID__FLOAT(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gfloat arg1, gpointer user_data).

marshalVOID__FLOATv
void marshalVOID__FLOATv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__INT
void marshalVOID__INT(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gint arg1, gpointer user_data).

marshalVOID__INTv
void marshalVOID__INTv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__LONG
void marshalVOID__LONG(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, glong arg1, gpointer user_data).

marshalVOID__LONGv
void marshalVOID__LONGv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__OBJECT
void marshalVOID__OBJECT(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, GObject *arg1, gpointer user_data).

marshalVOID__OBJECTv
void marshalVOID__OBJECTv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__PARAM
void marshalVOID__PARAM(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, GParamSpec *arg1, gpointer user_data).

marshalVOID__PARAMv
void marshalVOID__PARAMv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__POINTER
void marshalVOID__POINTER(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gpointer arg1, gpointer user_data).

marshalVOID__POINTERv
void marshalVOID__POINTERv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__STRING
void marshalVOID__STRING(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, const gchar *arg1, gpointer user_data).

marshalVOID__STRINGv
void marshalVOID__STRINGv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__UCHAR
void marshalVOID__UCHAR(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, guchar arg1, gpointer user_data).

marshalVOID__UCHARv
void marshalVOID__UCHARv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__UINT
void marshalVOID__UINT(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, guint arg1, gpointer user_data).

marshalVOID__UINT_POINTER
void marshalVOID__UINT_POINTER(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, guint arg1, gpointer arg2, gpointer user_data).

marshalVOID__UINT_POINTERv
void marshalVOID__UINT_POINTERv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__UINTv
void marshalVOID__UINTv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__ULONG
void marshalVOID__ULONG(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gulong arg1, gpointer user_data).

marshalVOID__ULONGv
void marshalVOID__ULONGv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__VARIANT
void marshalVOID__VARIANT(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, GVariant *arg1, gpointer user_data). Since 2.26

marshalVOID__VARIANTv
void marshalVOID__VARIANTv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
marshalVOID__VOID
void marshalVOID__VOID(Closure closure, Value returnValue, GValue[] paramValues, void* invocationHint, void* marshalData)

A marshaller for a GCClosure with a callback of type void (*callback) (gpointer instance, gpointer user_data).

marshalVOID__VOIDv
void marshalVOID__VOIDv(Closure closure, Value returnValue, void* instanc, void* args, void* marshalData, GType[] paramTypes)
newCClosure
Closure newCClosure(GCallback callbackFunc, void* userData, GClosureNotify destroyData)

Creates a new closure which invokes callback_func with user_data as the last parameter.

newObject
Closure newObject(GCallback callbackFunc, ObjectG object)

A variant of g_cclosure_new() which uses object as user_data and calls g_object_watch_closure() on object and the created closure. This function is useful when you have a callback closely associated with a GObject, and want the callback to no longer run after the object is is freed.

newObjectSwap
Closure newObjectSwap(GCallback callbackFunc, ObjectG object)

A variant of g_cclosure_new_swap() which uses object as user_data and calls g_object_watch_closure() on object and the created closure. This function is useful when you have a callback closely associated with a GObject, and want the callback to no longer run after the object is is freed.

newSwap
Closure newSwap(GCallback callbackFunc, void* userData, GClosureNotify destroyData)

Creates a new closure which invokes callback_func with user_data as the first parameter.

Variables

gCClosure
GCClosure* gCClosure;

the main Gtk struct

Meta