@gtkx/codegen 1.2.2 → 1.4.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 +6 -4
- package/dist/analysis/descriptor-render.d.ts +7 -1
- package/dist/analysis/descriptor-render.d.ts.map +1 -1
- package/dist/analysis/descriptor-render.js +37 -15
- package/dist/analysis/descriptor-render.js.map +1 -1
- package/dist/analysis/descriptor.d.ts +5 -1
- package/dist/analysis/descriptor.d.ts.map +1 -1
- package/dist/analysis/descriptor.js +12 -2
- package/dist/analysis/descriptor.js.map +1 -1
- package/dist/analysis/param-capability.d.ts +5 -2
- package/dist/analysis/param-capability.d.ts.map +1 -1
- package/dist/analysis/param-capability.js +36 -4
- package/dist/analysis/param-capability.js.map +1 -1
- package/dist/analysis/param-structure.d.ts +1 -1
- package/dist/analysis/param-structure.d.ts.map +1 -1
- package/dist/analysis/param-structure.js.map +1 -1
- package/dist/analysis/ts-type.d.ts +1 -1
- package/dist/analysis/ts-type.d.ts.map +1 -1
- package/dist/analysis/ts-type.js +28 -10
- package/dist/analysis/ts-type.js.map +1 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/docs/api-reference.d.ts +6 -0
- package/dist/docs/api-reference.d.ts.map +1 -1
- package/dist/docs/api-reference.js +11 -2
- package/dist/docs/api-reference.js.map +1 -1
- package/dist/docs/pipeline.d.ts +3 -0
- package/dist/docs/pipeline.d.ts.map +1 -1
- package/dist/docs/pipeline.js +10 -1
- package/dist/docs/pipeline.js.map +1 -1
- package/dist/fingerprint.d.ts +5 -0
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +111 -15
- package/dist/fingerprint.js.map +1 -1
- package/dist/gi.d.ts +3 -0
- package/dist/gi.d.ts.map +1 -1
- package/dist/gi.js +33 -7
- package/dist/gi.js.map +1 -1
- package/dist/gir/external-namespaces.d.ts +8 -0
- package/dist/gir/external-namespaces.d.ts.map +1 -0
- package/dist/gir/external-namespaces.js +4 -0
- package/dist/gir/external-namespaces.js.map +1 -0
- package/dist/gir/finish-overrides.d.ts +3 -0
- package/dist/gir/finish-overrides.d.ts.map +1 -0
- package/dist/gir/finish-overrides.js +5 -0
- package/dist/gir/finish-overrides.js.map +1 -0
- package/dist/gir/function.d.ts +5 -2
- package/dist/gir/function.d.ts.map +1 -1
- package/dist/gir/function.js +34 -5
- package/dist/gir/function.js.map +1 -1
- package/dist/gir/hidden-symbols.d.ts +3 -0
- package/dist/gir/hidden-symbols.d.ts.map +1 -0
- package/dist/gir/hidden-symbols.js +39 -0
- package/dist/gir/hidden-symbols.js.map +1 -0
- package/dist/gir/library.d.ts +22 -2
- package/dist/gir/library.d.ts.map +1 -1
- package/dist/gir/library.js +21 -3
- package/dist/gir/library.js.map +1 -1
- package/dist/gir/ucs4-overrides.d.ts +3 -0
- package/dist/gir/ucs4-overrides.d.ts.map +1 -0
- package/dist/gir/ucs4-overrides.js +7 -0
- package/dist/gir/ucs4-overrides.js.map +1 -0
- package/dist/guards.d.ts +2 -1
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +3 -1
- package/dist/guards.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts.map +1 -1
- package/dist/jsx.js +27 -8
- package/dist/jsx.js.map +1 -1
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +9 -3
- package/dist/runner.js.map +1 -1
- package/dist/store/external-package-links.d.ts +6 -0
- package/dist/store/external-package-links.d.ts.map +1 -0
- package/dist/store/external-package-links.js +158 -0
- package/dist/store/external-package-links.js.map +1 -0
- package/dist/store/gi/callable-doc.d.ts.map +1 -1
- package/dist/store/gi/callable-doc.js +4 -4
- package/dist/store/gi/callable-doc.js.map +1 -1
- package/dist/store/gi/callables.js +1 -1
- package/dist/store/gi/callables.js.map +1 -1
- package/dist/store/gi/class.d.ts.map +1 -1
- package/dist/store/gi/class.js +17 -0
- package/dist/store/gi/class.js.map +1 -1
- package/dist/store/gi/constructor-props.js +1 -1
- package/dist/store/gi/constructor-props.js.map +1 -1
- package/dist/store/gi/function.d.ts.map +1 -1
- package/dist/store/gi/function.js +2 -1
- package/dist/store/gi/function.js.map +1 -1
- package/dist/store/gi/generated-libraries.d.ts +26 -0
- package/dist/store/gi/generated-libraries.d.ts.map +1 -0
- package/dist/store/gi/generated-libraries.js +53 -0
- package/dist/store/gi/generated-libraries.js.map +1 -0
- package/dist/store/gi/gtype-binding.d.ts +2 -1
- package/dist/store/gi/gtype-binding.d.ts.map +1 -1
- package/dist/store/gi/gtype-binding.js +6 -1
- package/dist/store/gi/gtype-binding.js.map +1 -1
- package/dist/store/gi/method.d.ts +7 -2
- package/dist/store/gi/method.d.ts.map +1 -1
- package/dist/store/gi/method.js +126 -30
- package/dist/store/gi/method.js.map +1 -1
- package/dist/store/gi/param-marshal.d.ts +8 -1
- package/dist/store/gi/param-marshal.d.ts.map +1 -1
- package/dist/store/gi/param-marshal.js +52 -4
- package/dist/store/gi/param-marshal.js.map +1 -1
- package/dist/store/gi/record-constructor.d.ts.map +1 -1
- package/dist/store/gi/record-constructor.js +2 -3
- package/dist/store/gi/record-constructor.js.map +1 -1
- package/dist/store/gi/record-field-accessor.d.ts +2 -1
- package/dist/store/gi/record-field-accessor.d.ts.map +1 -1
- package/dist/store/gi/record-field-accessor.js +9 -3
- package/dist/store/gi/record-field-accessor.js.map +1 -1
- package/dist/store/gi/runtime-override.js +1 -1
- package/dist/store/gi/runtime-override.js.map +1 -1
- package/dist/store/gi/signal.js +2 -2
- package/dist/store/gi/signal.js.map +1 -1
- package/dist/store/gi/vtable.d.ts.map +1 -1
- package/dist/store/gi/vtable.js +82 -12
- package/dist/store/gi/vtable.js.map +1 -1
- package/dist/store/gi-store.d.ts +12 -2
- package/dist/store/gi-store.d.ts.map +1 -1
- package/dist/store/gi-store.js +24 -5
- package/dist/store/gi-store.js.map +1 -1
- package/dist/store/jsx/jsx.d.ts.map +1 -1
- package/dist/store/jsx/jsx.js +3 -1
- package/dist/store/jsx/jsx.js.map +1 -1
- package/dist/store/jsx/metadata.d.ts.map +1 -1
- package/dist/store/jsx/metadata.js +35 -60
- package/dist/store/jsx/metadata.js.map +1 -1
- package/dist/store/jsx-store.d.ts +8 -1
- package/dist/store/jsx-store.d.ts.map +1 -1
- package/dist/store/jsx-store.js +9 -2
- package/dist/store/jsx-store.js.map +1 -1
- package/dist/store/resolve-store.d.ts +2 -1
- package/dist/store/resolve-store.d.ts.map +1 -1
- package/dist/store/resolve-store.js +3 -1
- package/dist/store/resolve-store.js.map +1 -1
- package/dist/store/store-fs.d.ts +2 -1
- package/dist/store/store-fs.d.ts.map +1 -1
- package/dist/store/store-fs.js +8 -3
- package/dist/store/store-fs.js.map +1 -1
- package/dist/writer/context.d.ts.map +1 -1
- package/dist/writer/context.js +8 -0
- package/dist/writer/context.js.map +1 -1
- package/dist/writer/gtk-doc.d.ts.map +1 -1
- package/dist/writer/gtk-doc.js +27 -1
- package/dist/writer/gtk-doc.js.map +1 -1
- package/overrides/gdk/rgba.ts.ejs +15 -1
- package/overrides/glib/index.ts.ejs +3 -0
- package/overrides/glib/regex.ts.ejs +66 -0
- package/overrides/gobject/index.ts.ejs +3 -0
- package/overrides/gobject/object-class.ts.ejs +27 -0
- package/overrides/gobject/param-spec-getters.ts.ejs +57 -0
- package/overrides/gobject/param-spec.ts.ejs +21 -0
- package/overrides/gobject/value.ts.ejs +6 -1
- package/overrides/graphene/structs.ts.ejs +38 -3
- package/overrides/gtk/index.ts.ejs +2 -0
- package/overrides/gtk/widget-class.ts.ejs +28 -0
- package/package.json +7 -6
- package/src/analysis/descriptor-render.ts +60 -16
- package/src/analysis/descriptor.ts +17 -3
- package/src/analysis/param-capability.ts +68 -5
- package/src/analysis/param-structure.ts +1 -1
- package/src/analysis/ts-type.ts +45 -11
- package/src/compile.ts +1 -1
- package/src/docs/api-reference.ts +20 -2
- package/src/docs/pipeline.ts +15 -1
- package/src/fingerprint.ts +151 -16
- package/src/gi.ts +48 -9
- package/src/gir/external-namespaces.ts +8 -0
- package/src/gir/finish-overrides.ts +5 -0
- package/src/gir/function.ts +52 -14
- package/src/gir/hidden-symbols.ts +39 -0
- package/src/gir/library.ts +36 -3
- package/src/gir/ucs4-overrides.ts +7 -0
- package/src/guards.ts +6 -1
- package/src/index.ts +2 -0
- package/src/jsx.ts +33 -8
- package/src/runner.ts +17 -3
- package/src/store/external-package-links.ts +226 -0
- package/src/store/gi/callable-doc.ts +8 -4
- package/src/store/gi/callables.ts +1 -1
- package/src/store/gi/class.ts +29 -0
- package/src/store/gi/constructor-props.ts +1 -1
- package/src/store/gi/function.ts +2 -1
- package/src/store/gi/generated-libraries.ts +91 -0
- package/src/store/gi/gtype-binding.ts +8 -1
- package/src/store/gi/method.ts +189 -36
- package/src/store/gi/param-marshal.ts +67 -4
- package/src/store/gi/record-constructor.ts +8 -3
- package/src/store/gi/record-field-accessor.ts +11 -2
- package/src/store/gi/runtime-override.ts +1 -1
- package/src/store/gi/signal.ts +2 -2
- package/src/store/gi/vtable.ts +118 -11
- package/src/store/gi-store.ts +48 -5
- package/src/store/jsx/jsx.ts +3 -1
- package/src/store/jsx/metadata.ts +46 -99
- package/src/store/jsx-store.ts +23 -7
- package/src/store/resolve-store.ts +3 -1
- package/src/store/store-fs.ts +10 -2
- package/src/writer/context.ts +11 -0
- package/src/writer/gtk-doc.ts +38 -1
- package/overrides/cairo/context.ts.ejs +0 -1269
- package/overrides/cairo/font-face.ts.ejs +0 -151
- package/overrides/cairo/font-options.ts.ejs +0 -199
- package/overrides/cairo/image-surface.ts.ejs +0 -132
- package/overrides/cairo/index.ts.ejs +0 -22
- package/overrides/cairo/matrix.ts.ejs +0 -171
- package/overrides/cairo/pattern.ts.ejs +0 -476
- package/overrides/cairo/recording-surface.ts.ejs +0 -102
- package/overrides/cairo/region.ts.ejs +0 -237
- package/overrides/cairo/scaled-font.ts.ejs +0 -330
- package/overrides/cairo/surface.ts.ejs +0 -296
package/dist/store/gi/method.js
CHANGED
|
@@ -2,11 +2,12 @@ import { camelCase, escapeIdentifierStart, sourceStringLiteral } from "@gtkx/uti
|
|
|
2
2
|
import { isSkippedPrimaryReturn, renderCallbackType, renderDescriptor, renderSelfDescriptor, shouldOmitPrimaryReturn, } from "../../analysis/descriptor-render.js";
|
|
3
3
|
import { arrayLengthSources, closureAndDestroyIndices, emittedArgIndices, foldedLengthIndices, foldOutParamShape, inputParameters, parameterIdentifier, } from "../../analysis/param-structure.js";
|
|
4
4
|
import { renderParameterTsType, renderTsType } from "../../analysis/ts-type.js";
|
|
5
|
+
import { primitiveCategoryFor } from "../../analysis/type-shape.js";
|
|
5
6
|
import { isCallerAllocatedOut, isInoutParameter, isOutParameter } from "../../gir/parameter.js";
|
|
6
7
|
import { hasUnknownArrayLength } from "../../gir/type-id.js";
|
|
7
8
|
import { areClosuresInvoked } from "./closure-invocation.js";
|
|
8
9
|
import { itemComparatorArgDescriptors, itemComparatorTsType } from "./item-comparators.js";
|
|
9
|
-
import { isClosureType, isCollectibleCallerOut, isHandlePassedInPlace, isHandlePassing, renderCallerOutInstance, } from "./param-marshal.js";
|
|
10
|
+
import { isClosureType, isCollectibleCallerOut, isFixedArrayCallerOut, isHandlePassedInPlace, isHandlePassing, isValueType, renderCallerOutInstance, } from "./param-marshal.js";
|
|
10
11
|
const memberName = (girName) => escapeIdentifierStart(camelCase(girName));
|
|
11
12
|
const methodExportName = (fn) => memberName(fn.name);
|
|
12
13
|
const arrayLengthArgument = (source, sourceIndex) => {
|
|
@@ -23,12 +24,13 @@ const closureAnnotation = (context, base) => {
|
|
|
23
24
|
};
|
|
24
25
|
const requiresClosureMarshal = (context, fn, ref) => isClosureType(context, ref) && areClosuresInvoked(fn);
|
|
25
26
|
const requiresClosureAnnotation = (context, fn, parameter) => parameter.type !== undefined && requiresClosureMarshal(context, fn, parameter.type);
|
|
27
|
+
const isValueRead = (parameter) => !isInoutParameter(parameter) && parameter.cType?.includes("const ") === true;
|
|
26
28
|
const parameterAnnotation = (context, fn, parameter) => {
|
|
27
29
|
const comparator = itemComparatorTsType(context, fn, parameter);
|
|
28
30
|
if (comparator !== undefined) {
|
|
29
31
|
return comparator;
|
|
30
32
|
}
|
|
31
|
-
const base = renderParameterTsType(context, parameter.type, parameter.nullable);
|
|
33
|
+
const base = renderParameterTsType(context, parameter.type, parameter.nullable, isValueRead(parameter));
|
|
32
34
|
return requiresClosureAnnotation(context, fn, parameter) ? closureAnnotation(context, base) : base;
|
|
33
35
|
};
|
|
34
36
|
const isParameterOptional = (parameter, isOptionalExtra) => parameter.optional || isOptionalExtra(parameter);
|
|
@@ -49,9 +51,11 @@ const renderInputParameters = (context, fn, options) => {
|
|
|
49
51
|
}
|
|
50
52
|
return parts.join(", ");
|
|
51
53
|
};
|
|
54
|
+
const isInPlaceInout = (context, parameter) => context.library.isInoutInPlace && isInoutParameter(parameter) && isHandlePassedInPlace(context, parameter);
|
|
52
55
|
const isReturnedOutParameter = (context, parameter) => isOutParameter(parameter) ||
|
|
53
|
-
(isCallerAllocatedOut(parameter) &&
|
|
54
|
-
|
|
56
|
+
(isCallerAllocatedOut(parameter) &&
|
|
57
|
+
(isCollectibleCallerOut(context, parameter) || isFixedArrayCallerOut(context, parameter))) ||
|
|
58
|
+
(isInoutParameter(parameter) && !isInPlaceInout(context, parameter));
|
|
55
59
|
const returnedOutParameters = (context, fn) => {
|
|
56
60
|
const folded = foldedLengthIndices(context.library, fn);
|
|
57
61
|
const result = [];
|
|
@@ -62,15 +66,23 @@ const returnedOutParameters = (context, fn) => {
|
|
|
62
66
|
}
|
|
63
67
|
return result;
|
|
64
68
|
};
|
|
69
|
+
const isUnwrappedValue = (context, ref) => context.library.isValueUnwrapped && ref !== undefined && isValueType(context, ref);
|
|
70
|
+
const renderReturnedTsType = (context, ref, isNullable) => isUnwrappedValue(context, ref) ? "unknown" : renderTsType(context, ref, isNullable);
|
|
71
|
+
const isUnpackedOutParameter = (context, parameter) => isCallerAllocatedOut(parameter) &&
|
|
72
|
+
isCollectibleCallerOut(context, parameter) &&
|
|
73
|
+
isUnwrappedValue(context, parameter.type);
|
|
74
|
+
const renderOutTsType = (context, parameter) => isUnpackedOutParameter(context, parameter)
|
|
75
|
+
? "unknown"
|
|
76
|
+
: renderTsType(context, parameter.type, parameter.nullable);
|
|
65
77
|
const renderMethodReturnType = (context, fn) => {
|
|
66
78
|
const outs = returnedOutParameters(context, fn);
|
|
67
79
|
const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)
|
|
68
80
|
? undefined
|
|
69
|
-
:
|
|
81
|
+
: renderReturnedTsType(context, fn.returnValue.type, fn.returnValue.nullable);
|
|
70
82
|
if (outs.length === 0) {
|
|
71
83
|
return primary ?? "void";
|
|
72
84
|
}
|
|
73
|
-
const outTypes = outs.map(({ parameter }) =>
|
|
85
|
+
const outTypes = outs.map(({ parameter }) => renderOutTsType(context, parameter));
|
|
74
86
|
return foldOutParamShape(primary, outTypes);
|
|
75
87
|
};
|
|
76
88
|
const classifyPromisifiedParameter = (promisify, parameter, index, state) => {
|
|
@@ -108,8 +120,21 @@ const renderCancellableExpression = (parameters, cancellableIndex) => {
|
|
|
108
120
|
const parameter = parameters[cancellableIndex];
|
|
109
121
|
return parameter === undefined ? "null" : parameterIdentifier(parameter, cancellableIndex);
|
|
110
122
|
};
|
|
111
|
-
const
|
|
123
|
+
const shouldTrimFinishBoolean = (context, finishFn) => context.library.isFinishTrimmed &&
|
|
124
|
+
finishFn.throws &&
|
|
125
|
+
!shouldOmitPrimaryReturn(context.library, finishFn.returnValue) &&
|
|
126
|
+
primitiveCategoryFor(context.library, finishFn.returnValue.type) === "boolean" &&
|
|
127
|
+
returnedOutParameters(context, finishFn).length > 0;
|
|
128
|
+
const promisifiedFinishExpression = (context, finishFn, finishExpression) => {
|
|
129
|
+
if (!shouldTrimFinishBoolean(context, finishFn)) {
|
|
130
|
+
return finishExpression;
|
|
131
|
+
}
|
|
132
|
+
context.addRuntimeImport("trimFinish");
|
|
133
|
+
return `trimFinish(${finishExpression})`;
|
|
134
|
+
};
|
|
135
|
+
const renderPromisifiedBody = (context, asyncFn, finishTarget, bindingExpression) => {
|
|
112
136
|
context.addRuntimeImport("promisify");
|
|
137
|
+
const finish = promisifiedFinishExpression(context, finishTarget.fn, finishTarget.expression);
|
|
113
138
|
const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);
|
|
114
139
|
const promisifyContext = {
|
|
115
140
|
context,
|
|
@@ -125,7 +150,7 @@ const renderPromisifiedBody = (context, asyncFn, finishExpression, bindingExpres
|
|
|
125
150
|
leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));
|
|
126
151
|
const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);
|
|
127
152
|
const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(", ")}` : "";
|
|
128
|
-
return `return promisify(${bindingExpression}, ${
|
|
153
|
+
return `return promisify(${bindingExpression}, ${finish}, ${cancellableExpression}${leadingArguments});`;
|
|
129
154
|
};
|
|
130
155
|
const finishCallExpression = (asyncFn, finishFn, ownerName) => asyncFn.instance !== undefined && finishFn.instance === undefined
|
|
131
156
|
? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`
|
|
@@ -148,7 +173,9 @@ const renderPromisifiedSignature = (context, asyncFn, finishFn) => {
|
|
|
148
173
|
shouldSkip: (parameter) => isCallbackParameter(context, parameter),
|
|
149
174
|
isOptionalExtra: (parameter) => isCancellable(context, parameter),
|
|
150
175
|
});
|
|
151
|
-
const finishReturn =
|
|
176
|
+
const finishReturn = shouldTrimFinishBoolean(context, finishFn)
|
|
177
|
+
? foldOutParamShape(undefined, returnedOutParameters(context, finishFn).map(({ parameter }) => renderOutTsType(context, parameter)))
|
|
178
|
+
: renderMethodReturnType(context, finishFn);
|
|
152
179
|
return { signature, returnType: `Promise<${finishReturn}>` };
|
|
153
180
|
};
|
|
154
181
|
const isCancellable = (context, parameter) => parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === "Cancellable";
|
|
@@ -179,6 +206,12 @@ const paramDescriptorLiteral = (descriptor, options) => {
|
|
|
179
206
|
if (options.isConsumed === true) {
|
|
180
207
|
parts.push("isConsumed: true");
|
|
181
208
|
}
|
|
209
|
+
if (options.isUnpacked === true) {
|
|
210
|
+
parts.push("isUnpacked: true");
|
|
211
|
+
}
|
|
212
|
+
if (options.isRequired === true) {
|
|
213
|
+
parts.push("isRequired: true");
|
|
214
|
+
}
|
|
182
215
|
return `{ ${parts.join(", ")} }`;
|
|
183
216
|
};
|
|
184
217
|
const renderReturnDescriptor = (context, fn) => {
|
|
@@ -188,7 +221,11 @@ const renderReturnDescriptor = (context, fn) => {
|
|
|
188
221
|
argIndexMap: emittedArgIndices(fn, instanceOffset),
|
|
189
222
|
isNewlyCreated: fn.instance === undefined,
|
|
190
223
|
});
|
|
191
|
-
return {
|
|
224
|
+
return {
|
|
225
|
+
descriptor,
|
|
226
|
+
isSkipped: isSkippedPrimaryReturn(context.library, fn.returnValue),
|
|
227
|
+
isUnpacked: isUnwrappedValue(context, fn.returnValue.type),
|
|
228
|
+
};
|
|
192
229
|
};
|
|
193
230
|
const planCallArgs = (context, fn) => {
|
|
194
231
|
const plan = [];
|
|
@@ -217,6 +254,7 @@ const planCallArgs = (context, fn) => {
|
|
|
217
254
|
return plan;
|
|
218
255
|
};
|
|
219
256
|
const isSkippedPlanParameter = (parameter, index, closureIndices) => parameter.isVarargs || closureIndices.has(index);
|
|
257
|
+
const isRequiredParameter = (parameter) => !parameter.nullable && !parameter.optional;
|
|
220
258
|
const planParameter = (context, parameter, index, planContext) => {
|
|
221
259
|
const { folded, closureIndices, lengthSources } = planContext;
|
|
222
260
|
if (isSkippedPlanParameter(parameter, index, closureIndices)) {
|
|
@@ -272,15 +310,31 @@ const planOutParam = (context, parameter, argIndex, isConsumed) => {
|
|
|
272
310
|
};
|
|
273
311
|
};
|
|
274
312
|
const planCallerOut = (context, parameter, argIndex) => {
|
|
275
|
-
const descriptor = renderDescriptor(context, parameter.type, "none", argIndex);
|
|
276
313
|
if (isCollectibleCallerOut(context, parameter)) {
|
|
277
314
|
context.addRuntimeImport("getHandle");
|
|
278
315
|
return {
|
|
279
|
-
paramLiteral: paramDescriptorLiteral(
|
|
316
|
+
paramLiteral: paramDescriptorLiteral(renderDescriptor(context, parameter.type, "none", argIndex), {
|
|
317
|
+
direction: "out",
|
|
318
|
+
isCallerAllocated: true,
|
|
319
|
+
isUnpacked: isUnpackedOutParameter(context, parameter),
|
|
320
|
+
}),
|
|
280
321
|
inputExpr: renderCallerOutInstance(context, parameter),
|
|
281
322
|
};
|
|
282
323
|
}
|
|
283
|
-
|
|
324
|
+
if (isFixedArrayCallerOut(context, parameter)) {
|
|
325
|
+
const descriptor = renderDescriptor(context, parameter.type, "none", {
|
|
326
|
+
...argIndex,
|
|
327
|
+
isCallerAllocated: true,
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { direction: "out" }),
|
|
331
|
+
inputExpr: undefined,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
paramLiteral: paramDescriptorLiteral(renderDescriptor(context, parameter.type, "none", argIndex), {}),
|
|
336
|
+
inputExpr: "undefined",
|
|
337
|
+
};
|
|
284
338
|
};
|
|
285
339
|
const planInoutParam = (context, parameter, options) => {
|
|
286
340
|
const { fn, index, argIndex, isConsumed, lengthSource } = options;
|
|
@@ -290,7 +344,8 @@ const planInoutParam = (context, parameter, options) => {
|
|
|
290
344
|
paramLiteral: paramDescriptorLiteral(descriptor, {
|
|
291
345
|
direction: "inout",
|
|
292
346
|
isCallerAllocated: true,
|
|
293
|
-
isConsumed,
|
|
347
|
+
isConsumed: isConsumed || context.library.isInoutInPlace,
|
|
348
|
+
isRequired: isRequiredParameter(parameter),
|
|
294
349
|
}),
|
|
295
350
|
inputExpr: parameterIdentifier(parameter, index),
|
|
296
351
|
};
|
|
@@ -300,7 +355,11 @@ const planInoutParam = (context, parameter, options) => {
|
|
|
300
355
|
hasOutIndirection: true,
|
|
301
356
|
});
|
|
302
357
|
return {
|
|
303
|
-
paramLiteral: paramDescriptorLiteral(descriptor, {
|
|
358
|
+
paramLiteral: paramDescriptorLiteral(descriptor, {
|
|
359
|
+
direction: "inout",
|
|
360
|
+
isConsumed,
|
|
361
|
+
isRequired: lengthSource === undefined && isRequiredParameter(parameter),
|
|
362
|
+
}),
|
|
304
363
|
inputExpr: lengthSource === undefined
|
|
305
364
|
? parameterCallExpression(context, parameter, index, { fn })
|
|
306
365
|
: arrayLengthArgument(lengthSource.source, lengthSource.index),
|
|
@@ -312,7 +371,7 @@ const planInParam = (context, parameter, index, planContext) => {
|
|
|
312
371
|
const descriptor = callback ??
|
|
313
372
|
renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);
|
|
314
373
|
return {
|
|
315
|
-
paramLiteral: paramDescriptorLiteral(descriptor, {}),
|
|
374
|
+
paramLiteral: paramDescriptorLiteral(descriptor, { isRequired: isRequiredParameter(parameter) }),
|
|
316
375
|
inputExpr: parameterCallExpression(context, parameter, index, { fn }),
|
|
317
376
|
};
|
|
318
377
|
};
|
|
@@ -326,30 +385,46 @@ const closureArgument = (context, name, isNullable) => {
|
|
|
326
385
|
context.addRuntimeImport(helper);
|
|
327
386
|
return `${helper}(${name})`;
|
|
328
387
|
};
|
|
329
|
-
const
|
|
388
|
+
const valueArgument = (context, name, isNullable) => {
|
|
389
|
+
const helper = isNullable ? "tryToValueHandle" : "toValueHandle";
|
|
390
|
+
context.addRuntimeImport(helper);
|
|
391
|
+
return `${helper}(${name})`;
|
|
392
|
+
};
|
|
393
|
+
const hashtableArgument = (context, valueRef, name, isValueMarshalled) => {
|
|
394
|
+
if (isValueMarshalled && isValueType(context, valueRef)) {
|
|
395
|
+
context.addRuntimeImport("toValueHandle");
|
|
396
|
+
return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, toValueHandle(v)]) : null`;
|
|
397
|
+
}
|
|
330
398
|
if (isHandlePassing(context, valueRef)) {
|
|
331
399
|
context.addRuntimeImport("getHandle");
|
|
332
400
|
return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, ${nullableHandleExpression("v")}]) : null`;
|
|
333
401
|
}
|
|
334
402
|
return `${name} ? globalThis.Array.from(${name}) : null`;
|
|
335
403
|
};
|
|
336
|
-
const
|
|
337
|
-
const
|
|
404
|
+
const mapItemExpression = (name, isNullable, helper) => isNullable ? `${name}?.map((item) => ${helper}(item))` : `${name}.map((item) => ${helper}(item))`;
|
|
405
|
+
const itemHelper = (context, element, isValueMarshalled) => {
|
|
406
|
+
const helper = isValueMarshalled && isValueType(context, element) ? "toValueHandle" : "getHandle";
|
|
407
|
+
context.addRuntimeImport(helper);
|
|
408
|
+
return helper;
|
|
409
|
+
};
|
|
410
|
+
const collectionArgument = (options) => {
|
|
411
|
+
const { context, type, name, isNullable, isValueMarshalled } = options;
|
|
338
412
|
if (type?.kind === "hashtable") {
|
|
339
|
-
return hashtableArgument(context, type.value, name);
|
|
413
|
+
return hashtableArgument(context, type.value, name, isValueMarshalled);
|
|
340
414
|
}
|
|
341
|
-
|
|
415
|
+
const element = mappableElement(context, type);
|
|
416
|
+
if (element === undefined) {
|
|
342
417
|
return undefined;
|
|
343
418
|
}
|
|
344
|
-
context
|
|
345
|
-
return mapHandleExpression(name, isNullable);
|
|
419
|
+
return mapItemExpression(name, isNullable, itemHelper(context, element, isValueMarshalled));
|
|
346
420
|
};
|
|
347
|
-
const
|
|
421
|
+
const mappableElement = (context, type) => {
|
|
348
422
|
if (type?.kind === "carray") {
|
|
349
|
-
return
|
|
423
|
+
return hasUnknownArrayLength(type) ? undefined : mappableRef(context, type.element);
|
|
350
424
|
}
|
|
351
|
-
return type?.kind === "list"
|
|
425
|
+
return type?.kind === "list" ? mappableRef(context, type.element) : undefined;
|
|
352
426
|
};
|
|
427
|
+
const mappableRef = (context, element) => isHandlePassing(context, element) ? element : undefined;
|
|
353
428
|
const parameterCallExpression = (context, parameter, index, options) => {
|
|
354
429
|
const { fn, isForcedNullable = false } = options;
|
|
355
430
|
const name = parameterIdentifier(parameter, index);
|
|
@@ -361,11 +436,32 @@ const parameterCallExpression = (context, parameter, index, options) => {
|
|
|
361
436
|
if (requiresClosureMarshal(context, fn, ref)) {
|
|
362
437
|
return closureArgument(context, name, isNullable);
|
|
363
438
|
}
|
|
364
|
-
|
|
365
|
-
|
|
439
|
+
const marshalled = marshalledArgument({
|
|
440
|
+
context,
|
|
441
|
+
ref,
|
|
442
|
+
name,
|
|
443
|
+
isNullable,
|
|
444
|
+
isValueMarshalled: isValueRead(parameter),
|
|
445
|
+
});
|
|
446
|
+
if (marshalled !== undefined) {
|
|
447
|
+
return marshalled;
|
|
366
448
|
}
|
|
367
449
|
const type = context.library.typeFor(ref);
|
|
368
|
-
return collectionArgument(
|
|
450
|
+
return (collectionArgument({
|
|
451
|
+
context,
|
|
452
|
+
ref,
|
|
453
|
+
type,
|
|
454
|
+
name,
|
|
455
|
+
isNullable,
|
|
456
|
+
isValueMarshalled: isValueRead(parameter),
|
|
457
|
+
}) ?? name);
|
|
458
|
+
};
|
|
459
|
+
const marshalledArgument = (options) => {
|
|
460
|
+
const { context, ref, name, isNullable, isValueMarshalled } = options;
|
|
461
|
+
if (isValueMarshalled && isValueType(context, ref)) {
|
|
462
|
+
return valueArgument(context, name, isNullable);
|
|
463
|
+
}
|
|
464
|
+
return isHandlePassing(context, ref) ? handleArgument(context, name, isNullable) : undefined;
|
|
369
465
|
};
|
|
370
|
-
export { isCallbackParameter, memberName, methodExportName, renderMethodSignature, renderMethodReturnType, returnedOutParameters, renderPromisifiedBody, finishCallExpression, renderPromisifiedSignature, renderMethodBody, renderReturnDescriptor, planCallArgs, };
|
|
466
|
+
export { isCallbackParameter, memberName, methodExportName, renderMethodSignature, renderMethodReturnType, returnedOutParameters, renderPromisifiedBody, finishCallExpression, renderPromisifiedSignature, shouldTrimFinishBoolean, renderMethodBody, renderReturnDescriptor, planCallArgs, };
|
|
371
467
|
//# sourceMappingURL=method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIpF,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EAEjB,eAAe,EACf,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAqB,oBAAoB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,qBAAqB,EAAe,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,GAC1B,MAAM,oBAAoB,CAAC;AAwD5B,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1F,MAAM,gBAAgB,GAAG,CAAC,EAAe,EAAU,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAE1E,MAAM,mBAAmB,GAAG,CAAC,MAAoB,EAAE,WAAmB,EAAU,EAAE;IAC9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CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IAEhF,IAAI,sBAAsB,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,kBAAkB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC;AACvE,CAAC,CAAC;AAEF,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,GACf,CAAC","sourcesContent":["import { camelCase, escapeIdentifierStart, sourceStringLiteral } from \"@gtkx/utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirType } from \"../../gir/type.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n isSkippedPrimaryReturn,\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n shouldOmitPrimaryReturn,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n emittedArgIndices,\n foldedLengthIndices,\n foldOutParamShape,\n type InputParameter,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderParameterTsType, renderTsType } from \"../../analysis/ts-type.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport { hasUnknownArrayLength, type TypeId } from \"../../gir/type-id.js\";\nimport { areClosuresInvoked } from \"./closure-invocation.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport {\n isClosureType,\n isCollectibleCallerOut,\n isHandlePassedInPlace,\n isHandlePassing,\n renderCallerOutInstance,\n} from \"./param-marshal.js\";\n\ntype PromisifiedStep = { hasSeenOptional: boolean; expression: string | undefined };\n\ntype InputParameterOptions = {\n shouldSkip: (parameter: GirParameter) => boolean;\n isOptionalExtra: (parameter: GirParameter) => boolean;\n};\n\ntype CallExpressionOptions = {\n fn: GirFunction;\n isForcedNullable?: boolean | undefined;\n};\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthSources: Map<number, number>;\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ReturnDescriptorPlan = {\n descriptor: string;\n isSkipped: boolean;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n isCallerAllocated?: boolean;\n isConsumed?: boolean;\n};\n\ntype ArgIndexOptions = {\n argIndexOffset: number;\n argIndexMap: Map<number, number>;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n argIndex: ArgIndexOptions;\n lengthSources: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst memberName = (girName: string): string => escapeIdentifierStart(camelCase(girName));\nconst methodExportName = (fn: GirFunction): string => memberName(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nconst renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(context, fn, {\n shouldSkip: () => false,\n isOptionalExtra: () => false,\n });\n\nconst closureAnnotation = (context: ModuleContext, base: string): string => {\n context.addRuntimeTypeImport(\"ClosureCallback\");\n\n return `${base} | ClosureCallback`;\n};\n\nconst requiresClosureMarshal = (context: ModuleContext, fn: GirFunction, ref: TypeId): boolean =>\n isClosureType(context, ref) && areClosuresInvoked(fn);\n\nconst requiresClosureAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): boolean =>\n parameter.type !== undefined && requiresClosureMarshal(context, fn, parameter.type);\n\nconst parameterAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): string => {\n const comparator = itemComparatorTsType(context, fn, parameter);\n\n if (comparator !== undefined) {\n return comparator;\n }\n\n const base = renderParameterTsType(context, parameter.type, parameter.nullable);\n\n return requiresClosureAnnotation(context, fn, parameter) ? closureAnnotation(context, base) : base;\n};\n\nconst isParameterOptional = (parameter: GirParameter, isOptionalExtra: (parameter: GirParameter) => boolean): boolean =>\n parameter.optional || isOptionalExtra(parameter);\n\nconst formatParameterPart = (name: string, annotation: string, isOptional: boolean): string =>\n isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;\n\nconst renderInputParameters = (context: ModuleContext, fn: GirFunction, options: InputParameterOptions): string => {\n const parts: string[] = [];\n let hasSeenOptional = false;\n\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (options.shouldSkip(parameter)) {\n continue;\n }\n\n const name = parameterIdentifier(parameter, index);\n\n if (isParameterOptional(parameter, options.isOptionalExtra)) {\n hasSeenOptional = true;\n }\n\n const annotation = parameterAnnotation(context, fn, parameter);\n parts.push(formatParameterPart(name, annotation, hasSeenOptional));\n }\n\n return parts.join(\", \");\n};\n\nconst isReturnedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isOutParameter(parameter) ||\n (isCallerAllocatedOut(parameter) && isCollectibleCallerOut(context, parameter)) ||\n isInoutParameter(parameter);\n\nconst returnedOutParameters = (context: ModuleContext, fn: GirFunction): InputParameter[] => {\n const folded = foldedLengthIndices(context.library, fn);\n const result: InputParameter[] = [];\n\n for (const [index, parameter] of fn.parameters.entries()) {\n if (isReturnedOutParameter(context, parameter) && !folded.has(index)) {\n result.push({ parameter, index });\n }\n }\n\n return result;\n};\n\nconst renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const outs = returnedOutParameters(context, fn);\n\n const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)\n ? undefined\n : renderTsType(context, fn.returnValue.type, fn.returnValue.nullable);\n\n if (outs.length === 0) {\n return primary ?? \"void\";\n }\n\n const outTypes = outs.map(({ parameter }) => renderTsType(context, parameter.type, parameter.nullable));\n\n return foldOutParamShape(primary, outTypes);\n};\n\nconst classifyPromisifiedParameter = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n state: { cancellableIndex: number; hasSeenOptional: boolean },\n): PromisifiedStep => {\n if (parameter.isVarargs) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n if (index === state.cancellableIndex) {\n return { hasSeenOptional: true, expression: undefined };\n }\n\n if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n const hasSeenOptional = state.hasSeenOptional || parameter.optional;\n\n return { hasSeenOptional, expression: promisifiedArgument(promisify, parameter, index, hasSeenOptional) };\n};\n\nconst collectPromisifiedArguments = (promisify: PromisifyContext, cancellableIndex: number): string[] => {\n const expressions: string[] = [];\n let hasSeenOptional = false;\n\n for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {\n const step = classifyPromisifiedParameter(promisify, parameter, index, {\n cancellableIndex,\n hasSeenOptional,\n });\n\n hasSeenOptional = step.hasSeenOptional;\n\n if (step.expression !== undefined) {\n expressions.push(step.expression);\n }\n }\n\n return expressions;\n};\n\nconst renderCancellableExpression = (parameters: GirParameter[], cancellableIndex: number): string => {\n if (cancellableIndex < 0) {\n return \"null\";\n }\n\n const parameter = parameters[cancellableIndex];\n\n return parameter === undefined ? \"null\" : parameterIdentifier(parameter, cancellableIndex);\n};\n\nconst renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishExpression: string,\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n\n const promisifyContext: PromisifyContext = {\n context,\n asyncFn,\n closureIndices: closureAndDestroyIndices(asyncFn),\n lengthSources: arrayLengthSources(context.library, asyncFn),\n };\n\n const leadingExpressions: string[] = [];\n\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n\n leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));\n const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n\n return `return promisify(${bindingExpression}, ${finishExpression}, ${cancellableExpression}${leadingArguments});`;\n};\n\nconst finishCallExpression = (asyncFn: GirFunction, finishFn: GirFunction, ownerName: string): string =>\n asyncFn.instance !== undefined && finishFn.instance === undefined\n ? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`\n : `this.${methodExportName(finishFn)}.bind(this)`;\n\nconst shouldSkipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n hasSeenOptional: boolean,\n): string => {\n const { context, asyncFn, lengthSources } = promisify;\n const sourceIndex = lengthSources.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n\n if (sourceIndex !== undefined && source !== undefined) {\n return arrayLengthArgument(source, sourceIndex);\n }\n\n return parameterCallExpression(context, parameter, index, { fn: asyncFn, isForcedNullable: hasSeenOptional });\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number =>\n parameters.findIndex((parameter) => isCancellable(context, parameter));\n\nconst renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(context, asyncFn, {\n shouldSkip: (parameter) => isCallbackParameter(context, parameter),\n isOptionalExtra: (parameter) => isCancellable(context, parameter),\n });\n\n const finishReturn = renderMethodReturnType(context, finishFn);\n\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n\n if (ref === undefined) {\n return false;\n }\n\n return context.library.typeFor(ref)?.kind === \"callback\";\n};\n\nconst renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n\n if (options.direction !== undefined) {\n parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n }\n\n if (options.isCallerAllocated === true) {\n parts.push(\"isCallerAllocated: true\");\n }\n\n if (options.isConsumed === true) {\n parts.push(\"isConsumed: true\");\n }\n\n return `{ ${parts.join(\", \")} }`;\n};\n\nconst renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): ReturnDescriptorPlan => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const descriptor = renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n argIndexMap: emittedArgIndices(fn, instanceOffset),\n isNewlyCreated: fn.instance === undefined,\n });\n\n return { descriptor, isSkipped: isSkippedPrimaryReturn(context.library, fn.returnValue) };\n};\n\nconst planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset,\n argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },\n lengthSources: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n\n if (entry !== undefined) {\n plan.push(entry);\n }\n }\n\n return plan;\n};\n\nconst isSkippedPlanParameter = (parameter: GirParameter, index: number, closureIndices: Set<number>): boolean =>\n parameter.isVarargs || closureIndices.has(index);\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { folded, closureIndices, lengthSources } = planContext;\n\n if (isSkippedPlanParameter(parameter, index, closureIndices)) {\n return undefined;\n }\n\n if (isOutParameter(parameter)) {\n return planOutParam(context, parameter, planContext.argIndex, folded.has(index));\n }\n\n if (isCallerAllocatedOut(parameter)) {\n return planCallerOut(context, parameter, planContext.argIndex);\n }\n\n if (isInoutParameter(parameter)) {\n return planInoutArgument(context, parameter, index, planContext);\n }\n\n const sourceIndex = lengthSources.get(index);\n\n if (sourceIndex !== undefined) {\n return planLengthArgument(context, parameter, sourceIndex, planContext);\n }\n\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, folded, lengthSources } = planContext;\n const lengthSourceIndex = lengthSources.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n\n return planInoutParam(context, parameter, {\n fn,\n index,\n argIndex: planContext.argIndex,\n isConsumed: folded.has(index),\n lengthSource,\n });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n isConsumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n cursor: parameter.cursor,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isConsumed }),\n inputExpr: undefined,\n };\n};\n\nconst planCallerOut = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n if (isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isCallerAllocated: true }),\n inputExpr: renderCallerOutInstance(context, parameter),\n };\n }\n\n return { paramLiteral: paramDescriptorLiteral(descriptor, {}), inputExpr: \"undefined\" };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n fn: GirFunction;\n index: number;\n argIndex: ArgIndexOptions;\n isConsumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { fn, index, argIndex, isConsumed, lengthSource } = options;\n\n if (isHandlePassedInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {\n direction: \"inout\",\n isCallerAllocated: true,\n isConsumed,\n }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"inout\", isConsumed }),\n inputExpr:\n lengthSource === undefined\n ? parameterCallExpression(context, parameter, index, { fn })\n : arrayLengthArgument(lengthSource.source, lengthSource.index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn } = planContext;\n\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n\n const descriptor =\n callback ??\n renderDescriptor(\n context,\n parameter.type,\n parameter.transferOwnership,\n planContext.argIndex,\n );\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: parameterCallExpression(context, parameter, index, { fn }),\n };\n};\n\nconst nullableHandleExpression = (name: string): string => `${name} == null ? null : getHandle(${name})`;\n\nconst handleArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n context.addRuntimeImport(\"getHandle\");\n\n return isNullable ? nullableHandleExpression(name) : `getHandle(${name})`;\n};\n\nconst closureArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n const helper = isNullable ? \"tryToClosure\" : \"toClosure\";\n context.addRuntimeImport(helper);\n\n return `${helper}(${name})`;\n};\n\nconst hashtableArgument = (context: ModuleContext, valueRef: TypeId, name: string): string => {\n if (isHandlePassing(context, valueRef)) {\n context.addRuntimeImport(\"getHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, ${nullableHandleExpression(\"v\")}]) : null`;\n }\n\n return `${name} ? globalThis.Array.from(${name}) : null`;\n};\n\nconst mapHandleExpression = (name: string, isNullable: boolean): string =>\n isNullable ? `${name}?.map((item) => getHandle(item))` : `${name}.map((item) => getHandle(item))`;\n\nconst collectionArgument = (\n context: ModuleContext,\n type: GirType | undefined,\n name: string,\n isNullable: boolean,\n): string | undefined => {\n if (type?.kind === \"hashtable\") {\n return hashtableArgument(context, type.value, name);\n }\n\n if (!isMappableSequence(context, type)) {\n return undefined;\n }\n\n context.addRuntimeImport(\"getHandle\");\n\n return mapHandleExpression(name, isNullable);\n};\n\nconst isMappableSequence = (context: ModuleContext, type: GirType | undefined): boolean => {\n if (type?.kind === \"carray\") {\n return !hasUnknownArrayLength(type) && isHandlePassing(context, type.element);\n }\n\n return type?.kind === \"list\" && isHandlePassing(context, type.element);\n};\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n options: CallExpressionOptions,\n): string => {\n const { fn, isForcedNullable = false } = options;\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n\n if (ref === undefined) {\n return name;\n }\n\n const isNullable = parameter.nullable || parameter.optional || isForcedNullable;\n\n if (requiresClosureMarshal(context, fn, ref)) {\n return closureArgument(context, name, isNullable);\n }\n\n if (isHandlePassing(context, ref)) {\n return handleArgument(context, name, isNullable);\n }\n\n const type = context.library.typeFor(ref);\n\n return collectionArgument(context, type, name, isNullable) ?? name;\n};\n\nexport {\n isCallbackParameter,\n memberName,\n methodExportName,\n renderMethodSignature,\n renderMethodReturnType,\n returnedOutParameters,\n renderPromisifiedBody,\n finishCallExpression,\n renderPromisifiedSignature,\n renderMethodBody,\n renderReturnDescriptor,\n planCallArgs,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/store/gi/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIpF,OAAO,EACH,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EAEjB,eAAe,EACf,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAqB,oBAAoB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnH,OAAO,EAAE,qBAAqB,EAAe,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,uBAAuB,GAC1B,MAAM,oBAAoB,CAAC;AAmE5B,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,qBAAqB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1F,MAAM,gBAAgB,GAAG,CAAC,EAAe,EAAU,EAAE,CAAC,UAAU,CAAC,EA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utils\";\nimport type { GirFunction } from \"../../gir/function.js\";\nimport type { GirType } from \"../../gir/type.js\";\nimport type { ModuleContext } from \"../../writer/context.js\";\nimport {\n isSkippedPrimaryReturn,\n renderCallbackType,\n renderDescriptor,\n renderSelfDescriptor,\n shouldOmitPrimaryReturn,\n} from \"../../analysis/descriptor-render.js\";\nimport {\n arrayLengthSources,\n closureAndDestroyIndices,\n emittedArgIndices,\n foldedLengthIndices,\n foldOutParamShape,\n type InputParameter,\n inputParameters,\n parameterIdentifier,\n} from \"../../analysis/param-structure.js\";\nimport { renderParameterTsType, renderTsType } from \"../../analysis/ts-type.js\";\nimport { primitiveCategoryFor } from \"../../analysis/type-shape.js\";\nimport { type GirParameter, isCallerAllocatedOut, isInoutParameter, isOutParameter } from \"../../gir/parameter.js\";\nimport { hasUnknownArrayLength, type TypeId } from \"../../gir/type-id.js\";\nimport { areClosuresInvoked } from \"./closure-invocation.js\";\nimport { itemComparatorArgDescriptors, itemComparatorTsType } from \"./item-comparators.js\";\nimport {\n isClosureType,\n isCollectibleCallerOut,\n isFixedArrayCallerOut,\n isHandlePassedInPlace,\n isHandlePassing,\n isValueType,\n renderCallerOutInstance,\n} from \"./param-marshal.js\";\n\ntype PromisifiedStep = { hasSeenOptional: boolean; expression: string | undefined };\n\ntype InputParameterOptions = {\n shouldSkip: (parameter: GirParameter) => boolean;\n isOptionalExtra: (parameter: GirParameter) => boolean;\n};\n\ntype CallExpressionOptions = {\n fn: GirFunction;\n isForcedNullable?: boolean | undefined;\n};\n\ntype MarshalledArgumentOptions = {\n context: ModuleContext;\n ref: TypeId;\n name: string;\n isNullable: boolean;\n isValueMarshalled: boolean;\n};\n\ntype PromisifyContext = {\n context: ModuleContext;\n asyncFn: GirFunction;\n closureIndices: Set<number>;\n lengthSources: Map<number, number>;\n};\n\ntype WriteMethodBodyOptions = {\n bindingExpression: string;\n returnTypeOverride?: string | undefined;\n};\n\ntype CallArgPlan = {\n paramLiteral: string;\n inputExpr: string | undefined;\n};\n\ntype ReturnDescriptorPlan = {\n descriptor: string;\n isSkipped: boolean;\n isUnpacked: boolean;\n};\n\ntype ParamDescriptorOptions = {\n direction?: \"out\" | \"inout\";\n isCallerAllocated?: boolean;\n isConsumed?: boolean;\n isUnpacked?: boolean;\n isRequired?: boolean;\n};\n\ntype ArgIndexOptions = {\n argIndexOffset: number;\n argIndexMap: Map<number, number>;\n};\n\ntype PlanArgsContext = {\n fn: GirFunction;\n instanceOffset: number;\n argIndex: ArgIndexOptions;\n lengthSources: Map<number, number>;\n closureIndices: Set<number>;\n folded: Set<number>;\n};\n\nconst memberName = (girName: string): string => escapeIdentifierStart(camelCase(girName));\nconst methodExportName = (fn: GirFunction): string => memberName(fn.name);\n\nconst arrayLengthArgument = (source: GirParameter, sourceIndex: number): string => {\n const identifier = parameterIdentifier(source, sourceIndex);\n\n return source.nullable || source.optional ? `(${identifier}?.length ?? 0)` : `${identifier}.length`;\n};\n\nconst renderMethodSignature = (context: ModuleContext, fn: GirFunction): string =>\n renderInputParameters(context, fn, {\n shouldSkip: () => false,\n isOptionalExtra: () => false,\n });\n\nconst closureAnnotation = (context: ModuleContext, base: string): string => {\n context.addRuntimeTypeImport(\"ClosureCallback\");\n\n return `${base} | ClosureCallback`;\n};\n\nconst requiresClosureMarshal = (context: ModuleContext, fn: GirFunction, ref: TypeId): boolean =>\n isClosureType(context, ref) && areClosuresInvoked(fn);\n\nconst requiresClosureAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): boolean =>\n parameter.type !== undefined && requiresClosureMarshal(context, fn, parameter.type);\n\nconst isValueRead = (parameter: GirParameter): boolean =>\n !isInoutParameter(parameter) && parameter.cType?.includes(\"const \") === true;\n\nconst parameterAnnotation = (context: ModuleContext, fn: GirFunction, parameter: GirParameter): string => {\n const comparator = itemComparatorTsType(context, fn, parameter);\n\n if (comparator !== undefined) {\n return comparator;\n }\n\n const base = renderParameterTsType(context, parameter.type, parameter.nullable, isValueRead(parameter));\n\n return requiresClosureAnnotation(context, fn, parameter) ? closureAnnotation(context, base) : base;\n};\n\nconst isParameterOptional = (parameter: GirParameter, isOptionalExtra: (parameter: GirParameter) => boolean): boolean =>\n parameter.optional || isOptionalExtra(parameter);\n\nconst formatParameterPart = (name: string, annotation: string, isOptional: boolean): string =>\n isOptional ? `${name}?: ${annotation}` : `${name}: ${annotation}`;\n\nconst renderInputParameters = (context: ModuleContext, fn: GirFunction, options: InputParameterOptions): string => {\n const parts: string[] = [];\n let hasSeenOptional = false;\n\n for (const { parameter, index } of inputParameters(context.library, fn)) {\n if (options.shouldSkip(parameter)) {\n continue;\n }\n\n const name = parameterIdentifier(parameter, index);\n\n if (isParameterOptional(parameter, options.isOptionalExtra)) {\n hasSeenOptional = true;\n }\n\n const annotation = parameterAnnotation(context, fn, parameter);\n parts.push(formatParameterPart(name, annotation, hasSeenOptional));\n }\n\n return parts.join(\", \");\n};\n\nconst isInPlaceInout = (context: ModuleContext, parameter: GirParameter): boolean =>\n context.library.isInoutInPlace && isInoutParameter(parameter) && isHandlePassedInPlace(context, parameter);\n\nconst isReturnedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isOutParameter(parameter) ||\n (isCallerAllocatedOut(parameter) &&\n (isCollectibleCallerOut(context, parameter) || isFixedArrayCallerOut(context, parameter))) ||\n (isInoutParameter(parameter) && !isInPlaceInout(context, parameter));\n\nconst returnedOutParameters = (context: ModuleContext, fn: GirFunction): InputParameter[] => {\n const folded = foldedLengthIndices(context.library, fn);\n const result: InputParameter[] = [];\n\n for (const [index, parameter] of fn.parameters.entries()) {\n if (isReturnedOutParameter(context, parameter) && !folded.has(index)) {\n result.push({ parameter, index });\n }\n }\n\n return result;\n};\n\nconst isUnwrappedValue = (context: ModuleContext, ref: TypeId | undefined): boolean =>\n context.library.isValueUnwrapped && ref !== undefined && isValueType(context, ref);\n\nconst renderReturnedTsType = (context: ModuleContext, ref: TypeId | undefined, isNullable: boolean): string =>\n isUnwrappedValue(context, ref) ? \"unknown\" : renderTsType(context, ref, isNullable);\n\nconst isUnpackedOutParameter = (context: ModuleContext, parameter: GirParameter): boolean =>\n isCallerAllocatedOut(parameter) &&\n isCollectibleCallerOut(context, parameter) &&\n isUnwrappedValue(context, parameter.type);\n\nconst renderOutTsType = (context: ModuleContext, parameter: GirParameter): string =>\n isUnpackedOutParameter(context, parameter)\n ? \"unknown\"\n : renderTsType(context, parameter.type, parameter.nullable);\n\nconst renderMethodReturnType = (context: ModuleContext, fn: GirFunction): string => {\n const outs = returnedOutParameters(context, fn);\n\n const primary = shouldOmitPrimaryReturn(context.library, fn.returnValue)\n ? undefined\n : renderReturnedTsType(context, fn.returnValue.type, fn.returnValue.nullable);\n\n if (outs.length === 0) {\n return primary ?? \"void\";\n }\n\n const outTypes = outs.map(({ parameter }) => renderOutTsType(context, parameter));\n\n return foldOutParamShape(primary, outTypes);\n};\n\nconst classifyPromisifiedParameter = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n state: { cancellableIndex: number; hasSeenOptional: boolean },\n): PromisifiedStep => {\n if (parameter.isVarargs) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n if (index === state.cancellableIndex) {\n return { hasSeenOptional: true, expression: undefined };\n }\n\n if (shouldSkipPromisifiedParameter(promisify, parameter, index)) {\n return { hasSeenOptional: state.hasSeenOptional, expression: undefined };\n }\n\n const hasSeenOptional = state.hasSeenOptional || parameter.optional;\n\n return { hasSeenOptional, expression: promisifiedArgument(promisify, parameter, index, hasSeenOptional) };\n};\n\nconst collectPromisifiedArguments = (promisify: PromisifyContext, cancellableIndex: number): string[] => {\n const expressions: string[] = [];\n let hasSeenOptional = false;\n\n for (const [index, parameter] of promisify.asyncFn.parameters.entries()) {\n const step = classifyPromisifiedParameter(promisify, parameter, index, {\n cancellableIndex,\n hasSeenOptional,\n });\n\n hasSeenOptional = step.hasSeenOptional;\n\n if (step.expression !== undefined) {\n expressions.push(step.expression);\n }\n }\n\n return expressions;\n};\n\nconst renderCancellableExpression = (parameters: GirParameter[], cancellableIndex: number): string => {\n if (cancellableIndex < 0) {\n return \"null\";\n }\n\n const parameter = parameters[cancellableIndex];\n\n return parameter === undefined ? \"null\" : parameterIdentifier(parameter, cancellableIndex);\n};\n\nconst shouldTrimFinishBoolean = (context: ModuleContext, finishFn: GirFunction): boolean =>\n context.library.isFinishTrimmed &&\n finishFn.throws &&\n !shouldOmitPrimaryReturn(context.library, finishFn.returnValue) &&\n primitiveCategoryFor(context.library, finishFn.returnValue.type) === \"boolean\" &&\n returnedOutParameters(context, finishFn).length > 0;\n\nconst promisifiedFinishExpression = (\n context: ModuleContext,\n finishFn: GirFunction,\n finishExpression: string,\n): string => {\n if (!shouldTrimFinishBoolean(context, finishFn)) {\n return finishExpression;\n }\n\n context.addRuntimeImport(\"trimFinish\");\n\n return `trimFinish(${finishExpression})`;\n};\n\nconst renderPromisifiedBody = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishTarget: { fn: GirFunction; expression: string },\n bindingExpression: string,\n): string => {\n context.addRuntimeImport(\"promisify\");\n const finish = promisifiedFinishExpression(context, finishTarget.fn, finishTarget.expression);\n const cancellableIndex = findCancellableIndex(context, asyncFn.parameters);\n\n const promisifyContext: PromisifyContext = {\n context,\n asyncFn,\n closureIndices: closureAndDestroyIndices(asyncFn),\n lengthSources: arrayLengthSources(context.library, asyncFn),\n };\n\n const leadingExpressions: string[] = [];\n\n if (asyncFn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n leadingExpressions.push(\"getHandle(this)\");\n }\n\n leadingExpressions.push(...collectPromisifiedArguments(promisifyContext, cancellableIndex));\n const cancellableExpression = renderCancellableExpression(asyncFn.parameters, cancellableIndex);\n const leadingArguments = leadingExpressions.length > 0 ? `, ${leadingExpressions.join(\", \")}` : \"\";\n\n return `return promisify(${bindingExpression}, ${finish}, ${cancellableExpression}${leadingArguments});`;\n};\n\nconst finishCallExpression = (asyncFn: GirFunction, finishFn: GirFunction, ownerName: string): string =>\n asyncFn.instance !== undefined && finishFn.instance === undefined\n ? `${ownerName}.${methodExportName(finishFn)}.bind(${ownerName})`\n : `this.${methodExportName(finishFn)}.bind(this)`;\n\nconst shouldSkipPromisifiedParameter = (promisify: PromisifyContext, parameter: GirParameter, index: number): boolean =>\n isCallbackParameter(promisify.context, parameter) ||\n promisify.closureIndices.has(index) ||\n (isOutParameter(parameter) && !isCallerAllocatedOut(parameter));\n\nconst promisifiedArgument = (\n promisify: PromisifyContext,\n parameter: GirParameter,\n index: number,\n hasSeenOptional: boolean,\n): string => {\n const { context, asyncFn, lengthSources } = promisify;\n const sourceIndex = lengthSources.get(index);\n const source = sourceIndex === undefined ? undefined : asyncFn.parameters[sourceIndex];\n\n if (sourceIndex !== undefined && source !== undefined) {\n return arrayLengthArgument(source, sourceIndex);\n }\n\n return parameterCallExpression(context, parameter, index, { fn: asyncFn, isForcedNullable: hasSeenOptional });\n};\n\nconst findCancellableIndex = (context: ModuleContext, parameters: GirParameter[]): number =>\n parameters.findIndex((parameter) => isCancellable(context, parameter));\n\nconst renderPromisifiedSignature = (\n context: ModuleContext,\n asyncFn: GirFunction,\n finishFn: GirFunction,\n): { signature: string; returnType: string } => {\n const signature = renderInputParameters(context, asyncFn, {\n shouldSkip: (parameter) => isCallbackParameter(context, parameter),\n isOptionalExtra: (parameter) => isCancellable(context, parameter),\n });\n\n const finishReturn = shouldTrimFinishBoolean(context, finishFn)\n ? foldOutParamShape(\n undefined,\n returnedOutParameters(context, finishFn).map(({ parameter }) => renderOutTsType(context, parameter)),\n )\n : renderMethodReturnType(context, finishFn);\n\n return { signature, returnType: `Promise<${finishReturn}>` };\n};\n\nconst isCancellable = (context: ModuleContext, parameter: GirParameter): boolean =>\n parameter.type !== undefined && context.library.nameFor(parameter.type)?.typeName === \"Cancellable\";\n\nconst isCallbackParameter = (context: ModuleContext, parameter: GirParameter): boolean => {\n const ref = parameter.type;\n\n if (ref === undefined) {\n return false;\n }\n\n return context.library.typeFor(ref)?.kind === \"callback\";\n};\n\nconst renderMethodBody = (context: ModuleContext, fn: GirFunction, options: WriteMethodBodyOptions): string => {\n const { bindingExpression, returnTypeOverride } = options;\n\n const inputs = planCallArgs(context, fn)\n .map((arg) => arg.inputExpr)\n .filter((expression): expression is string => expression !== undefined);\n\n const callExpression = `${bindingExpression}(${inputs.join(\", \")})`;\n const annotation = returnTypeOverride ?? renderMethodReturnType(context, fn);\n\n return annotation === \"void\" ? `${callExpression};` : `return ${callExpression} as ${annotation};`;\n};\n\nconst paramDescriptorLiteral = (descriptor: string, options: ParamDescriptorOptions): string => {\n const parts = [`type: ${descriptor}`];\n\n if (options.direction !== undefined) {\n parts.push(`direction: ${sourceStringLiteral(options.direction)}`);\n }\n\n if (options.isCallerAllocated === true) {\n parts.push(\"isCallerAllocated: true\");\n }\n\n if (options.isConsumed === true) {\n parts.push(\"isConsumed: true\");\n }\n\n if (options.isUnpacked === true) {\n parts.push(\"isUnpacked: true\");\n }\n\n if (options.isRequired === true) {\n parts.push(\"isRequired: true\");\n }\n\n return `{ ${parts.join(\", \")} }`;\n};\n\nconst renderReturnDescriptor = (context: ModuleContext, fn: GirFunction): ReturnDescriptorPlan => {\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const descriptor = renderDescriptor(context, fn.returnValue.type, fn.returnValue.transferOwnership, {\n argIndexOffset: instanceOffset,\n argIndexMap: emittedArgIndices(fn, instanceOffset),\n isNewlyCreated: fn.instance === undefined,\n });\n\n return {\n descriptor,\n isSkipped: isSkippedPrimaryReturn(context.library, fn.returnValue),\n isUnpacked: isUnwrappedValue(context, fn.returnValue.type),\n };\n};\n\nconst planCallArgs = (context: ModuleContext, fn: GirFunction): CallArgPlan[] => {\n const plan: CallArgPlan[] = [];\n\n if (fn.instance !== undefined) {\n context.addRuntimeImport(\"getHandle\");\n\n plan.push({\n paramLiteral: `{ type: ${renderSelfDescriptor(context, fn.instance)} }`,\n inputExpr: \"getHandle(this)\",\n });\n }\n\n const instanceOffset = fn.instance === undefined ? 0 : 1;\n\n const planContext: PlanArgsContext = {\n fn,\n instanceOffset,\n argIndex: { argIndexOffset: instanceOffset, argIndexMap: emittedArgIndices(fn, instanceOffset) },\n lengthSources: arrayLengthSources(context.library, fn),\n closureIndices: closureAndDestroyIndices(fn),\n folded: foldedLengthIndices(context.library, fn),\n };\n\n for (const [index, parameter] of fn.parameters.entries()) {\n const entry = planParameter(context, parameter, index, planContext);\n\n if (entry !== undefined) {\n plan.push(entry);\n }\n }\n\n return plan;\n};\n\nconst isSkippedPlanParameter = (parameter: GirParameter, index: number, closureIndices: Set<number>): boolean =>\n parameter.isVarargs || closureIndices.has(index);\n\nconst isRequiredParameter = (parameter: GirParameter): boolean => !parameter.nullable && !parameter.optional;\n\nconst planParameter = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan | undefined => {\n const { folded, closureIndices, lengthSources } = planContext;\n\n if (isSkippedPlanParameter(parameter, index, closureIndices)) {\n return undefined;\n }\n\n if (isOutParameter(parameter)) {\n return planOutParam(context, parameter, planContext.argIndex, folded.has(index));\n }\n\n if (isCallerAllocatedOut(parameter)) {\n return planCallerOut(context, parameter, planContext.argIndex);\n }\n\n if (isInoutParameter(parameter)) {\n return planInoutArgument(context, parameter, index, planContext);\n }\n\n const sourceIndex = lengthSources.get(index);\n\n if (sourceIndex !== undefined) {\n return planLengthArgument(context, parameter, sourceIndex, planContext);\n }\n\n return planInParam(context, parameter, index, planContext);\n};\n\nconst planInoutArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn, folded, lengthSources } = planContext;\n const lengthSourceIndex = lengthSources.get(index);\n const lengthSourceParam = lengthSourceIndex === undefined ? undefined : fn.parameters[lengthSourceIndex];\n\n const lengthSource =\n lengthSourceIndex !== undefined && lengthSourceParam !== undefined\n ? { source: lengthSourceParam, index: lengthSourceIndex }\n : undefined;\n\n return planInoutParam(context, parameter, {\n fn,\n index,\n argIndex: planContext.argIndex,\n isConsumed: folded.has(index),\n lengthSource,\n });\n};\n\nconst planLengthArgument = (\n context: ModuleContext,\n parameter: GirParameter,\n sourceIndex: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const source = planContext.fn.parameters[sourceIndex];\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, planContext.argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {}),\n inputExpr: source === undefined ? \"0\" : arrayLengthArgument(source, sourceIndex),\n };\n};\n\nconst planOutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n isConsumed: boolean,\n): CallArgPlan => {\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n cursor: parameter.cursor,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\", isConsumed }),\n inputExpr: undefined,\n };\n};\n\nconst planCallerOut = (\n context: ModuleContext,\n parameter: GirParameter,\n argIndex: ArgIndexOptions,\n): CallArgPlan => {\n if (isCollectibleCallerOut(context, parameter)) {\n context.addRuntimeImport(\"getHandle\");\n\n return {\n paramLiteral: paramDescriptorLiteral(renderDescriptor(context, parameter.type, \"none\", argIndex), {\n direction: \"out\",\n isCallerAllocated: true,\n isUnpacked: isUnpackedOutParameter(context, parameter),\n }),\n inputExpr: renderCallerOutInstance(context, parameter),\n };\n }\n\n if (isFixedArrayCallerOut(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", {\n ...argIndex,\n isCallerAllocated: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { direction: \"out\" }),\n inputExpr: undefined,\n };\n }\n\n return {\n paramLiteral: paramDescriptorLiteral(renderDescriptor(context, parameter.type, \"none\", argIndex), {}),\n inputExpr: \"undefined\",\n };\n};\n\nconst planInoutParam = (\n context: ModuleContext,\n parameter: GirParameter,\n options: {\n fn: GirFunction;\n index: number;\n argIndex: ArgIndexOptions;\n isConsumed: boolean;\n lengthSource?: { source: GirParameter; index: number } | undefined;\n },\n): CallArgPlan => {\n const { fn, index, argIndex, isConsumed, lengthSource } = options;\n\n if (isHandlePassedInPlace(context, parameter)) {\n const descriptor = renderDescriptor(context, parameter.type, \"none\", argIndex);\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {\n direction: \"inout\",\n isCallerAllocated: true,\n isConsumed: isConsumed || context.library.isInoutInPlace,\n isRequired: isRequiredParameter(parameter),\n }),\n inputExpr: parameterIdentifier(parameter, index),\n };\n }\n\n const descriptor = renderDescriptor(context, parameter.type, parameter.transferOwnership, {\n ...argIndex,\n hasOutIndirection: true,\n });\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, {\n direction: \"inout\",\n isConsumed,\n isRequired: lengthSource === undefined && isRequiredParameter(parameter),\n }),\n inputExpr:\n lengthSource === undefined\n ? parameterCallExpression(context, parameter, index, { fn })\n : arrayLengthArgument(lengthSource.source, lengthSource.index),\n };\n};\n\nconst planInParam = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n planContext: PlanArgsContext,\n): CallArgPlan => {\n const { fn } = planContext;\n\n const callback = renderCallbackType(\n context,\n parameter.type,\n parameter,\n itemComparatorArgDescriptors(context, fn, parameter),\n );\n\n const descriptor =\n callback ??\n renderDescriptor(\n context,\n parameter.type,\n parameter.transferOwnership,\n planContext.argIndex,\n );\n\n return {\n paramLiteral: paramDescriptorLiteral(descriptor, { isRequired: isRequiredParameter(parameter) }),\n inputExpr: parameterCallExpression(context, parameter, index, { fn }),\n };\n};\n\nconst nullableHandleExpression = (name: string): string => `${name} == null ? null : getHandle(${name})`;\n\nconst handleArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n context.addRuntimeImport(\"getHandle\");\n\n return isNullable ? nullableHandleExpression(name) : `getHandle(${name})`;\n};\n\nconst closureArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n const helper = isNullable ? \"tryToClosure\" : \"toClosure\";\n context.addRuntimeImport(helper);\n\n return `${helper}(${name})`;\n};\n\nconst valueArgument = (context: ModuleContext, name: string, isNullable: boolean): string => {\n const helper = isNullable ? \"tryToValueHandle\" : \"toValueHandle\";\n context.addRuntimeImport(helper);\n\n return `${helper}(${name})`;\n};\n\nconst hashtableArgument = (\n context: ModuleContext,\n valueRef: TypeId,\n name: string,\n isValueMarshalled: boolean,\n): string => {\n if (isValueMarshalled && isValueType(context, valueRef)) {\n context.addRuntimeImport(\"toValueHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, toValueHandle(v)]) : null`;\n }\n\n if (isHandlePassing(context, valueRef)) {\n context.addRuntimeImport(\"getHandle\");\n\n return `${name} ? globalThis.Array.from(${name}).map(([k, v]) => [k, ${nullableHandleExpression(\"v\")}]) : null`;\n }\n\n return `${name} ? globalThis.Array.from(${name}) : null`;\n};\n\nconst mapItemExpression = (name: string, isNullable: boolean, helper: string): string =>\n isNullable ? `${name}?.map((item) => ${helper}(item))` : `${name}.map((item) => ${helper}(item))`;\n\nconst itemHelper = (context: ModuleContext, element: TypeId, isValueMarshalled: boolean): string => {\n const helper = isValueMarshalled && isValueType(context, element) ? \"toValueHandle\" : \"getHandle\";\n context.addRuntimeImport(helper);\n\n return helper;\n};\n\nconst collectionArgument = (options: MarshalledArgumentOptions & { type: GirType | undefined }): string | undefined => {\n const { context, type, name, isNullable, isValueMarshalled } = options;\n\n if (type?.kind === \"hashtable\") {\n return hashtableArgument(context, type.value, name, isValueMarshalled);\n }\n\n const element = mappableElement(context, type);\n\n if (element === undefined) {\n return undefined;\n }\n\n return mapItemExpression(name, isNullable, itemHelper(context, element, isValueMarshalled));\n};\n\nconst mappableElement = (context: ModuleContext, type: GirType | undefined): TypeId | undefined => {\n if (type?.kind === \"carray\") {\n return hasUnknownArrayLength(type) ? undefined : mappableRef(context, type.element);\n }\n\n return type?.kind === \"list\" ? mappableRef(context, type.element) : undefined;\n};\n\nconst mappableRef = (context: ModuleContext, element: TypeId): TypeId | undefined =>\n isHandlePassing(context, element) ? element : undefined;\n\nconst parameterCallExpression = (\n context: ModuleContext,\n parameter: GirParameter,\n index: number,\n options: CallExpressionOptions,\n): string => {\n const { fn, isForcedNullable = false } = options;\n const name = parameterIdentifier(parameter, index);\n const ref = parameter.type;\n\n if (ref === undefined) {\n return name;\n }\n\n const isNullable = parameter.nullable || parameter.optional || isForcedNullable;\n\n if (requiresClosureMarshal(context, fn, ref)) {\n return closureArgument(context, name, isNullable);\n }\n\n const marshalled = marshalledArgument({\n context,\n ref,\n name,\n isNullable,\n isValueMarshalled: isValueRead(parameter),\n });\n\n if (marshalled !== undefined) {\n return marshalled;\n }\n\n const type = context.library.typeFor(ref);\n\n return (\n collectionArgument({\n context,\n ref,\n type,\n name,\n isNullable,\n isValueMarshalled: isValueRead(parameter),\n }) ?? name\n );\n};\n\nconst marshalledArgument = (options: MarshalledArgumentOptions): string | undefined => {\n const { context, ref, name, isNullable, isValueMarshalled } = options;\n\n if (isValueMarshalled && isValueType(context, ref)) {\n return valueArgument(context, name, isNullable);\n }\n\n return isHandlePassing(context, ref) ? handleArgument(context, name, isNullable) : undefined;\n};\n\nexport {\n isCallbackParameter,\n memberName,\n methodExportName,\n renderMethodSignature,\n renderMethodReturnType,\n returnedOutParameters,\n renderPromisifiedBody,\n finishCallExpression,\n renderPromisifiedSignature,\n shouldTrimFinishBoolean,\n renderMethodBody,\n renderReturnDescriptor,\n planCallArgs,\n};\n"]}
|
|
@@ -2,13 +2,20 @@ import type { TypeId } from "../../gir/type-id.js";
|
|
|
2
2
|
import type { GirType } from "../../gir/type.js";
|
|
3
3
|
import type { ModuleContext } from "../../writer/context.js";
|
|
4
4
|
import { type GirParameter } from "../../gir/parameter.js";
|
|
5
|
+
type TypeName = {
|
|
6
|
+
namespaceName: string;
|
|
7
|
+
typeName: string;
|
|
8
|
+
};
|
|
5
9
|
declare const isHandlePassedInPlace: (context: ModuleContext, parameter: GirParameter) => boolean;
|
|
6
10
|
declare const underlyingType: (context: ModuleContext, ref: TypeId) => GirType | undefined;
|
|
7
11
|
declare const renderCallerOutInstance: (context: ModuleContext, parameter: GirParameter) => string;
|
|
8
12
|
declare const isCollectibleCallerOut: (context: ModuleContext, parameter: GirParameter) => boolean;
|
|
13
|
+
declare const isFixedArrayCallerOut: (context: ModuleContext, parameter: GirParameter) => boolean;
|
|
9
14
|
declare const isAllocatableCallerOut: (context: ModuleContext, parameter: GirParameter) => boolean;
|
|
10
15
|
declare const isRecordInout: (context: ModuleContext, parameter: GirParameter) => boolean;
|
|
11
16
|
declare const isHandlePassing: (context: ModuleContext, ref: TypeId) => boolean;
|
|
12
17
|
declare const isClosureType: (context: ModuleContext, ref: TypeId) => boolean;
|
|
13
|
-
|
|
18
|
+
declare const isValueType: (context: ModuleContext, ref: TypeId) => boolean;
|
|
19
|
+
declare const isValueTypeName: (name: TypeName) => boolean;
|
|
20
|
+
export { isAllocatableCallerOut, isClosureType, isValueType, isValueTypeName, isHandlePassedInPlace, isCollectibleCallerOut, isFixedArrayCallerOut, isRecordInout, isHandlePassing, renderCallerOutInstance, underlyingType, };
|
|
14
21
|
//# sourceMappingURL=param-marshal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param-marshal.d.ts","sourceRoot":"","sources":["../../../src/store/gi/param-marshal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"param-marshal.d.ts","sourceRoot":"","sources":["../../../src/store/gi/param-marshal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,KAAK,YAAY,EAA0C,MAAM,wBAAwB,CAAC;AAInG,KAAK,QAAQ,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MA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