@idlizer/core 2.1.2 → 2.1.7
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/LanguageWriters/ArgConvertors.d.ts +3 -4
- package/build/lib/src/LanguageWriters/ArgConvertors.js +43 -32
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +35 -17
- package/build/lib/src/LanguageWriters/LanguageWriter.js +30 -56
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.d.ts +3 -1
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +32 -11
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +5 -2
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +71 -62
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -1
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +9 -19
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.d.ts +4 -2
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +10 -3
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +2 -1
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +24 -4
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +8 -4
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +87 -33
- package/build/lib/src/LanguageWriters/nameConvertor.d.ts +3 -1
- package/build/lib/src/LanguageWriters/nameConvertor.js +5 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +19 -11
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +34 -47
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +4 -1
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +9 -9
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +15 -24
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +17 -8
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +48 -23
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +4 -6
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +15 -14
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +13 -8
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +33 -52
- package/build/lib/src/LibraryInterface.d.ts +1 -4
- package/build/lib/src/config.d.ts +813 -110
- package/build/lib/src/config.js +25 -3
- package/build/lib/src/configDescriber.d.ts +31 -4
- package/build/lib/src/configDescriber.js +101 -3
- package/build/lib/src/from-idl/DtsPrinter.js +31 -18
- package/build/lib/src/from-idl/IDLLinter.d.ts +40 -7
- package/build/lib/src/from-idl/IDLLinter.js +211 -25
- package/build/lib/src/from-idl/common.js +1 -1
- package/build/lib/src/from-idl/deserialize.d.ts +10 -1
- package/build/lib/src/from-idl/deserialize.js +486 -352
- package/build/lib/src/idl.d.ts +29 -19
- package/build/lib/src/idl.js +404 -119
- package/build/lib/src/idlize.d.ts +2 -1
- package/build/lib/src/idlize.js +82 -26
- package/build/lib/src/index.d.ts +4 -3
- package/build/lib/src/index.js +3 -2
- package/build/lib/src/options.d.ts +1 -1
- package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -2
- package/build/lib/src/peer-generation/BuilderClass.js +0 -8
- package/build/lib/src/peer-generation/LayoutManager.d.ts +10 -3
- package/build/lib/src/peer-generation/LayoutManager.js +3 -2
- package/build/lib/src/peer-generation/Materialized.d.ts +1 -1
- package/build/lib/src/peer-generation/Materialized.js +3 -3
- package/build/lib/src/peer-generation/PeerClass.d.ts +3 -8
- package/build/lib/src/peer-generation/PeerClass.js +0 -1
- package/build/lib/src/peer-generation/PeerFile.d.ts +1 -2
- package/build/lib/src/peer-generation/PeerFile.js +1 -1
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +12 -7
- package/build/lib/src/peer-generation/PeerLibrary.js +131 -67
- package/build/lib/src/peer-generation/ReferenceResolver.d.ts +1 -1
- package/build/lib/src/peer-generation/ReferenceResolver.js +2 -2
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +1 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +6 -2
- package/build/lib/src/peer-generation/idl/common.d.ts +3 -1
- package/build/lib/src/peer-generation/idl/common.js +21 -4
- package/build/lib/src/peer-generation/isMaterialized.js +28 -7
- package/build/lib/src/peer-generation/unions.d.ts +3 -2
- package/build/lib/src/peer-generation/unions.js +7 -3
- package/build/lib/src/resolveNamedNode.d.ts +3 -0
- package/build/lib/src/resolveNamedNode.js +105 -0
- package/build/lib/src/util.d.ts +8 -1
- package/build/lib/src/util.js +41 -3
- package/build/lib/src/visitor.d.ts +2 -1
- package/build/lib/src/visitor.js +109 -7
- package/package.json +2 -2
- package/webidl2.js/LICENSE +21 -0
- package/webidl2.js/README.md +827 -0
- package/webidl2.js/dist/package.json +3 -0
- package/webidl2.js/dist/webidl2.js +93 -19
package/build/lib/src/idl.js
CHANGED
|
@@ -64,7 +64,9 @@ export var IDLExtendedAttributes;
|
|
|
64
64
|
IDLExtendedAttributes["DtsName"] = "DtsName";
|
|
65
65
|
IDLExtendedAttributes["DtsTag"] = "DtsTag";
|
|
66
66
|
IDLExtendedAttributes["Entity"] = "Entity";
|
|
67
|
+
IDLExtendedAttributes["Extends"] = "Extends";
|
|
67
68
|
IDLExtendedAttributes["Import"] = "Import";
|
|
69
|
+
IDLExtendedAttributes["DefaultExport"] = "DefaultExport";
|
|
68
70
|
IDLExtendedAttributes["IndexSignature"] = "IndexSignature";
|
|
69
71
|
IDLExtendedAttributes["Interfaces"] = "Interfaces";
|
|
70
72
|
IDLExtendedAttributes["NativeModule"] = "NativeModule";
|
|
@@ -94,7 +96,7 @@ export var IDLInterfaceSubkind;
|
|
|
94
96
|
})(IDLInterfaceSubkind || (IDLInterfaceSubkind = {}));
|
|
95
97
|
export function forEachChild(node, cbEnter, cbLeave) {
|
|
96
98
|
var _a, _b;
|
|
97
|
-
cbEnter(node);
|
|
99
|
+
const cleanup = cbEnter(node);
|
|
98
100
|
switch (node.kind) {
|
|
99
101
|
case IDLKind.File:
|
|
100
102
|
node.entries.forEach((value) => forEachChild(value, cbEnter, cbLeave));
|
|
@@ -172,8 +174,108 @@ export function forEachChild(node, cbEnter, cbLeave) {
|
|
|
172
174
|
throw new Error(`Unhandled ${node.kind}`);
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
cbLeave === null || cbLeave === void 0 ? void 0 : cbLeave(node);
|
|
178
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
179
|
+
}
|
|
180
|
+
/** Updates tree in place! */
|
|
181
|
+
function updateEachChild(node, op, cbLeave) {
|
|
182
|
+
const old = node;
|
|
183
|
+
node = op(old);
|
|
184
|
+
if (node.kind !== old.kind) {
|
|
185
|
+
throw new Error("Kinds must be the same!");
|
|
186
|
+
}
|
|
187
|
+
switch (node.kind) {
|
|
188
|
+
case IDLKind.File: {
|
|
189
|
+
const concrete = node;
|
|
190
|
+
concrete.entries = concrete.entries.map(it => updateEachChild(it, op, cbLeave));
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case IDLKind.Namespace: {
|
|
194
|
+
const concrete = node;
|
|
195
|
+
concrete.members = concrete.members.map((it) => updateEachChild(it, op, cbLeave));
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case IDLKind.Interface: {
|
|
199
|
+
const concrete = node;
|
|
200
|
+
concrete.inheritance = concrete.inheritance.map((it) => updateEachChild(it, op, cbLeave));
|
|
201
|
+
concrete.constructors = concrete.constructors.map((it) => updateEachChild(it, op, cbLeave));
|
|
202
|
+
concrete.properties = concrete.properties.map((it) => updateEachChild(it, op, cbLeave));
|
|
203
|
+
concrete.methods = concrete.methods.map((it) => updateEachChild(it, op, cbLeave));
|
|
204
|
+
concrete.callables = concrete.callables.map((it) => updateEachChild(it, op, cbLeave));
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case IDLKind.Method:
|
|
208
|
+
case IDLKind.Callable:
|
|
209
|
+
case IDLKind.Callback:
|
|
210
|
+
case IDLKind.Constructor: {
|
|
211
|
+
const concrete = node;
|
|
212
|
+
concrete.parameters = concrete.parameters.map((it) => updateEachChild(it, op, cbLeave));
|
|
213
|
+
if (concrete.returnType) {
|
|
214
|
+
concrete.returnType = updateEachChild(concrete.returnType, op, cbLeave);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case IDLKind.UnionType: {
|
|
219
|
+
const concrete = node;
|
|
220
|
+
concrete.types = concrete.types.map((it) => updateEachChild(it, op, cbLeave));
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case IDLKind.OptionalType: {
|
|
224
|
+
const concrete = node;
|
|
225
|
+
concrete.type = updateEachChild(concrete.type, op, cbLeave);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case IDLKind.Const: {
|
|
229
|
+
const concrete = node;
|
|
230
|
+
concrete.type = updateEachChild(concrete.type, op, cbLeave);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
case IDLKind.Enum: {
|
|
234
|
+
const concrete = node;
|
|
235
|
+
concrete.elements = concrete.elements.map((it) => updateEachChild(it, op, cbLeave));
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case IDLKind.Property: {
|
|
239
|
+
const concrete = node;
|
|
240
|
+
concrete.type = updateEachChild(concrete.type, op, cbLeave);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case IDLKind.Parameter: {
|
|
244
|
+
const concrete = node;
|
|
245
|
+
if (concrete.type)
|
|
246
|
+
concrete.type = updateEachChild(concrete.type, op, cbLeave);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case IDLKind.Typedef: {
|
|
250
|
+
const concrete = node;
|
|
251
|
+
concrete.type = updateEachChild(concrete.type, op, cbLeave);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case IDLKind.ContainerType: {
|
|
255
|
+
const concrete = node;
|
|
256
|
+
concrete.elementType = concrete.elementType.map(it => updateEachChild(it, op, cbLeave));
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
case IDLKind.UnspecifiedGenericType: {
|
|
260
|
+
const concrete = node;
|
|
261
|
+
concrete.typeArguments = concrete.typeArguments.map(it => updateEachChild(it, op, cbLeave));
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case IDLKind.ReferenceType:
|
|
265
|
+
case IDLKind.TypeParameterType:
|
|
266
|
+
case IDLKind.EnumMember:
|
|
267
|
+
case IDLKind.Import:
|
|
268
|
+
case IDLKind.PrimitiveType:
|
|
269
|
+
case IDLKind.Version:
|
|
270
|
+
break;
|
|
271
|
+
default: {
|
|
272
|
+
throw new Error(`Unhandled ${node.kind}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (cbLeave) {
|
|
276
|
+
cbLeave === null || cbLeave === void 0 ? void 0 : cbLeave(node);
|
|
277
|
+
}
|
|
278
|
+
return node;
|
|
177
279
|
}
|
|
178
280
|
export function isNamedNode(type) {
|
|
179
281
|
return "_idlNamedNodeBrand" in type;
|
|
@@ -281,16 +383,14 @@ function createPrimitiveType(name) {
|
|
|
281
383
|
_idlNamedNodeBrand: innerIdlSymbol,
|
|
282
384
|
};
|
|
283
385
|
}
|
|
284
|
-
export function createOptionalType(element) {
|
|
285
|
-
if (isOptionalType(element)) {
|
|
386
|
+
export function createOptionalType(element, nodeInitializer) {
|
|
387
|
+
if (isOptionalType(element) && !nodeInitializer) {
|
|
286
388
|
return element;
|
|
287
389
|
}
|
|
288
|
-
|
|
289
|
-
kind: IDLKind.OptionalType,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
293
|
-
};
|
|
390
|
+
if (isOptionalType(element)) {
|
|
391
|
+
return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element.type }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
|
|
392
|
+
}
|
|
393
|
+
return Object.assign(Object.assign({ kind: IDLKind.OptionalType, type: element }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
|
|
294
394
|
}
|
|
295
395
|
/**
|
|
296
396
|
* This placeholder is used when a class has no superclass.
|
|
@@ -301,6 +401,7 @@ export function createOptionalType(element) {
|
|
|
301
401
|
* `C extends T implements I, J` : [T, I, J]
|
|
302
402
|
*/
|
|
303
403
|
export const IDLTopType = createReferenceType("__TOP__");
|
|
404
|
+
// must match with toIDLType in deserialize.ts
|
|
304
405
|
export const IDLPointerType = createPrimitiveType('pointer');
|
|
305
406
|
export const IDLVoidType = createPrimitiveType('void');
|
|
306
407
|
export const IDLBooleanType = createPrimitiveType('boolean');
|
|
@@ -321,7 +422,7 @@ export const IDLStringType = createPrimitiveType('String');
|
|
|
321
422
|
export const IDLAnyType = createPrimitiveType('any');
|
|
322
423
|
export const IDLUndefinedType = createPrimitiveType('undefined');
|
|
323
424
|
export const IDLUnknownType = createPrimitiveType('unknown');
|
|
324
|
-
export const IDLObjectType =
|
|
425
|
+
export const IDLObjectType = createPrimitiveType('Object');
|
|
325
426
|
export const IDLThisType = createPrimitiveType('this');
|
|
326
427
|
export const IDLDate = createPrimitiveType('date');
|
|
327
428
|
export const IDLBufferType = createPrimitiveType('buffer');
|
|
@@ -329,38 +430,41 @@ export const IDLUint8ArrayType = createContainerType('sequence', [IDLU8Type]);
|
|
|
329
430
|
export const IDLSerializerBuffer = createPrimitiveType('SerializerBuffer');
|
|
330
431
|
// Stub for IdlPeerLibrary
|
|
331
432
|
export const IDLFunctionType = createPrimitiveType('Function');
|
|
332
|
-
export const IDLLengthType = createPrimitiveType('Length');
|
|
333
433
|
export const IDLCustomObjectType = createPrimitiveType('CustomObject');
|
|
334
434
|
export const IDLInteropReturnBufferType = createPrimitiveType('InteropReturnBuffer');
|
|
335
|
-
export function createNamespace(name,
|
|
336
|
-
return {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
343
|
-
_idlEntryBrand: innerIdlSymbol,
|
|
344
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
345
|
-
};
|
|
435
|
+
export function createNamespace(name, members, nodeInitializer) {
|
|
436
|
+
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
|
+
function isSpecialNodes(node) {
|
|
439
|
+
return node === IDLTopType
|
|
440
|
+
|| node === IDLObjectType
|
|
441
|
+
|| isPrimitiveType(node);
|
|
346
442
|
}
|
|
347
443
|
export function linkParentBack(node) {
|
|
348
444
|
const parentStack = [];
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
return;
|
|
352
|
-
|
|
353
|
-
|
|
445
|
+
updateEachChild(node, (node) => {
|
|
446
|
+
if (isSpecialNodes(node)) {
|
|
447
|
+
return node;
|
|
448
|
+
}
|
|
449
|
+
if (parentStack.length) {
|
|
450
|
+
const top = parentStack[parentStack.length - 1];
|
|
451
|
+
if (node.parent !== undefined && node.parent !== top) {
|
|
452
|
+
node = clone(node);
|
|
453
|
+
}
|
|
454
|
+
node.parent = top;
|
|
455
|
+
}
|
|
354
456
|
parentStack.push(node);
|
|
457
|
+
return node;
|
|
355
458
|
}, (node) => {
|
|
356
|
-
if (
|
|
459
|
+
if (isSpecialNodes(node)) {
|
|
357
460
|
return;
|
|
461
|
+
}
|
|
358
462
|
parentStack.pop();
|
|
359
463
|
});
|
|
360
464
|
return node;
|
|
361
465
|
}
|
|
362
|
-
export function getNamespacesPathFor(
|
|
363
|
-
let iterator =
|
|
466
|
+
export function getNamespacesPathFor(node) {
|
|
467
|
+
let iterator = node.parent;
|
|
364
468
|
const result = [];
|
|
365
469
|
while (iterator) {
|
|
366
470
|
if (isNamespace(iterator))
|
|
@@ -369,28 +473,29 @@ export function getNamespacesPathFor(entry) {
|
|
|
369
473
|
}
|
|
370
474
|
return result;
|
|
371
475
|
}
|
|
372
|
-
export function getFileFor(
|
|
373
|
-
let iterator =
|
|
476
|
+
export function getFileFor(node) {
|
|
477
|
+
let iterator = node;
|
|
374
478
|
while (iterator) {
|
|
375
479
|
if (isFile(iterator))
|
|
376
480
|
return iterator;
|
|
377
481
|
iterator = iterator.parent;
|
|
378
482
|
}
|
|
379
|
-
console.warn(`
|
|
483
|
+
console.warn(`Node ${getQualifiedName(node, "namespace.name")} does not have IDLFile in parents`);
|
|
380
484
|
return undefined;
|
|
381
485
|
}
|
|
382
|
-
export function isEqualByQualifedName(a, b) {
|
|
486
|
+
export function isEqualByQualifedName(a, b, pattern = "package.namespace.name") {
|
|
383
487
|
if (a === b)
|
|
384
488
|
return true;
|
|
385
489
|
if (!a || !b)
|
|
386
490
|
return false;
|
|
387
491
|
if (a.kind !== b.kind || a.name !== b.name)
|
|
388
492
|
return false;
|
|
389
|
-
return
|
|
493
|
+
return getQualifiedName(a, pattern) === getQualifiedName(b, pattern);
|
|
390
494
|
}
|
|
391
|
-
export function getPackageClause(
|
|
392
|
-
|
|
393
|
-
|
|
495
|
+
export function getPackageClause(node) {
|
|
496
|
+
var _a;
|
|
497
|
+
const file = getFileFor(node);
|
|
498
|
+
return (_a = file === null || file === void 0 ? void 0 : file.packageClause) !== null && _a !== void 0 ? _a : [];
|
|
394
499
|
}
|
|
395
500
|
export function getPackageName(node) {
|
|
396
501
|
return getPackageClause(node).join(".");
|
|
@@ -404,22 +509,21 @@ export function isInPackage(entry, packageName, exactMatch = false) {
|
|
|
404
509
|
export function getNamespaceName(a) {
|
|
405
510
|
return getNamespacesPathFor(a).map(it => it.name).join('.');
|
|
406
511
|
}
|
|
512
|
+
export function getQualifiedName(a, pattern) {
|
|
513
|
+
const result = [];
|
|
514
|
+
if ("package.namespace.name" === pattern)
|
|
515
|
+
result.push(...getPackageClause(a), ...getNamespacesPathFor(a).map(it => it.name));
|
|
516
|
+
else if ("namespace.name" === pattern)
|
|
517
|
+
result.push(...getNamespacesPathFor(a).map(it => it.name));
|
|
518
|
+
if (isNamedNode(a) && a.name)
|
|
519
|
+
result.push(a.name);
|
|
520
|
+
return result.join(".");
|
|
521
|
+
}
|
|
407
522
|
export function getFQName(a) {
|
|
408
|
-
|
|
409
|
-
// return [...getPackageClause(a), ...getNamespacesPathFor(a).map(it => it.name), a.name].join('.')
|
|
410
|
-
return [...getNamespacesPathFor(a).map(it => it.name), a.name].join('.');
|
|
523
|
+
return getQualifiedName(a, "package.namespace.name");
|
|
411
524
|
}
|
|
412
|
-
export function createVersion(value,
|
|
413
|
-
return {
|
|
414
|
-
kind: IDLKind.Version,
|
|
415
|
-
value,
|
|
416
|
-
name: "version",
|
|
417
|
-
extendedAttributes,
|
|
418
|
-
fileName,
|
|
419
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
420
|
-
_idlEntryBrand: innerIdlSymbol,
|
|
421
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
422
|
-
};
|
|
525
|
+
export function createVersion(value, nodeInitializer) {
|
|
526
|
+
return Object.assign(Object.assign({ kind: IDLKind.Version, value, name: "version" }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
423
527
|
}
|
|
424
528
|
export function fetchNamespaceFrom(pointOfView) {
|
|
425
529
|
let node = pointOfView;
|
|
@@ -430,7 +534,7 @@ export function fetchNamespaceFrom(pointOfView) {
|
|
|
430
534
|
}
|
|
431
535
|
return undefined;
|
|
432
536
|
}
|
|
433
|
-
export function createReferenceType(nameOrSource, typeArguments) {
|
|
537
|
+
export function createReferenceType(nameOrSource, typeArguments, nodeInitializer) {
|
|
434
538
|
let name;
|
|
435
539
|
if (typeof nameOrSource === 'string') {
|
|
436
540
|
name = nameOrSource;
|
|
@@ -438,24 +542,12 @@ export function createReferenceType(nameOrSource, typeArguments) {
|
|
|
438
542
|
else {
|
|
439
543
|
name = getFQName(nameOrSource);
|
|
440
544
|
}
|
|
441
|
-
return {
|
|
442
|
-
|
|
443
|
-
name,
|
|
444
|
-
typeArguments,
|
|
445
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
446
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
447
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
448
|
-
};
|
|
545
|
+
return Object.assign(Object.assign({ kind: IDLKind.ReferenceType, name,
|
|
546
|
+
typeArguments }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
449
547
|
}
|
|
450
|
-
export function createUnspecifiedGenericType(name, typeArguments) {
|
|
451
|
-
return {
|
|
452
|
-
|
|
453
|
-
name,
|
|
454
|
-
typeArguments,
|
|
455
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
456
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
457
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
458
|
-
};
|
|
548
|
+
export function createUnspecifiedGenericType(name, typeArguments, nodeInitializer) {
|
|
549
|
+
return Object.assign(Object.assign({ kind: IDLKind.UnspecifiedGenericType, name,
|
|
550
|
+
typeArguments }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
459
551
|
}
|
|
460
552
|
export function entityToType(entity) {
|
|
461
553
|
if (isType(entity)) {
|
|
@@ -468,38 +560,19 @@ export function entityToType(entity) {
|
|
|
468
560
|
throw new Error(`Expected to have IDLType or IDLEntry, got ${entity}`);
|
|
469
561
|
}
|
|
470
562
|
}
|
|
471
|
-
export function createContainerType(container, element) {
|
|
472
|
-
return {
|
|
473
|
-
kind: IDLKind.ContainerType,
|
|
474
|
-
containerKind: container,
|
|
475
|
-
elementType: element,
|
|
476
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
477
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
478
|
-
};
|
|
563
|
+
export function createContainerType(container, element, nodeInitializer) {
|
|
564
|
+
return Object.assign(Object.assign({ kind: IDLKind.ContainerType, containerKind: container, elementType: element }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol });
|
|
479
565
|
}
|
|
480
|
-
export function createUnionType(types, name) {
|
|
566
|
+
export function createUnionType(types, name, nodeInitializer) {
|
|
481
567
|
if (types.length < 2)
|
|
482
568
|
throw new Error("IDLUnionType should contain at least 2 types");
|
|
483
|
-
return {
|
|
484
|
-
kind: IDLKind.UnionType,
|
|
485
|
-
name: name !== null && name !== void 0 ? name : "Union_" + types.map(it => generateSyntheticIdlNodeName(it)).join("_"),
|
|
486
|
-
types: types,
|
|
487
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
488
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
489
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
490
|
-
};
|
|
569
|
+
return Object.assign(Object.assign({ kind: IDLKind.UnionType, name: name !== null && name !== void 0 ? name : "Union_" + types.map(it => generateSyntheticIdlNodeName(it)).join("_"), types: types }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
491
570
|
}
|
|
492
|
-
export function createFile(entries, fileName, packageClause = []) {
|
|
493
|
-
return {
|
|
494
|
-
kind: IDLKind.File,
|
|
495
|
-
packageClause,
|
|
496
|
-
entries: entries,
|
|
497
|
-
fileName,
|
|
498
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
499
|
-
};
|
|
571
|
+
export function createFile(entries, fileName, packageClause = [], nodeInitializer) {
|
|
572
|
+
return Object.assign(Object.assign({ kind: IDLKind.File, packageClause, entries: entries, fileName }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol });
|
|
500
573
|
}
|
|
501
574
|
export function createImport(clause, name, nodeInitializer) {
|
|
502
|
-
return Object.assign(Object.assign({ kind: IDLKind.Import, name: name
|
|
575
|
+
return Object.assign(Object.assign({ kind: IDLKind.Import, name: name !== null && name !== void 0 ? name : "", clause }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
503
576
|
}
|
|
504
577
|
export function createEnum(name, elements, nodeInitializer) {
|
|
505
578
|
return Object.assign(Object.assign({ kind: IDLKind.Enum, name: name, elements: elements }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
@@ -553,23 +626,10 @@ export function createConstructor(parameters, returnType, nodeInitializer = {})
|
|
|
553
626
|
returnType }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
554
627
|
}
|
|
555
628
|
export function createCallback(name, parameters, returnType, nodeInitializer = {}, typeParameters = []) {
|
|
556
|
-
if (returnType === IDLThisType || isReferenceType(returnType) && returnType.name === "this")
|
|
557
|
-
returnType = IDLAnyType;
|
|
558
|
-
parameters = parameters.map(it => {
|
|
559
|
-
if (it.type && isNamedNode(it.type) && (it.type.name === "T" || it.type.name === "this"))
|
|
560
|
-
return createParameter(it.name, IDLAnyType, it.isOptional, it.isVariadic, { fileName: it.fileName });
|
|
561
|
-
return it;
|
|
562
|
-
});
|
|
563
629
|
return Object.assign(Object.assign({ kind: IDLKind.Callback, name, parameters, returnType, typeParameters }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
564
630
|
}
|
|
565
|
-
export function createTypeParameterReference(name) {
|
|
566
|
-
return {
|
|
567
|
-
kind: IDLKind.TypeParameterType,
|
|
568
|
-
name: name,
|
|
569
|
-
_idlNodeBrand: innerIdlSymbol,
|
|
570
|
-
_idlTypeBrand: innerIdlSymbol,
|
|
571
|
-
_idlNamedNodeBrand: innerIdlSymbol,
|
|
572
|
-
};
|
|
631
|
+
export function createTypeParameterReference(name, nodeInitializer) {
|
|
632
|
+
return Object.assign(Object.assign({ kind: IDLKind.TypeParameterType, name: name }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlTypeBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
573
633
|
}
|
|
574
634
|
export function createTypedef(name, type, typeParameters = [], nodeInitializer = {}) {
|
|
575
635
|
return Object.assign(Object.assign({ name, type, typeParameters, kind: IDLKind.Typedef }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
@@ -579,6 +639,205 @@ export function createConstant(name, type, value, nodeInitializer = {}) {
|
|
|
579
639
|
type,
|
|
580
640
|
value }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
581
641
|
}
|
|
642
|
+
export function clone(node) {
|
|
643
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
644
|
+
const make = (node) => node;
|
|
645
|
+
const get = (node) => node;
|
|
646
|
+
switch (node.kind) {
|
|
647
|
+
case IDLKind.Interface: {
|
|
648
|
+
const entry = get(node);
|
|
649
|
+
return make(createInterface(entry.name, entry.subkind, (_a = entry.inheritance) === null || _a === void 0 ? void 0 : _a.map(clone), (_b = entry.constructors) === null || _b === void 0 ? void 0 : _b.map(clone), entry.constants.map(clone), entry.properties.map(clone), entry.methods.map(clone), entry.callables.map(clone), (_c = entry.typeParameters) === null || _c === void 0 ? void 0 : _c.map(it => it), {
|
|
650
|
+
documentation: node.documentation,
|
|
651
|
+
extendedAttributes: (_d = node.extendedAttributes) === null || _d === void 0 ? void 0 : _d.slice(),
|
|
652
|
+
fileName: node.fileName
|
|
653
|
+
}));
|
|
654
|
+
}
|
|
655
|
+
case IDLKind.Import: {
|
|
656
|
+
const entry = get(node);
|
|
657
|
+
return make(createImport(entry.clause, entry.name, {
|
|
658
|
+
documentation: entry.documentation,
|
|
659
|
+
extendedAttributes: (_e = entry.extendedAttributes) === null || _e === void 0 ? void 0 : _e.slice(),
|
|
660
|
+
fileName: entry.fileName
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
case IDLKind.Callback: {
|
|
664
|
+
const entry = get(node);
|
|
665
|
+
return make(createCallback(entry.name, entry.parameters.map(clone), clone(entry.returnType), {
|
|
666
|
+
documentation: entry.documentation,
|
|
667
|
+
extendedAttributes: (_f = entry.extendedAttributes) === null || _f === void 0 ? void 0 : _f.slice(),
|
|
668
|
+
fileName: entry.fileName
|
|
669
|
+
}, entry.typeParameters));
|
|
670
|
+
}
|
|
671
|
+
case IDLKind.Const: {
|
|
672
|
+
const entry = get(node);
|
|
673
|
+
return make(createConstant(entry.name, clone(entry.type), entry.value, {
|
|
674
|
+
documentation: entry.documentation,
|
|
675
|
+
extendedAttributes: (_g = entry.extendedAttributes) === null || _g === void 0 ? void 0 : _g.slice(),
|
|
676
|
+
fileName: entry.fileName
|
|
677
|
+
}));
|
|
678
|
+
}
|
|
679
|
+
case IDLKind.Property: {
|
|
680
|
+
const entry = get(node);
|
|
681
|
+
return make(createProperty(entry.name, clone(entry.type), entry.isReadonly, entry.isStatic, entry.isOptional, {
|
|
682
|
+
documentation: entry.documentation,
|
|
683
|
+
extendedAttributes: (_h = entry.extendedAttributes) === null || _h === void 0 ? void 0 : _h.slice(),
|
|
684
|
+
fileName: entry.fileName
|
|
685
|
+
}));
|
|
686
|
+
}
|
|
687
|
+
case IDLKind.Parameter: {
|
|
688
|
+
const entry = get(node);
|
|
689
|
+
return make(createParameter(entry.name, clone(entry.type), entry.isOptional, entry.isVariadic, {
|
|
690
|
+
documentation: entry.documentation,
|
|
691
|
+
extendedAttributes: (_j = entry.extendedAttributes) === null || _j === void 0 ? void 0 : _j.slice(),
|
|
692
|
+
fileName: entry.fileName
|
|
693
|
+
}));
|
|
694
|
+
}
|
|
695
|
+
case IDLKind.Method: {
|
|
696
|
+
const entry = get(node);
|
|
697
|
+
return make(createMethod(entry.name, entry.parameters.map(clone), clone(entry.returnType), {
|
|
698
|
+
isAsync: entry.isAsync,
|
|
699
|
+
isFree: entry.isFree,
|
|
700
|
+
isOptional: entry.isOptional,
|
|
701
|
+
isStatic: entry.isStatic
|
|
702
|
+
}, {
|
|
703
|
+
documentation: entry.documentation,
|
|
704
|
+
extendedAttributes: (_k = entry.extendedAttributes) === null || _k === void 0 ? void 0 : _k.slice(),
|
|
705
|
+
fileName: entry.fileName
|
|
706
|
+
}, entry.typeParameters));
|
|
707
|
+
}
|
|
708
|
+
case IDLKind.Callable: {
|
|
709
|
+
const entry = get(node);
|
|
710
|
+
return make(createCallable(entry.name, entry.parameters.map(clone), clone(entry.returnType), {
|
|
711
|
+
isAsync: entry.isAsync,
|
|
712
|
+
isStatic: entry.isStatic
|
|
713
|
+
}, {
|
|
714
|
+
documentation: entry.documentation,
|
|
715
|
+
extendedAttributes: (_l = entry.extendedAttributes) === null || _l === void 0 ? void 0 : _l.slice(),
|
|
716
|
+
fileName: entry.documentation
|
|
717
|
+
}, entry.typeParameters));
|
|
718
|
+
}
|
|
719
|
+
case IDLKind.Constructor: {
|
|
720
|
+
const entry = get(node);
|
|
721
|
+
return make(createConstructor(entry.parameters.map(clone), entry.returnType ? clone(entry.returnType) : undefined, {
|
|
722
|
+
documentation: entry.documentation,
|
|
723
|
+
extendedAttributes: (_m = entry.extendedAttributes) === null || _m === void 0 ? void 0 : _m.slice(),
|
|
724
|
+
fileName: entry.fileName
|
|
725
|
+
}));
|
|
726
|
+
}
|
|
727
|
+
case IDLKind.Enum: {
|
|
728
|
+
const entry = get(node);
|
|
729
|
+
const cloned = createEnum(entry.name, entry.elements.map(clone), {
|
|
730
|
+
documentation: entry.documentation,
|
|
731
|
+
extendedAttributes: (_o = entry.extendedAttributes) === null || _o === void 0 ? void 0 : _o.slice(),
|
|
732
|
+
fileName: entry.fileName
|
|
733
|
+
});
|
|
734
|
+
cloned.elements.forEach(it => {
|
|
735
|
+
it.parent = cloned;
|
|
736
|
+
});
|
|
737
|
+
return make(cloned);
|
|
738
|
+
}
|
|
739
|
+
case IDLKind.EnumMember: {
|
|
740
|
+
const entry = get(node);
|
|
741
|
+
return make(createEnumMember(entry.name, entry.parent, clone(entry.type), entry.initializer, {
|
|
742
|
+
documentation: entry.documentation,
|
|
743
|
+
extendedAttributes: (_p = entry.extendedAttributes) === null || _p === void 0 ? void 0 : _p.slice(),
|
|
744
|
+
fileName: entry.fileName
|
|
745
|
+
}));
|
|
746
|
+
}
|
|
747
|
+
case IDLKind.Typedef: {
|
|
748
|
+
const entry = get(node);
|
|
749
|
+
return make(createTypedef(entry.name, clone(entry.type), entry.typeParameters, {
|
|
750
|
+
documentation: entry.documentation,
|
|
751
|
+
extendedAttributes: (_q = entry.extendedAttributes) === null || _q === void 0 ? void 0 : _q.slice(),
|
|
752
|
+
fileName: entry.fileName
|
|
753
|
+
}));
|
|
754
|
+
}
|
|
755
|
+
case IDLKind.PrimitiveType: {
|
|
756
|
+
return node;
|
|
757
|
+
}
|
|
758
|
+
case IDLKind.ContainerType: {
|
|
759
|
+
const type = get(node);
|
|
760
|
+
return make(createContainerType(type.containerKind, type.elementType.map(clone), {
|
|
761
|
+
documentation: type.documentation,
|
|
762
|
+
extendedAttributes: (_r = type.extendedAttributes) === null || _r === void 0 ? void 0 : _r.slice(),
|
|
763
|
+
fileName: type.fileName
|
|
764
|
+
}));
|
|
765
|
+
}
|
|
766
|
+
case IDLKind.UnspecifiedGenericType: {
|
|
767
|
+
const type = get(node);
|
|
768
|
+
return make(createUnspecifiedGenericType(type.name, type.typeArguments.map(clone), {
|
|
769
|
+
documentation: type.documentation,
|
|
770
|
+
extendedAttributes: (_s = type.extendedAttributes) === null || _s === void 0 ? void 0 : _s.slice(),
|
|
771
|
+
fileName: type.fileName
|
|
772
|
+
}));
|
|
773
|
+
}
|
|
774
|
+
case IDLKind.ReferenceType: {
|
|
775
|
+
const type = get(node);
|
|
776
|
+
return make(createReferenceType(type.name, (_t = type.typeArguments) === null || _t === void 0 ? void 0 : _t.map(clone), {
|
|
777
|
+
documentation: type.documentation,
|
|
778
|
+
extendedAttributes: (_u = type.extendedAttributes) === null || _u === void 0 ? void 0 : _u.slice(),
|
|
779
|
+
fileName: type.fileName
|
|
780
|
+
}));
|
|
781
|
+
}
|
|
782
|
+
case IDLKind.UnionType: {
|
|
783
|
+
const type = get(node);
|
|
784
|
+
return make(createUnionType(type.types.map(clone), type.name, {
|
|
785
|
+
documentation: type.documentation,
|
|
786
|
+
extendedAttributes: (_v = type.extendedAttributes) === null || _v === void 0 ? void 0 : _v.slice(),
|
|
787
|
+
fileName: type.fileName
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
case IDLKind.TypeParameterType: {
|
|
791
|
+
const type = get(node);
|
|
792
|
+
return make(createTypeParameterReference(type.name, {
|
|
793
|
+
documentation: type.documentation,
|
|
794
|
+
extendedAttributes: (_w = type.extendedAttributes) === null || _w === void 0 ? void 0 : _w.slice(),
|
|
795
|
+
fileName: type.fileName
|
|
796
|
+
}));
|
|
797
|
+
}
|
|
798
|
+
case IDLKind.OptionalType: {
|
|
799
|
+
const type = get(node);
|
|
800
|
+
return make(createOptionalType(clone(type.type), {
|
|
801
|
+
documentation: type.documentation,
|
|
802
|
+
extendedAttributes: (_x = type.extendedAttributes) === null || _x === void 0 ? void 0 : _x.slice(),
|
|
803
|
+
fileName: type.fileName
|
|
804
|
+
}));
|
|
805
|
+
}
|
|
806
|
+
case IDLKind.Version: {
|
|
807
|
+
const entry = get(node);
|
|
808
|
+
return make(createVersion(entry.value, {
|
|
809
|
+
documentation: entry.documentation,
|
|
810
|
+
extendedAttributes: (_y = entry.extendedAttributes) === null || _y === void 0 ? void 0 : _y.slice(),
|
|
811
|
+
fileName: entry.fileName
|
|
812
|
+
}));
|
|
813
|
+
}
|
|
814
|
+
case IDLKind.Namespace: {
|
|
815
|
+
const ns = get(node);
|
|
816
|
+
return make(createNamespace(ns.name, ns.members.map(clone), {
|
|
817
|
+
documentation: ns.documentation,
|
|
818
|
+
extendedAttributes: (_z = ns.extendedAttributes) === null || _z === void 0 ? void 0 : _z.slice(),
|
|
819
|
+
fileName: ns.fileName
|
|
820
|
+
}));
|
|
821
|
+
}
|
|
822
|
+
case IDLKind.File: {
|
|
823
|
+
const file = get(node);
|
|
824
|
+
return make(createFile(file.entries.map(clone), file.fileName, file.packageClause, {
|
|
825
|
+
documentation: file.documentation,
|
|
826
|
+
extendedAttributes: (_0 = file.extendedAttributes) === null || _0 === void 0 ? void 0 : _0.slice(),
|
|
827
|
+
fileName: file.fileName
|
|
828
|
+
}));
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
export function hasTypeParameters(entry) {
|
|
833
|
+
let foundTypeParameter = false;
|
|
834
|
+
forEachChild(entry, n => {
|
|
835
|
+
if (isTypeParameterType(n)) {
|
|
836
|
+
foundTypeParameter = true;
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
return foundTypeParameter;
|
|
840
|
+
}
|
|
582
841
|
export function escapeIDLKeyword(name) {
|
|
583
842
|
return name + (IDLKeywords.has(name) ? "_" : "");
|
|
584
843
|
}
|
|
@@ -735,15 +994,17 @@ export function printMethod(idl) {
|
|
|
735
994
|
];
|
|
736
995
|
}
|
|
737
996
|
export function printPackage(idl) {
|
|
738
|
-
|
|
997
|
+
const effectiveClause = idl.packageClause.filter(it => !!it);
|
|
998
|
+
if (!effectiveClause.length)
|
|
739
999
|
return [];
|
|
740
1000
|
return [
|
|
741
|
-
`package ${
|
|
1001
|
+
`package ${effectiveClause.join(".")};`
|
|
742
1002
|
];
|
|
743
1003
|
}
|
|
744
1004
|
export function printImport(idl) {
|
|
1005
|
+
const effectiveClause = idl.clause.filter(it => !!it);
|
|
745
1006
|
return [
|
|
746
|
-
`import ${
|
|
1007
|
+
`import ${effectiveClause.join(".") || "NULL_IMPORT"}${idl.name ? " as " : ""}${idl.name};`
|
|
747
1008
|
];
|
|
748
1009
|
}
|
|
749
1010
|
export function printNamespace(idl) {
|
|
@@ -769,10 +1030,35 @@ export function printScoped(idl) {
|
|
|
769
1030
|
return printInterface(idl);
|
|
770
1031
|
throw new Error(`Unexpected scoped: ${idl.kind} ${idl.name}`);
|
|
771
1032
|
}
|
|
1033
|
+
function printInterfaceInherit(idl) {
|
|
1034
|
+
var _a;
|
|
1035
|
+
if (idl.inheritance.length === 0) {
|
|
1036
|
+
return "";
|
|
1037
|
+
}
|
|
1038
|
+
const inheritance = [...idl.inheritance];
|
|
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
|
+
});
|
|
1056
|
+
return ": " + types.join(', ');
|
|
1057
|
+
}
|
|
772
1058
|
export function printInterface(idl) {
|
|
773
1059
|
return [
|
|
774
1060
|
...printExtendedAttributes(idl, 0),
|
|
775
|
-
`interface ${idl.name}${
|
|
1061
|
+
`interface ${idl.name}${printInterfaceInherit(idl)} {`,
|
|
776
1062
|
// TODO: type system hack!
|
|
777
1063
|
]
|
|
778
1064
|
.concat(printedIndentInc)
|
|
@@ -1026,10 +1312,9 @@ export function isStringEnum(decl) {
|
|
|
1026
1312
|
export function linearizeNamespaceMembers(entries) {
|
|
1027
1313
|
const linearized = [];
|
|
1028
1314
|
for (const entry of entries) {
|
|
1315
|
+
linearized.push(entry);
|
|
1029
1316
|
if (isNamespace(entry))
|
|
1030
1317
|
linearized.push(...linearizeNamespaceMembers(entry.members));
|
|
1031
|
-
else
|
|
1032
|
-
linearized.push(entry);
|
|
1033
1318
|
}
|
|
1034
1319
|
return linearized;
|
|
1035
1320
|
}
|