@gtkx/runtime 1.0.0-rc.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/application-class.d.ts +32 -0
- package/dist/application-class.d.ts.map +1 -0
- package/dist/application-class.js +68 -0
- package/dist/application-class.js.map +1 -0
- package/dist/arg.d.ts +2 -1
- package/dist/arg.d.ts.map +1 -1
- package/dist/arg.js +2 -1
- package/dist/arg.js.map +1 -1
- package/dist/bind.d.ts +11 -0
- package/dist/bind.d.ts.map +1 -1
- package/dist/bind.js +11 -0
- package/dist/bind.js.map +1 -1
- package/dist/callback.d.ts +2 -1
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +118 -20
- package/dist/callback.js.map +1 -1
- package/dist/closure.d.ts +26 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +99 -0
- package/dist/closure.js.map +1 -0
- package/dist/descriptors.d.ts +74 -3
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +44 -0
- package/dist/descriptors.js.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fn.d.ts +19 -2
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +64 -27
- package/dist/fn.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/internal.js.map +1 -1
- package/dist/library.d.ts +2 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +2 -1
- package/dist/library.js.map +1 -1
- package/dist/lifecycle.d.ts +43 -11
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +62 -19
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +3 -1
- package/dist/listeners.js.map +1 -1
- package/dist/mixin.d.ts +3 -2
- package/dist/mixin.d.ts.map +1 -1
- package/dist/mixin.js +13 -1
- package/dist/mixin.js.map +1 -1
- package/dist/native-value.d.ts.map +1 -1
- package/dist/native-value.js +4 -3
- package/dist/native-value.js.map +1 -1
- package/dist/object.d.ts +34 -6
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +89 -25
- package/dist/object.js.map +1 -1
- package/dist/param-spec.d.ts +11 -0
- package/dist/param-spec.d.ts.map +1 -0
- package/dist/param-spec.js +149 -0
- package/dist/param-spec.js.map +1 -0
- package/dist/promisify.d.ts.map +1 -1
- package/dist/promisify.js +3 -2
- package/dist/promisify.js.map +1 -1
- package/dist/properties.d.ts +38 -7
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +305 -42
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +117 -12
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +108 -76
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +69 -19
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +70 -26
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +9 -2
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +63 -7
- package/dist/signal.js.map +1 -1
- package/dist/type.d.ts +2 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -1
- package/dist/value.d.ts +8 -1
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +42 -13
- package/dist/value.js.map +1 -1
- package/dist/vfunc-call.d.ts +37 -0
- package/dist/vfunc-call.d.ts.map +1 -0
- package/dist/vfunc-call.js +168 -0
- package/dist/vfunc-call.js.map +1 -0
- package/dist/vfunc-seeds.d.ts +12 -0
- package/dist/vfunc-seeds.d.ts.map +1 -0
- package/dist/vfunc-seeds.js +19 -0
- package/dist/vfunc-seeds.js.map +1 -0
- package/dist/vfunc.d.ts +8 -0
- package/dist/vfunc.d.ts.map +1 -0
- package/dist/vfunc.js +23 -0
- package/dist/vfunc.js.map +1 -0
- package/package.json +4 -4
- package/src/application-class.ts +116 -0
- package/src/arg.ts +2 -1
- package/src/bind.ts +11 -0
- package/src/callback.ts +162 -22
- package/src/closure.ts +136 -0
- package/src/descriptors.ts +85 -24
- package/src/error.ts +1 -0
- package/src/fn.ts +92 -31
- package/src/index.ts +21 -6
- package/src/internal.ts +1 -0
- package/src/library.ts +2 -1
- package/src/lifecycle.ts +90 -23
- package/src/listeners.ts +3 -1
- package/src/mixin.ts +15 -2
- package/src/native-value.ts +5 -3
- package/src/object.ts +128 -34
- package/src/param-spec.ts +235 -0
- package/src/promisify.ts +4 -2
- package/src/properties.ts +458 -45
- package/src/register-class.ts +326 -109
- package/src/registry.ts +138 -40
- package/src/signal.ts +84 -14
- package/src/type.ts +3 -1
- package/src/value.ts +55 -10
- package/src/vfunc-call.ts +243 -0
- package/src/vfunc-seeds.ts +36 -0
- package/src/vfunc.ts +31 -0
package/dist/closure.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { read } from "@gtkx/native";
|
|
2
|
+
import {} from "@gtkx/utils";
|
|
3
|
+
import { bind } from "./bind.js";
|
|
4
|
+
import { boxedT, callbackT, sizedArrayT, structT, uint32T, uint64T, voidT } from "./descriptors.js";
|
|
5
|
+
import { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T } from "./library.js";
|
|
6
|
+
import { getClassType, getHandle, getWrapperClass, instanceClassName, wrapHandle } from "./registry.js";
|
|
7
|
+
import { resolveBoxedType, typeIsA } from "./type.js";
|
|
8
|
+
import { fromValue, getValueType, intoValue } from "./value.js";
|
|
9
|
+
const CCLOSURE_CALLBACK_OFFSET = CLOSURE_SIZE;
|
|
10
|
+
const N_PARAM_VALUES_INDEX = 2;
|
|
11
|
+
const MARSHAL_DATA_INDEX = 5;
|
|
12
|
+
const CLOSURE_T = boxedT("GClosure", { sharedLibrary: LIB, getTypeFnName: "g_closure_get_type" });
|
|
13
|
+
const OWNED_CLOSURE_T = boxedT("GClosure", {
|
|
14
|
+
ownership: "full",
|
|
15
|
+
sharedLibrary: LIB,
|
|
16
|
+
getTypeFnName: "g_closure_get_type",
|
|
17
|
+
});
|
|
18
|
+
const MARSHAL_VALUE_T = boxedT("GValue", {
|
|
19
|
+
sharedLibrary: LIB,
|
|
20
|
+
getTypeFnName: "g_value_get_type",
|
|
21
|
+
size: VALUE_SIZE,
|
|
22
|
+
isCallerAllocated: true,
|
|
23
|
+
});
|
|
24
|
+
const MARSHAL_T = callbackT([
|
|
25
|
+
CLOSURE_T,
|
|
26
|
+
MARSHAL_VALUE_T,
|
|
27
|
+
uint32T,
|
|
28
|
+
sizedArrayT(MARSHAL_VALUE_T, N_PARAM_VALUES_INDEX, "borrowed", VALUE_SIZE),
|
|
29
|
+
uint64T,
|
|
30
|
+
uint64T,
|
|
31
|
+
], voidT, {
|
|
32
|
+
hasUserData: true,
|
|
33
|
+
userDataIndex: MARSHAL_DATA_INDEX,
|
|
34
|
+
hasDestroy: true,
|
|
35
|
+
destroyKind: "closureNotify",
|
|
36
|
+
scope: "notified",
|
|
37
|
+
});
|
|
38
|
+
const NESTED_VALUE_T = structT("borrowed");
|
|
39
|
+
const gCclosureNew = bind(LIB, "g_cclosure_new", [MARSHAL_T], OWNED_CLOSURE_T);
|
|
40
|
+
const gValueGetBoxed = bind(LIB, "g_value_get_boxed", [VALUE_T], NESTED_VALUE_T);
|
|
41
|
+
const gClosureRef = bind(LIB, "g_closure_ref", [CLOSURE_T], uint64T);
|
|
42
|
+
const gClosureSink = bind(LIB, "g_closure_sink", [CLOSURE_T], voidT);
|
|
43
|
+
const gClosureSetMarshal = bind(LIB, "g_closure_set_marshal", [CLOSURE_T, uint64T], voidT);
|
|
44
|
+
const isClosureInstance = (value) => typeIsA(getClassType(value.constructor), resolveBoxedType(CLOSURE_T));
|
|
45
|
+
const getNestedValue = (param) => wrapHandle(gValueGetBoxed(param), getWrapperClass(resolveBoxedType(VALUE_T)));
|
|
46
|
+
const fromParamValue = (param) => getValueType(param) === resolveBoxedType(VALUE_T) ? getNestedValue(param) : fromValue(param);
|
|
47
|
+
function describeValue(value) {
|
|
48
|
+
if (value === null) {
|
|
49
|
+
return "null";
|
|
50
|
+
}
|
|
51
|
+
if (typeof value !== "object") {
|
|
52
|
+
return typeof value;
|
|
53
|
+
}
|
|
54
|
+
return instanceClassName(value);
|
|
55
|
+
}
|
|
56
|
+
function marshalFor(callback) {
|
|
57
|
+
return (_closure, returnValue, _count, paramValues) => {
|
|
58
|
+
const values = paramValues;
|
|
59
|
+
const args = values.map((value) => fromParamValue(value));
|
|
60
|
+
const result = callback(...args);
|
|
61
|
+
if (returnValue !== null) {
|
|
62
|
+
intoValue(returnValue, result);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function newClosure(callback) {
|
|
67
|
+
const handle = gCclosureNew(marshalFor(callback));
|
|
68
|
+
const marshal = read(handle, uint64T, CCLOSURE_CALLBACK_OFFSET);
|
|
69
|
+
gClosureRef(handle);
|
|
70
|
+
gClosureSink(handle);
|
|
71
|
+
gClosureSetMarshal(handle, marshal);
|
|
72
|
+
return handle;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Marshals a value passed where a `GObject.Closure` is expected into a closure handle: a function
|
|
76
|
+
* becomes a new `GClosure` dispatching into it, and an existing closure yields its own handle.
|
|
77
|
+
* @param value Function to wrap, or an already-built closure.
|
|
78
|
+
* @throws {ClosureMarshalError} When the value is neither.
|
|
79
|
+
*/
|
|
80
|
+
function toClosure(value) {
|
|
81
|
+
if (typeof value === "function") {
|
|
82
|
+
return newClosure(value);
|
|
83
|
+
}
|
|
84
|
+
if (typeof value === "object" && value !== null && isClosureInstance(value)) {
|
|
85
|
+
return getHandle(value);
|
|
86
|
+
}
|
|
87
|
+
throw new ClosureMarshalError(`Cannot marshal ${describeValue(value)} into a GObject.Closure`);
|
|
88
|
+
}
|
|
89
|
+
/** Same as {@link toClosure}, but passes a null or undefined value through as no closure at all. */
|
|
90
|
+
function tryToClosure(value) {
|
|
91
|
+
return value == null ? undefined : toClosure(value);
|
|
92
|
+
}
|
|
93
|
+
/** Thrown when a value passed where a `GObject.Closure` is expected cannot be marshalled into one. */
|
|
94
|
+
class ClosureMarshalError extends TypeError {
|
|
95
|
+
/** Name callers match on when the error is caught as a plain `TypeError`. */
|
|
96
|
+
name = "ClosureMarshalError";
|
|
97
|
+
}
|
|
98
|
+
export { ClosureMarshalError, toClosure, tryToClosure };
|
|
99
|
+
//# sourceMappingURL=closure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closure.js","sourceRoot":"","sources":["../src/closure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAiB,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYhE,MAAM,wBAAwB,GAAG,YAAY,CAAC;AAC9C,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,aAAa,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;QAC7D,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED,SAAS,UAAU,CAAC,QAAyB;IACzC,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAA2B,CAAC;IAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAChE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpB,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,KAAwB,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1E,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,aAAa,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnG,CAAC;AAED,oGAAoG;AACpG,SAAS,YAAY,CAAC,KAAc;IAChC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,sGAAsG;AACtG,MAAM,mBAAoB,SAAQ,SAAS;IACvC,6EAA6E;IAC7D,IAAI,GAAG,qBAAqB,CAAC;CAChD;AAED,OAAO,EAAwB,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { type ExternalObject, type Handle, read } from \"@gtkx/native\";\nimport { type AnyClass } from \"@gtkx/utils\";\nimport { bind } from \"./bind.js\";\nimport { boxedT, callbackT, sizedArrayT, structT, uint32T, uint64T, voidT } from \"./descriptors.js\";\nimport { CLOSURE_SIZE, LIB, VALUE_SIZE, VALUE_T } from \"./library.js\";\nimport { getClassType, getHandle, getWrapperClass, instanceClassName, wrapHandle } from \"./registry.js\";\nimport { resolveBoxedType, typeIsA } from \"./type.js\";\nimport { fromValue, getValueType, intoValue } from \"./value.js\";\n\n/**\n * Handler backing a `GClosure`. It receives the closure's parameters already converted from their\n * `GValue`s, and its result is written back into the closure's return `GValue` when it has one.\n *\n * A parameter that is itself a `GValue`, such as the target a property binding transform fills in,\n * arrives as the caller's own `GObject.Value` rather than a copy, so writing to it is how the\n * handler produces that parameter's value. It stops being valid once the handler returns.\n */\ntype ClosureCallback = (...args: never[]) => unknown;\n\nconst CCLOSURE_CALLBACK_OFFSET = CLOSURE_SIZE;\nconst N_PARAM_VALUES_INDEX = 2;\nconst MARSHAL_DATA_INDEX = 5;\nconst CLOSURE_T = boxedT(\"GClosure\", { sharedLibrary: LIB, getTypeFnName: \"g_closure_get_type\" });\n\nconst OWNED_CLOSURE_T = boxedT(\"GClosure\", {\n ownership: \"full\",\n sharedLibrary: LIB,\n getTypeFnName: \"g_closure_get_type\",\n});\n\nconst MARSHAL_VALUE_T = boxedT(\"GValue\", {\n sharedLibrary: LIB,\n getTypeFnName: \"g_value_get_type\",\n size: VALUE_SIZE,\n isCallerAllocated: true,\n});\n\nconst MARSHAL_T = callbackT(\n [\n CLOSURE_T,\n MARSHAL_VALUE_T,\n uint32T,\n sizedArrayT(MARSHAL_VALUE_T, N_PARAM_VALUES_INDEX, \"borrowed\", VALUE_SIZE),\n uint64T,\n uint64T,\n ],\n voidT,\n {\n hasUserData: true,\n userDataIndex: MARSHAL_DATA_INDEX,\n hasDestroy: true,\n destroyKind: \"closureNotify\",\n scope: \"notified\",\n },\n);\n\nconst NESTED_VALUE_T = structT(\"borrowed\");\nconst gCclosureNew = bind(LIB, \"g_cclosure_new\", [MARSHAL_T], OWNED_CLOSURE_T);\nconst gValueGetBoxed = bind(LIB, \"g_value_get_boxed\", [VALUE_T], NESTED_VALUE_T);\nconst gClosureRef = bind(LIB, \"g_closure_ref\", [CLOSURE_T], uint64T);\nconst gClosureSink = bind(LIB, \"g_closure_sink\", [CLOSURE_T], voidT);\nconst gClosureSetMarshal = bind(LIB, \"g_closure_set_marshal\", [CLOSURE_T, uint64T], voidT);\n\nconst isClosureInstance = (value: object): boolean =>\n typeIsA(getClassType(value.constructor as AnyClass), resolveBoxedType(CLOSURE_T));\n\nconst getNestedValue = (param: ExternalObject<Handle>): object | null =>\n wrapHandle(gValueGetBoxed(param) as ExternalObject<Handle> | null, getWrapperClass(resolveBoxedType(VALUE_T)));\n\nconst fromParamValue = (param: ExternalObject<Handle>): unknown =>\n getValueType(param) === resolveBoxedType(VALUE_T) ? getNestedValue(param) : fromValue(param);\n\nfunction describeValue(value: unknown): string {\n if (value === null) {\n return \"null\";\n }\n\n if (typeof value !== \"object\") {\n return typeof value;\n }\n\n return instanceClassName(value);\n}\n\nfunction marshalFor(callback: ClosureCallback): (...args: unknown[]) => void {\n return (_closure: unknown, returnValue: unknown, _count: unknown, paramValues: unknown): void => {\n const values = paramValues as ExternalObject<Handle>[];\n const args = values.map((value) => fromParamValue(value));\n const result = (callback as (...values: unknown[]) => unknown)(...(args as never[]));\n\n if (returnValue !== null) {\n intoValue(returnValue as ExternalObject<Handle>, result);\n }\n };\n}\n\nfunction newClosure(callback: ClosureCallback): ExternalObject<Handle> {\n const handle = gCclosureNew(marshalFor(callback)) as ExternalObject<Handle>;\n const marshal = read(handle, uint64T, CCLOSURE_CALLBACK_OFFSET);\n gClosureRef(handle);\n gClosureSink(handle);\n gClosureSetMarshal(handle, marshal);\n\n return handle;\n}\n\n/**\n * Marshals a value passed where a `GObject.Closure` is expected into a closure handle: a function\n * becomes a new `GClosure` dispatching into it, and an existing closure yields its own handle.\n * @param value Function to wrap, or an already-built closure.\n * @throws {ClosureMarshalError} When the value is neither.\n */\nfunction toClosure(value: unknown): ExternalObject<Handle> {\n if (typeof value === \"function\") {\n return newClosure(value as ClosureCallback);\n }\n\n if (typeof value === \"object\" && value !== null && isClosureInstance(value)) {\n return getHandle(value);\n }\n\n throw new ClosureMarshalError(`Cannot marshal ${describeValue(value)} into a GObject.Closure`);\n}\n\n/** Same as {@link toClosure}, but passes a null or undefined value through as no closure at all. */\nfunction tryToClosure(value: unknown): ExternalObject<Handle> | undefined {\n return value == null ? undefined : toClosure(value);\n}\n\n/** Thrown when a value passed where a `GObject.Closure` is expected cannot be marshalled into one. */\nclass ClosureMarshalError extends TypeError {\n /** Name callers match on when the error is caught as a plain `TypeError`. */\n public override name = \"ClosureMarshalError\";\n}\n\nexport { type ClosureCallback, ClosureMarshalError, toClosure, tryToClosure };\n"]}
|
package/dist/descriptors.d.ts
CHANGED
|
@@ -1,93 +1,122 @@
|
|
|
1
1
|
import type { ArrayKind, Descriptor, Ownership } from "@gtkx/native";
|
|
2
2
|
import type { AnyClass } from "@gtkx/utils";
|
|
3
|
+
/** Descriptor variant for a `gint8`. */
|
|
3
4
|
type Int8Descriptor = Extract<Descriptor, {
|
|
4
5
|
kind: "int8";
|
|
5
6
|
}>;
|
|
7
|
+
/** Descriptor variant for a `guint8`. */
|
|
6
8
|
type Uint8Descriptor = Extract<Descriptor, {
|
|
7
9
|
kind: "uint8";
|
|
8
10
|
}>;
|
|
11
|
+
/** Descriptor variant for a `gint16`. */
|
|
9
12
|
type Int16Descriptor = Extract<Descriptor, {
|
|
10
13
|
kind: "int16";
|
|
11
14
|
}>;
|
|
15
|
+
/** Descriptor variant for a `guint16`. */
|
|
12
16
|
type Uint16Descriptor = Extract<Descriptor, {
|
|
13
17
|
kind: "uint16";
|
|
14
18
|
}>;
|
|
19
|
+
/** Descriptor variant for a `gint32`. */
|
|
15
20
|
type Int32Descriptor = Extract<Descriptor, {
|
|
16
21
|
kind: "int32";
|
|
17
22
|
}>;
|
|
23
|
+
/** Descriptor variant for a `guint32`. */
|
|
18
24
|
type Uint32Descriptor = Extract<Descriptor, {
|
|
19
25
|
kind: "uint32";
|
|
20
26
|
}>;
|
|
27
|
+
/** Descriptor variant for a `gint64` marshalled as a number. */
|
|
21
28
|
type Int64Descriptor = Extract<Descriptor, {
|
|
22
29
|
kind: "int64";
|
|
23
30
|
}>;
|
|
31
|
+
/** Descriptor variant for a `guint64` marshalled as a number. */
|
|
24
32
|
type Uint64Descriptor = Extract<Descriptor, {
|
|
25
33
|
kind: "uint64";
|
|
26
34
|
}>;
|
|
35
|
+
/** Descriptor variant for a `gint64` marshalled as a bigint. */
|
|
27
36
|
type BigInt64Descriptor = Extract<Descriptor, {
|
|
28
37
|
kind: "bigint64";
|
|
29
38
|
}>;
|
|
39
|
+
/** Descriptor variant for a `guint64` marshalled as a bigint. */
|
|
30
40
|
type BigUint64Descriptor = Extract<Descriptor, {
|
|
31
41
|
kind: "biguint64";
|
|
32
42
|
}>;
|
|
43
|
+
/** Descriptor variant for a `gfloat`. */
|
|
33
44
|
type Float32Descriptor = Extract<Descriptor, {
|
|
34
45
|
kind: "float32";
|
|
35
46
|
}>;
|
|
47
|
+
/** Descriptor variant for a `gdouble`. */
|
|
36
48
|
type Float64Descriptor = Extract<Descriptor, {
|
|
37
49
|
kind: "float64";
|
|
38
50
|
}>;
|
|
51
|
+
/** Descriptor variant for an enumeration, carrying the library and `get_type` symbol its GType comes from. */
|
|
39
52
|
type EnumDescriptor = Extract<Descriptor, {
|
|
40
53
|
kind: "enum";
|
|
41
54
|
}>;
|
|
55
|
+
/** Descriptor variant for a flags type, carrying the library and `get_type` symbol its GType comes from. */
|
|
42
56
|
type FlagsDescriptor = Extract<Descriptor, {
|
|
43
57
|
kind: "flags";
|
|
44
58
|
}>;
|
|
59
|
+
/** Descriptor variant for a `gboolean`. */
|
|
45
60
|
type BooleanDescriptor = Extract<Descriptor, {
|
|
46
61
|
kind: "boolean";
|
|
47
62
|
}>;
|
|
63
|
+
/** Descriptor variant for a C string. */
|
|
48
64
|
type StringDescriptor = Extract<Descriptor, {
|
|
49
65
|
kind: "string";
|
|
50
66
|
}>;
|
|
67
|
+
/** Descriptor variant for a `GObject`. */
|
|
51
68
|
type ObjectDescriptor = Extract<Descriptor, {
|
|
52
69
|
kind: "object";
|
|
53
70
|
}>;
|
|
71
|
+
/** Descriptor variant for a `gunichar`. */
|
|
54
72
|
type UnicharDescriptor = Extract<Descriptor, {
|
|
55
73
|
kind: "unichar";
|
|
56
74
|
}>;
|
|
75
|
+
/** Descriptor variant for the absence of a value. */
|
|
57
76
|
type VoidDescriptor = Extract<Descriptor, {
|
|
58
77
|
kind: "void";
|
|
59
78
|
}>;
|
|
79
|
+
/** Descriptor variant for an opaque `gpointer`. */
|
|
60
80
|
type BufferDescriptor = Extract<Descriptor, {
|
|
61
81
|
kind: "buffer";
|
|
62
82
|
}>;
|
|
83
|
+
/** Descriptor variant for a `GBoxed` value. */
|
|
63
84
|
type BoxedDescriptor = Extract<Descriptor, {
|
|
64
85
|
kind: "boxed";
|
|
65
86
|
}>;
|
|
87
|
+
/** Descriptor variant for a plain C struct, extended with the class its decoded value is wrapped in. */
|
|
66
88
|
type StructDescriptor = Extract<Descriptor, {
|
|
67
89
|
kind: "struct";
|
|
68
90
|
}> & {
|
|
69
91
|
/** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */
|
|
70
92
|
wrapperClass?: AnyClass;
|
|
71
93
|
};
|
|
94
|
+
/** Descriptor variant for a ref-counted fundamental type, extended with the class its decoded value is wrapped in. */
|
|
72
95
|
type FundamentalDescriptor = Extract<Descriptor, {
|
|
73
96
|
kind: "fundamental";
|
|
74
97
|
}> & {
|
|
75
98
|
/** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */
|
|
76
99
|
wrapperClass?: AnyClass;
|
|
77
100
|
};
|
|
101
|
+
/** Descriptor variant for an array of items in one of the supported container layouts. */
|
|
78
102
|
type ArrayDescriptor = Extract<Descriptor, {
|
|
79
103
|
kind: "array";
|
|
80
104
|
}>;
|
|
105
|
+
/** Descriptor variant for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
81
106
|
type HashTableDescriptor = Extract<Descriptor, {
|
|
82
107
|
kind: "hashtable";
|
|
83
108
|
}>;
|
|
109
|
+
/** Descriptor variant for a function pointer a JavaScript function is marshalled into. */
|
|
84
110
|
type CallbackDescriptor = Extract<Descriptor, {
|
|
85
111
|
kind: "callback";
|
|
86
112
|
}>;
|
|
113
|
+
/** Descriptor variant for a pointer to another descriptor's value, for an output or inout argument. */
|
|
87
114
|
type RefDescriptor = Extract<Descriptor, {
|
|
88
115
|
kind: "ref";
|
|
89
116
|
}>;
|
|
117
|
+
/** Descriptor for a `GType`: a `guint64` marked so it resolves to `G_TYPE_GTYPE` rather than an integer. */
|
|
90
118
|
type TypeDescriptor = BigUint64Descriptor & {
|
|
119
|
+
/** Distinguishes a GType from a plain `guint64` when the GLib type and the GValue type are resolved. */
|
|
91
120
|
type: true;
|
|
92
121
|
};
|
|
93
122
|
/** How a boxed value is stored, and where its GType and free function are resolved from. */
|
|
@@ -109,9 +138,13 @@ type BoxedOptions = {
|
|
|
109
138
|
};
|
|
110
139
|
/** How the callee takes a callback's closure, and how long that closure has to stay alive. */
|
|
111
140
|
type CallbackOptions = {
|
|
112
|
-
/** The callee also takes a
|
|
141
|
+
/** The callee also takes a destroy notify, which frees the closure once it is done with it. */
|
|
113
142
|
hasDestroy?: boolean;
|
|
114
|
-
/**
|
|
143
|
+
/** Signature of that destroy notify; defaults to `destroyNotify`, a one-argument `GDestroyNotify`. */
|
|
144
|
+
destroyKind?: CallbackDescriptor["destroyKind"];
|
|
145
|
+
/** The callee also takes a `user_data` pointer; without one the closure can never be freed. */
|
|
146
|
+
hasUserData?: boolean;
|
|
147
|
+
/** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */
|
|
115
148
|
userDataIndex?: number;
|
|
116
149
|
/** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */
|
|
117
150
|
scope?: CallbackDescriptor["scope"];
|
|
@@ -147,40 +180,78 @@ type StructOptions = {
|
|
|
147
180
|
/** Class a decoded value is wrapped in, instead of the one registered for its GType. */
|
|
148
181
|
wrapperClass?: AnyClass;
|
|
149
182
|
};
|
|
183
|
+
/** Descriptor for a `gint8`, marshalled as a number. */
|
|
150
184
|
declare const int8T: Int8Descriptor;
|
|
185
|
+
/** Descriptor for a `guint8`, marshalled as a number. */
|
|
151
186
|
declare const uint8T: Uint8Descriptor;
|
|
187
|
+
/** Descriptor for a `gint16`, marshalled as a number. */
|
|
152
188
|
declare const int16T: Int16Descriptor;
|
|
189
|
+
/** Descriptor for a `guint16`, marshalled as a number. */
|
|
153
190
|
declare const uint16T: Uint16Descriptor;
|
|
191
|
+
/** Descriptor for a `gint32`, marshalled as a number. */
|
|
154
192
|
declare const int32T: Int32Descriptor;
|
|
193
|
+
/** Descriptor for a `guint32`, marshalled as a number. */
|
|
155
194
|
declare const uint32T: Uint32Descriptor;
|
|
195
|
+
/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
156
196
|
declare const int64T: Int64Descriptor;
|
|
197
|
+
/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
157
198
|
declare const uint64T: Uint64Descriptor;
|
|
199
|
+
/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
158
200
|
declare const bigint64T: BigInt64Descriptor;
|
|
201
|
+
/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
159
202
|
declare const biguint64T: BigUint64Descriptor;
|
|
203
|
+
/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */
|
|
160
204
|
declare const gtypeT: TypeDescriptor;
|
|
205
|
+
/** Descriptor for a `gfloat`. */
|
|
161
206
|
declare const float32T: Float32Descriptor;
|
|
207
|
+
/** Descriptor for a `gdouble`. */
|
|
162
208
|
declare const float64T: Float64Descriptor;
|
|
209
|
+
/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */
|
|
163
210
|
declare const booleanT: BooleanDescriptor;
|
|
211
|
+
/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */
|
|
164
212
|
declare const voidT: VoidDescriptor;
|
|
213
|
+
/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */
|
|
165
214
|
declare const unicharT: UnicharDescriptor;
|
|
215
|
+
/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
|
|
166
216
|
declare const bufferT: BufferDescriptor;
|
|
217
|
+
/**
|
|
218
|
+
* Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
|
|
219
|
+
* used when the string is passed by reference.
|
|
220
|
+
*/
|
|
167
221
|
declare const stringT: (ownership?: Ownership, length?: number) => StringDescriptor;
|
|
222
|
+
/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */
|
|
168
223
|
declare const objectT: (ownership?: Ownership) => ObjectDescriptor;
|
|
224
|
+
/** Wraps a descriptor in a pointer to it, for an output or inout argument. */
|
|
169
225
|
declare const refT: (innerDescriptor: Descriptor, isInout?: boolean) => RefDescriptor;
|
|
226
|
+
/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
170
227
|
declare const hashTableT: (keyDescriptor: Descriptor, valueDescriptor: Descriptor, ownership?: Ownership) => HashTableDescriptor;
|
|
228
|
+
/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */
|
|
171
229
|
declare const enumT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => EnumDescriptor;
|
|
230
|
+
/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
|
|
172
231
|
declare const flagsT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => FlagsDescriptor;
|
|
232
|
+
/** Builds a descriptor for a `GBoxed` value of the named type. */
|
|
173
233
|
declare const boxedT: (typeName: string, options?: BoxedOptions) => BoxedDescriptor;
|
|
234
|
+
/** Builds a descriptor for a plain C struct. */
|
|
174
235
|
declare const structT: (ownership?: Ownership, options?: StructOptions) => StructDescriptor;
|
|
236
|
+
/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */
|
|
175
237
|
declare const fundamentalT: (sharedLibrary: string, refFnName: string, unrefFnName: string, options?: FundamentalOptions) => FundamentalDescriptor;
|
|
238
|
+
/** Builds a descriptor for an array of items in one of the supported container layouts. */
|
|
176
239
|
declare const arrayT: (itemDescriptor: Descriptor, arrayKind?: ArrayKind, ownership?: Ownership, options?: ArrayOptions) => ArrayDescriptor;
|
|
240
|
+
/** Builds a descriptor for a `GList` of items. */
|
|
177
241
|
declare const listT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
242
|
+
/** Builds a descriptor for a `GSList` of items. */
|
|
178
243
|
declare const slistT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
244
|
+
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
179
245
|
declare const ptrArrayT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
246
|
+
/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */
|
|
180
247
|
declare const gArrayT: (itemDescriptor: Descriptor, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
248
|
+
/** Builds a descriptor for a `GByteArray`. */
|
|
181
249
|
declare const byteArrayT: (ownership?: Ownership) => ArrayDescriptor;
|
|
250
|
+
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
182
251
|
declare const sizedArrayT: (itemDescriptor: Descriptor, sizeParamIndex: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
252
|
+
/** Builds a descriptor for a C array of a fixed length. */
|
|
183
253
|
declare const fixedArrayT: (itemDescriptor: Descriptor, fixedSize: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
254
|
+
/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
|
|
184
255
|
declare const callbackT: (argDescriptors: Descriptor[], returnDescriptor: Descriptor, options?: CallbackOptions) => CallbackDescriptor;
|
|
185
|
-
export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, float32T, float64T, booleanT, voidT, unicharT, bufferT, stringT, objectT, refT, hashTableT, enumT, flagsT, boxedT, structT, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, callbackT, type
|
|
256
|
+
export { int8T, uint8T, int16T, uint16T, int32T, uint32T, int64T, uint64T, bigint64T, biguint64T, gtypeT, float32T, float64T, booleanT, voidT, unicharT, bufferT, stringT, objectT, refT, hashTableT, enumT, flagsT, boxedT, structT, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, callbackT, type BoxedDescriptor, type StructDescriptor, type FundamentalDescriptor, type ArrayDescriptor, type HashTableDescriptor, type CallbackDescriptor, type RefDescriptor, };
|
|
186
257
|
//# sourceMappingURL=descriptors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptors.d.ts","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC5D,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAC9D,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAC9D,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC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T,gBAAgB,UAAU,EAC1B,YAAW,SAAsB,EACjC,cAAc,MAAM,KACrB,eACqG,CAAC;AAEzG,8CAA8C;AAC9C,QAAA,MAAM,UAAU,GAAI,YAAW,SAAsB,KAAG,eACb,CAAC;AAE5C,qFAAqF;AACrF,QAAA,MAAM,WAAW,GACb,gBAAgB,UAAU,EAC1B,gBAAgB,MAAM,EACtB,YAAW,SAAsB,EACjC,cAAc,MAAM,KACrB,eAA8F,CAAC;AAElG,2DAA2D;AAC3D,QAAA,MAAM,WAAW,GACb,gBAAgB,UAAU,EAC1B,WAAW,MAAM,EACjB,YAAW,SAAsB,EACjC,cAAc,MAAM,KACrB,eAAyF,CAAC;AAE7F,2GAA2G;AAC3G,QAAA,MAAM,SAAS,GACX,gBAAgB,UAAU,EAAE,EAC5B,kBAAkB,UAAU,EAC5B,UAAU,eAAe,KAC1B,kBAwBF,CAAC;AAEF,OAAO,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACrB,CAAC"}
|
package/dist/descriptors.js
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
|
+
/** Descriptor for a `gint8`, marshalled as a number. */
|
|
1
2
|
const int8T = { kind: "int8" };
|
|
3
|
+
/** Descriptor for a `guint8`, marshalled as a number. */
|
|
2
4
|
const uint8T = { kind: "uint8" };
|
|
5
|
+
/** Descriptor for a `gint16`, marshalled as a number. */
|
|
3
6
|
const int16T = { kind: "int16" };
|
|
7
|
+
/** Descriptor for a `guint16`, marshalled as a number. */
|
|
4
8
|
const uint16T = { kind: "uint16" };
|
|
9
|
+
/** Descriptor for a `gint32`, marshalled as a number. */
|
|
5
10
|
const int32T = { kind: "int32" };
|
|
11
|
+
/** Descriptor for a `guint32`, marshalled as a number. */
|
|
6
12
|
const uint32T = { kind: "uint32" };
|
|
13
|
+
/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
7
14
|
const int64T = { kind: "int64" };
|
|
15
|
+
/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
8
16
|
const uint64T = { kind: "uint64" };
|
|
17
|
+
/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
9
18
|
const bigint64T = { kind: "bigint64" };
|
|
19
|
+
/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
10
20
|
const biguint64T = { kind: "biguint64" };
|
|
21
|
+
/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */
|
|
11
22
|
const gtypeT = { kind: "biguint64", type: true };
|
|
23
|
+
/** Descriptor for a `gfloat`. */
|
|
12
24
|
const float32T = { kind: "float32" };
|
|
25
|
+
/** Descriptor for a `gdouble`. */
|
|
13
26
|
const float64T = { kind: "float64" };
|
|
27
|
+
/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */
|
|
14
28
|
const booleanT = { kind: "boolean" };
|
|
29
|
+
/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */
|
|
15
30
|
const voidT = { kind: "void" };
|
|
31
|
+
/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */
|
|
16
32
|
const unicharT = { kind: "unichar" };
|
|
33
|
+
/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
|
|
17
34
|
const bufferT = { kind: "buffer" };
|
|
35
|
+
/**
|
|
36
|
+
* Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
|
|
37
|
+
* used when the string is passed by reference.
|
|
38
|
+
*/
|
|
18
39
|
const stringT = (ownership = "borrowed", length) => length === undefined ? { kind: "string", ownership } : { kind: "string", ownership, length };
|
|
40
|
+
/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */
|
|
19
41
|
const objectT = (ownership = "borrowed") => ({ kind: "object", ownership });
|
|
42
|
+
/** Wraps a descriptor in a pointer to it, for an output or inout argument. */
|
|
20
43
|
const refT = (innerDescriptor, isInout = false) => isInout ? { kind: "ref", innerDescriptor, inout: true } : { kind: "ref", innerDescriptor };
|
|
44
|
+
/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
21
45
|
const hashTableT = (keyDescriptor, valueDescriptor, ownership = "borrowed") => ({
|
|
22
46
|
kind: "hashtable",
|
|
23
47
|
keyDescriptor,
|
|
24
48
|
valueDescriptor,
|
|
25
49
|
ownership,
|
|
26
50
|
});
|
|
51
|
+
/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */
|
|
27
52
|
const enumT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
28
53
|
kind: "enum",
|
|
29
54
|
sharedLibrary,
|
|
30
55
|
getTypeFnName: typeFnName,
|
|
31
56
|
isSigned,
|
|
32
57
|
});
|
|
58
|
+
/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
|
|
33
59
|
const flagsT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
34
60
|
kind: "flags",
|
|
35
61
|
sharedLibrary,
|
|
@@ -59,6 +85,7 @@ const applyBoxedOptions = (result, options) => {
|
|
|
59
85
|
result.size = options.size;
|
|
60
86
|
}
|
|
61
87
|
};
|
|
88
|
+
/** Builds a descriptor for a `GBoxed` value of the named type. */
|
|
62
89
|
const boxedT = (typeName, options = {}) => {
|
|
63
90
|
const result = {
|
|
64
91
|
kind: "boxed",
|
|
@@ -68,6 +95,7 @@ const boxedT = (typeName, options = {}) => {
|
|
|
68
95
|
applyBoxedOptions(result, options);
|
|
69
96
|
return result;
|
|
70
97
|
};
|
|
98
|
+
/** Builds a descriptor for a plain C struct. */
|
|
71
99
|
const structT = (ownership = "borrowed", options = {}) => {
|
|
72
100
|
const result = { kind: "struct", ownership };
|
|
73
101
|
if (options.size !== undefined) {
|
|
@@ -84,6 +112,7 @@ const structT = (ownership = "borrowed", options = {}) => {
|
|
|
84
112
|
}
|
|
85
113
|
return result;
|
|
86
114
|
};
|
|
115
|
+
/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */
|
|
87
116
|
const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
88
117
|
const ownership = options.ownership ?? "borrowed";
|
|
89
118
|
const result = { kind: "fundamental", ownership, sharedLibrary, refFnName, unrefFnName };
|
|
@@ -98,6 +127,7 @@ const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
|
98
127
|
}
|
|
99
128
|
return result;
|
|
100
129
|
};
|
|
130
|
+
/** Builds a descriptor for an array of items in one of the supported container layouts. */
|
|
101
131
|
const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
|
|
102
132
|
const result = { kind: "array", itemDescriptor, arrayKind, ownership };
|
|
103
133
|
if (options?.elementSize !== undefined) {
|
|
@@ -111,18 +141,32 @@ const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", opt
|
|
|
111
141
|
}
|
|
112
142
|
return result;
|
|
113
143
|
};
|
|
144
|
+
/** Builds a descriptor for a `GList` of items. */
|
|
114
145
|
const listT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "glist", ownership);
|
|
146
|
+
/** Builds a descriptor for a `GSList` of items. */
|
|
115
147
|
const slistT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gslist", ownership);
|
|
148
|
+
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
116
149
|
const ptrArrayT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gptrarray", ownership);
|
|
150
|
+
/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */
|
|
117
151
|
const gArrayT = (itemDescriptor, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "garray", ownership, elementSize === undefined ? undefined : { elementSize });
|
|
152
|
+
/** Builds a descriptor for a `GByteArray`. */
|
|
118
153
|
const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership);
|
|
154
|
+
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
119
155
|
const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "sized", ownership, { sizeParamIndex, elementSize });
|
|
156
|
+
/** Builds a descriptor for a C array of a fixed length. */
|
|
120
157
|
const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "fixed", ownership, { fixedSize, elementSize });
|
|
158
|
+
/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
|
|
121
159
|
const callbackT = (argDescriptors, returnDescriptor, options) => {
|
|
122
160
|
const result = { kind: "callback", argDescriptors, returnDescriptor };
|
|
123
161
|
if (options?.hasDestroy !== undefined) {
|
|
124
162
|
result.hasDestroy = options.hasDestroy;
|
|
125
163
|
}
|
|
164
|
+
if (options?.destroyKind !== undefined) {
|
|
165
|
+
result.destroyKind = options.destroyKind;
|
|
166
|
+
}
|
|
167
|
+
if (options?.hasUserData !== undefined) {
|
|
168
|
+
result.hasUserData = options.hasUserData;
|
|
169
|
+
}
|
|
126
170
|
if (options?.userDataIndex !== undefined) {
|
|
127
171
|
result.userDataIndex = options.userDataIndex;
|
|
128
172
|
}
|
package/dist/descriptors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptors.js","sourceRoot":"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ACX,SAAS,GA6BZ,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\ntype Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\ntype Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\ntype Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\ntype Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\ntype Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\ntype Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\ntype Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\ntype Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\ntype BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\ntype BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\ntype Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\ntype Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\ntype EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\ntype FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\ntype BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\ntype StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\ntype ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\ntype UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\ntype VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\ntype BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\ntype BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\n\ntype StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */\n wrapperClass?: AnyClass;\n};\n\ntype FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */\n wrapperClass?: AnyClass;\n};\n\ntype ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\ntype HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\ntype CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\ntype RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\ntype TypeDescriptor = BigUint64Descriptor & { type: true };\n\n/** How a boxed value is stored, and where its GType and free function are resolved from. */\ntype BoxedOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** Library `getTypeFnName` and `freeFnName` are resolved in. */\n sharedLibrary?: string;\n /** Symbol returning the boxed GType, used when the type is not already registered under its name. */\n getTypeFnName?: string;\n /** Symbol that frees the value, for a boxed type with no GType of its own. */\n freeFnName?: string;\n /** Byte size of the value, needed to copy it into an inline field. */\n size?: number;\n};\n\n/** How the callee takes a callback's closure, and how long that closure has to stay alive. */\ntype CallbackOptions = {\n /** The callee also takes a `GDestroyNotify`, which frees the closure once it is done with it. */\n hasDestroy?: boolean;\n /** Position of the `user_data` argument carrying the closure; without one it can never be freed. */\n userDataIndex?: number;\n /** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */\n scope?: CallbackDescriptor[\"scope\"];\n};\n\n/** The lengths and strides a C array layout needs beyond its element type. */\ntype ArrayOptions = {\n /** Stride in bytes between elements stored inline in the array. */\n elementSize?: number | undefined;\n /** Position of the argument carrying the element count, for a length-bounded array. */\n sizeParamIndex?: number | undefined;\n /** Element count of a fixed-length array. */\n fixedSize?: number | undefined;\n};\n\n/** How a ref-counted fundamental value is named, wrapped and stored. */\ntype FundamentalOptions = {\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** GLib type name the wrapper class is looked up by. */\n typeName?: string;\n /** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */\n wrapperClass?: AnyClass;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n};\n\n/** How a plain C struct is stored and wrapped. */\ntype StructOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Byte size of the struct, needed to copy it rather than borrow the pointer. */\n size?: number;\n /** Class a decoded value is wrapped in, instead of the one registered for its GType. */\n wrapperClass?: AnyClass;\n};\n\nconst int8T: Int8Descriptor = { kind: \"int8\" };\nconst uint8T: Uint8Descriptor = { kind: \"uint8\" };\nconst int16T: Int16Descriptor = { kind: \"int16\" };\nconst uint16T: Uint16Descriptor = { kind: \"uint16\" };\nconst int32T: Int32Descriptor = { kind: \"int32\" };\nconst uint32T: Uint32Descriptor = { kind: \"uint32\" };\nconst int64T: Int64Descriptor = { kind: \"int64\" };\nconst uint64T: Uint64Descriptor = { kind: \"uint64\" };\nconst bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\nconst biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\nconst gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\nconst float32T: Float32Descriptor = { kind: \"float32\" };\nconst float64T: Float64Descriptor = { kind: \"float64\" };\nconst booleanT: BooleanDescriptor = { kind: \"boolean\" };\nconst voidT: VoidDescriptor = { kind: \"void\" };\nconst unicharT: UnicharDescriptor = { kind: \"unichar\" };\nconst bufferT: BufferDescriptor = { kind: \"buffer\" };\n\nconst stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\nconst objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\nconst refT = (innerDescriptor: Descriptor, isInout = false): RefDescriptor =>\n isInout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\nconst hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\nconst enumT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\nconst applyBoxedNames = (result: BoxedDescriptor, options: BoxedOptions): void => {\n if (options.sharedLibrary !== undefined) {\n result.sharedLibrary = options.sharedLibrary;\n }\n\n if (options.getTypeFnName !== undefined) {\n result.getTypeFnName = options.getTypeFnName;\n }\n\n if (options.freeFnName !== undefined) {\n result.freeFnName = options.freeFnName;\n }\n};\n\nconst applyBoxedOptions = (result: BoxedDescriptor, options: BoxedOptions): void => {\n applyBoxedNames(result, options);\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n};\n\nconst boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n\n applyBoxedOptions(result, options);\n\n return result;\n};\n\nconst structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\nconst fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n\n if (options.typeName !== undefined) {\n result.typeName = options.typeName;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\nconst arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n\n if (options?.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options?.sizeParamIndex !== undefined) {\n result.sizeParamIndex = options.sizeParamIndex;\n }\n\n if (options?.fixedSize !== undefined) {\n result.fixedSize = options.fixedSize;\n }\n\n return result;\n};\n\nconst listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\nconst slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\nconst ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\nconst gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\nconst byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\nconst sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\nconst fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\nconst callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n\n if (options?.hasDestroy !== undefined) {\n result.hasDestroy = options.hasDestroy;\n }\n\n if (options?.userDataIndex !== undefined) {\n result.userDataIndex = options.userDataIndex;\n }\n\n if (options?.scope !== undefined) {\n result.scope = options.scope;\n }\n\n return result;\n};\n\nexport {\n int8T,\n uint8T,\n int16T,\n uint16T,\n int32T,\n uint32T,\n int64T,\n uint64T,\n bigint64T,\n biguint64T,\n gtypeT,\n float32T,\n float64T,\n booleanT,\n voidT,\n unicharT,\n bufferT,\n stringT,\n objectT,\n refT,\n hashTableT,\n enumT,\n flagsT,\n boxedT,\n structT,\n fundamentalT,\n arrayT,\n listT,\n slistT,\n ptrArrayT,\n gArrayT,\n byteArrayT,\n sizedArrayT,\n fixedArrayT,\n callbackT,\n type Int8Descriptor,\n type Uint8Descriptor,\n type Int16Descriptor,\n type Uint16Descriptor,\n type Int32Descriptor,\n type Uint32Descriptor,\n type Int64Descriptor,\n type Uint64Descriptor,\n type BigInt64Descriptor,\n type BigUint64Descriptor,\n type Float32Descriptor,\n type Float64Descriptor,\n type EnumDescriptor,\n type FlagsDescriptor,\n type BooleanDescriptor,\n type StringDescriptor,\n type ObjectDescriptor,\n type UnicharDescriptor,\n type VoidDescriptor,\n type BufferDescriptor,\n type BoxedDescriptor,\n type StructDescriptor,\n type FundamentalDescriptor,\n type ArrayDescriptor,\n type HashTableDescriptor,\n type CallbackDescript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C,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO,EAAE,WAAW,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO,EAAE,aAAa,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,GAQZ,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\n/** Descriptor variant for a `gint8`. */\ntype Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\n/** Descriptor variant for a `guint8`. */\ntype Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\n/** Descriptor variant for a `gint16`. */\ntype Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\n/** Descriptor variant for a `guint16`. */\ntype Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\n/** Descriptor variant for a `gint32`. */\ntype Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\n/** Descriptor variant for a `guint32`. */\ntype Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\n/** Descriptor variant for a `gint64` marshalled as a number. */\ntype Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a number. */\ntype Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\n/** Descriptor variant for a `gint64` marshalled as a bigint. */\ntype BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\n/** Descriptor variant for a `guint64` marshalled as a bigint. */\ntype BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\n/** Descriptor variant for a `gfloat`. */\ntype Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\n/** Descriptor variant for a `gdouble`. */\ntype Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\n/** Descriptor variant for an enumeration, carrying the library and `get_type` symbol its GType comes from. */\ntype EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\n/** Descriptor variant for a flags type, carrying the library and `get_type` symbol its GType comes from. */\ntype FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\n/** Descriptor variant for a `gboolean`. */\ntype BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\n/** Descriptor variant for a C string. */\ntype StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\n/** Descriptor variant for a `GObject`. */\ntype ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\n/** Descriptor variant for a `gunichar`. */\ntype UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\n/** Descriptor variant for the absence of a value. */\ntype VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\n/** Descriptor variant for an opaque `gpointer`. */\ntype BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\n/** Descriptor variant for a `GBoxed` value. */\ntype BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\n\n/** Descriptor variant for a plain C struct, extended with the class its decoded value is wrapped in. */\ntype StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for a ref-counted fundamental type, extended with the class its decoded value is wrapped in. */\ntype FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & {\n /** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor variant for an array of items in one of the supported container layouts. */\ntype ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\n/** Descriptor variant for a `GHashTable`, marshalled as an array of key/value pairs. */\ntype HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\n/** Descriptor variant for a function pointer a JavaScript function is marshalled into. */\ntype CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\n/** Descriptor variant for a pointer to another descriptor's value, for an output or inout argument. */\ntype RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\n\n/** Descriptor for a `GType`: a `guint64` marked so it resolves to `G_TYPE_GTYPE` rather than an integer. */\ntype TypeDescriptor = BigUint64Descriptor & {\n /** Distinguishes a GType from a plain `guint64` when the GLib type and the GValue type are resolved. */\n type: true;\n};\n\n/** How a boxed value is stored, and where its GType and free function are resolved from. */\ntype BoxedOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** Library `getTypeFnName` and `freeFnName` are resolved in. */\n sharedLibrary?: string;\n /** Symbol returning the boxed GType, used when the type is not already registered under its name. */\n getTypeFnName?: string;\n /** Symbol that frees the value, for a boxed type with no GType of its own. */\n freeFnName?: string;\n /** Byte size of the value, needed to copy it into an inline field. */\n size?: number;\n};\n\n/** How the callee takes a callback's closure, and how long that closure has to stay alive. */\ntype CallbackOptions = {\n /** The callee also takes a destroy notify, which frees the closure once it is done with it. */\n hasDestroy?: boolean;\n /** Signature of that destroy notify; defaults to `destroyNotify`, a one-argument `GDestroyNotify`. */\n destroyKind?: CallbackDescriptor[\"destroyKind\"];\n /** The callee also takes a `user_data` pointer; without one the closure can never be freed. */\n hasUserData?: boolean;\n /** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */\n userDataIndex?: number;\n /** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */\n scope?: CallbackDescriptor[\"scope\"];\n};\n\n/** The lengths and strides a C array layout needs beyond its element type. */\ntype ArrayOptions = {\n /** Stride in bytes between elements stored inline in the array. */\n elementSize?: number | undefined;\n /** Position of the argument carrying the element count, for a length-bounded array. */\n sizeParamIndex?: number | undefined;\n /** Element count of a fixed-length array. */\n fixedSize?: number | undefined;\n};\n\n/** How a ref-counted fundamental value is named, wrapped and stored. */\ntype FundamentalOptions = {\n /** Whether a decoded value is owned by the caller; defaults to `\"borrowed\"`. */\n ownership?: Ownership;\n /** GLib type name the wrapper class is looked up by. */\n typeName?: string;\n /** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */\n wrapperClass?: AnyClass;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n};\n\n/** How a plain C struct is stored and wrapped. */\ntype StructOptions = {\n /** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */\n isCallerAllocated?: boolean;\n /** The value is embedded in the containing struct rather than reached through a pointer. */\n isInline?: boolean;\n /** Byte size of the struct, needed to copy it rather than borrow the pointer. */\n size?: number;\n /** Class a decoded value is wrapped in, instead of the one registered for its GType. */\n wrapperClass?: AnyClass;\n};\n\n/** Descriptor for a `gint8`, marshalled as a number. */\nconst int8T: Int8Descriptor = { kind: \"int8\" };\n/** Descriptor for a `guint8`, marshalled as a number. */\nconst uint8T: Uint8Descriptor = { kind: \"uint8\" };\n/** Descriptor for a `gint16`, marshalled as a number. */\nconst int16T: Int16Descriptor = { kind: \"int16\" };\n/** Descriptor for a `guint16`, marshalled as a number. */\nconst uint16T: Uint16Descriptor = { kind: \"uint16\" };\n/** Descriptor for a `gint32`, marshalled as a number. */\nconst int32T: Int32Descriptor = { kind: \"int32\" };\n/** Descriptor for a `guint32`, marshalled as a number. */\nconst uint32T: Uint32Descriptor = { kind: \"uint32\" };\n/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst int64T: Int64Descriptor = { kind: \"int64\" };\n/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */\nconst uint64T: Uint64Descriptor = { kind: \"uint64\" };\n/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\n/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */\nconst biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\n/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */\nconst gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\n/** Descriptor for a `gfloat`. */\nconst float32T: Float32Descriptor = { kind: \"float32\" };\n/** Descriptor for a `gdouble`. */\nconst float64T: Float64Descriptor = { kind: \"float64\" };\n/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */\nconst booleanT: BooleanDescriptor = { kind: \"boolean\" };\n/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */\nconst voidT: VoidDescriptor = { kind: \"void\" };\n/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */\nconst unicharT: UnicharDescriptor = { kind: \"unichar\" };\n/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */\nconst bufferT: BufferDescriptor = { kind: \"buffer\" };\n\n/**\n * Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer\n * used when the string is passed by reference.\n */\nconst stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\n/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */\nconst objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\n/** Wraps a descriptor in a pointer to it, for an output or inout argument. */\nconst refT = (innerDescriptor: Descriptor, isInout = false): RefDescriptor =>\n isInout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\n/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */\nconst hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\n/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */\nconst enumT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\n/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */\nconst flagsT = (sharedLibrary: string, typeFnName: string, isSigned: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName: typeFnName,\n isSigned,\n});\n\nconst applyBoxedNames = (result: BoxedDescriptor, options: BoxedOptions): void => {\n if (options.sharedLibrary !== undefined) {\n result.sharedLibrary = options.sharedLibrary;\n }\n\n if (options.getTypeFnName !== undefined) {\n result.getTypeFnName = options.getTypeFnName;\n }\n\n if (options.freeFnName !== undefined) {\n result.freeFnName = options.freeFnName;\n }\n};\n\nconst applyBoxedOptions = (result: BoxedDescriptor, options: BoxedOptions): void => {\n applyBoxedNames(result, options);\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n};\n\n/** Builds a descriptor for a `GBoxed` value of the named type. */\nconst boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n\n applyBoxedOptions(result, options);\n\n return result;\n};\n\n/** Builds a descriptor for a plain C struct. */\nconst structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n\n if (options.size !== undefined) {\n result.size = options.size;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isCallerAllocated) {\n result.isCallerAllocated = true;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */\nconst fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n\n if (options.typeName !== undefined) {\n result.typeName = options.typeName;\n }\n\n if (options.wrapperClass !== undefined) {\n result.wrapperClass = options.wrapperClass;\n }\n\n if (options.isInline) {\n result.isInline = true;\n }\n\n return result;\n};\n\n/** Builds a descriptor for an array of items in one of the supported container layouts. */\nconst arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n\n if (options?.elementSize !== undefined) {\n result.elementSize = options.elementSize;\n }\n\n if (options?.sizeParamIndex !== undefined) {\n result.sizeParamIndex = options.sizeParamIndex;\n }\n\n if (options?.fixedSize !== undefined) {\n result.fixedSize = options.fixedSize;\n }\n\n return result;\n};\n\n/** Builds a descriptor for a `GList` of items. */\nconst listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\n/** Builds a descriptor for a `GSList` of items. */\nconst slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\n/** Builds a descriptor for a `GPtrArray` of items. */\nconst ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\n/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */\nconst gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\n/** Builds a descriptor for a `GByteArray`. */\nconst byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\n/** Builds a descriptor for a C array whose length is carried by another argument. */\nconst sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\n/** Builds a descriptor for a C array of a fixed length. */\nconst fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\n/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */\nconst callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n\n if (options?.hasDestroy !== undefined) {\n result.hasDestroy = options.hasDestroy;\n }\n\n if (options?.destroyKind !== undefined) {\n result.destroyKind = options.destroyKind;\n }\n\n if (options?.hasUserData !== undefined) {\n result.hasUserData = options.hasUserData;\n }\n\n if (options?.userDataIndex !== undefined) {\n result.userDataIndex = options.userDataIndex;\n }\n\n if (options?.scope !== undefined) {\n result.scope = options.scope;\n }\n\n return result;\n};\n\nexport {\n int8T,\n uint8T,\n int16T,\n uint16T,\n int32T,\n uint32T,\n int64T,\n uint64T,\n bigint64T,\n biguint64T,\n gtypeT,\n float32T,\n float64T,\n booleanT,\n voidT,\n unicharT,\n bufferT,\n stringT,\n objectT,\n refT,\n hashTableT,\n enumT,\n flagsT,\n boxedT,\n structT,\n fundamentalT,\n arrayT,\n listT,\n slistT,\n ptrArrayT,\n gArrayT,\n byteArrayT,\n sizedArrayT,\n fixedArrayT,\n callbackT,\n type BoxedDescriptor,\n type StructDescriptor,\n type FundamentalDescriptor,\n type ArrayDescriptor,\n type HashTableDescriptor,\n type CallbackDescriptor,\n type RefDescriptor,\n};\n"]}
|
package/dist/error.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ type ErrorLike = Error & {
|
|
|
14
14
|
* matches wrapped GLib errors belonging to a specific error domain.
|
|
15
15
|
*/
|
|
16
16
|
type ErrorDomain<T extends Record<string, number>> = T & {
|
|
17
|
+
/** Backs `instanceof`, matching a wrapped GLib error whose domain is this one. */
|
|
17
18
|
[Symbol.hasInstance]: (value: unknown) => value is ErrorLike;
|
|
18
19
|
};
|
|
19
20
|
declare function checkError(error: Ref): void;
|