Function: getNativeObject()
getNativeObject<
T,TClass>(handle,targetType?):GetNativeObjectResult<T,TClass>
Defined in: packages/ffi/src/native/object.ts:34
Creates a JavaScript wrapper for a native GObject.
Resolves the runtime type of the object and creates an instance of the appropriate wrapper class. If a target type is provided, uses that class directly without runtime type resolution.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
T extends NativeHandle | null | undefined | - | The handle type (null, undefined, or NativeHandle) |
TClass extends NativeClass | undefined | undefined | Optional target wrapper class type |
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | T | The native handle (or null/undefined) |
targetType? | TClass | Optional wrapper class to use directly |
Returns
GetNativeObjectResult<T, TClass>
A wrapper instance, or null if handle is null/undefined
Example
// Automatic type resolution
const widget = getNativeObject(widgetHandle);
// Explicit type
const button = getNativeObject(buttonHandle, Gtk.Button);