Skip to content

API Reference / @gtkx/runtime

@gtkx/runtime ​

Classes ​

ClassDescription
CallbackMarshalErrorThrown when a value passed where a callback, signal handler or vfunc is expected cannot be called.
ClosureMarshalErrorThrown when a value passed where a GObject.Closure is expected cannot be marshalled into one.
ValueMarshalErrorThrown when a value passed where a GObject.Value is expected holds no GType one can be built from.

Interfaces ​

InterfaceDescription
ExternalObject-

Type Aliases ​

Type AliasDescription
AnyClassAny class constructor, abstract ones included, whose instances are T.
ClosureCallbackHandler backing a GClosure. It receives the closure's parameters already converted from their GValues, and its result is written back into the closure's return GValue when it has one.
ConstructBindingOne construct property a wrapper class accepts: the canonical GObject name it is set under, and the descriptor its value is marshalled through.
ConstructBindingsThe construct properties a wrapper class accepts, keyed by the camelCased name callers give them.
Descriptor-
ErrorDomainAn error enum object carrying its member codes plus an instanceof check that matches wrapped GLib errors belonging to a specific error domain. As in GJS, its valueOf() returns the domain quark, so it converts to the quark with Number().
FieldA field of a native struct at a fixed offset, bound once against the runtime conversion plan for its descriptor.
HandleAn opaque handle to a native memory region: a GObject, a boxed value, or a raw allocation. Produced by alloc and consumed by the memory and wrapper functions (readField, writeField, getType, getWrapper, setWrapper). Its bytes are not accessible from JavaScript.
InterfaceA generated interface value, such as Gio.ListModel, accepted by registerClass.
InterfaceClass-
JsValueValues accepted when a GObject.Value parameter infers its GType:
MixinA factory that, given a base class, returns a subclass adding extra members to be merged onto a target prototype.
NativeIdentity-
NativeInstance-
RegisteredClassThe registered class with its declared properties and signals.
SignalBaseClassThe base class withSignals returns. It is typed by the base class's instance type and construct arguments rather than by the base class itself, so a package that emits declarations can export a class extending it; the base class's static members are left out of its type.
SignalGTypeA numeric GType, a generated or registered wrapper class, or a generated enum or flags type.
SignalHandlerFunction invoked when a connected GObject signal is emitted.
SignalHandlerId-
SignalSpecA signal installed by registerClass.
StaticBaseStatic side of C without members named K, preserving its abstract construct signature. Generated subclasses redeclare their own statics, allowing narrower types than the parent. Keeping the signature abstract also supports abstract base classes.
StridedFieldA field of a native struct whose offset is supplied per access, bound once against the descriptor its bytes are marshalled through, for walking records stored at a stride.
TypedClassObject tagged with its GLib type through a __type__ GType field.
TypedEnumGenerated enumeration, flags or error domain object tagged with its GLib type through a __type__ GType field, like the generated classes.
WrapperClassStatic side of C whose constructor produces I. Generated wrappers export a registered constant and a separate instance interface for declaration merging and module augmentation; this type makes constructing the constant return that interface.
WrapperClassResolverPicks the wrapper class for one handle of a registered type, such as a subclass keyed on a tag the handle carries.

Variables ​

VariableDescription
quitRuns every registered exit callback, disposes the objects that only JavaScript still references while their JavaScript vfuncs and signal handlers can still run, and shuts down the native runtime. Safe to call more than once; only the first call takes effect.
tFFI descriptor factories and native function binders.
TYPE_BOOLEANGType tag for gboolean.
TYPE_BOXEDGType tag for the base GBoxed type.
TYPE_CHARGType tag for gchar (signed 8-bit integer).
TYPE_DOUBLEGType tag for gdouble.
TYPE_ENUMGType tag for the base GEnum type.
TYPE_FLAGSGType tag for the base GFlags type.
TYPE_FLOATGType tag for gfloat.
TYPE_GTYPEGType tag for a GType value itself.
TYPE_INTGType tag for gint.
TYPE_INT64GType tag for gint64.
TYPE_INTERFACEGType tag for the base GInterface type.
TYPE_INVALIDGType tag for an invalid or uninitialized type.
TYPE_LONGGType tag for glong.
TYPE_NONEGType tag for the absence of a value (void).
TYPE_OBJECTGType tag for the base GObject type.
TYPE_PARAMGType tag for the base GParam type.
TYPE_POINTERGType tag for gpointer (an opaque pointer).
TYPE_STRINGGType tag for gchararray (a nul-terminated C string).
TYPE_UCHARGType tag for guchar (unsigned 8-bit integer).
TYPE_UINTGType tag for guint.
TYPE_UINT64GType tag for guint64.
TYPE_ULONGGType tag for gulong.
TYPE_UNICHARGType tag for a Unicode character stored as guint.
TYPE_VARIANTGType tag for GVariant.

Functions ​

FunctionDescription
allocAllocates a zero-filled native memory block of size bytes and returns an opaque handle to it.
callParentCalls a parent virtual function from an override.
callVfuncCalls a virtual-function slot for a generated vfunc member.
coerceObjectPropertyCoerces a finite number to a native property's accepted range. Integer, enum, and flag values are truncated toward zero, then clamped to the GObject.ParamSpec range.
connectSignalConnects a handler to a GObject signal on an instance and returns the handler id.
createErrorDomainBuilds an error domain enum object from its members and a lazy resolver for the domain quark, giving it an instanceof check that matches wrapped GLib errors of that domain.
disconnectSignalDisconnects the handler an instance connected under the given id, and forgets the connection.
emitSignalEmits a signal on an instance with the given arguments and returns its result combined with any output-argument values.
fromNativeConverts a raw value returned from native code into its JavaScript form, wrapping object, struct, boxed, and fundamental handles and recursively converting arrays and hash tables according to the descriptor.
fromValueReads what a GObject.Value holds as its JavaScript form, wrapping an object, boxed, param, variant, or fundamental payload in the class registered for its GType, and handing back a string, number, bigint, boolean, or array of strings for the rest.
getClassTypeReturns the GType a class was registered under, or the invalid type when it carries none. The tag is read off the class's own prototype, so a subclass that never went through registerClass reports the invalid type rather than inheriting the one its parent was registered with.
getDeclaredPropertyNameThe GObject name a class registered with registerClass installed an accessor under, or undefined when the accessor names no property the class declared itself.
getHandleReturns the native handle bound to a wrapper instance.
getInstanceTypeReturns the GType the given instance's handle carries, or the invalid type when it has no handle. This is the object's own type rather than the type of the class it was wrapped as, and the two differ for an object GTK created itself, such as the row widget inside a Gtk.ListView, which GTKX wraps as the nearest registered ancestor.
getSignalBaseNameReturns the signal name without its detail suffix (the part after ::).
getWrapperClassReturns the wrapper class registered for a GType, walking up to ancestor types, and throws if none is registered.
installInterfacesCopies registered interface mixins onto a wrapper class, in the supplied order. Interfaces must already be registered through registerInterface; generated code declares them before their implementing classes.
installMixinsCopies each mixin's prototype members onto the target class prototype, skipping any member already defined anywhere in the target's class chain.
isReadablePropertyWhether the type declares a readable GObject property under propertyName, asking GObject itself rather than looking for a generated accessor, which codegen omits when a method shares the name.
keepAlive-
newObjectWithPropertiesConstructs a GObject with the supplied properties and binds its JavaScript wrapper.
offSignalDisconnects a handler previously connected with onSignal or onceSignal. Does nothing if the handler is not currently connected.
onceSignalConnects a handler that runs at most once, disconnecting itself after the first emission.
onExitRegisters a callback to run once when the process quits, before the native runtime is torn down.
onSignalConnects a handler to a signal and tracks it so it can later be removed with offSignal.
promisifyWraps a GIO-style asynchronous function that takes a completion callback into a promise, invoking the finish function to extract the result. Outside production, the call site's stack is captured and attached as the rejection error's cause.
read-
registerClassRegisters a wrapper subclass as a GType with discovered vfuncs, properties, signals, and interfaces. Vfuncs must be prototype methods; function-valued fields never reach the vtable. A matching on<SignalName> method becomes the signal's default handler.
registerClassStructRegisters the wrapper class of a type's class struct, such as Gtk.WidgetClass for Gtk.Widget, so registerClass can hand a classInit hook the new type's class struct wrapped in it.
registerConstructPropertiesDeclares the construct properties a wrapper class accepts, so newObjectWithProperties marshals each one through its descriptor rather than resolving it from the GObject.ParamSpec the type installs. A class inherits the declarations of its ancestors. Registering takes effect immediately, including for classes already constructed from and for subclasses that already inherited an earlier declaration.
registerInterfaceRegisters a GInterface, associating its GType with a mixin used to compose the interface onto wrapper classes and, when introspection describes its vtable, that layout.
registerWrapperClassRegisters a wrapper class as the JS representation of a GType, optionally installing a registry of virtual functions.
registerWrapperClassResolverRegisters a resolver for native subtypes sharing one GType, such as Cairo surface types.
resolveTypeResolves the GType produced by a get_type function in a shared library, caching the result per library and function name. Returns zero when the symbol is absent; library-loading and invocation errors propagate to the caller.
setHandleAssociates a native handle with a wrapper instance.
signalForHandlerNameThe signal a generated on… handler prop names on the given type, or undefined when it carries none.
toClosureMarshals a value passed where a GObject.Closure is expected into a closure handle: a function becomes a new GClosure dispatching into it, and an existing closure yields its own handle.
toHashTableEntriesConverts a Map or other iterable of pairs to hash-table entries. Rejects other values, including plain objects, which Array.from would silently turn into empty tables.
toNativeConverts a JavaScript value into the raw form native code expects, unwrapping object, struct, boxed, and fundamental wrappers back to their handles, resolving a class passed for a GType to the GType it was registered under, and recursively converting arrays and maps according to the descriptor.
toValueHandleMarshals a value passed where a GObject.Value is expected into a value handle: an already-built value yields its own handle, and any other JsValue is stored in a new one initialized to the GType inferred from it.
trimFinishWraps a finish function whose result leads with the success boolean of a throwing C call, dropping that boolean: failure already surfaces as a thrown error, so the boolean is always true. A single remaining value is handed back bare, several stay a tuple. The finish result must carry at least one value beyond the boolean; a boolean-only finish needs no trimming.
tryToClosureSame as toClosure, but passes a null or undefined value through as no closure at all.
tryToValueHandleSame as toValueHandle, but passes a null or undefined value through as no value at all.
typeFromNameReturns the GType registered under the given name, or TYPE_INVALID if none exists.
typeInterfacesReturns the GTypes of the interfaces implemented by the given type.
typeIsAReturns whether type is ancestorType or descends from it.
typeNameReturns the registered name of a GType, or null if it has none.
typeParentReturns the immediate parent GType of the given type.
valueIsAReturns whether value is a typed wrapper whose GType is or descends from gtype.
withSignalsReturns an unregistered subclass of base that declares signals, so a class extending it can emit, connect and listen to them on this inside its own body. registerClass installs these signals together with its signals option when it registers that class; a name declared in both is an error.
wrapHandleWraps a native handle, returning null for a null or undefined handle.
write-