@idlizer/core 2.1.7 → 2.1.9-arktscgen-5
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/build/lib/src/IndentedPrinter.js +2 -0
- package/build/lib/src/Language.d.ts +1 -0
- package/build/lib/src/Language.js +3 -0
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +18 -3
- package/build/lib/src/LanguageWriters/ArgConvertors.js +154 -23
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +29 -4
- package/build/lib/src/LanguageWriters/LanguageWriter.js +42 -0
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +23 -10
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.d.ts +24 -0
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.js +69 -0
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.d.ts +25 -0
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +128 -0
- package/build/lib/src/LanguageWriters/index.js +4 -0
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +5 -5
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +25 -23
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +1 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +11 -2
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +43 -10
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -2
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +20 -11
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +2 -2
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +3 -3
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +149 -0
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +495 -0
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +2 -2
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +6 -4
- package/build/lib/src/LibraryInterface.d.ts +2 -0
- package/build/lib/src/config.d.ts +132 -66
- package/build/lib/src/config.js +4 -2
- package/build/lib/src/configDescriber.d.ts +1 -1
- package/build/lib/src/configDescriber.js +1 -1
- package/build/lib/src/from-idl/DtsPrinter.js +10 -7
- package/build/lib/src/from-idl/IDLLinter.d.ts +0 -1
- package/build/lib/src/from-idl/IDLLinter.js +0 -6
- package/build/lib/src/from-idl/deserialize.js +7 -21
- package/build/lib/src/idl.d.ts +4 -13
- package/build/lib/src/idl.js +24 -58
- package/build/lib/src/idlize.js +2 -0
- package/build/lib/src/index.d.ts +2 -0
- package/build/lib/src/index.js +2 -0
- package/build/lib/src/peer-generation/LayoutManager.d.ts +4 -1
- package/build/lib/src/peer-generation/LayoutManager.js +5 -1
- package/build/lib/src/peer-generation/Materialized.d.ts +7 -3
- package/build/lib/src/peer-generation/Materialized.js +18 -3
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +5 -2
- package/build/lib/src/peer-generation/PeerLibrary.js +26 -6
- package/build/lib/src/peer-generation/PeerMethod.d.ts +1 -1
- package/build/lib/src/peer-generation/getSuperType.d.ts +5 -0
- package/build/lib/src/peer-generation/getSuperType.js +55 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +4 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +7 -0
- package/build/lib/src/peer-generation/idl/common.js +1 -1
- package/build/lib/src/peer-generation/isExternalType.d.ts +4 -0
- package/build/lib/src/peer-generation/isExternalType.js +15 -0
- package/build/lib/src/peer-generation/isMaterialized.js +15 -7
- package/build/lib/src/util.d.ts +2 -0
- package/build/lib/src/util.js +17 -7
- package/build/lib/src/visitor.js +0 -1
- package/package.json +2 -2
- package/webidl2.js/LICENSE +0 -21
- package/webidl2.js/README.md +0 -827
- package/webidl2.js/dist/package.json +0 -3
package/build/lib/src/config.js
CHANGED
|
@@ -39,7 +39,8 @@ export const CoreConfigurationSchema = D.object({
|
|
|
39
39
|
forceResource: T.stringArray(),
|
|
40
40
|
forceContext: T.stringArray(),
|
|
41
41
|
hooks: D.map(D.string(), D.map(D.string(), HookMethodSchema)).onMerge('replace'),
|
|
42
|
-
|
|
42
|
+
externalTypes: D.map(D.string(), D.string()).onMerge('replace'),
|
|
43
|
+
externalPackages: T.stringArray(),
|
|
43
44
|
moduleName: D.string(),
|
|
44
45
|
modules: D.map(D.string(), ModuleConfigurationSchema).onMerge('replace'),
|
|
45
46
|
globalPackages: T.stringArray()
|
|
@@ -58,7 +59,8 @@ export const defaultCoreConfiguration = {
|
|
|
58
59
|
forceResource: [],
|
|
59
60
|
forceContext: [],
|
|
60
61
|
hooks: new Map(),
|
|
61
|
-
|
|
62
|
+
externalTypes: new Map(),
|
|
63
|
+
externalPackages: [],
|
|
62
64
|
moduleName: "",
|
|
63
65
|
modules: new Map(),
|
|
64
66
|
globalPackages: []
|
|
@@ -102,7 +102,7 @@ export declare const D: {
|
|
|
102
102
|
string<T_3 extends string>(x: T_3): ConfigDescriberLeaf<T_3>;
|
|
103
103
|
number<T_4 extends number>(x: T_4): ConfigDescriberLeaf<T_4>;
|
|
104
104
|
boolean<T_5 extends boolean>(x: T_5): ConfigDescriberLeaf<T_5>;
|
|
105
|
-
null(
|
|
105
|
+
null(): ConfigDescriberLeaf<null>;
|
|
106
106
|
};
|
|
107
107
|
combine<A, B>(a: ConfigDescriberObjectLeaf<A>, b: ConfigDescriberObjectLeaf<B>): ConfigDescriberObjectLeaf<A & B>;
|
|
108
108
|
printJSONSchema<T_6>(schema: ConfigDescriberLeaf<T_6>): string;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
import { indentedBy, isInNamespace } from "../util";
|
|
16
|
-
import { IDLEntity, IDLKind, getExtAttribute, getVerbatimDts, hasExtAttribute, isCallback, isConstructor, isContainerType, isEnum, isInterface, isMethod, isPrimitiveType, isProperty, isReferenceType, isSyntheticEntry, isTypeParameterType, isTypedef, isUnionType, isImport, isVersion, isNamespace, IDLExtendedAttributes, IDLAccessorAttribute, IDLVoidType, IDLStringType, IDLUndefinedType, isCallable,
|
|
16
|
+
import { IDLEntity, IDLKind, getExtAttribute, getVerbatimDts, hasExtAttribute, isCallback, isConstructor, isContainerType, isEnum, isInterface, isMethod, isPrimitiveType, isProperty, isReferenceType, isSyntheticEntry, isTypeParameterType, isTypedef, isUnionType, isImport, isVersion, isNamespace, IDLExtendedAttributes, IDLAccessorAttribute, IDLVoidType, IDLStringType, IDLUndefinedType, isCallable, IDLAnyType, IDLContainerUtils, DebugUtils, mixMethodParametersAndTags, createReferenceType, transformMethodsAsync2ReturnPromise, linearizeNamespaceMembers, isNamedNode, IDLThisType, isOptionalType, IDLI8Type, IDLU8Type, IDLI16Type, IDLU16Type, IDLI32Type, IDLU32Type, IDLI64Type, IDLU64Type, IDLF16Type, IDLF32Type, IDLF64Type, IDLBufferType, isUnspecifiedGenericType, IDLUnknownType, IDLBooleanType, IDLNumberType, IDLPointerType, IDLInterfaceSubkind, escapeIDLKeyword, getNamespacesPathFor, IDLBigintType, IDLDate, IDLFunctionType, getQualifiedName, IDLObjectType } from "../idl";
|
|
17
17
|
import { resolveSyntheticType, toIDLFile } from "./deserialize";
|
|
18
18
|
import { Language } from "../Language";
|
|
19
19
|
import { warn } from "../util";
|
|
@@ -103,7 +103,7 @@ export class CustomPrintVisitor {
|
|
|
103
103
|
let interfaces = node.inheritance;
|
|
104
104
|
let keyword = "extends";
|
|
105
105
|
if (node.subkind === IDLInterfaceSubkind.Class) {
|
|
106
|
-
const superType =
|
|
106
|
+
const superType = node.inheritance.find(it => hasExtAttribute(it, IDLExtendedAttributes.Extends));
|
|
107
107
|
if (superType)
|
|
108
108
|
typeSpec += ` extends ${this.printTypeForTS(superType)}`;
|
|
109
109
|
interfaces = interfaces.slice(1);
|
|
@@ -129,8 +129,11 @@ export class CustomPrintVisitor {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
printMethod(node, forceAsFree = false) {
|
|
132
|
-
|
|
132
|
+
let returnType = node.returnType && !(isConstructor(node) && this.currentInterface.subkind === IDLInterfaceSubkind.Class)
|
|
133
133
|
? `: ${this.printTypeForTS(node.returnType, true)}` : "";
|
|
134
|
+
if (hasExtAttribute(node, IDLExtendedAttributes.CommonMethod)) {
|
|
135
|
+
returnType = `: ${this.currentInterface.name}`;
|
|
136
|
+
}
|
|
134
137
|
const name = isConstructor(node)
|
|
135
138
|
? this.currentInterface.subkind === IDLInterfaceSubkind.Class ? "constructor" : "new"
|
|
136
139
|
: getName(node);
|
|
@@ -188,11 +191,11 @@ export class CustomPrintVisitor {
|
|
|
188
191
|
this.print(`${isInNamespace(node) ? "" : "declare "}enum ${node.name} {`);
|
|
189
192
|
this.pushIndent();
|
|
190
193
|
node.elements.forEach(it => {
|
|
191
|
-
const initializer = (it.type === IDLStringType ? `"${it.initializer}"` :
|
|
192
|
-
this.print(`${getName(it)}
|
|
194
|
+
const initializer = it.initializer ? (it.type === IDLStringType ? ` = "${it.initializer}"` : ` = ${it.initializer}`) : "";
|
|
195
|
+
this.print(`${getName(it)}${initializer},`);
|
|
193
196
|
let originalName = getExtAttribute(it, IDLExtendedAttributes.OriginalEnumMemberName);
|
|
194
197
|
if (originalName && originalName != getName(it)) {
|
|
195
|
-
this.print(`${originalName}
|
|
198
|
+
this.print(`${originalName}${initializer},`);
|
|
196
199
|
}
|
|
197
200
|
});
|
|
198
201
|
this.popIndent();
|
|
@@ -290,7 +293,7 @@ export class CustomPrintVisitor {
|
|
|
290
293
|
case IDLUndefinedType: return undefinedToVoid ? "void" : "undefined";
|
|
291
294
|
case IDLStringType: return "string";
|
|
292
295
|
case IDLVoidType: return "void";
|
|
293
|
-
case IDLThisType: return
|
|
296
|
+
case IDLThisType: return this.currentInterface.name;
|
|
294
297
|
case IDLBigintType:
|
|
295
298
|
case IDLPointerType: return "number|bigint";
|
|
296
299
|
case IDLDate: return "Date";
|
|
@@ -39,7 +39,6 @@ export declare class IDLLinter {
|
|
|
39
39
|
protected check(node: idl.IDLNode): void;
|
|
40
40
|
protected checkValidAttributes(entry: idl.IDLEntry, validAttributes: string[]): void;
|
|
41
41
|
protected checkEnumConsistency(entry: idl.IDLEnum): void;
|
|
42
|
-
private static builtinReferences;
|
|
43
42
|
protected checkReferenceResolved(reference: idl.IDLReferenceType): void;
|
|
44
43
|
}
|
|
45
44
|
interface IDLLinterDiagnosticsSummary {
|
|
@@ -129,8 +129,6 @@ export class IDLLinter {
|
|
|
129
129
|
}
|
|
130
130
|
checkReferenceResolved(reference) {
|
|
131
131
|
var _a, _b, _c, _d, _e, _f;
|
|
132
|
-
if (IDLLinter.builtinReferences.includes(reference.name))
|
|
133
|
-
return;
|
|
134
132
|
if (this.context.hasTypeParameter(reference.name)) {
|
|
135
133
|
return;
|
|
136
134
|
}
|
|
@@ -156,10 +154,6 @@ export class IDLLinter {
|
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
|
-
IDLLinter.builtinReferences = [
|
|
160
|
-
idl.IDLTopType.name,
|
|
161
|
-
idl.IDLObjectType.name,
|
|
162
|
-
];
|
|
163
157
|
export class IDLLinterError extends Error {
|
|
164
158
|
constructor(message, size) {
|
|
165
159
|
super(message);
|
|
@@ -116,13 +116,12 @@ class IDLDeserializer {
|
|
|
116
116
|
interfaceSubkind(node) {
|
|
117
117
|
var _a, _b;
|
|
118
118
|
const nodeIDLEntity = (_b = (_a = node.extAttrs.find(it => it.name === "Entity")) === null || _a === void 0 ? void 0 : _a.rhs) === null || _b === void 0 ? void 0 : _b.value;
|
|
119
|
-
|
|
120
|
-
return idl.IDLInterfaceSubkind.Class;
|
|
121
|
-
|
|
122
|
-
return idl.IDLInterfaceSubkind.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return idl.IDLInterfaceSubkind.Interface;
|
|
119
|
+
switch (nodeIDLEntity) {
|
|
120
|
+
case idl.IDLEntity.Class: return idl.IDLInterfaceSubkind.Class;
|
|
121
|
+
case idl.IDLEntity.Literal: return idl.IDLInterfaceSubkind.AnonymousInterface;
|
|
122
|
+
case idl.IDLEntity.Tuple: return idl.IDLInterfaceSubkind.Tuple;
|
|
123
|
+
default: return idl.IDLInterfaceSubkind.Interface;
|
|
124
|
+
}
|
|
126
125
|
}
|
|
127
126
|
toIDLInterface(file, node) {
|
|
128
127
|
const generics = this.extractGenerics(node.extAttrs);
|
|
@@ -133,29 +132,16 @@ class IDLDeserializer {
|
|
|
133
132
|
return [];
|
|
134
133
|
}
|
|
135
134
|
const implementations = [];
|
|
136
|
-
let extension = undefined;
|
|
137
135
|
node.inheritance.forEach(it => {
|
|
138
136
|
var _a;
|
|
139
137
|
const attributes = it.extAttrs;
|
|
140
138
|
const parentTypeArgs = this.extractTypeArguments(file, attributes !== null && attributes !== void 0 ? attributes : [], idl.IDLExtendedAttributes.TypeArguments);
|
|
141
139
|
const attrs = (_a = this.toExtendedAttributes(attributes !== null && attributes !== void 0 ? attributes : [])) === null || _a === void 0 ? void 0 : _a.filter(it => it.name !== idl.IDLExtendedAttributes.TypeArguments);
|
|
142
|
-
const baseClass = attrs === null || attrs === void 0 ? void 0 : attrs.find(it => it.name === idl.IDLExtendedAttributes.Extends);
|
|
143
140
|
const ref = idl.createReferenceType(it.inheritance, parentTypeArgs, {
|
|
144
141
|
extendedAttributes: attrs
|
|
145
142
|
});
|
|
146
|
-
|
|
147
|
-
extension = ref;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
implementations.push(ref);
|
|
151
|
-
}
|
|
143
|
+
implementations.push(ref);
|
|
152
144
|
});
|
|
153
|
-
if (subkind === idl.IDLInterfaceSubkind.Class && extension === undefined && this.inheritanceMode === 'multiple') {
|
|
154
|
-
extension = idl.IDLTopType;
|
|
155
|
-
}
|
|
156
|
-
if (extension) {
|
|
157
|
-
return [extension, ...implementations];
|
|
158
|
-
}
|
|
159
145
|
return implementations;
|
|
160
146
|
})(), node.members
|
|
161
147
|
.filter(isConstructor)
|
package/build/lib/src/idl.d.ts
CHANGED
|
@@ -56,10 +56,12 @@ export declare enum IDLExtendedAttributes {
|
|
|
56
56
|
Protected = "Protected",
|
|
57
57
|
Synthetic = "Synthetic",
|
|
58
58
|
Throws = "Throws",
|
|
59
|
+
TraceKey = "TraceKey",
|
|
59
60
|
TypeArguments = "TypeArguments",
|
|
60
61
|
TypeParameters = "TypeParameters",
|
|
61
62
|
VerbatimDts = "VerbatimDts",
|
|
62
|
-
HandWrittenImplementation = "HandWrittenImplementation"
|
|
63
|
+
HandWrittenImplementation = "HandWrittenImplementation",
|
|
64
|
+
ExtraMethod = "ExtraMethod"
|
|
63
65
|
}
|
|
64
66
|
export declare enum IDLAccessorAttribute {
|
|
65
67
|
Getter = "Getter",
|
|
@@ -253,15 +255,6 @@ export declare function isSyntheticEntry(node: IDLNode): boolean;
|
|
|
253
255
|
export declare function isOptionalType(type: IDLNode): type is IDLOptionalType;
|
|
254
256
|
export declare function isVersion(node: IDLNode): node is IDLVersion;
|
|
255
257
|
export declare function createOptionalType(element: IDLType, nodeInitializer?: IDLNodeInitializer): IDLOptionalType;
|
|
256
|
-
/**
|
|
257
|
-
* This placeholder is used when a class has no superclass.
|
|
258
|
-
* Examples:
|
|
259
|
-
* class definition: inheritance:
|
|
260
|
-
* `C extends T` : [T]
|
|
261
|
-
* `C implements T` : [Top, T]
|
|
262
|
-
* `C extends T implements I, J` : [T, I, J]
|
|
263
|
-
*/
|
|
264
|
-
export declare const IDLTopType: IDLReferenceType;
|
|
265
258
|
export declare const IDLPointerType: IDLPrimitiveType;
|
|
266
259
|
export declare const IDLVoidType: IDLPrimitiveType;
|
|
267
260
|
export declare const IDLBooleanType: IDLPrimitiveType;
|
|
@@ -306,6 +299,7 @@ export declare function getPackageName(node: IDLNode): string;
|
|
|
306
299
|
export declare function isInPackage(entry: IDLEntry | IDLFile, packageName: string, exactMatch?: boolean): boolean;
|
|
307
300
|
export declare function getNamespaceName(a: IDLEntry): string;
|
|
308
301
|
export type QNPattern = "package.namespace.name" | "namespace.name" | "name";
|
|
302
|
+
export declare function deriveQualifiedNameFrom(name: string, from: IDLNode): string;
|
|
309
303
|
export declare function getQualifiedName(a: IDLNode, pattern: QNPattern): string;
|
|
310
304
|
export declare function getFQName(a: IDLNode): string;
|
|
311
305
|
export declare function createVersion(value: string[], nodeInitializer?: IDLNodeInitializer): IDLVersion;
|
|
@@ -367,9 +361,6 @@ export declare function printNamespace(idl: IDLNamespace): PrintedLine[];
|
|
|
367
361
|
export declare function printCallback(idl: IDLCallback): PrintedLine[];
|
|
368
362
|
export declare function printScoped(idl: IDLEntry): PrintedLine[];
|
|
369
363
|
export declare function printInterface(idl: IDLInterface): PrintedLine[];
|
|
370
|
-
export declare function getSuperType(idl: IDLInterface): IDLReferenceType | undefined;
|
|
371
|
-
export declare function getSuperTypes(idl: IDLInterface): IDLReferenceType[] | undefined;
|
|
372
|
-
export declare function hasSuperType(idl: IDLInterface): boolean;
|
|
373
364
|
export declare function printEnumMember(idl: IDLEnumMember): PrintedLine[];
|
|
374
365
|
export declare function printEnum(idl: IDLEnum, skipInitializers: boolean): PrintedLine[];
|
|
375
366
|
export declare function printTypedef(idl: IDLTypedef): PrintedLine[];
|
package/build/lib/src/idl.js
CHANGED
|
@@ -76,10 +76,12 @@ export var IDLExtendedAttributes;
|
|
|
76
76
|
IDLExtendedAttributes["Protected"] = "Protected";
|
|
77
77
|
IDLExtendedAttributes["Synthetic"] = "Synthetic";
|
|
78
78
|
IDLExtendedAttributes["Throws"] = "Throws";
|
|
79
|
+
IDLExtendedAttributes["TraceKey"] = "TraceKey";
|
|
79
80
|
IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
|
|
80
81
|
IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
|
|
81
82
|
IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
|
|
82
83
|
IDLExtendedAttributes["HandWrittenImplementation"] = "HandWrittenImplementation";
|
|
84
|
+
IDLExtendedAttributes["ExtraMethod"] = "ExtraMethod";
|
|
83
85
|
})(IDLExtendedAttributes || (IDLExtendedAttributes = {}));
|
|
84
86
|
export var IDLAccessorAttribute;
|
|
85
87
|
(function (IDLAccessorAttribute) {
|
|
@@ -95,7 +97,7 @@ export var IDLInterfaceSubkind;
|
|
|
95
97
|
IDLInterfaceSubkind[IDLInterfaceSubkind["Tuple"] = 3] = "Tuple";
|
|
96
98
|
})(IDLInterfaceSubkind || (IDLInterfaceSubkind = {}));
|
|
97
99
|
export function forEachChild(node, cbEnter, cbLeave) {
|
|
98
|
-
var _a, _b;
|
|
100
|
+
var _a, _b, _c;
|
|
99
101
|
const cleanup = cbEnter(node);
|
|
100
102
|
switch (node.kind) {
|
|
101
103
|
case IDLKind.File:
|
|
@@ -163,7 +165,10 @@ export function forEachChild(node, cbEnter, cbLeave) {
|
|
|
163
165
|
node.typeArguments.forEach((value) => forEachChild(value, cbEnter, cbLeave));
|
|
164
166
|
break;
|
|
165
167
|
}
|
|
166
|
-
case IDLKind.ReferenceType:
|
|
168
|
+
case IDLKind.ReferenceType: {
|
|
169
|
+
(_c = node.typeArguments) === null || _c === void 0 ? void 0 : _c.forEach((value) => forEachChild(value, cbEnter, cbLeave));
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
167
172
|
case IDLKind.TypeParameterType:
|
|
168
173
|
case IDLKind.EnumMember:
|
|
169
174
|
case IDLKind.Import:
|
|
@@ -179,6 +184,7 @@ export function forEachChild(node, cbEnter, cbLeave) {
|
|
|
179
184
|
}
|
|
180
185
|
/** Updates tree in place! */
|
|
181
186
|
function updateEachChild(node, op, cbLeave) {
|
|
187
|
+
var _a;
|
|
182
188
|
const old = node;
|
|
183
189
|
node = op(old);
|
|
184
190
|
if (node.kind !== old.kind) {
|
|
@@ -261,7 +267,11 @@ function updateEachChild(node, op, cbLeave) {
|
|
|
261
267
|
concrete.typeArguments = concrete.typeArguments.map(it => updateEachChild(it, op, cbLeave));
|
|
262
268
|
break;
|
|
263
269
|
}
|
|
264
|
-
case IDLKind.ReferenceType:
|
|
270
|
+
case IDLKind.ReferenceType: {
|
|
271
|
+
const concrete = node;
|
|
272
|
+
concrete.typeArguments = (_a = concrete.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => updateEachChild(it, op, cbLeave));
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
265
275
|
case IDLKind.TypeParameterType:
|
|
266
276
|
case IDLKind.EnumMember:
|
|
267
277
|
case IDLKind.Import:
|
|
@@ -392,15 +402,6 @@ export function createOptionalType(element, nodeInitializer) {
|
|
|
392
402
|
}
|
|
393
403
|
return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
|
|
394
404
|
}
|
|
395
|
-
/**
|
|
396
|
-
* This placeholder is used when a class has no superclass.
|
|
397
|
-
* Examples:
|
|
398
|
-
* class definition: inheritance:
|
|
399
|
-
* `C extends T` : [T]
|
|
400
|
-
* `C implements T` : [Top, T]
|
|
401
|
-
* `C extends T implements I, J` : [T, I, J]
|
|
402
|
-
*/
|
|
403
|
-
export const IDLTopType = createReferenceType("__TOP__");
|
|
404
405
|
// must match with toIDLType in deserialize.ts
|
|
405
406
|
export const IDLPointerType = createPrimitiveType('pointer');
|
|
406
407
|
export const IDLVoidType = createPrimitiveType('void');
|
|
@@ -435,15 +436,10 @@ export const IDLInteropReturnBufferType = createPrimitiveType('InteropReturnBuff
|
|
|
435
436
|
export function createNamespace(name, members, nodeInitializer) {
|
|
436
437
|
return Object.assign(Object.assign({ kind: IDLKind.Namespace, members: members !== null && members !== void 0 ? members : [], name: name }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
437
438
|
}
|
|
438
|
-
function isSpecialNodes(node) {
|
|
439
|
-
return node === IDLTopType
|
|
440
|
-
|| node === IDLObjectType
|
|
441
|
-
|| isPrimitiveType(node);
|
|
442
|
-
}
|
|
443
439
|
export function linkParentBack(node) {
|
|
444
440
|
const parentStack = [];
|
|
445
441
|
updateEachChild(node, (node) => {
|
|
446
|
-
if (
|
|
442
|
+
if (isPrimitiveType(node)) {
|
|
447
443
|
return node;
|
|
448
444
|
}
|
|
449
445
|
if (parentStack.length) {
|
|
@@ -456,7 +452,7 @@ export function linkParentBack(node) {
|
|
|
456
452
|
parentStack.push(node);
|
|
457
453
|
return node;
|
|
458
454
|
}, (node) => {
|
|
459
|
-
if (
|
|
455
|
+
if (isPrimitiveType(node)) {
|
|
460
456
|
return;
|
|
461
457
|
}
|
|
462
458
|
parentStack.pop();
|
|
@@ -509,6 +505,9 @@ export function isInPackage(entry, packageName, exactMatch = false) {
|
|
|
509
505
|
export function getNamespaceName(a) {
|
|
510
506
|
return getNamespacesPathFor(a).map(it => it.name).join('.');
|
|
511
507
|
}
|
|
508
|
+
export function deriveQualifiedNameFrom(name, from) {
|
|
509
|
+
return [...getPackageClause(from), ...getNamespacesPathFor(from).map(it => it.name), name].join(".");
|
|
510
|
+
}
|
|
512
511
|
export function getQualifiedName(a, pattern) {
|
|
513
512
|
const result = [];
|
|
514
513
|
if ("package.namespace.name" === pattern)
|
|
@@ -889,7 +888,10 @@ export function printParameters(parameters) {
|
|
|
889
888
|
return (_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.map(it => nameWithType(it, it.isVariadic, it.isOptional))) === null || _a === void 0 ? void 0 : _a.join(", ")) !== null && _b !== void 0 ? _b : "";
|
|
890
889
|
}
|
|
891
890
|
export function printConstructor(idl) {
|
|
892
|
-
return [
|
|
891
|
+
return [
|
|
892
|
+
...printExtendedAttributes(idl, 1),
|
|
893
|
+
`constructor(${printParameters(idl.parameters)});`
|
|
894
|
+
];
|
|
893
895
|
}
|
|
894
896
|
export function nameWithType(idl, isVariadic = false, isOptional = false) {
|
|
895
897
|
const type = printType(idl.type);
|
|
@@ -955,6 +957,7 @@ export const attributesToQuote = new Set([
|
|
|
955
957
|
IDLExtendedAttributes.DtsTag,
|
|
956
958
|
IDLExtendedAttributes.Import,
|
|
957
959
|
IDLExtendedAttributes.Interfaces,
|
|
960
|
+
IDLExtendedAttributes.TraceKey,
|
|
958
961
|
IDLExtendedAttributes.TypeArguments,
|
|
959
962
|
IDLExtendedAttributes.TypeParameters,
|
|
960
963
|
]);
|
|
@@ -1031,28 +1034,10 @@ export function printScoped(idl) {
|
|
|
1031
1034
|
throw new Error(`Unexpected scoped: ${idl.kind} ${idl.name}`);
|
|
1032
1035
|
}
|
|
1033
1036
|
function printInterfaceInherit(idl) {
|
|
1034
|
-
var _a;
|
|
1035
1037
|
if (idl.inheritance.length === 0) {
|
|
1036
1038
|
return "";
|
|
1037
1039
|
}
|
|
1038
|
-
const
|
|
1039
|
-
const types = [];
|
|
1040
|
-
if (idl.subkind === IDLInterfaceSubkind.Class) {
|
|
1041
|
-
if (inheritance[0] !== IDLTopType) {
|
|
1042
|
-
const ref = clone(inheritance[0]);
|
|
1043
|
-
(_a = ref.extendedAttributes) !== null && _a !== void 0 ? _a : (ref.extendedAttributes = []);
|
|
1044
|
-
if (!hasExtAttribute(ref, IDLExtendedAttributes.Extends)) {
|
|
1045
|
-
ref.extendedAttributes = ref.extendedAttributes.concat([
|
|
1046
|
-
{ name: IDLExtendedAttributes.Extends }
|
|
1047
|
-
]);
|
|
1048
|
-
}
|
|
1049
|
-
types.push(`${printType(ref)}`);
|
|
1050
|
-
inheritance.shift();
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
inheritance.forEach(type => {
|
|
1054
|
-
types.push(printType(type));
|
|
1055
|
-
});
|
|
1040
|
+
const types = idl.inheritance.map(type => printType(type));
|
|
1056
1041
|
return ": " + types.join(', ');
|
|
1057
1042
|
}
|
|
1058
1043
|
export function printInterface(idl) {
|
|
@@ -1070,25 +1055,6 @@ export function printInterface(idl) {
|
|
|
1070
1055
|
.concat(printedIndentDec)
|
|
1071
1056
|
.concat(["};"]);
|
|
1072
1057
|
}
|
|
1073
|
-
export function getSuperType(idl) {
|
|
1074
|
-
if (!idl.inheritance)
|
|
1075
|
-
return undefined;
|
|
1076
|
-
const parent = idl.inheritance[0];
|
|
1077
|
-
return parent && parent !== IDLTopType ? parent : undefined;
|
|
1078
|
-
}
|
|
1079
|
-
export function getSuperTypes(idl) {
|
|
1080
|
-
if (!idl.inheritance)
|
|
1081
|
-
return undefined;
|
|
1082
|
-
if (idl.inheritance[0] == IDLTopType) {
|
|
1083
|
-
return idl.inheritance.length == 1 ? undefined : idl.inheritance.slice(1);
|
|
1084
|
-
}
|
|
1085
|
-
else {
|
|
1086
|
-
return idl.inheritance.length == 0 ? undefined : idl.inheritance;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
export function hasSuperType(idl) {
|
|
1090
|
-
return isDefined(getSuperType(idl));
|
|
1091
|
-
}
|
|
1092
1058
|
export function printEnumMember(idl) {
|
|
1093
1059
|
const type = printType(idl.type);
|
|
1094
1060
|
const initializer = idl.initializer === undefined
|
package/build/lib/src/idlize.js
CHANGED
|
@@ -53,6 +53,8 @@ export function scanInputDirs(inputDirs, fileFilter = undefined, recursive = fal
|
|
|
53
53
|
console.warn(`Warning: Directory does not exist or is not a directory: ${dir}`);
|
|
54
54
|
return [];
|
|
55
55
|
}
|
|
56
|
+
}).sort((a, b) => {
|
|
57
|
+
return path.basename(a).localeCompare(path.basename(b));
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
function fileExists(fileName) {
|
package/build/lib/src/index.d.ts
CHANGED
|
@@ -40,9 +40,11 @@ export * from "./peer-generation/BuilderClass";
|
|
|
40
40
|
export * from "./peer-generation/Materialized";
|
|
41
41
|
export * from "./peer-generation/modules";
|
|
42
42
|
export * from "./peer-generation/isMaterialized";
|
|
43
|
+
export * from "./peer-generation/isExternalType";
|
|
43
44
|
export * from "./peer-generation/isStructureType";
|
|
44
45
|
export * from "./peer-generation/isEnumType";
|
|
45
46
|
export * from "./peer-generation/unions";
|
|
47
|
+
export * from "./peer-generation/getSuperType";
|
|
46
48
|
export * from "./LanguageWriters";
|
|
47
49
|
export * from "./peer-generation/ReferenceResolver";
|
|
48
50
|
export * from "./peer-generation/idl/common";
|
package/build/lib/src/index.js
CHANGED
|
@@ -54,9 +54,11 @@ export * from "./peer-generation/BuilderClass";
|
|
|
54
54
|
export * from "./peer-generation/Materialized";
|
|
55
55
|
export * from "./peer-generation/modules";
|
|
56
56
|
export * from "./peer-generation/isMaterialized";
|
|
57
|
+
export * from "./peer-generation/isExternalType";
|
|
57
58
|
export * from "./peer-generation/isStructureType";
|
|
58
59
|
export * from "./peer-generation/isEnumType";
|
|
59
60
|
export * from "./peer-generation/unions";
|
|
61
|
+
export * from "./peer-generation/getSuperType";
|
|
60
62
|
export * from "./LanguageWriters";
|
|
61
63
|
export * from "./peer-generation/ReferenceResolver";
|
|
62
64
|
export * from "./peer-generation/idl/common";
|
|
@@ -3,7 +3,8 @@ export declare enum LayoutNodeRole {
|
|
|
3
3
|
PEER = 0,
|
|
4
4
|
INTERFACE = 1,
|
|
5
5
|
GLOBAL = 2,
|
|
6
|
-
COMPONENT = 3
|
|
6
|
+
COMPONENT = 3,
|
|
7
|
+
SERIALIZER = 4
|
|
7
8
|
}
|
|
8
9
|
export type LayoutTargetDescriptionHint = 'component.implementation' | 'component.interface' | 'component.function';
|
|
9
10
|
export interface LayoutTargetDescription {
|
|
@@ -13,11 +14,13 @@ export interface LayoutTargetDescription {
|
|
|
13
14
|
}
|
|
14
15
|
export interface LayoutManagerStrategy {
|
|
15
16
|
resolve(target: LayoutTargetDescription): string;
|
|
17
|
+
handwrittenPackage(): string;
|
|
16
18
|
}
|
|
17
19
|
export declare class LayoutManager {
|
|
18
20
|
private strategy;
|
|
19
21
|
constructor(strategy: LayoutManagerStrategy);
|
|
20
22
|
resolve(target: LayoutTargetDescription): string;
|
|
23
|
+
handwrittenPackage(): string;
|
|
21
24
|
static Empty(): LayoutManager;
|
|
22
25
|
}
|
|
23
26
|
//# sourceMappingURL=LayoutManager.d.ts.map
|
|
@@ -18,6 +18,7 @@ export var LayoutNodeRole;
|
|
|
18
18
|
LayoutNodeRole[LayoutNodeRole["INTERFACE"] = 1] = "INTERFACE";
|
|
19
19
|
LayoutNodeRole[LayoutNodeRole["GLOBAL"] = 2] = "GLOBAL";
|
|
20
20
|
LayoutNodeRole[LayoutNodeRole["COMPONENT"] = 3] = "COMPONENT";
|
|
21
|
+
LayoutNodeRole[LayoutNodeRole["SERIALIZER"] = 4] = "SERIALIZER";
|
|
21
22
|
})(LayoutNodeRole || (LayoutNodeRole = {}));
|
|
22
23
|
export class LayoutManager {
|
|
23
24
|
constructor(strategy) {
|
|
@@ -26,9 +27,12 @@ export class LayoutManager {
|
|
|
26
27
|
resolve(target) {
|
|
27
28
|
return this.strategy.resolve(target);
|
|
28
29
|
}
|
|
30
|
+
handwrittenPackage() {
|
|
31
|
+
return this.strategy.handwrittenPackage();
|
|
32
|
+
}
|
|
29
33
|
////////////////////////////////////////////////////////////////////
|
|
30
34
|
static Empty() {
|
|
31
|
-
return new LayoutManager({ resolve: () => '' });
|
|
35
|
+
return new LayoutManager({ resolve: () => '', handwrittenPackage: () => '' });
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=LayoutManager.js.map
|
|
@@ -9,7 +9,8 @@ export declare class MaterializedField {
|
|
|
9
9
|
argConvertor: ArgConvertor;
|
|
10
10
|
outArgConvertor?: ArgConvertor | undefined;
|
|
11
11
|
isNullableOriginalTypeField?: boolean | undefined;
|
|
12
|
-
|
|
12
|
+
extraMethodName: string | undefined;
|
|
13
|
+
constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined, extraMethodName?: string | undefined);
|
|
13
14
|
}
|
|
14
15
|
export declare class MaterializedMethod extends PeerMethod {
|
|
15
16
|
implementationParentName: string;
|
|
@@ -29,6 +30,9 @@ export declare class MaterializedMethod extends PeerMethod {
|
|
|
29
30
|
getImplementationName(): string;
|
|
30
31
|
tsReturnType(): idl.IDLType | undefined;
|
|
31
32
|
getPrivateMethod(): MaterializedMethod;
|
|
33
|
+
withReturnType(returnType: idl.IDLType): MaterializedMethod;
|
|
34
|
+
setOverloadIndex(index: number): void;
|
|
35
|
+
getOverloadPostfix(): string;
|
|
32
36
|
}
|
|
33
37
|
export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
|
|
34
38
|
method?: Method;
|
|
@@ -42,12 +46,12 @@ export declare class MaterializedClass implements PeerClassBase {
|
|
|
42
46
|
readonly interfaces: idl.IDLReferenceType[] | undefined;
|
|
43
47
|
readonly generics: string[] | undefined;
|
|
44
48
|
readonly fields: MaterializedField[];
|
|
45
|
-
readonly
|
|
49
|
+
readonly ctors: MaterializedMethod[];
|
|
46
50
|
readonly finalizer: MaterializedMethod | undefined;
|
|
47
51
|
readonly methods: MaterializedMethod[];
|
|
48
52
|
readonly needBeGenerated: boolean;
|
|
49
53
|
readonly taggedMethods: idl.IDLMethod[];
|
|
50
|
-
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[],
|
|
54
|
+
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctors: MaterializedMethod[], // zero size when used for global functions
|
|
51
55
|
finalizer: MaterializedMethod | undefined, // undefined when used for global functions
|
|
52
56
|
methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
|
|
53
57
|
getComponentName(): string;
|
|
@@ -18,11 +18,12 @@ import { capitalize } from '../util';
|
|
|
18
18
|
import { qualifiedName } from './idl/common';
|
|
19
19
|
import { PeerMethod } from './PeerMethod';
|
|
20
20
|
export class MaterializedField {
|
|
21
|
-
constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField) {
|
|
21
|
+
constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField, extraMethodName = undefined) {
|
|
22
22
|
this.field = field;
|
|
23
23
|
this.argConvertor = argConvertor;
|
|
24
24
|
this.outArgConvertor = outArgConvertor;
|
|
25
25
|
this.isNullableOriginalTypeField = isNullableOriginalTypeField;
|
|
26
|
+
this.extraMethodName = extraMethodName;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
export class MaterializedMethod extends PeerMethod {
|
|
@@ -88,6 +89,20 @@ export class MaterializedMethod extends PeerMethod {
|
|
|
88
89
|
}
|
|
89
90
|
return privateMethod;
|
|
90
91
|
}
|
|
92
|
+
withReturnType(returnType) {
|
|
93
|
+
const s = this.method.signature;
|
|
94
|
+
const argNames = s.args.map((_, i) => s.argName(i));
|
|
95
|
+
const signature = new NamedMethodSignature(returnType, s.args, argNames, s.defaults, s.argsModifiers, s.printHints);
|
|
96
|
+
const method = copyMethod(this.method, { signature: signature });
|
|
97
|
+
return copyMaterializedMethod(this, { method: method });
|
|
98
|
+
}
|
|
99
|
+
setOverloadIndex(index) {
|
|
100
|
+
this.overloadIndex = index;
|
|
101
|
+
}
|
|
102
|
+
getOverloadPostfix() {
|
|
103
|
+
var _a;
|
|
104
|
+
return `${(_a = this.overloadIndex) !== null && _a !== void 0 ? _a : ""}`;
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
export function copyMaterializedMethod(method, overrides) {
|
|
93
108
|
var _a;
|
|
@@ -96,7 +111,7 @@ export function copyMaterializedMethod(method, overrides) {
|
|
|
96
111
|
return copied;
|
|
97
112
|
}
|
|
98
113
|
export class MaterializedClass {
|
|
99
|
-
constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields,
|
|
114
|
+
constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctors, // zero size when used for global functions
|
|
100
115
|
finalizer, // undefined when used for global functions
|
|
101
116
|
methods, needBeGenerated = true, taggedMethods = []) {
|
|
102
117
|
this.decl = decl;
|
|
@@ -107,7 +122,7 @@ export class MaterializedClass {
|
|
|
107
122
|
this.interfaces = interfaces;
|
|
108
123
|
this.generics = generics;
|
|
109
124
|
this.fields = fields;
|
|
110
|
-
this.
|
|
125
|
+
this.ctors = ctors;
|
|
111
126
|
this.finalizer = finalizer;
|
|
112
127
|
this.methods = methods;
|
|
113
128
|
this.needBeGenerated = needBeGenerated;
|
|
@@ -8,6 +8,7 @@ import { BuilderClass } from './BuilderClass';
|
|
|
8
8
|
import { MaterializedClass } from './Materialized';
|
|
9
9
|
import { LayoutManager, LayoutManagerStrategy } from './LayoutManager';
|
|
10
10
|
import { IDLLibrary } from '../library';
|
|
11
|
+
import { NativeModuleType } from '../LanguageWriters/common';
|
|
11
12
|
export interface GlobalScopeDeclarations {
|
|
12
13
|
methods: idl.IDLMethod[];
|
|
13
14
|
constants: idl.IDLConstant[];
|
|
@@ -10252,6 +10253,7 @@ export declare const lenses: {
|
|
|
10252
10253
|
};
|
|
10253
10254
|
export declare class PeerLibrary implements LibraryInterface {
|
|
10254
10255
|
language: Language;
|
|
10256
|
+
interopNativeModule: NativeModuleType;
|
|
10255
10257
|
readonly useMemoM3: boolean;
|
|
10256
10258
|
private _cachedIdlLibrary?;
|
|
10257
10259
|
asIDLLibrary(): IDLLibrary;
|
|
@@ -10265,8 +10267,8 @@ export declare class PeerLibrary implements LibraryInterface {
|
|
|
10265
10267
|
readonly builderClasses: Map<string, BuilderClass>;
|
|
10266
10268
|
get buildersToGenerate(): BuilderClass[];
|
|
10267
10269
|
readonly materializedClasses: Map<string, MaterializedClass>;
|
|
10268
|
-
get
|
|
10269
|
-
constructor(language: Language, useMemoM3?: boolean);
|
|
10270
|
+
get orderedMaterialized(): MaterializedClass[];
|
|
10271
|
+
constructor(language: Language, interopNativeModule: NativeModuleType, useMemoM3?: boolean);
|
|
10270
10272
|
name: string;
|
|
10271
10273
|
readonly customComponentMethods: string[];
|
|
10272
10274
|
createLanguageWriter(language?: Language): LanguageWriter;
|
|
@@ -10284,6 +10286,7 @@ export declare class PeerLibrary implements LibraryInterface {
|
|
|
10284
10286
|
private referenceCache;
|
|
10285
10287
|
enableCache(): void;
|
|
10286
10288
|
resolveTypeReference(type: idl.IDLReferenceType, singleStep?: boolean): idl.IDLEntry | undefined;
|
|
10289
|
+
private resolveTypeReferenceUncached;
|
|
10287
10290
|
private _useFallback;
|
|
10288
10291
|
disableFallback(): void;
|
|
10289
10292
|
resolveNamedNode(target: string[], pov?: idl.IDLNode | undefined): idl.IDLEntry | undefined;
|