@gtkx/runtime 0.0.1 → 1.0.0-rc.1

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.
Files changed (113) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +171 -3
  3. package/dist/arg.d.ts +12 -0
  4. package/dist/arg.d.ts.map +1 -0
  5. package/dist/arg.js +5 -0
  6. package/dist/arg.js.map +1 -0
  7. package/dist/bind.d.ts +4 -0
  8. package/dist/bind.d.ts.map +1 -0
  9. package/dist/bind.js +17 -0
  10. package/dist/bind.js.map +1 -0
  11. package/dist/callback.d.ts +13 -0
  12. package/dist/callback.d.ts.map +1 -0
  13. package/dist/callback.js +68 -0
  14. package/dist/callback.js.map +1 -0
  15. package/dist/descriptors.d.ts +155 -0
  16. package/dist/descriptors.d.ts.map +1 -0
  17. package/dist/descriptors.js +103 -0
  18. package/dist/descriptors.js.map +1 -0
  19. package/dist/error.d.ts +25 -0
  20. package/dist/error.d.ts.map +1 -0
  21. package/dist/error.js +29 -0
  22. package/dist/error.js.map +1 -0
  23. package/dist/fn.d.ts +10 -0
  24. package/dist/fn.d.ts.map +1 -0
  25. package/dist/fn.js +79 -0
  26. package/dist/fn.js.map +1 -0
  27. package/dist/index.d.ts +15 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +15 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/internal.d.ts +5 -0
  32. package/dist/internal.d.ts.map +1 -0
  33. package/dist/internal.js +5 -0
  34. package/dist/internal.js.map +1 -0
  35. package/dist/library.d.ts +7 -0
  36. package/dist/library.d.ts.map +1 -0
  37. package/dist/library.js +13 -0
  38. package/dist/library.js.map +1 -0
  39. package/dist/lifecycle.d.ts +41 -0
  40. package/dist/lifecycle.d.ts.map +1 -0
  41. package/dist/lifecycle.js +55 -0
  42. package/dist/lifecycle.js.map +1 -0
  43. package/dist/listeners.d.ts +36 -0
  44. package/dist/listeners.d.ts.map +1 -0
  45. package/dist/listeners.js +72 -0
  46. package/dist/listeners.js.map +1 -0
  47. package/dist/mixin.d.ts +19 -0
  48. package/dist/mixin.d.ts.map +1 -0
  49. package/dist/mixin.js +39 -0
  50. package/dist/mixin.js.map +1 -0
  51. package/dist/native-value.d.ts +12 -0
  52. package/dist/native-value.d.ts.map +1 -0
  53. package/dist/native-value.js +72 -0
  54. package/dist/native-value.js.map +1 -0
  55. package/dist/object.d.ts +31 -0
  56. package/dist/object.d.ts.map +1 -0
  57. package/dist/object.js +63 -0
  58. package/dist/object.js.map +1 -0
  59. package/dist/promisify.d.ts +13 -0
  60. package/dist/promisify.d.ts.map +1 -0
  61. package/dist/promisify.js +36 -0
  62. package/dist/promisify.js.map +1 -0
  63. package/dist/register-class.d.ts +17 -0
  64. package/dist/register-class.d.ts.map +1 -0
  65. package/dist/register-class.js +124 -0
  66. package/dist/register-class.js.map +1 -0
  67. package/dist/registry.d.ts +67 -0
  68. package/dist/registry.d.ts.map +1 -0
  69. package/dist/registry.js +167 -0
  70. package/dist/registry.js.map +1 -0
  71. package/dist/signal.d.ts +34 -0
  72. package/dist/signal.d.ts.map +1 -0
  73. package/dist/signal.js +88 -0
  74. package/dist/signal.js.map +1 -0
  75. package/dist/t.d.ts +50 -0
  76. package/dist/t.d.ts.map +1 -0
  77. package/dist/t.js +48 -0
  78. package/dist/t.js.map +1 -0
  79. package/dist/tuple.d.ts +6 -0
  80. package/dist/tuple.d.ts.map +1 -0
  81. package/dist/tuple.js +23 -0
  82. package/dist/tuple.js.map +1 -0
  83. package/dist/type.d.ts +81 -0
  84. package/dist/type.d.ts.map +1 -0
  85. package/dist/type.js +174 -0
  86. package/dist/type.js.map +1 -0
  87. package/dist/value.d.ts +20 -0
  88. package/dist/value.d.ts.map +1 -0
  89. package/dist/value.js +227 -0
  90. package/dist/value.js.map +1 -0
  91. package/package.json +56 -13
  92. package/src/arg.ts +13 -0
  93. package/src/bind.ts +22 -0
  94. package/src/callback.ts +87 -0
  95. package/src/descriptors.ts +208 -0
  96. package/src/error.ts +49 -0
  97. package/src/fn.ts +108 -0
  98. package/src/index.ts +57 -0
  99. package/src/internal.ts +12 -0
  100. package/src/library.ts +15 -0
  101. package/src/lifecycle.ts +73 -0
  102. package/src/listeners.ts +84 -0
  103. package/src/mixin.ts +48 -0
  104. package/src/native-value.ts +78 -0
  105. package/src/object.ts +83 -0
  106. package/src/promisify.ts +40 -0
  107. package/src/register-class.ts +178 -0
  108. package/src/registry.ts +221 -0
  109. package/src/signal.ts +152 -0
  110. package/src/t.ts +88 -0
  111. package/src/tuple.ts +25 -0
  112. package/src/type.ts +200 -0
  113. package/src/value.ts +307 -0
@@ -0,0 +1,68 @@
1
+ import { copy } from "@gtkx/native";
2
+ import { fromNative, toNative } from "./native-value.js";
3
+ import { getHandle } from "./registry.js";
4
+ import { splitTupleResult } from "./tuple.js";
5
+ import { copyValue } from "./value.js";
6
+ const fillCallerAllocatedBuffer = (descriptor, target, source) => {
7
+ if (descriptor.kind === "boxed" && descriptor.typeName === "GValue") {
8
+ copyValue(getHandle(target), getHandle(source));
9
+ return;
10
+ }
11
+ if ((descriptor.kind === "boxed" || descriptor.kind === "struct") && descriptor.size !== undefined) {
12
+ copy(getHandle(target), getHandle(source), descriptor.size);
13
+ return;
14
+ }
15
+ throw new Error(`Cannot write caller-allocated ${descriptor.kind} out-parameter: no known byte size`);
16
+ };
17
+ const partitionCallbackArgs = (effectiveTypes, wrapped, start) => {
18
+ const inputs = [];
19
+ const outParams = [];
20
+ for (let i = start; i < effectiveTypes.length; i++) {
21
+ const descriptor = effectiveTypes[i];
22
+ if (descriptor !== undefined && descriptor.kind === "ref") {
23
+ if (descriptor.inout === true)
24
+ inputs.push(wrapped[i].value);
25
+ outParams.push({ value: wrapped[i], descriptor });
26
+ }
27
+ else if (descriptor !== undefined &&
28
+ (descriptor.kind === "boxed" || descriptor.kind === "struct") &&
29
+ descriptor.callerAllocated === true) {
30
+ inputs.push(wrapped[i]);
31
+ outParams.push({ value: wrapped[i], descriptor });
32
+ }
33
+ else {
34
+ inputs.push(wrapped[i]);
35
+ }
36
+ }
37
+ return { inputs, outParams };
38
+ };
39
+ const writeOutParams = (outParams, outValues) => {
40
+ outParams.forEach((outParam, position) => {
41
+ const outValue = outValues[position];
42
+ if (outParam.descriptor.kind === "ref") {
43
+ outParam.value.value = outValue;
44
+ }
45
+ else if (outValue != null && outParam.value != null) {
46
+ fillCallerAllocatedBuffer(outParam.descriptor, outParam.value, outValue);
47
+ }
48
+ });
49
+ };
50
+ export const wrapCallbackValue = (spec, callback) => callback == null ? callback : wrapCallback(callback, spec, "none");
51
+ export function wrapCallback(fn, spec, receiver) {
52
+ const { returnDescriptor, userDataIndex } = spec;
53
+ const effectiveTypes = userDataIndex === undefined ? spec.argDescriptors : spec.argDescriptors.filter((_, i) => i !== userDataIndex);
54
+ const start = receiver === "none" ? 0 : 1;
55
+ return (...rawArgs) => {
56
+ const wrapped = effectiveTypes.map((descriptor, i) => fromNative(descriptor, rawArgs[i]));
57
+ const thisArg = receiver === "this" ? (wrapped[0] ?? null) : null;
58
+ const { inputs, outParams } = partitionCallbackArgs(effectiveTypes, wrapped, start);
59
+ const result = fn.apply(thisArg, inputs);
60
+ if (outParams.length === 0) {
61
+ return toNative(returnDescriptor, result);
62
+ }
63
+ const { primary, outValues } = splitTupleResult(result, returnDescriptor.kind !== "void", outParams.length);
64
+ writeOutParams(outParams, outValues);
65
+ return toNative(returnDescriptor, primary);
66
+ };
67
+ }
68
+ //# sourceMappingURL=callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback.js","sourceRoot":"","sources":["../src/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,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gBAAgB,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,KAAK,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAC5G,cAAc,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC;AACN,CAAC","sourcesContent":["import { copy, type Descriptor } from \"@gtkx/native\";\nimport type { CallbackDescriptor } from \"./descriptors.js\";\nimport { fromNative, toNative } from \"./native-value.js\";\nimport { getHandle } from \"./registry.js\";\nimport { splitTupleResult } from \"./tuple.js\";\nimport { copyValue } from \"./value.js\";\n\ntype Callback = (...args: unknown[]) => unknown;\ntype CallbackReceiver = \"this\" | \"emitter\" | \"none\";\ntype OutParam = { value: unknown; descriptor: Descriptor };\n\ntype CallbackSpec = {\n argDescriptors: Descriptor[];\n returnDescriptor: Descriptor;\n userDataIndex?: number;\n};\n\nconst fillCallerAllocatedBuffer = (descriptor: Descriptor, target: object, source: object): void => {\n if (descriptor.kind === \"boxed\" && descriptor.typeName === \"GValue\") {\n copyValue(getHandle(target), getHandle(source));\n return;\n }\n if ((descriptor.kind === \"boxed\" || descriptor.kind === \"struct\") && descriptor.size !== undefined) {\n copy(getHandle(target), getHandle(source), descriptor.size);\n return;\n }\n throw new Error(`Cannot write caller-allocated ${descriptor.kind} out-parameter: no known byte size`);\n};\n\nconst partitionCallbackArgs = (\n effectiveTypes: Descriptor[],\n wrapped: unknown[],\n start: number,\n): { inputs: unknown[]; outParams: OutParam[] } => {\n const inputs: unknown[] = [];\n const outParams: OutParam[] = [];\n for (let i = start; i < effectiveTypes.length; i++) {\n const descriptor = effectiveTypes[i];\n if (descriptor !== undefined && descriptor.kind === \"ref\") {\n if (descriptor.inout === true) inputs.push((wrapped[i] as { value: unknown }).value);\n outParams.push({ value: wrapped[i], descriptor });\n } else if (\n descriptor !== undefined &&\n (descriptor.kind === \"boxed\" || descriptor.kind === \"struct\") &&\n descriptor.callerAllocated === true\n ) {\n inputs.push(wrapped[i]);\n outParams.push({ value: wrapped[i], descriptor });\n } else {\n inputs.push(wrapped[i]);\n }\n }\n return { inputs, outParams };\n};\n\nconst writeOutParams = (outParams: OutParam[], outValues: unknown[]): void => {\n outParams.forEach((outParam, position) => {\n const outValue = outValues[position];\n if (outParam.descriptor.kind === \"ref\") {\n (outParam.value as { value: unknown }).value = outValue;\n } else if (outValue != null && outParam.value != null) {\n fillCallerAllocatedBuffer(outParam.descriptor, outParam.value as object, outValue as object);\n }\n });\n};\n\nexport const wrapCallbackValue = (spec: CallbackDescriptor, callback: unknown): unknown =>\n callback == null ? callback : wrapCallback(callback as Callback, spec, \"none\");\n\nexport function wrapCallback(fn: Callback, spec: CallbackSpec, receiver: CallbackReceiver): Callback {\n const { returnDescriptor, userDataIndex } = spec;\n const effectiveTypes =\n userDataIndex === undefined ? spec.argDescriptors : spec.argDescriptors.filter((_, i) => i !== userDataIndex);\n const start = receiver === \"none\" ? 0 : 1;\n return (...rawArgs: unknown[]): unknown => {\n const wrapped = effectiveTypes.map((descriptor, i) => fromNative(descriptor, rawArgs[i]));\n const thisArg = receiver === \"this\" ? (wrapped[0] ?? null) : null;\n const { inputs, outParams } = partitionCallbackArgs(effectiveTypes, wrapped, start);\n const result = (fn as (this: unknown, ...args: unknown[]) => unknown).apply(thisArg, inputs);\n if (outParams.length === 0) {\n return toNative(returnDescriptor, result);\n }\n const { primary, outValues } = splitTupleResult(result, returnDescriptor.kind !== \"void\", outParams.length);\n writeOutParams(outParams, outValues);\n return toNative(returnDescriptor, primary);\n };\n}\n"]}
@@ -0,0 +1,155 @@
1
+ import type { ArrayKind, Descriptor, Ownership } from "@gtkx/native";
2
+ import type { AnyClass } from "@gtkx/utils";
3
+ export type Int8Descriptor = Extract<Descriptor, {
4
+ kind: "int8";
5
+ }>;
6
+ export type Uint8Descriptor = Extract<Descriptor, {
7
+ kind: "uint8";
8
+ }>;
9
+ export type Int16Descriptor = Extract<Descriptor, {
10
+ kind: "int16";
11
+ }>;
12
+ export type Uint16Descriptor = Extract<Descriptor, {
13
+ kind: "uint16";
14
+ }>;
15
+ export type Int32Descriptor = Extract<Descriptor, {
16
+ kind: "int32";
17
+ }>;
18
+ export type Uint32Descriptor = Extract<Descriptor, {
19
+ kind: "uint32";
20
+ }>;
21
+ export type Int64Descriptor = Extract<Descriptor, {
22
+ kind: "int64";
23
+ }>;
24
+ export type Uint64Descriptor = Extract<Descriptor, {
25
+ kind: "uint64";
26
+ }>;
27
+ export type BigInt64Descriptor = Extract<Descriptor, {
28
+ kind: "bigint64";
29
+ }>;
30
+ export type BigUint64Descriptor = Extract<Descriptor, {
31
+ kind: "biguint64";
32
+ }>;
33
+ export type Float32Descriptor = Extract<Descriptor, {
34
+ kind: "float32";
35
+ }>;
36
+ export type Float64Descriptor = Extract<Descriptor, {
37
+ kind: "float64";
38
+ }>;
39
+ export type EnumDescriptor = Extract<Descriptor, {
40
+ kind: "enum";
41
+ }>;
42
+ export type FlagsDescriptor = Extract<Descriptor, {
43
+ kind: "flags";
44
+ }>;
45
+ export type BooleanDescriptor = Extract<Descriptor, {
46
+ kind: "boolean";
47
+ }>;
48
+ export type StringDescriptor = Extract<Descriptor, {
49
+ kind: "string";
50
+ }>;
51
+ export type ObjectDescriptor = Extract<Descriptor, {
52
+ kind: "object";
53
+ }>;
54
+ export type UnicharDescriptor = Extract<Descriptor, {
55
+ kind: "unichar";
56
+ }>;
57
+ export type VoidDescriptor = Extract<Descriptor, {
58
+ kind: "void";
59
+ }>;
60
+ export type BufferDescriptor = Extract<Descriptor, {
61
+ kind: "buffer";
62
+ }>;
63
+ export type BoxedDescriptor = Extract<Descriptor, {
64
+ kind: "boxed";
65
+ }>;
66
+ export type StructDescriptor = Extract<Descriptor, {
67
+ kind: "struct";
68
+ }> & {
69
+ wrapperClass?: AnyClass;
70
+ };
71
+ export type FundamentalDescriptor = Extract<Descriptor, {
72
+ kind: "fundamental";
73
+ }> & {
74
+ wrapperClass?: AnyClass;
75
+ };
76
+ export type ArrayDescriptor = Extract<Descriptor, {
77
+ kind: "array";
78
+ }>;
79
+ export type HashTableDescriptor = Extract<Descriptor, {
80
+ kind: "hashtable";
81
+ }>;
82
+ export type CallbackDescriptor = Extract<Descriptor, {
83
+ kind: "callback";
84
+ }>;
85
+ export type RefDescriptor = Extract<Descriptor, {
86
+ kind: "ref";
87
+ }>;
88
+ export type TypeDescriptor = BigUint64Descriptor & {
89
+ type: true;
90
+ };
91
+ type BoxedOptions = {
92
+ callerAllocated?: boolean;
93
+ ownership?: Ownership;
94
+ sharedLibrary?: string;
95
+ getTypeFnName?: string;
96
+ freeFnName?: string;
97
+ size?: number;
98
+ };
99
+ type CallbackOptions = {
100
+ hasDestroy?: boolean;
101
+ userDataIndex?: number;
102
+ scope?: CallbackDescriptor["scope"];
103
+ };
104
+ type ArrayOptions = {
105
+ elementSize?: number | undefined;
106
+ sizeParamIndex?: number | undefined;
107
+ fixedSize?: number | undefined;
108
+ };
109
+ type FundamentalOptions = {
110
+ ownership?: Ownership;
111
+ typeName?: string;
112
+ wrapperClass?: AnyClass;
113
+ };
114
+ type StructOptions = {
115
+ callerAllocated?: boolean;
116
+ size?: number;
117
+ wrapperClass?: AnyClass;
118
+ };
119
+ export declare const int8T: Int8Descriptor;
120
+ export declare const uint8T: Uint8Descriptor;
121
+ export declare const int16T: Int16Descriptor;
122
+ export declare const uint16T: Uint16Descriptor;
123
+ export declare const int32T: Int32Descriptor;
124
+ export declare const uint32T: Uint32Descriptor;
125
+ export declare const int64T: Int64Descriptor;
126
+ export declare const uint64T: Uint64Descriptor;
127
+ export declare const bigint64T: BigInt64Descriptor;
128
+ export declare const biguint64T: BigUint64Descriptor;
129
+ export declare const gtypeT: TypeDescriptor;
130
+ export declare const float32T: Float32Descriptor;
131
+ export declare const float64T: Float64Descriptor;
132
+ export declare const booleanT: BooleanDescriptor;
133
+ export declare const voidT: VoidDescriptor;
134
+ export declare const unicharT: UnicharDescriptor;
135
+ export declare const bufferT: BufferDescriptor;
136
+ export declare const stringT: (ownership?: Ownership, length?: number) => StringDescriptor;
137
+ export declare const objectT: (ownership?: Ownership) => ObjectDescriptor;
138
+ export declare const refT: (innerDescriptor: Descriptor, inout?: boolean) => RefDescriptor;
139
+ export declare const hashTableT: (keyDescriptor: Descriptor, valueDescriptor: Descriptor, ownership?: Ownership) => HashTableDescriptor;
140
+ export declare const enumT: (sharedLibrary: string, getTypeFnName: string, signed: boolean) => EnumDescriptor;
141
+ export declare const flagsT: (sharedLibrary: string, getTypeFnName: string, signed: boolean) => FlagsDescriptor;
142
+ export declare const boxedT: (typeName: string, options?: BoxedOptions) => BoxedDescriptor;
143
+ export declare const structT: (ownership?: Ownership, options?: StructOptions) => StructDescriptor;
144
+ export declare const fundamentalT: (sharedLibrary: string, refFnName: string, unrefFnName: string, options?: FundamentalOptions) => FundamentalDescriptor;
145
+ export declare const arrayT: (itemDescriptor: Descriptor, arrayKind?: ArrayKind, ownership?: Ownership, options?: ArrayOptions) => ArrayDescriptor;
146
+ export declare const listT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
147
+ export declare const slistT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
148
+ export declare const ptrArrayT: (itemDescriptor: Descriptor, ownership?: Ownership) => ArrayDescriptor;
149
+ export declare const gArrayT: (itemDescriptor: Descriptor, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
150
+ export declare const byteArrayT: (ownership?: Ownership) => ArrayDescriptor;
151
+ export declare const sizedArrayT: (itemDescriptor: Descriptor, sizeParamIndex: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
152
+ export declare const fixedArrayT: (itemDescriptor: Descriptor, fixedSize: number, ownership?: Ownership, elementSize?: number) => ArrayDescriptor;
153
+ export declare const callbackT: (argDescriptors: Descriptor[], returnDescriptor: Descriptor, options?: CallbackOptions) => CallbackDescriptor;
154
+ export {};
155
+ //# sourceMappingURL=descriptors.d.ts.map
@@ -0,0 +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AE7F,eAAO,MAAM,SAAS,mBACF,UAAU,EAAE,oBACV,UAAU,YAClB,eAAe,KAC1B,kBAMF,CAAC"}
@@ -0,0 +1,103 @@
1
+ export const int8T = { kind: "int8" };
2
+ export const uint8T = { kind: "uint8" };
3
+ export const int16T = { kind: "int16" };
4
+ export const uint16T = { kind: "uint16" };
5
+ export const int32T = { kind: "int32" };
6
+ export const uint32T = { kind: "uint32" };
7
+ export const int64T = { kind: "int64" };
8
+ export const uint64T = { kind: "uint64" };
9
+ export const bigint64T = { kind: "bigint64" };
10
+ export const biguint64T = { kind: "biguint64" };
11
+ export const gtypeT = { kind: "biguint64", type: true };
12
+ export const float32T = { kind: "float32" };
13
+ export const float64T = { kind: "float64" };
14
+ export const booleanT = { kind: "boolean" };
15
+ export const voidT = { kind: "void" };
16
+ export const unicharT = { kind: "unichar" };
17
+ export const bufferT = { kind: "buffer" };
18
+ export const stringT = (ownership = "borrowed", length) => length === undefined ? { kind: "string", ownership } : { kind: "string", ownership, length };
19
+ export const objectT = (ownership = "borrowed") => ({ kind: "object", ownership });
20
+ export const refT = (innerDescriptor, inout = false) => inout ? { kind: "ref", innerDescriptor, inout: true } : { kind: "ref", innerDescriptor };
21
+ export const hashTableT = (keyDescriptor, valueDescriptor, ownership = "borrowed") => ({
22
+ kind: "hashtable",
23
+ keyDescriptor,
24
+ valueDescriptor,
25
+ ownership,
26
+ });
27
+ export const enumT = (sharedLibrary, getTypeFnName, signed) => ({
28
+ kind: "enum",
29
+ sharedLibrary,
30
+ getTypeFnName,
31
+ signed,
32
+ });
33
+ export const flagsT = (sharedLibrary, getTypeFnName, signed) => ({
34
+ kind: "flags",
35
+ sharedLibrary,
36
+ getTypeFnName,
37
+ signed,
38
+ });
39
+ export const boxedT = (typeName, options = {}) => {
40
+ const result = {
41
+ kind: "boxed",
42
+ ownership: options.ownership ?? "borrowed",
43
+ typeName,
44
+ };
45
+ if (options.sharedLibrary !== undefined)
46
+ result.sharedLibrary = options.sharedLibrary;
47
+ if (options.getTypeFnName !== undefined)
48
+ result.getTypeFnName = options.getTypeFnName;
49
+ if (options.freeFnName !== undefined)
50
+ result.freeFnName = options.freeFnName;
51
+ if (options.callerAllocated)
52
+ result.callerAllocated = true;
53
+ if (options.size !== undefined)
54
+ result.size = options.size;
55
+ return result;
56
+ };
57
+ export const structT = (ownership = "borrowed", options = {}) => {
58
+ const result = { kind: "struct", ownership };
59
+ if (options.size !== undefined)
60
+ result.size = options.size;
61
+ if (options.wrapperClass !== undefined)
62
+ result.wrapperClass = options.wrapperClass;
63
+ if (options.callerAllocated)
64
+ result.callerAllocated = true;
65
+ return result;
66
+ };
67
+ export const fundamentalT = (sharedLibrary, refFnName, unrefFnName, options = {}) => {
68
+ const ownership = options.ownership ?? "borrowed";
69
+ const result = { kind: "fundamental", ownership, sharedLibrary, refFnName, unrefFnName };
70
+ if (options.typeName !== undefined)
71
+ result.typeName = options.typeName;
72
+ if (options.wrapperClass !== undefined)
73
+ result.wrapperClass = options.wrapperClass;
74
+ return result;
75
+ };
76
+ export const arrayT = (itemDescriptor, arrayKind = "array", ownership = "borrowed", options) => {
77
+ const result = { kind: "array", itemDescriptor, arrayKind, ownership };
78
+ if (options?.elementSize !== undefined)
79
+ result.elementSize = options.elementSize;
80
+ if (options?.sizeParamIndex !== undefined)
81
+ result.sizeParamIndex = options.sizeParamIndex;
82
+ if (options?.fixedSize !== undefined)
83
+ result.fixedSize = options.fixedSize;
84
+ return result;
85
+ };
86
+ export const listT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "glist", ownership);
87
+ export const slistT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gslist", ownership);
88
+ export const ptrArrayT = (itemDescriptor, ownership = "borrowed") => arrayT(itemDescriptor, "gptrarray", ownership);
89
+ export const gArrayT = (itemDescriptor, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "garray", ownership, elementSize === undefined ? undefined : { elementSize });
90
+ export const byteArrayT = (ownership = "borrowed") => arrayT(uint8T, "gbytearray", ownership);
91
+ export const sizedArrayT = (itemDescriptor, sizeParamIndex, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "sized", ownership, { sizeParamIndex, elementSize });
92
+ export const fixedArrayT = (itemDescriptor, fixedSize, ownership = "borrowed", elementSize) => arrayT(itemDescriptor, "fixed", ownership, { fixedSize, elementSize });
93
+ export const callbackT = (argDescriptors, returnDescriptor, options) => {
94
+ const result = { kind: "callback", argDescriptors, returnDescriptor };
95
+ if (options?.hasDestroy !== undefined)
96
+ result.hasDestroy = options.hasDestroy;
97
+ if (options?.userDataIndex !== undefined)
98
+ result.userDataIndex = options.userDataIndex;
99
+ if (options?.scope !== undefined)
100
+ result.scope = options.scope;
101
+ return result;
102
+ };
103
+ //# sourceMappingURL=descriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../src/descriptors.ts"],"names":[],"mappings":"AAiEA,MAAM,CAAC,MAAM,KAAK,GAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACtD,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,OAAO,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAuB,EAAE,IAAI,EAAE,UAAU,EAA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AAM,WAAW,GAAG,CACvB,cAA0B,EAC1B,cAAsB,EACtB,SAAS,GAAc,UAAU,EACjC,WAAoB,EACL,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,cAA0B,EAC1B,SAAiB,EACjB,SAAS,GAAc,UAAU,EACjC,WAAoB,EACL,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;AAE7F,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,cAA4B,EAC5B,gBAA4B,EAC5B,OAAyB,EACP,EAAE;IACpB,MAAM,MAAM,GAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAC1F,IAAI,OAAO,EAAE,UAAU,KAAK,SAAS;QAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAC9E,IAAI,OAAO,EAAE,aAAa,KAAK,SAAS;QAAE,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IACvF,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC/D,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import type { ArrayKind, Descriptor, Ownership } from \"@gtkx/native\";\nimport type { AnyClass } from \"@gtkx/utils\";\n\nexport type Int8Descriptor = Extract<Descriptor, { kind: \"int8\" }>;\nexport type Uint8Descriptor = Extract<Descriptor, { kind: \"uint8\" }>;\nexport type Int16Descriptor = Extract<Descriptor, { kind: \"int16\" }>;\nexport type Uint16Descriptor = Extract<Descriptor, { kind: \"uint16\" }>;\nexport type Int32Descriptor = Extract<Descriptor, { kind: \"int32\" }>;\nexport type Uint32Descriptor = Extract<Descriptor, { kind: \"uint32\" }>;\nexport type Int64Descriptor = Extract<Descriptor, { kind: \"int64\" }>;\nexport type Uint64Descriptor = Extract<Descriptor, { kind: \"uint64\" }>;\nexport type BigInt64Descriptor = Extract<Descriptor, { kind: \"bigint64\" }>;\nexport type BigUint64Descriptor = Extract<Descriptor, { kind: \"biguint64\" }>;\nexport type Float32Descriptor = Extract<Descriptor, { kind: \"float32\" }>;\nexport type Float64Descriptor = Extract<Descriptor, { kind: \"float64\" }>;\nexport type EnumDescriptor = Extract<Descriptor, { kind: \"enum\" }>;\nexport type FlagsDescriptor = Extract<Descriptor, { kind: \"flags\" }>;\nexport type BooleanDescriptor = Extract<Descriptor, { kind: \"boolean\" }>;\nexport type StringDescriptor = Extract<Descriptor, { kind: \"string\" }>;\nexport type ObjectDescriptor = Extract<Descriptor, { kind: \"object\" }>;\nexport type UnicharDescriptor = Extract<Descriptor, { kind: \"unichar\" }>;\nexport type VoidDescriptor = Extract<Descriptor, { kind: \"void\" }>;\nexport type BufferDescriptor = Extract<Descriptor, { kind: \"buffer\" }>;\nexport type BoxedDescriptor = Extract<Descriptor, { kind: \"boxed\" }>;\nexport type StructDescriptor = Extract<Descriptor, { kind: \"struct\" }> & { wrapperClass?: AnyClass };\nexport type FundamentalDescriptor = Extract<Descriptor, { kind: \"fundamental\" }> & { wrapperClass?: AnyClass };\nexport type ArrayDescriptor = Extract<Descriptor, { kind: \"array\" }>;\nexport type HashTableDescriptor = Extract<Descriptor, { kind: \"hashtable\" }>;\nexport type CallbackDescriptor = Extract<Descriptor, { kind: \"callback\" }>;\nexport type RefDescriptor = Extract<Descriptor, { kind: \"ref\" }>;\nexport type TypeDescriptor = BigUint64Descriptor & { type: true };\n\ntype BoxedOptions = {\n callerAllocated?: boolean;\n ownership?: Ownership;\n sharedLibrary?: string;\n getTypeFnName?: string;\n freeFnName?: string;\n size?: number;\n};\n\ntype CallbackOptions = {\n hasDestroy?: boolean;\n userDataIndex?: number;\n scope?: CallbackDescriptor[\"scope\"];\n};\n\ntype ArrayOptions = {\n elementSize?: number | undefined;\n sizeParamIndex?: number | undefined;\n fixedSize?: number | undefined;\n};\n\ntype FundamentalOptions = {\n ownership?: Ownership;\n typeName?: string;\n wrapperClass?: AnyClass;\n};\n\ntype StructOptions = {\n callerAllocated?: boolean;\n size?: number;\n wrapperClass?: AnyClass;\n};\n\nexport const int8T: Int8Descriptor = { kind: \"int8\" };\nexport const uint8T: Uint8Descriptor = { kind: \"uint8\" };\nexport const int16T: Int16Descriptor = { kind: \"int16\" };\nexport const uint16T: Uint16Descriptor = { kind: \"uint16\" };\nexport const int32T: Int32Descriptor = { kind: \"int32\" };\nexport const uint32T: Uint32Descriptor = { kind: \"uint32\" };\nexport const int64T: Int64Descriptor = { kind: \"int64\" };\nexport const uint64T: Uint64Descriptor = { kind: \"uint64\" };\nexport const bigint64T: BigInt64Descriptor = { kind: \"bigint64\" };\nexport const biguint64T: BigUint64Descriptor = { kind: \"biguint64\" };\nexport const gtypeT: TypeDescriptor = { kind: \"biguint64\", type: true };\nexport const float32T: Float32Descriptor = { kind: \"float32\" };\nexport const float64T: Float64Descriptor = { kind: \"float64\" };\nexport const booleanT: BooleanDescriptor = { kind: \"boolean\" };\nexport const voidT: VoidDescriptor = { kind: \"void\" };\nexport const unicharT: UnicharDescriptor = { kind: \"unichar\" };\nexport const bufferT: BufferDescriptor = { kind: \"buffer\" };\n\nexport const stringT = (ownership: Ownership = \"borrowed\", length?: number): StringDescriptor =>\n length === undefined ? { kind: \"string\", ownership } : { kind: \"string\", ownership, length };\n\nexport const objectT = (ownership: Ownership = \"borrowed\"): ObjectDescriptor => ({ kind: \"object\", ownership });\n\nexport const refT = (innerDescriptor: Descriptor, inout = false): RefDescriptor =>\n inout ? { kind: \"ref\", innerDescriptor, inout: true } : { kind: \"ref\", innerDescriptor };\n\nexport const hashTableT = (\n keyDescriptor: Descriptor,\n valueDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n): HashTableDescriptor => ({\n kind: \"hashtable\",\n keyDescriptor,\n valueDescriptor,\n ownership,\n});\n\nexport const enumT = (sharedLibrary: string, getTypeFnName: string, signed: boolean): EnumDescriptor => ({\n kind: \"enum\",\n sharedLibrary,\n getTypeFnName,\n signed,\n});\n\nexport const flagsT = (sharedLibrary: string, getTypeFnName: string, signed: boolean): FlagsDescriptor => ({\n kind: \"flags\",\n sharedLibrary,\n getTypeFnName,\n signed,\n});\n\nexport const boxedT = (typeName: string, options: BoxedOptions = {}): BoxedDescriptor => {\n const result: BoxedDescriptor = {\n kind: \"boxed\",\n ownership: options.ownership ?? \"borrowed\",\n typeName,\n };\n if (options.sharedLibrary !== undefined) result.sharedLibrary = options.sharedLibrary;\n if (options.getTypeFnName !== undefined) result.getTypeFnName = options.getTypeFnName;\n if (options.freeFnName !== undefined) result.freeFnName = options.freeFnName;\n if (options.callerAllocated) result.callerAllocated = true;\n if (options.size !== undefined) result.size = options.size;\n return result;\n};\n\nexport const structT = (ownership: Ownership = \"borrowed\", options: StructOptions = {}): StructDescriptor => {\n const result: StructDescriptor = { kind: \"struct\", ownership };\n if (options.size !== undefined) result.size = options.size;\n if (options.wrapperClass !== undefined) result.wrapperClass = options.wrapperClass;\n if (options.callerAllocated) result.callerAllocated = true;\n return result;\n};\n\nexport const fundamentalT = (\n sharedLibrary: string,\n refFnName: string,\n unrefFnName: string,\n options: FundamentalOptions = {},\n): FundamentalDescriptor => {\n const ownership = options.ownership ?? \"borrowed\";\n const result: FundamentalDescriptor = { kind: \"fundamental\", ownership, sharedLibrary, refFnName, unrefFnName };\n if (options.typeName !== undefined) result.typeName = options.typeName;\n if (options.wrapperClass !== undefined) result.wrapperClass = options.wrapperClass;\n return result;\n};\n\nexport const arrayT = (\n itemDescriptor: Descriptor,\n arrayKind: ArrayKind = \"array\",\n ownership: Ownership = \"borrowed\",\n options?: ArrayOptions,\n): ArrayDescriptor => {\n const result: ArrayDescriptor = { kind: \"array\", itemDescriptor, arrayKind, ownership };\n if (options?.elementSize !== undefined) result.elementSize = options.elementSize;\n if (options?.sizeParamIndex !== undefined) result.sizeParamIndex = options.sizeParamIndex;\n if (options?.fixedSize !== undefined) result.fixedSize = options.fixedSize;\n return result;\n};\n\nexport const listT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"glist\", ownership);\n\nexport const slistT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gslist\", ownership);\n\nexport const ptrArrayT = (itemDescriptor: Descriptor, ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(itemDescriptor, \"gptrarray\", ownership);\n\nexport const gArrayT = (\n itemDescriptor: Descriptor,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor =>\n arrayT(itemDescriptor, \"garray\", ownership, elementSize === undefined ? undefined : { elementSize });\n\nexport const byteArrayT = (ownership: Ownership = \"borrowed\"): ArrayDescriptor =>\n arrayT(uint8T, \"gbytearray\", ownership);\n\nexport const sizedArrayT = (\n itemDescriptor: Descriptor,\n sizeParamIndex: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"sized\", ownership, { sizeParamIndex, elementSize });\n\nexport const fixedArrayT = (\n itemDescriptor: Descriptor,\n fixedSize: number,\n ownership: Ownership = \"borrowed\",\n elementSize?: number,\n): ArrayDescriptor => arrayT(itemDescriptor, \"fixed\", ownership, { fixedSize, elementSize });\n\nexport const callbackT = (\n argDescriptors: Descriptor[],\n returnDescriptor: Descriptor,\n options?: CallbackOptions,\n): CallbackDescriptor => {\n const result: CallbackDescriptor = { kind: \"callback\", argDescriptors, returnDescriptor };\n if (options?.hasDestroy !== undefined) result.hasDestroy = options.hasDestroy;\n if (options?.userDataIndex !== undefined) result.userDataIndex = options.userDataIndex;\n if (options?.scope !== undefined) result.scope = options.scope;\n return result;\n};\n"]}
@@ -0,0 +1,25 @@
1
+ import type { Ref } from "@gtkx/native";
2
+ type ErrorLike = {
3
+ domain: number;
4
+ code: number;
5
+ message: string;
6
+ };
7
+ /**
8
+ * An error enum object carrying its member codes plus an `instanceof` check that
9
+ * matches wrapped GLib errors belonging to a specific error domain.
10
+ */
11
+ export type ErrorDomain<T extends Record<string, number>> = T & {
12
+ [Symbol.hasInstance]: (value: unknown) => value is ErrorLike;
13
+ };
14
+ export declare function checkError(error: Ref): void;
15
+ /**
16
+ * Builds an error domain enum object from its members and a lazy resolver for the
17
+ * domain quark, giving it an `instanceof` check that matches wrapped GLib errors of
18
+ * that domain.
19
+ *
20
+ * @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.
21
+ * @param members The error code enum members to expose on the returned object.
22
+ */
23
+ export declare function createErrorDomain<const T extends Record<string, number>>(resolveDomain: () => number, members: T): ErrorDomain<T>;
24
+ export {};
25
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,GAAG,EAAE,MAAM,cAAc,CAAC;AAIhE,KAAK,SAAS,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IAC5D,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,SAAS,CAAC;CAChE,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAM3C;AAID;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpE,aAAa,EAAE,MAAM,MAAM,EAC3B,OAAO,EAAE,CAAC,GACX,WAAW,CAAC,CAAC,CAAC,CAShB"}
package/dist/error.js ADDED
@@ -0,0 +1,29 @@
1
+ import { getWrapperClass, wrapHandle } from "./registry.js";
2
+ import { getErrorType, isTypedClass } from "./type.js";
3
+ export function checkError(error) {
4
+ if (error.value !== null) {
5
+ const gerror = wrapHandle(error.value, getWrapperClass(getErrorType()));
6
+ Error.captureStackTrace(gerror, checkError);
7
+ throw gerror;
8
+ }
9
+ }
10
+ const isError = (value) => isTypedClass(value) && value.__type__ === getErrorType();
11
+ /**
12
+ * Builds an error domain enum object from its members and a lazy resolver for the
13
+ * domain quark, giving it an `instanceof` check that matches wrapped GLib errors of
14
+ * that domain.
15
+ *
16
+ * @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.
17
+ * @param members The error code enum members to expose on the returned object.
18
+ */
19
+ export function createErrorDomain(resolveDomain, members) {
20
+ let domain;
21
+ const hasInstance = (value) => {
22
+ domain ??= resolveDomain();
23
+ return isError(value) && value.domain === domain;
24
+ };
25
+ const enumObject = { ...members };
26
+ Object.defineProperty(enumObject, Symbol.hasInstance, { value: hasInstance });
27
+ return enumObject;
28
+ }
29
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAgBvD,MAAM,UAAU,UAAU,CAAC,KAAU;IACjC,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,UAAU,CAAY,KAAK,CAAC,KAA+B,EAAE,eAAe,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAC7G,KAAK,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC5C,MAAM,MAAM,CAAC;IACjB,CAAC;AACL,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,KAAc,EAAsB,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;AAEjH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC7B,aAA2B,EAC3B,OAAU;IAEV,IAAI,MAA0B,CAAC;IAC/B,MAAM,WAAW,GAAG,CAAC,KAAc,EAAsB,EAAE;QACvD,MAAM,KAAK,aAAa,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;IACrD,CAAC,CAAC;IACF,MAAM,UAAU,GAA4B,EAAE,GAAG,OAAO,EAAE,CAAC;IAC3D,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;IAC9E,OAAO,UAA4B,CAAC;AACxC,CAAC","sourcesContent":["import type { ExternalObject, Handle, Ref } from \"@gtkx/native\";\nimport { getWrapperClass, wrapHandle } from \"./registry.js\";\nimport { getErrorType, isTypedClass } from \"./type.js\";\n\ntype ErrorLike = {\n domain: number;\n code: number;\n message: string;\n};\n\n/**\n * An error enum object carrying its member codes plus an `instanceof` check that\n * matches wrapped GLib errors belonging to a specific error domain.\n */\nexport type ErrorDomain<T extends Record<string, number>> = T & {\n [Symbol.hasInstance]: (value: unknown) => value is ErrorLike;\n};\n\nexport function checkError(error: Ref): void {\n if (error.value !== null) {\n const gerror = wrapHandle<ErrorLike>(error.value as ExternalObject<Handle>, getWrapperClass(getErrorType()));\n Error.captureStackTrace(gerror, checkError);\n throw gerror;\n }\n}\n\nconst isError = (value: unknown): value is ErrorLike => isTypedClass(value) && value.__type__ === getErrorType();\n\n/**\n * Builds an error domain enum object from its members and a lazy resolver for the\n * domain quark, giving it an `instanceof` check that matches wrapped GLib errors of\n * that domain.\n *\n * @param resolveDomain Called once, on first `instanceof` check, to obtain the domain quark.\n * @param members The error code enum members to expose on the returned object.\n */\nexport function createErrorDomain<const T extends Record<string, number>>(\n resolveDomain: () => number,\n members: T,\n): ErrorDomain<T> {\n let domain: number | undefined;\n const hasInstance = (value: unknown): value is ErrorLike => {\n domain ??= resolveDomain();\n return isError(value) && value.domain === domain;\n };\n const enumObject: Record<string, unknown> = { ...members };\n Object.defineProperty(enumObject, Symbol.hasInstance, { value: hasInstance });\n return enumObject as ErrorDomain<T>;\n}\n"]}
package/dist/fn.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { Descriptor } from "@gtkx/native";
2
+ import { type Arg } from "./arg.js";
3
+ type FnSpec = {
4
+ args: Arg[];
5
+ returns: Descriptor;
6
+ throws?: boolean;
7
+ };
8
+ export declare function fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown;
9
+ export {};
10
+ //# sourceMappingURL=fn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fn.d.ts","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAO,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,GAAG,EAA2D,MAAM,UAAU,CAAC;AAU7F,KAAK,MAAM,GAAG;IACV,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiEF,wBAAgB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,OAAO,CA2BzG"}
package/dist/fn.js ADDED
@@ -0,0 +1,79 @@
1
+ import { isCallerAllocatedArg, isInoutArg, isOutputArg, isRefArg } from "./arg.js";
2
+ import { bind } from "./bind.js";
3
+ import { wrapCallbackValue } from "./callback.js";
4
+ import { boxedT, refT } from "./descriptors.js";
5
+ import { checkError } from "./error.js";
6
+ import { LIB } from "./library.js";
7
+ import { fromNative } from "./native-value.js";
8
+ import { getHandle } from "./registry.js";
9
+ import { packTupleResult } from "./tuple.js";
10
+ const buildNativeArgTypes = (args, throws) => {
11
+ const nativeArgTypes = args.map((argSpec) => argSpec.direction !== undefined && argSpec.callerAllocated !== true ? refT(argSpec.type) : argSpec.type);
12
+ if (throws)
13
+ nativeArgTypes.push(refT(boxedT("GError", { ownership: "full", sharedLibrary: LIB, getTypeFnName: "g_error_get_type" })));
14
+ return nativeArgTypes;
15
+ };
16
+ const buildArgSpecs = (args) => {
17
+ let inputCursor = 0;
18
+ return args.map((arg) => {
19
+ const isRef = isRefArg(arg);
20
+ const consumesInput = !isRef || isInoutArg(arg);
21
+ const isOutParam = isOutputArg(arg) && arg.consumed !== true;
22
+ return {
23
+ arg,
24
+ isRef,
25
+ isCallerAllocated: isCallerAllocatedArg(arg),
26
+ consumesInput,
27
+ inputIndex: consumesInput ? inputCursor++ : -1,
28
+ isOutParam,
29
+ };
30
+ });
31
+ };
32
+ const buildNativeValues = (plans, inputs) => plans.map(({ arg, isRef, isCallerAllocated, consumesInput, inputIndex }) => {
33
+ if (isCallerAllocated) {
34
+ const wrapper = inputs[inputIndex];
35
+ return wrapper == null ? wrapper : getHandle(wrapper);
36
+ }
37
+ if (isRef) {
38
+ return { value: consumesInput ? inputs[inputIndex] : null };
39
+ }
40
+ if (arg.type.kind === "callback") {
41
+ return wrapCallbackValue(arg.type, inputs[inputIndex]);
42
+ }
43
+ return inputs[inputIndex];
44
+ });
45
+ const readOutParams = (plans, inputs, nativeValues) => {
46
+ const outParams = [];
47
+ plans.forEach(({ arg, isCallerAllocated, inputIndex, isOutParam }, index) => {
48
+ if (!isOutParam)
49
+ return;
50
+ outParams.push(isCallerAllocated ? inputs[inputIndex] : fromNative(arg.type, nativeValues[index].value));
51
+ });
52
+ return outParams;
53
+ };
54
+ export function fn(sharedLibrary, symbol, spec) {
55
+ const { args, returns: returnDescriptor, throws = false } = spec;
56
+ const nativeArgTypes = buildNativeArgTypes(args, throws);
57
+ const nativeFn = bind(sharedLibrary, symbol, nativeArgTypes, returnDescriptor);
58
+ const hasPrimary = returnDescriptor.kind !== "void";
59
+ const plans = buildArgSpecs(args);
60
+ const shape = (inputs, nativeValues, nativeResult) => {
61
+ const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;
62
+ return packTupleResult(readOutParams(plans, inputs, nativeValues), primary, hasPrimary);
63
+ };
64
+ if (throws) {
65
+ return (...inputs) => {
66
+ const nativeValues = buildNativeValues(plans, inputs);
67
+ const errorRef = { value: null };
68
+ nativeValues.push(errorRef);
69
+ const nativeResult = nativeFn(...nativeValues);
70
+ checkError(errorRef);
71
+ return shape(inputs, nativeValues, nativeResult);
72
+ };
73
+ }
74
+ return (...inputs) => {
75
+ const nativeValues = buildNativeValues(plans, inputs);
76
+ return shape(inputs, nativeValues, nativeFn(...nativeValues));
77
+ };
78
+ }
79
+ //# sourceMappingURL=fn.js.map
package/dist/fn.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fn.js","sourceRoot":"","sources":["../src/fn.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,oBAAoB,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe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AAC;IAED,OAAO,CAAC,GAAG,MAAM,EAAE,EAAE;QACjB,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { Descriptor, Ref } from \"@gtkx/native\";\nimport { type Arg, isCallerAllocatedArg, isInoutArg, isOutputArg, isRefArg } from \"./arg.js\";\nimport { bind } from \"./bind.js\";\nimport { wrapCallbackValue } from \"./callback.js\";\nimport { boxedT, refT } from \"./descriptors.js\";\nimport { checkError } from \"./error.js\";\nimport { LIB } from \"./library.js\";\nimport { fromNative } from \"./native-value.js\";\nimport { getHandle } from \"./registry.js\";\nimport { packTupleResult } from \"./tuple.js\";\n\ntype FnSpec = {\n args: Arg[];\n returns: Descriptor;\n throws?: boolean;\n};\n\ntype ArgSpec = {\n arg: Arg;\n isRef: boolean;\n isCallerAllocated: boolean;\n consumesInput: boolean;\n inputIndex: number;\n isOutParam: boolean;\n};\n\nconst buildNativeArgTypes = (args: Arg[], throws: boolean): Descriptor[] => {\n const nativeArgTypes = args.map((argSpec) =>\n argSpec.direction !== undefined && argSpec.callerAllocated !== true ? refT(argSpec.type) : argSpec.type,\n );\n if (throws)\n nativeArgTypes.push(\n refT(boxedT(\"GError\", { ownership: \"full\", sharedLibrary: LIB, getTypeFnName: \"g_error_get_type\" })),\n );\n return nativeArgTypes;\n};\n\nconst buildArgSpecs = (args: Arg[]): ArgSpec[] => {\n let inputCursor = 0;\n return args.map((arg) => {\n const isRef = isRefArg(arg);\n const consumesInput = !isRef || isInoutArg(arg);\n const isOutParam = isOutputArg(arg) && arg.consumed !== true;\n return {\n arg,\n isRef,\n isCallerAllocated: isCallerAllocatedArg(arg),\n consumesInput,\n inputIndex: consumesInput ? inputCursor++ : -1,\n isOutParam,\n };\n });\n};\n\nconst buildNativeValues = (plans: ArgSpec[], inputs: unknown[]): unknown[] =>\n plans.map(({ arg, isRef, isCallerAllocated, consumesInput, inputIndex }) => {\n if (isCallerAllocated) {\n const wrapper = inputs[inputIndex];\n return wrapper == null ? wrapper : getHandle(wrapper as object);\n }\n if (isRef) {\n return { value: consumesInput ? inputs[inputIndex] : null };\n }\n if (arg.type.kind === \"callback\") {\n return wrapCallbackValue(arg.type, inputs[inputIndex]);\n }\n return inputs[inputIndex];\n });\n\nconst readOutParams = (plans: ArgSpec[], inputs: unknown[], nativeValues: unknown[]): unknown[] => {\n const outParams: unknown[] = [];\n plans.forEach(({ arg, isCallerAllocated, inputIndex, isOutParam }, index) => {\n if (!isOutParam) return;\n outParams.push(\n isCallerAllocated ? inputs[inputIndex] : fromNative(arg.type, (nativeValues[index] as Ref).value),\n );\n });\n return outParams;\n};\n\nexport function fn(sharedLibrary: string, symbol: string, spec: FnSpec): (...inputs: unknown[]) => unknown {\n const { args, returns: returnDescriptor, throws = false } = spec;\n const nativeArgTypes = buildNativeArgTypes(args, throws);\n const nativeFn = bind(sharedLibrary, symbol, nativeArgTypes, returnDescriptor);\n const hasPrimary = returnDescriptor.kind !== \"void\";\n const plans = buildArgSpecs(args);\n\n const shape = (inputs: unknown[], nativeValues: unknown[], nativeResult: unknown): unknown => {\n const primary = hasPrimary ? fromNative(returnDescriptor, nativeResult) : undefined;\n return packTupleResult(readOutParams(plans, inputs, nativeValues), primary, hasPrimary);\n };\n\n if (throws) {\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs);\n const errorRef: Ref = { value: null };\n nativeValues.push(errorRef);\n const nativeResult = nativeFn(...nativeValues);\n checkError(errorRef);\n return shape(inputs, nativeValues, nativeResult);\n };\n }\n\n return (...inputs) => {\n const nativeValues = buildNativeValues(plans, inputs);\n return shape(inputs, nativeValues, nativeFn(...nativeValues));\n };\n}\n"]}
@@ -0,0 +1,15 @@
1
+ export { alloc, type ExternalObject, type Handle, read, setWrapper, write } from "@gtkx/native";
2
+ export { createErrorDomain, type ErrorDomain } from "./error.js";
3
+ export { type ApplicationLike, onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
4
+ export { offSignal, onceSignal, onSignal } from "./listeners.js";
5
+ export { installMixins, type Mixin } from "./mixin.js";
6
+ export { fromNative } from "./native-value.js";
7
+ export { getObjectProperty, newObjectWithProperties, setObjectProperty } from "./object.js";
8
+ export { promisify } from "./promisify.js";
9
+ export { registerClass } from "./register-class.js";
10
+ export { getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, type StaticBase, setHandle, tryGetHandle, wrapHandle, } from "./registry.js";
11
+ export { connectSignal, emitSignal, getSignalBaseName, type SignalHandler } from "./signal.js";
12
+ export { t } from "./t.js";
13
+ export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENUM, TYPE_FLAGS, TYPE_FLOAT, TYPE_GTYPE, TYPE_INT, TYPE_INT64, TYPE_INTERFACE, TYPE_INVALID, TYPE_LONG, TYPE_NONE, TYPE_OBJECT, TYPE_PARAM, TYPE_POINTER, TYPE_STRING, TYPE_UCHAR, TYPE_UINT, TYPE_UINT64, TYPE_ULONG, TYPE_UNICHAR, TYPE_VARIANT, type TypedClass, typeFromName, typeInterfaces, typeIsA, typeName, typeParent, valueIsA, } from "./type.js";
14
+ export { getBoxedValue, setBoxedValue } from "./value.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,c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2
+ export { createErrorDomain } from "./error.js";
3
+ export { onExit, quit, quitApplication, runApplication } from "./lifecycle.js";
4
+ export { offSignal, onceSignal, onSignal } from "./listeners.js";
5
+ export { installMixins } from "./mixin.js";
6
+ export { fromNative } from "./native-value.js";
7
+ export { getObjectProperty, newObjectWithProperties, setObjectProperty } from "./object.js";
8
+ export { promisify } from "./promisify.js";
9
+ export { registerClass } from "./register-class.js";
10
+ export { getHandle, getInstanceType, getWrapperClass, registerInterface, registerWrapperClass, setHandle, tryGetHandle, wrapHandle, } from "./registry.js";
11
+ export { connectSignal, emitSignal, getSignalBaseName } from "./signal.js";
12
+ export { t } from "./t.js";
13
+ export { resolveType, TYPE_BOOLEAN, TYPE_BOXED, TYPE_CHAR, TYPE_DOUBLE, TYPE_ENUM, TYPE_FLAGS, TYPE_FLOAT, TYPE_GTYPE, TYPE_INT, TYPE_INT64, TYPE_INTERFACE, TYPE_INVALID, TYPE_LONG, TYPE_NONE, TYPE_OBJECT, TYPE_PARAM, TYPE_POINTER, TYPE_STRING, TYPE_UCHAR, TYPE_UINT, TYPE_UINT64, TYPE_ULONG, TYPE_UNICHAR, TYPE_VARIANT, typeFromName, typeInterfaces, typeIsA, typeName, typeParent, valueIsA, } from "./type.js";
14
+ export { getBoxedValue, setBoxedValue } from "./value.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAwB,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAc,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACH,SAAS,EACT,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EAEpB,SAAS,EACT,YAAY,EACZ,UAAU,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EACH,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACd,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,YAAY,EACZ,cAAc,EACd,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { alloc, type ExternalObject, type Handle, read, setWrapper, write } from \"@gtkx/native\";\nexport { createErrorDomain, type ErrorDomain } from \"./error.js\";\nexport { type ApplicationLike, onExit, quit, quitApplication, runApplication } from \"./lifecycle.js\";\nexport { offSignal, onceSignal, onSignal } from \"./listeners.js\";\nexport { installMixins, type Mixin } from \"./mixin.js\";\nexport { fromNative } from \"./native-value.js\";\nexport { getObjectProperty, newObjectWithProperties, setObjectProperty } from \"./object.js\";\nexport { promisify } from \"./promisify.js\";\nexport { registerClass } from \"./register-class.js\";\nexport {\n getHandle,\n getInstanceType,\n getWrapperClass,\n registerInterface,\n registerWrapperClass,\n type StaticBase,\n setHandle,\n tryGetHandle,\n wrapHandle,\n} from \"./registry.js\";\nexport { connectSignal, emitSignal, getSignalBaseName, type SignalHandler } from \"./signal.js\";\nexport { t } from \"./t.js\";\nexport {\n resolveType,\n TYPE_BOOLEAN,\n TYPE_BOXED,\n TYPE_CHAR,\n TYPE_DOUBLE,\n TYPE_ENUM,\n TYPE_FLAGS,\n TYPE_FLOAT,\n TYPE_GTYPE,\n TYPE_INT,\n TYPE_INT64,\n TYPE_INTERFACE,\n TYPE_INVALID,\n TYPE_LONG,\n TYPE_NONE,\n TYPE_OBJECT,\n TYPE_PARAM,\n TYPE_POINTER,\n TYPE_STRING,\n TYPE_UCHAR,\n TYPE_UINT,\n TYPE_UINT64,\n TYPE_ULONG,\n TYPE_UNICHAR,\n TYPE_VARIANT,\n type TypedClass,\n typeFromName,\n typeInterfaces,\n typeIsA,\n typeName,\n typeParent,\n valueIsA,\n} from \"./type.js\";\nexport { getBoxedValue, setBoxedValue } from \"./value.js\";\n"]}
@@ -0,0 +1,5 @@
1
+ export { checkError, createErrorDomain } from "./error.js";
2
+ export { registerClassType, resolveWrapperClass, wrapHandle } from "./registry.js";
3
+ export { resolveType } from "./type.js";
4
+ export { fromValue, getBoxedValue, getValueType, inoutValueForBoxedDescriptor, newValueForDescriptor, outValueForBoxedDescriptor, toValue, } from "./value.js";
5
+ //# sourceMappingURL=internal.d.ts.map