@gtkx/runtime 1.0.0-rc.3 → 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 +8 -9
- 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 +9 -3
- package/dist/arg.d.ts.map +1 -1
- package/dist/arg.js +4 -3
- 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 +119 -21
- 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 +105 -6
- package/dist/descriptors.d.ts.map +1 -1
- package/dist/descriptors.js +56 -12
- package/dist/descriptors.js.map +1 -1
- package/dist/error.d.ts +7 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fn.d.ts +24 -3
- package/dist/fn.d.ts.map +1 -1
- package/dist/fn.js +70 -33
- package/dist/fn.js.map +1 -1
- package/dist/index.d.ts +29 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -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 +52 -10
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +62 -18
- package/dist/lifecycle.js.map +1 -1
- package/dist/listeners.d.ts +6 -0
- 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 +16 -2
- package/dist/mixin.d.ts.map +1 -1
- package/dist/mixin.js +18 -6
- package/dist/mixin.js.map +1 -1
- package/dist/native-value.d.ts +8 -0
- package/dist/native-value.d.ts.map +1 -1
- package/dist/native-value.js +12 -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 +3 -5
- package/dist/promisify.d.ts.map +1 -1
- package/dist/promisify.js +4 -3
- 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 +305 -42
- package/dist/properties.js.map +1 -1
- package/dist/register-class.d.ts +119 -14
- package/dist/register-class.d.ts.map +1 -1
- package/dist/register-class.js +109 -80
- package/dist/register-class.js.map +1 -1
- package/dist/registry.d.ts +81 -17
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +72 -26
- package/dist/registry.js.map +1 -1
- package/dist/signal.d.ts +22 -3
- package/dist/signal.d.ts.map +1 -1
- package/dist/signal.js +64 -8
- package/dist/signal.js.map +1 -1
- package/dist/t.d.ts +44 -0
- package/dist/t.d.ts.map +1 -1
- package/dist/t.js.map +1 -1
- package/dist/type.d.ts +2 -2
- 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 -10
- package/dist/value.d.ts.map +1 -1
- package/dist/value.js +44 -22
- 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 +11 -5
- package/src/bind.ts +11 -0
- package/src/callback.ts +163 -23
- package/src/closure.ts +136 -0
- package/src/descriptors.ts +137 -41
- package/src/error.ts +8 -1
- package/src/fn.ts +104 -39
- package/src/index.ts +36 -7
- package/src/internal.ts +1 -0
- package/src/library.ts +2 -1
- package/src/lifecycle.ts +99 -22
- package/src/listeners.ts +9 -1
- package/src/mixin.ts +27 -8
- package/src/native-value.ts +13 -3
- package/src/object.ts +128 -34
- package/src/param-spec.ts +235 -0
- package/src/promisify.ts +8 -8
- package/src/properties.ts +459 -45
- package/src/register-class.ts +329 -114
- package/src/registry.ts +150 -38
- package/src/signal.ts +101 -17
- package/src/t.ts +44 -0
- package/src/type.ts +3 -2
- package/src/value.ts +57 -19
- 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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ED,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,158 +1,257 @@
|
|
|
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
|
}> & {
|
|
91
|
+
/** Class a decoded value is wrapped in; without it the wrapper comes from the value's own GType. */
|
|
69
92
|
wrapperClass?: AnyClass;
|
|
70
93
|
};
|
|
94
|
+
/** Descriptor variant for a ref-counted fundamental type, extended with the class its decoded value is wrapped in. */
|
|
71
95
|
type FundamentalDescriptor = Extract<Descriptor, {
|
|
72
96
|
kind: "fundamental";
|
|
73
97
|
}> & {
|
|
98
|
+
/** Class a decoded value is wrapped in; without it the wrapper comes from the type named by `typeName`. */
|
|
74
99
|
wrapperClass?: AnyClass;
|
|
75
100
|
};
|
|
101
|
+
/** Descriptor variant for an array of items in one of the supported container layouts. */
|
|
76
102
|
type ArrayDescriptor = Extract<Descriptor, {
|
|
77
103
|
kind: "array";
|
|
78
104
|
}>;
|
|
105
|
+
/** Descriptor variant for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
79
106
|
type HashTableDescriptor = Extract<Descriptor, {
|
|
80
107
|
kind: "hashtable";
|
|
81
108
|
}>;
|
|
109
|
+
/** Descriptor variant for a function pointer a JavaScript function is marshalled into. */
|
|
82
110
|
type CallbackDescriptor = Extract<Descriptor, {
|
|
83
111
|
kind: "callback";
|
|
84
112
|
}>;
|
|
113
|
+
/** Descriptor variant for a pointer to another descriptor's value, for an output or inout argument. */
|
|
85
114
|
type RefDescriptor = Extract<Descriptor, {
|
|
86
115
|
kind: "ref";
|
|
87
116
|
}>;
|
|
117
|
+
/** Descriptor for a `GType`: a `guint64` marked so it resolves to `G_TYPE_GTYPE` rather than an integer. */
|
|
88
118
|
type TypeDescriptor = BigUint64Descriptor & {
|
|
119
|
+
/** Distinguishes a GType from a plain `guint64` when the GLib type and the GValue type are resolved. */
|
|
89
120
|
type: true;
|
|
90
121
|
};
|
|
122
|
+
/** How a boxed value is stored, and where its GType and free function are resolved from. */
|
|
91
123
|
type BoxedOptions = {
|
|
92
|
-
|
|
93
|
-
|
|
124
|
+
/** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */
|
|
125
|
+
isCallerAllocated?: boolean;
|
|
126
|
+
/** The value is embedded in the containing struct rather than reached through a pointer. */
|
|
127
|
+
isInline?: boolean;
|
|
128
|
+
/** Whether a decoded value is owned by the caller; defaults to `"borrowed"`. */
|
|
94
129
|
ownership?: Ownership;
|
|
130
|
+
/** Library `getTypeFnName` and `freeFnName` are resolved in. */
|
|
95
131
|
sharedLibrary?: string;
|
|
132
|
+
/** Symbol returning the boxed GType, used when the type is not already registered under its name. */
|
|
96
133
|
getTypeFnName?: string;
|
|
134
|
+
/** Symbol that frees the value, for a boxed type with no GType of its own. */
|
|
97
135
|
freeFnName?: string;
|
|
136
|
+
/** Byte size of the value, needed to copy it into an inline field. */
|
|
98
137
|
size?: number;
|
|
99
138
|
};
|
|
139
|
+
/** How the callee takes a callback's closure, and how long that closure has to stay alive. */
|
|
100
140
|
type CallbackOptions = {
|
|
141
|
+
/** The callee also takes a destroy notify, which frees the closure once it is done with it. */
|
|
101
142
|
hasDestroy?: boolean;
|
|
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. */
|
|
102
148
|
userDataIndex?: number;
|
|
149
|
+
/** Lifetime of the closure; defaults to `notified` when `hasDestroy` is set and `call` otherwise. */
|
|
103
150
|
scope?: CallbackDescriptor["scope"];
|
|
104
151
|
};
|
|
152
|
+
/** The lengths and strides a C array layout needs beyond its element type. */
|
|
105
153
|
type ArrayOptions = {
|
|
154
|
+
/** Stride in bytes between elements stored inline in the array. */
|
|
106
155
|
elementSize?: number | undefined;
|
|
156
|
+
/** Position of the argument carrying the element count, for a length-bounded array. */
|
|
107
157
|
sizeParamIndex?: number | undefined;
|
|
158
|
+
/** Element count of a fixed-length array. */
|
|
108
159
|
fixedSize?: number | undefined;
|
|
109
160
|
};
|
|
161
|
+
/** How a ref-counted fundamental value is named, wrapped and stored. */
|
|
110
162
|
type FundamentalOptions = {
|
|
163
|
+
/** Whether a decoded value is owned by the caller; defaults to `"borrowed"`. */
|
|
111
164
|
ownership?: Ownership;
|
|
165
|
+
/** GLib type name the wrapper class is looked up by. */
|
|
112
166
|
typeName?: string;
|
|
167
|
+
/** Class a decoded value is wrapped in, instead of the one registered for `typeName`. */
|
|
113
168
|
wrapperClass?: AnyClass;
|
|
114
|
-
|
|
169
|
+
/** The value is embedded in the containing struct rather than reached through a pointer. */
|
|
170
|
+
isInline?: boolean;
|
|
115
171
|
};
|
|
172
|
+
/** How a plain C struct is stored and wrapped. */
|
|
116
173
|
type StructOptions = {
|
|
117
|
-
|
|
118
|
-
|
|
174
|
+
/** The caller owns the storage the callee fills, so a decoded value is borrowed instead of copied. */
|
|
175
|
+
isCallerAllocated?: boolean;
|
|
176
|
+
/** The value is embedded in the containing struct rather than reached through a pointer. */
|
|
177
|
+
isInline?: boolean;
|
|
178
|
+
/** Byte size of the struct, needed to copy it rather than borrow the pointer. */
|
|
119
179
|
size?: number;
|
|
180
|
+
/** Class a decoded value is wrapped in, instead of the one registered for its GType. */
|
|
120
181
|
wrapperClass?: AnyClass;
|
|
121
182
|
};
|
|
183
|
+
/** Descriptor for a `gint8`, marshalled as a number. */
|
|
122
184
|
declare const int8T: Int8Descriptor;
|
|
185
|
+
/** Descriptor for a `guint8`, marshalled as a number. */
|
|
123
186
|
declare const uint8T: Uint8Descriptor;
|
|
187
|
+
/** Descriptor for a `gint16`, marshalled as a number. */
|
|
124
188
|
declare const int16T: Int16Descriptor;
|
|
189
|
+
/** Descriptor for a `guint16`, marshalled as a number. */
|
|
125
190
|
declare const uint16T: Uint16Descriptor;
|
|
191
|
+
/** Descriptor for a `gint32`, marshalled as a number. */
|
|
126
192
|
declare const int32T: Int32Descriptor;
|
|
193
|
+
/** Descriptor for a `guint32`, marshalled as a number. */
|
|
127
194
|
declare const uint32T: Uint32Descriptor;
|
|
195
|
+
/** Descriptor for a `gint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
128
196
|
declare const int64T: Int64Descriptor;
|
|
197
|
+
/** Descriptor for a `guint64`, marshalled as a number and rejected outside the 2^53 safe range. */
|
|
129
198
|
declare const uint64T: Uint64Descriptor;
|
|
199
|
+
/** Descriptor for a `gint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
130
200
|
declare const bigint64T: BigInt64Descriptor;
|
|
201
|
+
/** Descriptor for a `guint64`, marshalled as a bigint so the full 64-bit range survives. */
|
|
131
202
|
declare const biguint64T: BigUint64Descriptor;
|
|
203
|
+
/** Descriptor for a `GType`, marshalled as a bigint and recognized as a GType by GValue conversion. */
|
|
132
204
|
declare const gtypeT: TypeDescriptor;
|
|
205
|
+
/** Descriptor for a `gfloat`. */
|
|
133
206
|
declare const float32T: Float32Descriptor;
|
|
207
|
+
/** Descriptor for a `gdouble`. */
|
|
134
208
|
declare const float64T: Float64Descriptor;
|
|
209
|
+
/** Descriptor for a `gboolean`, marshalled as a JavaScript boolean. */
|
|
135
210
|
declare const booleanT: BooleanDescriptor;
|
|
211
|
+
/** Descriptor for the absence of a value, used as the return descriptor of a `void` function. */
|
|
136
212
|
declare const voidT: VoidDescriptor;
|
|
213
|
+
/** Descriptor for a `gunichar`, marshalled as a single-character string or a codepoint number. */
|
|
137
214
|
declare const unicharT: UnicharDescriptor;
|
|
215
|
+
/** Descriptor for an opaque `gpointer`, taken from a typed array's memory or a numeric address. */
|
|
138
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
|
+
*/
|
|
139
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. */
|
|
140
223
|
declare const objectT: (ownership?: Ownership) => ObjectDescriptor;
|
|
224
|
+
/** Wraps a descriptor in a pointer to it, for an output or inout argument. */
|
|
141
225
|
declare const refT: (innerDescriptor: Descriptor, isInout?: boolean) => RefDescriptor;
|
|
226
|
+
/** Builds a descriptor for a `GHashTable`, marshalled as an array of key/value pairs. */
|
|
142
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. */
|
|
143
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. */
|
|
144
231
|
declare const flagsT: (sharedLibrary: string, typeFnName: string, isSigned: boolean) => FlagsDescriptor;
|
|
232
|
+
/** Builds a descriptor for a `GBoxed` value of the named type. */
|
|
145
233
|
declare const boxedT: (typeName: string, options?: BoxedOptions) => BoxedDescriptor;
|
|
234
|
+
/** Builds a descriptor for a plain C struct. */
|
|
146
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. */
|
|
147
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. */
|
|
148
239
|
declare const arrayT: (itemDescriptor: Descriptor, arrayKind?: ArrayKind, ownership?: Ownership, options?: ArrayOptions) => ArrayDescriptor;
|
|
240
|
+
/** Builds a descriptor for a `GList` of items. */
|
|
149
241
|
declare const listT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
242
|
+
/** Builds a descriptor for a `GSList` of items. */
|
|
150
243
|
declare const slistT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
244
|
+
/** Builds a descriptor for a `GPtrArray` of items. */
|
|
151
245
|
declare const ptrArrayT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
|
|
246
|
+
/** Builds a descriptor for a `GArray` of items, optionally with an explicit element size. */
|
|
152
247
|
declare const gArrayT: (itemDescriptor: Descriptor, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
|
|
248
|
+
/** Builds a descriptor for a `GByteArray`. */
|
|
153
249
|
declare const byteArrayT: (ownership?: Ownership) => ArrayDescriptor;
|
|
250
|
+
/** Builds a descriptor for a C array whose length is carried by another argument. */
|
|
154
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. */
|
|
155
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. */
|
|
156
255
|
declare const callbackT: (argDescriptors: Descriptor[], returnDescriptor: Descriptor, options?: CallbackOptions) => CallbackDescriptor;
|
|
157
|
-
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, };
|
|
158
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,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AW,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,40 +1,66 @@
|
|
|
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,
|
|
36
62
|
getTypeFnName: typeFnName,
|
|
37
|
-
|
|
63
|
+
isSigned,
|
|
38
64
|
});
|
|
39
65
|
const applyBoxedNames = (result, options) => {
|
|
40
66
|
if (options.sharedLibrary !== undefined) {
|
|
@@ -49,16 +75,17 @@ const applyBoxedNames = (result, options) => {
|
|
|
49
75
|
};
|
|
50
76
|
const applyBoxedOptions = (result, options) => {
|
|
51
77
|
applyBoxedNames(result, options);
|
|
52
|
-
if (options.
|
|
53
|
-
result.
|
|
78
|
+
if (options.isCallerAllocated) {
|
|
79
|
+
result.isCallerAllocated = true;
|
|
54
80
|
}
|
|
55
|
-
if (options.
|
|
56
|
-
result.
|
|
81
|
+
if (options.isInline) {
|
|
82
|
+
result.isInline = true;
|
|
57
83
|
}
|
|
58
84
|
if (options.size !== undefined) {
|
|
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) {
|
|
@@ -76,14 +104,15 @@ const structT = (ownership = "borrowed", options = {}) => {
|
|
|
76
104
|
if (options.wrapperClass !== undefined) {
|
|
77
105
|
result.wrapperClass = options.wrapperClass;
|
|
78
106
|
}
|
|
79
|
-
if (options.
|
|
80
|
-
result.
|
|
107
|
+
if (options.isCallerAllocated) {
|
|
108
|
+
result.isCallerAllocated = true;
|
|
81
109
|
}
|
|
82
|
-
if (options.
|
|
83
|
-
result.
|
|
110
|
+
if (options.isInline) {
|
|
111
|
+
result.isInline = true;
|
|
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 };
|
|
@@ -93,11 +122,12 @@ const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
|
|
|
93
122
|
if (options.wrapperClass !== undefined) {
|
|
94
123
|
result.wrapperClass = options.wrapperClass;
|
|
95
124
|
}
|
|
96
|
-
if (options.
|
|
97
|
-
result.
|
|
125
|
+
if (options.isInline) {
|
|
126
|
+
result.isInline = true;
|
|
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
|
}
|