@gtkx/runtime 1.0.0-rc.4 → 1.1.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 +37 -0
- package/dist/application-class.d.ts.map +1 -0
- package/dist/application-class.js +78 -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 +4 -3
- package/dist/callback.d.ts.map +1 -1
- package/dist/callback.js +124 -29
- 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/default-application.d.ts +4 -0
- package/dist/default-application.d.ts.map +1 -0
- package/dist/default-application.js +17 -0
- package/dist/default-application.js.map +1 -0
- package/dist/descriptors.d.ts +98 -4
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +72 -6
- 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/exit-hook.js +13 -0
- package/dist/exit-hook.js.map +1 -1
- package/dist/fn.d.ts +24 -2
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +67 -32
- package/dist/fn.js.map +1 -1
- package/dist/folded-lengths.d.ts +16 -0
- package/dist/folded-lengths.d.ts.map +1 -0
- package/dist/folded-lengths.js +38 -0
- package/dist/folded-lengths.js.map +1 -0
- 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 +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -1
- package/dist/library.d.ts +3 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +3 -1
- package/dist/library.js.map +1 -1
- package/dist/lifecycle.d.ts +58 -11
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +95 -22
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts.map +1 -1
- package/dist/listeners.js +19 -5
- 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 +40 -7
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +95 -26
- 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 +147 -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 +39 -7
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +310 -43
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +147 -12
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +129 -83
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +80 -21
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +86 -33
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +11 -4
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +85 -25
- package/dist/signal.js.map +1 -1
- package/dist/t.d.ts +2 -0
- package/dist/t.d.ts.map +1 -1
- package/dist/t.js +1 -0
- package/dist/t.js.map +1 -1
- package/dist/tuple.d.ts +6 -3
- package/dist/tuple.d.ts.map +1 -1
- package/dist/tuple.js +9 -7
- package/dist/tuple.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 +10 -1
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +99 -24
- 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 +172 -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 +29 -0
- package/dist/vfunc.js.map +1 -0
- package/package.json +14 -4
- package/src/application-class.ts +126 -0
- package/src/arg.ts +2 -1
- package/src/bind.ts +11 -0
- package/src/callback.ts +178 -34
- package/src/closure.ts +136 -0
- package/src/default-application.ts +21 -0
- package/src/descriptors.ts +150 -34
- package/src/error.ts +1 -0
- package/src/exit-hook.ts +18 -0
- package/src/fn.ts +107 -36
- package/src/folded-lengths.ts +64 -0
- package/src/index.ts +21 -6
- package/src/internal.ts +2 -0
- package/src/library.ts +3 -1
- package/src/lifecycle.ts +138 -25
- package/src/listeners.ts +25 -6
- package/src/mixin.ts +15 -2
- package/src/native-value.ts +5 -3
- package/src/object.ts +134 -35
- package/src/param-spec.ts +234 -0
- package/src/promisify.ts +4 -2
- package/src/properties.ts +473 -46
- package/src/register-class.ts +386 -114
- package/src/registry.ts +169 -49
- package/src/signal.ts +116 -42
- package/src/t.ts +3 -0
- package/src/tuple.ts +18 -12
- package/src/type.ts +3 -1
- package/src/value.ts +143 -23
- package/src/vfunc-call.ts +247 -0
- package/src/vfunc-seeds.ts +36 -0
- package/src/vfunc.ts +38 -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,EA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C;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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-application.d.ts","sourceRoot":"","sources":["../src/default-application.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,uBAAuB,GAAI,aAAa,MAAM,KAAG,IAEtD,CAAC;AAEF,QAAA,MAAM,yBAAyB,GAAI,aAAa,MAAM,KAAG,IAMxD,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bind } from "./bind.js";
|
|
2
|
+
import { objectT, voidT } from "./descriptors.js";
|
|
3
|
+
import { GIO_LIB } from "./library.js";
|
|
4
|
+
import { getHandle } from "./registry.js";
|
|
5
|
+
const readDefaultApplication = bind(GIO_LIB, "g_application_get_default", [], objectT("borrowed"));
|
|
6
|
+
const writeDefaultApplication = bind(GIO_LIB, "g_application_set_default", [objectT("borrowed")], voidT);
|
|
7
|
+
const claimDefaultApplication = (application) => {
|
|
8
|
+
writeDefaultApplication(getHandle(application));
|
|
9
|
+
};
|
|
10
|
+
const releaseDefaultApplication = (application) => {
|
|
11
|
+
if (readDefaultApplication() !== application) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
writeDefaultApplication(null);
|
|
15
|
+
};
|
|
16
|
+
export { claimDefaultApplication, releaseDefaultApplication };
|
|
17
|
+
//# sourceMappingURL=default-application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-application.js","sourceRoot":"","sources":["../src/default-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,EAAE,2BAA2B,EAAE,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AACnG,MAAM,uBAAuB,GAAG,IAAI,CAAC,OAAO,EAAE,2BAA2B,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAEzG,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAQ,EAAE;IAC1D,uBAAuB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,WAAmB,EAAQ,EAAE;IAC5D,IAAI,sBAAsB,EAAE,KAAK,WAAW,EAAE,CAAC;QAC3C,OAAO;IACX,CAAC;IAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,CAAC","sourcesContent":["import { bind } from \"./bind.js\";\nimport { objectT, voidT } from \"./descriptors.js\";\nimport { GIO_LIB } from \"./library.js\";\nimport { getHandle } from \"./registry.js\";\n\nconst readDefaultApplication = bind(GIO_LIB, \"g_application_get_default\", [], objectT(\"borrowed\"));\nconst writeDefaultApplication = bind(GIO_LIB, \"g_application_set_default\", [objectT(\"borrowed\")], voidT);\n\nconst claimDefaultApplication = (application: object): void => {\n writeDefaultApplication(getHandle(application));\n};\n\nconst releaseDefaultApplication = (application: object): void => {\n if (readDefaultApplication() !== application) {\n return;\n }\n\n writeDefaultApplication(null);\n};\n\nexport { claimDefaultApplication, releaseDefaultApplication };\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. */
|
|
@@ -107,11 +136,18 @@ type BoxedOptions = {
|
|
|
107
136
|
/** Byte size of the value, needed to copy it into an inline field. */
|
|
108
137
|
size?: number;
|
|
109
138
|
};
|
|
110
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* What the bindings do with a callback's return value, how the callee takes its closure, and how
|
|
141
|
+
* long that closure has to stay alive.
|
|
142
|
+
*/
|
|
111
143
|
type CallbackOptions = {
|
|
112
|
-
/** The callee also takes a
|
|
144
|
+
/** The callee also takes a destroy notify, which frees the closure once it is done with it. */
|
|
113
145
|
hasDestroy?: boolean;
|
|
114
|
-
/**
|
|
146
|
+
/** Signature of that destroy notify; defaults to `destroyNotify`, a one-argument `GDestroyNotify`. */
|
|
147
|
+
destroyKind?: CallbackDescriptor["destroyKind"];
|
|
148
|
+
/** The callee also takes a `user_data` pointer; without one the closure can never be freed. */
|
|
149
|
+
hasUserData?: boolean;
|
|
150
|
+
/** Position of `user_data` among the callback's own arguments, dropped before the closure is called. */
|
|
115
151
|
userDataIndex?: number;
|
|
116
152
|
/** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */
|
|
117
153
|
scope?: CallbackDescriptor["scope"];
|
|
@@ -120,11 +156,20 @@ type CallbackOptions = {
|
|
|
120
156
|
type ArrayOptions = {
|
|
121
157
|
/** Stride in bytes between elements stored inline in the array. */
|
|
122
158
|
elementSize?: number | undefined;
|
|
159
|
+
/** Position of the argument whose buffer a cursor array points into. */
|
|
160
|
+
baseParamIndex?: number | undefined;
|
|
123
161
|
/** Position of the argument carrying the element count, for a length-bounded array. */
|
|
124
162
|
sizeParamIndex?: number | undefined;
|
|
125
163
|
/** Element count of a fixed-length array. */
|
|
126
164
|
fixedSize?: number | undefined;
|
|
127
165
|
};
|
|
166
|
+
/** Where a cursor array's base buffer and total length come from. */
|
|
167
|
+
type CursorBounds = {
|
|
168
|
+
/** Position of the argument holding the buffer the cursor points into. */
|
|
169
|
+
baseParamIndex: number;
|
|
170
|
+
/** Position of the argument carrying that buffer's element count. */
|
|
171
|
+
sizeParamIndex: number;
|
|
172
|
+
};
|
|
128
173
|
/** How a ref-counted fundamental value is named, wrapped and stored. */
|
|
129
174
|
type FundamentalOptions = {
|
|
130
175
|
/** Whether a decoded value is owned by the caller; defaults to `"borrowed"`. */
|
|
@@ -136,6 +181,11 @@ type FundamentalOptions = {
|
|
|
136
181
|
/** The value is embedded in the containing struct rather than reached through a pointer. */
|
|
137
182
|
isInline?: boolean;
|
|
138
183
|
};
|
|
184
|
+
type FundamentalLifecycle = {
|
|
185
|
+
sharedLibrary: string;
|
|
186
|
+
refFnName: string;
|
|
187
|
+
unrefFnName: string;
|
|
188
|
+
};
|
|
139
189
|
/** How a plain C struct is stored and wrapped. */
|
|
140
190
|
type StructOptions = {
|
|
141
191
|
/** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */
|
|
@@ -147,40 +197,84 @@ type StructOptions = {
|
|
|
147
197
|
/** Class a decoded value is wrapped in, instead of the one registered for its GType. */
|
|
148
198
|
wrapperClass?: AnyClass;
|
|
149
199
|
};
|
|
200
|
+
/** Descriptor for a `gint8`, marshalled as a number. */
|
|
150
201
|
declare const int8T: Int8Descriptor;
|
|
202
|
+
/** Descriptor for a `guint8`, marshalled as a number. */
|
|
151
203
|
declare const uint8T: Uint8Descriptor;
|
|
204
|
+
/** Descriptor for a `gint16`, marshalled as a number. */
|
|
152
205
|
declare const int16T: Int16Descriptor;
|
|
206
|
+
/** Descriptor for a `guint16`, marshalled as a number. */
|
|
153
207
|
declare const uint16T: Uint16Descriptor;
|
|
208
|
+
/** Descriptor for a `gint32`, marshalled as a number. */
|
|
154
209
|
declare const int32T: Int32Descriptor;
|
|
210
|
+
/** Descriptor for a `guint32`, marshalled as a number. */
|
|
155
211
|
declare const uint32T: Uint32Descriptor;
|
|
212
|
+
/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
156
213
|
declare const int64T: Int64Descriptor;
|
|
214
|
+
/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
157
215
|
declare const uint64T: Uint64Descriptor;
|
|
216
|
+
/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
158
217
|
declare const bigint64T: BigInt64Descriptor;
|
|
218
|
+
/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
159
219
|
declare const biguint64T: BigUint64Descriptor;
|
|
220
|
+
/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */
|
|
160
221
|
declare const gtypeT: TypeDescriptor;
|
|
222
|
+
/** Descriptor for a `gfloat`. */
|
|
161
223
|
declare const float32T: Float32Descriptor;
|
|
224
|
+
/** Descriptor for a `gdouble`. */
|
|
162
225
|
declare const float64T: Float64Descriptor;
|
|
226
|
+
/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */
|
|
163
227
|
declare const booleanT: BooleanDescriptor;
|
|
228
|
+
/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */
|
|
164
229
|
declare const voidT: VoidDescriptor;
|
|
230
|
+
/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */
|
|
165
231
|
declare const unicharT: UnicharDescriptor;
|
|
232
|
+
/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
|
|
166
233
|
declare const bufferT: BufferDescriptor;
|
|
234
|
+
/**
|
|
235
|
+
* Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
|
|
236
|
+
* used when the string is passed by reference.
|
|
237
|
+
*/
|
|
167
238
|
declare const stringT: (ownership?: Ownership, length?: number) => StringDescriptor;
|
|
239
|
+
/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */
|
|
168
240
|
declare const objectT: (ownership?: Ownership) => ObjectDescriptor;
|
|
241
|
+
/** Wraps a descriptor in a pointer to it, for an output or inout argument. */
|
|
169
242
|
declare const refT: (innerDescriptor: Descriptor, isInout?: boolean) => RefDescriptor;
|
|
243
|
+
/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
170
244
|
declare const hashTableT: (keyDescriptor: Descriptor, valueDescriptor: Descriptor, ownership?: Ownership) => HashTableDescriptor;
|
|
245
|
+
/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */
|
|
171
246
|
declare const enumT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => EnumDescriptor;
|
|
247
|
+
/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
|
|
172
248
|
declare const flagsT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => FlagsDescriptor;
|
|
249
|
+
/** Builds a descriptor for a `GBoxed` value of the named type. */
|
|
173
250
|
declare const boxedT: (typeName: string, options?: BoxedOptions) => BoxedDescriptor;
|
|
251
|
+
/** Builds a descriptor for a plain C struct. */
|
|
174
252
|
declare const structT: (ownership?: Ownership, options?: StructOptions) => StructDescriptor;
|
|
253
|
+
declare const fundamentalLifecycleFor: (typeName: string) => FundamentalLifecycle | undefined;
|
|
254
|
+
/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */
|
|
175
255
|
declare const fundamentalT: (sharedLibrary: string, refFnName: string, unrefFnName: string, options?: FundamentalOptions) => FundamentalDescriptor;
|
|
256
|
+
/** Builds a descriptor for an array of items in one of the supported container layouts. */
|
|
176
257
|
declare const arrayT: (itemDescriptor: Descriptor, arrayKind?: ArrayKind, ownership?: Ownership, options?: ArrayOptions) => ArrayDescriptor;
|
|
258
|
+
/** Builds a descriptor for a `GList` of items. */
|
|
177
259
|
declare const listT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
260
|
+
/** Builds a descriptor for a `GSList` of items. */
|
|
178
261
|
declare const slistT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
262
|
+
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
179
263
|
declare const ptrArrayT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
264
|
+
/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */
|
|
180
265
|
declare const gArrayT: (itemDescriptor: Descriptor, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
266
|
+
/** Builds a descriptor for a `GByteArray`. */
|
|
181
267
|
declare const byteArrayT: (ownership?: Ownership) => ArrayDescriptor;
|
|
268
|
+
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
182
269
|
declare const sizedArrayT: (itemDescriptor: Descriptor, sizeParamIndex: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
270
|
+
/**
|
|
271
|
+
* Builds a descriptor for an out pointer into the buffer another argument supplied, decoded as the
|
|
272
|
+
* elements from where it points to the end of that buffer.
|
|
273
|
+
*/
|
|
274
|
+
declare const cursorArrayT: (itemDescriptor: Descriptor, bounds: CursorBounds, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
275
|
+
/** Builds a descriptor for a C array of a fixed length. */
|
|
183
276
|
declare const fixedArrayT: (itemDescriptor: Descriptor, fixedSize: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
277
|
+
/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
|
|
184
278
|
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,
|
|
279
|
+
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, fundamentalLifecycleFor, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, cursorArrayT, callbackT, type BoxedDescriptor, type StructDescriptor, type FundamentalDescriptor, type ArrayDescriptor, type HashTableDescriptor, type CallbackDescriptor, type RefDescriptor, };
|
|
186
280
|
//# 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,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AAU,EAC1B,QAAQ,YAAY,EACpB,YAAW,SAAsB,EACjC,cAAc,MAAM,KACrB,eAA0F,CAAC;AAE9F,2DAA2D;AAC3D,QAAA,MAAM,WAAW,GACb,gBAAgB,UAAU,EAC1B,WAAW,MAAM,EACjB,YAAW,SAAsB,EACjC,cAAc,MAAM,KACrB,eAAyF,CAAC;AAwB7F,2GAA2G;AAC3G,QAAA,MAAM,SAAS,GACX,gBAAgB,UAAU,EAAE,EAC5B,kBAAkB,UAAU,EAC5B,UAAU,eAAe,KAC1B,kBAUF,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,uBAAuB,EACvB,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,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,62 @@
|
|
|
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
|
+
const fundamentalLifecycles = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* Builds a descriptor for a C string, whose optional length sizes the caller-allocated buffer
|
|
38
|
+
* used when the string is passed by reference.
|
|
39
|
+
*/
|
|
18
40
|
const stringT = (ownership = "borrowed", length) => length === undefined ? { kind: "string", ownership } : { kind: "string", ownership, length };
|
|
41
|
+
/** Builds a descriptor for a `GObject`, wrapped in the class registered for its runtime GType. */
|
|
19
42
|
const objectT = (ownership = "borrowed") => ({ kind: "object", ownership });
|
|
43
|
+
/** Wraps a descriptor in a pointer to it, for an output or inout argument. */
|
|
20
44
|
const refT = (innerDescriptor, isInout = false) => isInout ? { kind: "ref", innerDescriptor, inout: true } : { kind: "ref", innerDescriptor };
|
|
45
|
+
/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
21
46
|
const hashTableT = (keyDescriptor, valueDescriptor, ownership = "borrowed") => ({
|
|
22
47
|
kind: "hashtable",
|
|
23
48
|
keyDescriptor,
|
|
24
49
|
valueDescriptor,
|
|
25
50
|
ownership,
|
|
26
51
|
});
|
|
52
|
+
/** Builds a descriptor for an enumeration, resolving its GType from the named `get_type` function. */
|
|
27
53
|
const enumT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
28
54
|
kind: "enum",
|
|
29
55
|
sharedLibrary,
|
|
30
56
|
getTypeFnName: typeFnName,
|
|
31
57
|
isSigned,
|
|
32
58
|
});
|
|
59
|
+
/** Builds a descriptor for a flags type, resolving its GType from the named `get_type` function. */
|
|
33
60
|
const flagsT = (sharedLibrary, typeFnName, isSigned) => ({
|
|
34
61
|
kind: "flags",
|
|
35
62
|
sharedLibrary,
|
|
@@ -59,6 +86,7 @@ const applyBoxedOptions = (result, options) => {
|
|
|
59
86
|
result.size = options.size;
|
|
60
87
|
}
|
|
61
88
|
};
|
|
89
|
+
/** Builds a descriptor for a `GBoxed` value of the named type. */
|
|
62
90
|
const boxedT = (typeName, options = {}) => {
|
|
63
91
|
const result = {
|
|
64
92
|
kind: "boxed",
|
|
@@ -68,6 +96,7 @@ const boxedT = (typeName, options = {}) => {
|
|
|
68
96
|
applyBoxedOptions(result, options);
|
|
69
97
|
return result;
|
|
70
98
|
};
|
|
99
|
+
/** Builds a descriptor for a plain C struct. */
|
|
71
100
|
const structT = (ownership = "borrowed", options = {}) => {
|
|
72
101
|
const result = { kind: "struct", ownership };
|
|
73
102
|
if (options.size !== undefined) {
|
|
@@ -84,11 +113,19 @@ const structT = (ownership = "borrowed", options = {}) => {
|
|
|
84
113
|
}
|
|
85
114
|
return result;
|
|
86
115
|
};
|
|
116
|
+
const recordFundamentalLifecycle = (typeName, lifecycle) => {
|
|
117
|
+
if (!fundamentalLifecycles.has(typeName)) {
|
|
118
|
+
fundamentalLifecycles.set(typeName, lifecycle);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const fundamentalLifecycleFor = (typeName) => fundamentalLifecycles.get(typeName);
|
|
122
|
+
/** Builds a descriptor for a fundamental type whose lifetime is managed by named ref and unref functions. */
|
|
87
123
|
const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
88
124
|
const ownership = options.ownership ?? "borrowed";
|
|
89
125
|
const result = { kind: "fundamental", ownership, sharedLibrary, refFnName, unrefFnName };
|
|
90
126
|
if (options.typeName !== undefined) {
|
|
91
127
|
result.typeName = options.typeName;
|
|
128
|
+
recordFundamentalLifecycle(options.typeName, { sharedLibrary, refFnName, unrefFnName });
|
|
92
129
|
}
|
|
93
130
|
if (options.wrapperClass !== undefined) {
|
|
94
131
|
result.wrapperClass = options.wrapperClass;
|
|
@@ -98,11 +135,15 @@ const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
|
98
135
|
}
|
|
99
136
|
return result;
|
|
100
137
|
};
|
|
138
|
+
/** Builds a descriptor for an array of items in one of the supported container layouts. */
|
|
101
139
|
const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
|
|
102
140
|
const result = { kind: "array", itemDescriptor, arrayKind, ownership };
|
|
103
141
|
if (options?.elementSize !== undefined) {
|
|
104
142
|
result.elementSize = options.elementSize;
|
|
105
143
|
}
|
|
144
|
+
if (options?.baseParamIndex !== undefined) {
|
|
145
|
+
result.baseParamIndex = options.baseParamIndex;
|
|
146
|
+
}
|
|
106
147
|
if (options?.sizeParamIndex !== undefined) {
|
|
107
148
|
result.sizeParamIndex = options.sizeParamIndex;
|
|
108
149
|
}
|
|
@@ -111,25 +152,50 @@ const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", opt
|
|
|
111
152
|
}
|
|
112
153
|
return result;
|
|
113
154
|
};
|
|
155
|
+
/** Builds a descriptor for a `GList` of items. */
|
|
114
156
|
const listT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "glist", ownership);
|
|
157
|
+
/** Builds a descriptor for a `GSList` of items. */
|
|
115
158
|
const slistT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gslist", ownership);
|
|
159
|
+
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
116
160
|
const ptrArrayT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gptrarray", ownership);
|
|
161
|
+
/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */
|
|
117
162
|
const gArrayT = (itemDescriptor, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "garray", ownership, elementSize === undefined ? undefined : { elementSize });
|
|
163
|
+
/** Builds a descriptor for a `GByteArray`. */
|
|
118
164
|
const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership);
|
|
165
|
+
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
119
166
|
const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "sized", ownership, { sizeParamIndex, elementSize });
|
|
167
|
+
/**
|
|
168
|
+
* Builds a descriptor for an out pointer into the buffer another argument supplied, decoded as the
|
|
169
|
+
* elements from where it points to the end of that buffer.
|
|
170
|
+
*/
|
|
171
|
+
const cursorArrayT = (itemDescriptor, bounds, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "cursor", ownership, { ...bounds, elementSize });
|
|
172
|
+
/** Builds a descriptor for a C array of a fixed length. */
|
|
120
173
|
const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "fixed", ownership, { fixedSize, elementSize });
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
if (options?.hasDestroy !== undefined) {
|
|
174
|
+
const applyClosureOptions = (result, options) => {
|
|
175
|
+
if (options.hasDestroy !== undefined) {
|
|
124
176
|
result.hasDestroy = options.hasDestroy;
|
|
125
177
|
}
|
|
126
|
-
if (options
|
|
178
|
+
if (options.destroyKind !== undefined) {
|
|
179
|
+
result.destroyKind = options.destroyKind;
|
|
180
|
+
}
|
|
181
|
+
if (options.hasUserData !== undefined) {
|
|
182
|
+
result.hasUserData = options.hasUserData;
|
|
183
|
+
}
|
|
184
|
+
if (options.userDataIndex !== undefined) {
|
|
127
185
|
result.userDataIndex = options.userDataIndex;
|
|
128
186
|
}
|
|
129
|
-
if (options
|
|
187
|
+
if (options.scope !== undefined) {
|
|
130
188
|
result.scope = options.scope;
|
|
131
189
|
}
|
|
190
|
+
};
|
|
191
|
+
/** Builds a descriptor for a function pointer, marshalling a JavaScript function into a native closure. */
|
|
192
|
+
const callbackT = (argDescriptors, returnDescriptor, options) => {
|
|
193
|
+
const result = { kind: "callback", argDescriptors, returnDescriptor };
|
|
194
|
+
if (options === undefined) {
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
applyClosureOptions(result, options);
|
|
132
198
|
return result;
|
|
133
199
|
};
|
|
134
|
-
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, };
|
|
200
|
+
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, fundamentalLifecycleFor, fundamentalT, arrayT, listT, slistT, ptrArrayT, gArrayT, byteArrayT, sizedArrayT, fixedArrayT, cursorArrayT, callbackT, };
|
|
135
201
|
//# sourceMappingURL=descriptors.js.map
|