Closure

class Closure(pointer: <Error class: unknown class><<Error class: unknown class>>)

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 responsibility 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 language as callbacks. Use g_closure_set_marshal() to set the marshaller on such a custom closure implementation.

Within GObject, closures play an important role in the implementation of signals. When a signal is registered, the

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val gobjectClosurePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
var inMarshal: <Error class: unknown class>

Indicates whether the closure is currently being invoked with g_closure_invoke()

Link copied to clipboard
var isInvalid: <Error class: unknown class>

Indicates whether the closure has been invalidated by g_closure_invalidate()

Functions

Link copied to clipboard

Sets a flag on the closure to indicate that its calling environment has become invalid, and thus causes any future invocations of g_closure_invoke() on this @closure to be ignored.

Link copied to clipboard
fun ref(): Closure

Increments the reference count on a closure to force it staying alive while the caller holds a pointer to it.

Link copied to clipboard
fun sink()

Takes over the initial ownership of a closure.

Link copied to clipboard
fun unref()

Decrements the reference count of a closure after it was previously incremented by the same caller.