API Reference / @gtkx/runtime
@gtkx/runtime
Classes
| Class | Description |
|---|---|
| CallbackMarshalError | Thrown when a value passed where a callback, signal handler or vfunc is expected cannot be called. |
| ClosureMarshalError | Thrown when a value passed where a GObject.Closure is expected cannot be marshalled into one. |
| ValueMarshalError | Thrown when a value passed where a GObject.Value is expected holds no GType one can be built from. |
Interfaces
| Interface | Description |
|---|---|
| ExternalObject | - |
Type Aliases
| Type Alias | Description |
|---|---|
| AnyClass | Any class constructor, abstract ones included, whose instances are T. |
| ClosureCallback | Handler 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. |
| ConstructBinding | One construct property a wrapper class accepts: the canonical GObject name it is set under, and the descriptor its value is marshalled through. |
| ConstructBindings | The construct properties a wrapper class accepts, keyed by the camelCased name callers give them. |
| Descriptor | - |
| ErrorDomain | An 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(). |
| Field | A field of a native struct at a fixed offset, bound once against the runtime conversion plan for its descriptor. |
| Handle | An 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. |
| Interface | A generated interface value, such as Gio.ListModel, accepted by registerClass. |
| InterfaceClass | - |
| JsValue | Values accepted when a GObject.Value parameter infers its GType: |
| Mixin | A factory that, given a base class, returns a subclass adding extra members to be merged onto a target prototype. |
| NativeIdentity | - |
| NativeInstance | - |
| RegisteredClass | The registered class with its declared properties and signals. |
| SignalBaseClass | The 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. |
| SignalGType | A numeric GType, a generated or registered wrapper class, or a generated enum or flags type. |
| SignalHandler | Function invoked when a connected GObject signal is emitted. |
| SignalHandlerId | - |
| SignalSpec | A signal installed by registerClass. |
| StaticBase | Static 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. |
| StridedField | A 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. |
| TypedClass | Object tagged with its GLib type through a __type__ GType field. |
| TypedEnum | Generated enumeration, flags or error domain object tagged with its GLib type through a __type__ GType field, like the generated classes. |
| WrapperClass | Static 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. |
| WrapperClassResolver | Picks the wrapper class for one handle of a registered type, such as a subclass keyed on a tag the handle carries. |
Variables
| Variable | Description |
|---|---|
| quit | Runs 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. |
| t | FFI descriptor factories and native function binders. |
| TYPE_BOOLEAN | GType tag for gboolean. |
| TYPE_BOXED | GType tag for the base GBoxed type. |
| TYPE_CHAR | GType tag for gchar (signed 8-bit integer). |
| TYPE_DOUBLE | GType tag for gdouble. |
| TYPE_ENUM | GType tag for the base GEnum type. |
| TYPE_FLAGS | GType tag for the base GFlags type. |
| TYPE_FLOAT | GType tag for gfloat. |
| TYPE_GTYPE | GType tag for a GType value itself. |
| TYPE_INT | GType tag for gint. |
| TYPE_INT64 | GType tag for gint64. |
| TYPE_INTERFACE | GType tag for the base GInterface type. |
| TYPE_INVALID | GType tag for an invalid or uninitialized type. |
| TYPE_LONG | GType tag for glong. |
| TYPE_NONE | GType tag for the absence of a value (void). |
| TYPE_OBJECT | GType tag for the base GObject type. |
| TYPE_PARAM | GType tag for the base GParam type. |
| TYPE_POINTER | GType tag for gpointer (an opaque pointer). |
| TYPE_STRING | GType tag for gchararray (a nul-terminated C string). |
| TYPE_UCHAR | GType tag for guchar (unsigned 8-bit integer). |
| TYPE_UINT | GType tag for guint. |
| TYPE_UINT64 | GType tag for guint64. |
| TYPE_ULONG | GType tag for gulong. |
| TYPE_UNICHAR | GType tag for a Unicode character stored as guint. |
| TYPE_VARIANT | GType tag for GVariant. |
Functions
| Function | Description |
|---|---|
| alloc | Allocates a zero-filled native memory block of size bytes and returns an opaque handle to it. |
| callParent | Calls a parent virtual function from an override. |
| callVfunc | Calls a virtual-function slot for a generated vfunc member. |
| coerceObjectProperty | Coerces 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. |
| connectSignal | Connects a handler to a GObject signal on an instance and returns the handler id. |
| createErrorDomain | Builds 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. |
| disconnectSignal | Disconnects the handler an instance connected under the given id, and forgets the connection. |
| emitSignal | Emits a signal on an instance with the given arguments and returns its result combined with any output-argument values. |
| fromNative | Converts 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. |
| fromValue | Reads 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. |
| getClassType | Returns 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. |
| getDeclaredPropertyName | The GObject name a class registered with registerClass installed an accessor under, or undefined when the accessor names no property the class declared itself. |
| getHandle | Returns the native handle bound to a wrapper instance. |
| getInstanceType | Returns 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. |
| getSignalBaseName | Returns the signal name without its detail suffix (the part after ::). |
| getWrapperClass | Returns the wrapper class registered for a GType, walking up to ancestor types, and throws if none is registered. |
| installInterfaces | Copies 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. |
| installMixins | Copies each mixin's prototype members onto the target class prototype, skipping any member already defined anywhere in the target's class chain. |
| isReadableProperty | Whether 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 | - |
| newObjectWithProperties | Constructs a GObject with the supplied properties and binds its JavaScript wrapper. |
| offSignal | Disconnects a handler previously connected with onSignal or onceSignal. Does nothing if the handler is not currently connected. |
| onceSignal | Connects a handler that runs at most once, disconnecting itself after the first emission. |
| onExit | Registers a callback to run once when the process quits, before the native runtime is torn down. |
| onSignal | Connects a handler to a signal and tracks it so it can later be removed with offSignal. |
| promisify | Wraps 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 | - |
| registerClass | Registers 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. |
| registerClassStruct | Registers 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. |
| registerConstructProperties | Declares 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. |
| registerInterface | Registers a GInterface, associating its GType with a mixin used to compose the interface onto wrapper classes and, when introspection describes its vtable, that layout. |
| registerWrapperClass | Registers a wrapper class as the JS representation of a GType, optionally installing a registry of virtual functions. |
| registerWrapperClassResolver | Registers a resolver for native subtypes sharing one GType, such as Cairo surface types. |
| resolveType | Resolves 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. |
| setHandle | Associates a native handle with a wrapper instance. |
| signalForHandlerName | The signal a generated on… handler prop names on the given type, or undefined when it carries none. |
| toClosure | Marshals 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. |
| toHashTableEntries | Converts 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. |
| toNative | Converts 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. |
| toValueHandle | Marshals 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. |
| trimFinish | Wraps 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. |
| tryToClosure | Same as toClosure, but passes a null or undefined value through as no closure at all. |
| tryToValueHandle | Same as toValueHandle, but passes a null or undefined value through as no value at all. |
| typeFromName | Returns the GType registered under the given name, or TYPE_INVALID if none exists. |
| typeInterfaces | Returns the GTypes of the interfaces implemented by the given type. |
| typeIsA | Returns whether type is ancestorType or descends from it. |
| typeName | Returns the registered name of a GType, or null if it has none. |
| typeParent | Returns the immediate parent GType of the given type. |
| valueIsA | Returns whether value is a typed wrapper whose GType is or descends from gtype. |
| withSignals | Returns 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. |
| wrapHandle | Wraps a native handle, returning null for a null or undefined handle. |
| write | - |