@idlizer/core 2.1.10-arktscgen-7 → 2.1.10-arktscgen-10
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 -2
- package/build/lib/src/Language.d.ts +1 -0
- package/build/lib/src/Language.js +8 -0
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +47 -3
- package/build/lib/src/LanguageWriters/ArgConvertors.js +216 -19
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +12 -4
- package/build/lib/src/LanguageWriters/LanguageWriter.js +28 -3
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +6 -2
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +7 -1
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +3 -0
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +4 -0
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.d.ts +10 -5
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +138 -51
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +5 -1
- package/build/lib/src/LanguageWriters/index.d.ts +1 -2
- package/build/lib/src/LanguageWriters/index.js +17 -3
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +1 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +5 -3
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.d.ts +1 -1
- package/build/lib/src/LanguageWriters/writers/CLikeLanguageWriter.js +5 -3
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +2 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +8 -3
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +4 -10
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +6 -4
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +59 -42
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +1 -1
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +5 -3
- package/build/lib/src/LibraryInterface.d.ts +6 -0
- package/build/lib/src/LibraryInterface.js +22 -1
- package/build/lib/src/from-idl/DtsPrinter.d.ts +3 -2
- package/build/lib/src/from-idl/DtsPrinter.js +9 -6
- package/build/lib/src/from-idl/parser.d.ts +1 -1
- package/build/lib/src/from-idl/parser.js +3 -3
- package/build/lib/src/idl/builders.d.ts +36 -1
- package/build/lib/src/idl/builders.js +62 -2
- package/build/lib/src/idl/dump.d.ts +3 -0
- package/build/lib/src/idl/dump.js +22 -4
- package/build/lib/src/idl/index.d.ts +0 -1
- package/build/lib/src/idl/index.js +0 -1
- package/build/lib/src/idl/node.d.ts +1 -0
- package/build/lib/src/idl/node.js +1 -0
- package/build/lib/src/idl/stdlib.d.ts +1 -0
- package/build/lib/src/idl/stdlib.js +1 -0
- package/build/lib/src/idl/utils.d.ts +4 -3
- package/build/lib/src/idl/utils.js +26 -13
- package/build/lib/src/idl/visitors.js +24 -104
- package/build/lib/src/index.d.ts +4 -1
- package/build/lib/src/index.js +4 -1
- package/build/lib/src/peer-generation/Extractors.d.ts +7 -0
- package/build/lib/src/peer-generation/Extractors.js +40 -0
- package/build/lib/src/peer-generation/Initializers.d.ts +5 -0
- package/build/lib/src/peer-generation/Initializers.js +28 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +0 -4
- package/build/lib/src/peer-generation/Materialized.js +13 -24
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +1 -0
- package/build/lib/src/peer-generation/PeerLibrary.js +54 -3
- package/build/lib/src/peer-generation/PeerMethod.d.ts +1 -0
- package/build/lib/src/peer-generation/PeerMethod.js +1 -0
- package/build/lib/src/peer-generation/idl/common.d.ts +0 -2
- package/build/lib/src/peer-generation/idl/common.js +3 -25
- package/build/lib/src/peer-generation/isMaterialized.d.ts +4 -0
- package/build/lib/src/peer-generation/isMaterialized.js +12 -0
- package/build/lib/src/peer-generation/unions.d.ts +1 -27
- package/build/lib/src/peer-generation/unions.js +1 -99
- package/build/lib/src/transformers/FqnTransformer.js +26 -2
- package/build/lib/src/transformers/GenericTransformer.d.ts +0 -2
- package/build/lib/src/transformers/GenericTransformer.js +20 -20
- package/build/lib/src/transformers/IdlTransformer.js +14 -0
- package/build/lib/src/transformers/NullTransformer.js +16 -3
- package/build/lib/src/transformers/OnSerializeTransformer.js +14 -0
- package/build/lib/src/transformers/ThrowsTransformer.d.ts +3 -0
- package/build/lib/src/transformers/ThrowsTransformer.js +51 -0
- package/build/lib/src/transformers/transformUtils.d.ts +7 -0
- package/build/lib/src/transformers/transformUtils.js +55 -0
- package/build/lib/src/util.d.ts +0 -15
- package/build/lib/src/util.js +2 -73
- package/package.json +11 -5
|
@@ -85,20 +85,20 @@ export class KotlinEnumWithGetter {
|
|
|
85
85
|
let mangledName = removePoints(idl.getQualifiedName(this.enumEntity, 'namespace.name'));
|
|
86
86
|
writer.writeClass(mangledName, () => {
|
|
87
87
|
const enumType = idl.createReferenceType(this.enumEntity);
|
|
88
|
-
writer.
|
|
88
|
+
writer.writeStaticEntitiesBlock(() => {
|
|
89
89
|
members.forEach(it => {
|
|
90
|
-
writer.writeFieldDeclaration(it.name, enumType, [FieldModifier.PUBLIC, FieldModifier.STATIC, FieldModifier.
|
|
90
|
+
writer.writeFieldDeclaration(it.name, enumType, [FieldModifier.PUBLIC, FieldModifier.STATIC, FieldModifier.READONLY], false, writer.makeString(`${mangledName}(${it.stringId ? `\"${it.stringId}\"` : it.numberId})`));
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
const value = 'value';
|
|
94
|
-
writer.writeFieldDeclaration(value, idl.IDLI32Type, [FieldModifier.PUBLIC], true
|
|
94
|
+
writer.writeFieldDeclaration(value, idl.IDLI32Type, [FieldModifier.PUBLIC, FieldModifier.READONLY], true);
|
|
95
95
|
const signature = new MethodSignature(idl.IDLVoidType, [idl.IDLI32Type]);
|
|
96
96
|
writer.writeConstructorImplementation('constructor', signature, () => {
|
|
97
97
|
writer.writeStatement(writer.makeAssign(`this.${value}`, undefined, writer.makeString(signature.argName(0)), false));
|
|
98
98
|
});
|
|
99
99
|
if (isStringEnum) {
|
|
100
100
|
const stringValue = 'stringValue';
|
|
101
|
-
writer.writeFieldDeclaration(stringValue, idl.IDLStringType, [FieldModifier.PUBLIC], true
|
|
101
|
+
writer.writeFieldDeclaration(stringValue, idl.IDLStringType, [FieldModifier.PUBLIC, FieldModifier.READONLY], true);
|
|
102
102
|
const signature = new MethodSignature(idl.IDLVoidType, [idl.IDLStringType]);
|
|
103
103
|
writer.writeConstructorImplementation('constructor', signature, () => {
|
|
104
104
|
writer.writeStatement(writer.makeAssign(`this.${stringValue}`, undefined, writer.makeString(signature.argName(0)), false));
|
|
@@ -123,11 +123,11 @@ class KotlinMapForEachStatement {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
export class KotlinThrowErrorStatement {
|
|
126
|
-
constructor(
|
|
127
|
-
this.
|
|
126
|
+
constructor(exception) {
|
|
127
|
+
this.exception = exception;
|
|
128
128
|
}
|
|
129
129
|
write(writer) {
|
|
130
|
-
writer.print(`throw
|
|
130
|
+
writer.print(`throw ${this.exception.asString()}`);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
class KotlinArrayResizeStatement {
|
|
@@ -236,11 +236,11 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
236
236
|
maybeSemicolon() { return ""; }
|
|
237
237
|
writeClass(name, op, superClass, interfaces, generics, isDeclared, isAbstract) {
|
|
238
238
|
let extendsClause = superClass ? `${superClass}` : undefined;
|
|
239
|
-
let implementsClause = interfaces ? `${interfaces.join('
|
|
239
|
+
let implementsClause = interfaces ? `${interfaces.join(', ')}` : undefined;
|
|
240
240
|
let inheritancePart = [extendsClause, implementsClause]
|
|
241
241
|
.filter(isDefined)
|
|
242
|
-
.join('
|
|
243
|
-
inheritancePart = inheritancePart.length != 0 ? '
|
|
242
|
+
.join(', ');
|
|
243
|
+
inheritancePart = inheritancePart.length != 0 ? ': '.concat(inheritancePart) : '';
|
|
244
244
|
this.printer.print(`public open class ${name}${inheritancePart} {`);
|
|
245
245
|
this.pushIndent();
|
|
246
246
|
op(this);
|
|
@@ -286,7 +286,11 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
286
286
|
prefix = prefix ? prefix.trim() + " " : "";
|
|
287
287
|
const typeParams = (generics === null || generics === void 0 ? void 0 : generics.length) ? `<${generics.join(", ")}>` : "";
|
|
288
288
|
const normalizedArgs = signature.args.map((it, i) => idl.isOptionalType(it) && signature.isArgOptional(i) ? idl.maybeUnwrapOptionalType(it) : it);
|
|
289
|
-
|
|
289
|
+
if (signature.returnType === idl.IDLThisType) {
|
|
290
|
+
throw new Error(`Return type 'this' must be substituted when generating for Kotlin`);
|
|
291
|
+
}
|
|
292
|
+
const returnTypePart = needReturn ? ": " + this.getNodeName(signature.returnType) : "";
|
|
293
|
+
this.printer.print(`${prefix}fun ${name}${typeParams}(${normalizedArgs.map((it, index) => `${signature.argName(index)}: ${this.getNodeName(it)}${signature.isArgOptional(index) ? "?" : ``}${signature.argDefault(index) ? ' = ' + signature.argDefault(index) : ""}`).join(", ")})${returnTypePart}${needBracket ? " {" : ""}`);
|
|
290
294
|
}
|
|
291
295
|
writeFieldDeclaration(name, type, modifiers, optional, initExpr) {
|
|
292
296
|
const init = initExpr != undefined ? ` = ${initExpr.asString()}` : ``;
|
|
@@ -348,30 +352,32 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
348
352
|
const realInteropType = this.getNodeName(type);
|
|
349
353
|
let expr;
|
|
350
354
|
switch (realInteropType) {
|
|
351
|
-
case "
|
|
352
|
-
case "
|
|
353
|
-
case "
|
|
355
|
+
case "KUint8ArrayPtr":
|
|
356
|
+
case "KInt32ArrayPtr":
|
|
357
|
+
case "KFloat32ArrayPtr":
|
|
354
358
|
expr = `${varName}Pinned.addressOf(0)`;
|
|
355
359
|
break;
|
|
356
|
-
case "KPointer":
|
|
357
360
|
case "KNativePointer":
|
|
358
361
|
case "KSerializerBuffer":
|
|
359
362
|
expr = `${varName}.toCPointer<CPointed>()!!`;
|
|
360
363
|
break;
|
|
361
|
-
case "
|
|
364
|
+
case "KByte":
|
|
365
|
+
case "KShort":
|
|
366
|
+
case "KUShort":
|
|
362
367
|
case "KInt":
|
|
368
|
+
case "KUInt":
|
|
363
369
|
case "KLong":
|
|
370
|
+
case "KULong":
|
|
364
371
|
case "KFloat":
|
|
365
372
|
case "KDouble":
|
|
366
|
-
case "String":
|
|
367
373
|
case "KStringPtr":
|
|
368
|
-
case "KBoolean":
|
|
369
|
-
case "Float":
|
|
370
|
-
case "Double":
|
|
371
|
-
case "UInt":
|
|
372
|
-
case "Int":
|
|
373
374
|
expr = varName;
|
|
374
375
|
break;
|
|
376
|
+
case "Boolean": {
|
|
377
|
+
// small trick to hide all casts Boolean <=> KBoolean in a NativeModule
|
|
378
|
+
expr = `${varName}.toByte()`;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
375
381
|
default: throw new Error(`Unexpected type ${realInteropType} in interop with Kotlin`);
|
|
376
382
|
}
|
|
377
383
|
return this.makeString(expr);
|
|
@@ -381,26 +387,32 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
381
387
|
let expr;
|
|
382
388
|
switch (realInteropType) {
|
|
383
389
|
case "KNativePointer":
|
|
384
|
-
case "KPointer":
|
|
385
390
|
expr = `${varName}.toLong()`;
|
|
386
391
|
break;
|
|
392
|
+
case "KByte":
|
|
393
|
+
case "KShort":
|
|
394
|
+
case "KUShort":
|
|
387
395
|
case "KInt":
|
|
396
|
+
case "KUInt":
|
|
388
397
|
case "KLong":
|
|
389
|
-
case "
|
|
390
|
-
case "
|
|
391
|
-
case "
|
|
392
|
-
case "Long":
|
|
393
|
-
case "Int":
|
|
398
|
+
case "KULong":
|
|
399
|
+
case "KFloat":
|
|
400
|
+
case "KDouble":
|
|
394
401
|
expr = varName;
|
|
395
402
|
break;
|
|
396
|
-
case "String":
|
|
397
403
|
case "KStringPtr":
|
|
398
404
|
expr = `${varName}?.toKString() ?: ""`;
|
|
399
405
|
break;
|
|
400
|
-
case "Boolean":
|
|
401
|
-
|
|
406
|
+
case "Boolean": {
|
|
407
|
+
// small trick to hide all casts Boolean <=> KBoolean in a NativeModule
|
|
402
408
|
expr = `${varName} != 0.toByte()`;
|
|
403
409
|
break;
|
|
410
|
+
}
|
|
411
|
+
case "Any": {
|
|
412
|
+
// unsupported case for now, implementation returns Unit (analogue of void) instead of a real object
|
|
413
|
+
expr = varName;
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
404
416
|
case "KInteropReturnBuffer":
|
|
405
417
|
expr = `${varName}.useContents { KInteropReturnBuffer(length, data.toLong()) }`;
|
|
406
418
|
break;
|
|
@@ -409,19 +421,20 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
409
421
|
return this.makeString(expr);
|
|
410
422
|
}
|
|
411
423
|
writeMethodDeclaration(name, signature, modifiers) {
|
|
412
|
-
this.writeDeclaration(name, signature, true, false, modifiers);
|
|
424
|
+
this.writeDeclaration(name, signature, true, false, modifiers, []);
|
|
413
425
|
}
|
|
414
426
|
writeConstructorImplementation(className, signature, op, delegationCall, modifiers) {
|
|
415
427
|
const delegationType = ((delegationCall === null || delegationCall === void 0 ? void 0 : delegationCall.delegationType) == DelegationType.THIS) ? "this" : "super";
|
|
416
428
|
const superInvocation = delegationCall
|
|
417
429
|
? ` : ${delegationType}(${delegationCall.delegationArgs.map(it => it.asString()).join(", ")})`
|
|
418
|
-
:
|
|
430
|
+
: ``;
|
|
419
431
|
const argList = signature.args.map((it, index) => {
|
|
420
432
|
var _a;
|
|
421
433
|
const maybeDefault = ((_a = signature.defaults) === null || _a === void 0 ? void 0 : _a[index]) ? ` = ${signature.defaults[index]}` : "";
|
|
422
434
|
return `${signature.argName(index)}: ${this.getNodeName(it)}${maybeDefault}`;
|
|
423
435
|
}).join(", ");
|
|
424
|
-
|
|
436
|
+
const modifierList = modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(" ") + " " : "";
|
|
437
|
+
this.print(`${modifierList}constructor(${argList})${superInvocation} {`);
|
|
425
438
|
this.pushIndent();
|
|
426
439
|
op(this);
|
|
427
440
|
this.popIndent();
|
|
@@ -494,6 +507,8 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
494
507
|
return new KotlinLambdaExpression(this, signature, this.resolver, body);
|
|
495
508
|
}
|
|
496
509
|
makeThrowError(message) {
|
|
510
|
+
if (typeof message === 'string')
|
|
511
|
+
message = this.makeString(`Error("${message}")`);
|
|
497
512
|
return new KotlinThrowErrorStatement(message);
|
|
498
513
|
}
|
|
499
514
|
makeReturn(expr) {
|
|
@@ -590,7 +605,7 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
590
605
|
throw new Error("Not implemented");
|
|
591
606
|
}
|
|
592
607
|
get supportedModifiers() {
|
|
593
|
-
return [MethodModifier.PUBLIC, MethodModifier.PRIVATE, MethodModifier.OVERRIDE];
|
|
608
|
+
return [MethodModifier.PUBLIC, MethodModifier.PROTECTED, MethodModifier.PRIVATE, MethodModifier.OVERRIDE, MethodModifier.OPEN];
|
|
594
609
|
}
|
|
595
610
|
get supportedFieldModifiers() {
|
|
596
611
|
return [FieldModifier.PUBLIC, FieldModifier.PRIVATE, FieldModifier.PROTECTED, FieldModifier.READONLY, FieldModifier.OVERRIDE];
|
|
@@ -605,7 +620,7 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
605
620
|
return new KotlinEnumWithGetter(enumEntity, options.isExport);
|
|
606
621
|
}
|
|
607
622
|
castToBoolean(value) {
|
|
608
|
-
return
|
|
623
|
+
return value;
|
|
609
624
|
}
|
|
610
625
|
castToInt(value, bitness) {
|
|
611
626
|
return `${this.escapeKeyword(value)}.${bitness == 8 ? 'toByte()' : 'toInt()'}`;
|
|
@@ -616,15 +631,17 @@ export class KotlinLanguageWriter extends LanguageWriter {
|
|
|
616
631
|
makeNewObject(objectName, params = []) {
|
|
617
632
|
return new KotlinNewObjectExpression(objectName, params);
|
|
618
633
|
}
|
|
634
|
+
makeFunctionReference(name) {
|
|
635
|
+
return this.makeString(`::${name}`);
|
|
636
|
+
}
|
|
637
|
+
makeMethodReference(receiver, method) {
|
|
638
|
+
return this.makeString(`${receiver}::${method}`);
|
|
639
|
+
}
|
|
619
640
|
escapeKeyword(keyword) {
|
|
620
641
|
return keyword;
|
|
621
642
|
}
|
|
622
|
-
|
|
623
|
-
this.
|
|
624
|
-
this.printer.pushIndent();
|
|
625
|
-
op(this);
|
|
626
|
-
this.popIndent();
|
|
627
|
-
this.printer.print('}');
|
|
643
|
+
writeStaticEntitiesBlock(op) {
|
|
644
|
+
this.writePrefixedBlock("companion object", op);
|
|
628
645
|
}
|
|
629
646
|
pushNamespace(namespace, options) { }
|
|
630
647
|
popNamespace(options) { }
|
|
@@ -71,7 +71,7 @@ export declare class TSLanguageWriter extends LanguageWriter {
|
|
|
71
71
|
makeNull(type?: idl.IDLOptionalType): LanguageExpression;
|
|
72
72
|
makeAssign(variableName: string, type: idl.IDLType | undefined, expr: LanguageExpression | undefined, isDeclared?: boolean, isConst?: boolean, options?: MakeAssignOptions): LanguageStatement;
|
|
73
73
|
makeLambda(signature: MethodSignature, body?: LanguageStatement[]): LanguageExpression;
|
|
74
|
-
makeThrowError(message: string): LanguageStatement;
|
|
74
|
+
makeThrowError(message: string | LanguageExpression): LanguageStatement;
|
|
75
75
|
makeReturn(expr: LanguageExpression): LanguageStatement;
|
|
76
76
|
makeStatement(expr: LanguageExpression): LanguageStatement;
|
|
77
77
|
makeLoop(counter: string, limit: string, statement?: LanguageStatement): LanguageStatement;
|
|
@@ -63,11 +63,11 @@ class TSUnwrapOptionalExpression {
|
|
|
63
63
|
// STATEMENTS //
|
|
64
64
|
////////////////////////////////////////////////////////////////
|
|
65
65
|
class TSThrowErrorStatement {
|
|
66
|
-
constructor(
|
|
67
|
-
this.
|
|
66
|
+
constructor(exception) {
|
|
67
|
+
this.exception = exception;
|
|
68
68
|
}
|
|
69
69
|
write(writer) {
|
|
70
|
-
writer.print(`throw
|
|
70
|
+
writer.print(`throw ${this.exception.asString()}`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
export class TSReturnStatement extends ReturnStatement {
|
|
@@ -339,6 +339,8 @@ export class TSLanguageWriter extends LanguageWriter {
|
|
|
339
339
|
return new TSLambdaExpression(this, this.typeConvertor, signature, this.resolver, body);
|
|
340
340
|
}
|
|
341
341
|
makeThrowError(message) {
|
|
342
|
+
if (typeof message === 'string')
|
|
343
|
+
message = this.makeString(`new Error('${message}')`);
|
|
342
344
|
return new TSThrowErrorStatement(message);
|
|
343
345
|
}
|
|
344
346
|
makeReturn(expr) {
|
|
@@ -18,4 +18,10 @@ export interface LibraryInterface extends ReferenceResolver {
|
|
|
18
18
|
*/
|
|
19
19
|
libraryPrefix: string;
|
|
20
20
|
}
|
|
21
|
+
export declare function getTransformer(library: LibraryInterface, from: idl.IDLNode, to: idl.IDLNode): {
|
|
22
|
+
module: string;
|
|
23
|
+
ns?: string;
|
|
24
|
+
method: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function mapLibraryName(node: idl.IDLEntry, lang: Language, mapping?: Map<string, Map<string, string>>, prefix?: string): string;
|
|
21
27
|
//# sourceMappingURL=LibraryInterface.d.ts.map
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import * as idl from "./idl";
|
|
2
|
+
import { Language } from "./Language";
|
|
3
|
+
import { getModuleFor } from "./peer-generation/modules";
|
|
4
|
+
export function getTransformer(library, from, to) {
|
|
5
|
+
const convertor = library.createTypeNameConvertor(Language.CPP);
|
|
6
|
+
const withNS = Language.supportNS(library.language);
|
|
7
|
+
const handwritten = library.layout.handwrittenPackage();
|
|
8
|
+
return {
|
|
9
|
+
module: withNS ? handwritten : `${handwritten}.extractors`,
|
|
10
|
+
ns: withNS ? "extractors" : undefined,
|
|
11
|
+
method: `transform_${convertor.convert(from)}_to_${convertor.convert(to)}`
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function mapLibraryName(node, lang, mapping, prefix = "@") {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const module = getModuleFor(node);
|
|
17
|
+
if (module.tsLikePackage !== undefined) {
|
|
18
|
+
return `^` + module.tsLikePackage;
|
|
19
|
+
}
|
|
20
|
+
const packageName = idl.getPackageName(node);
|
|
21
|
+
return `^` + ((_b = (_a = mapping === null || mapping === void 0 ? void 0 : mapping.get(packageName)) === null || _a === void 0 ? void 0 : _a.get(lang.name)) !== null && _b !== void 0 ? _b : `${prefix}${packageName}`);
|
|
22
|
+
}
|
|
2
23
|
//# sourceMappingURL=LibraryInterface.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { stringOrNone } from "../util";
|
|
2
|
-
import { IDLCallback, IDLConstructor, IDLEntry, IDLEnum, IDLInterface, IDLMethod, IDLParameter, IDLProperty, IDLTypedef, IDLNamespace, IDLFile, IDLImport,
|
|
2
|
+
import { IDLCallback, IDLConstructor, IDLEntry, IDLEnum, IDLInterface, IDLMethod, IDLParameter, IDLProperty, IDLTypedef, IDLNamespace, IDLFile, IDLImport, IDLCallable, IDLConstant, SignatureTag, IDLVersion } from "../idl";
|
|
3
3
|
import { Language } from "../Language";
|
|
4
|
+
import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
|
|
4
5
|
export declare class CustomPrintVisitor {
|
|
5
6
|
private resolver;
|
|
6
7
|
private language;
|
|
7
8
|
output: string[];
|
|
8
|
-
constructor(resolver:
|
|
9
|
+
constructor(resolver: ReferenceResolver, language: Language);
|
|
9
10
|
currentInterface?: IDLInterface;
|
|
10
11
|
visit(node: IDLEntry, wrapNamespaces?: boolean): void;
|
|
11
12
|
printMetadata(node: IDLEnum): void;
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
|
-
import { indentedBy
|
|
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, IDLUnknownType, IDLBooleanType, IDLNumberType, IDLPointerType, IDLInterfaceSubkind, escapeIDLKeyword, getNamespacesPathFor, IDLBigintType, IDLDate, IDLFunctionType, getQualifiedName, IDLObjectType, isConstant, } from "../idl";
|
|
17
|
-
import {
|
|
15
|
+
import { indentedBy } 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, IDLAnyType, IDLContainerUtils, DebugUtils, mixMethodParametersAndTags, createReferenceType, transformMethodsAsync2ReturnPromise, linearizeNamespaceMembers, isNamedNode, IDLThisType, isOptionalType, IDLI8Type, IDLU8Type, IDLI16Type, IDLU16Type, IDLI32Type, IDLU32Type, IDLI64Type, IDLU64Type, IDLF16Type, IDLF32Type, IDLF64Type, IDLBufferType, IDLUnknownType, IDLBooleanType, IDLNumberType, IDLPointerType, IDLInterfaceSubkind, escapeIDLKeyword, getNamespacesPathFor, IDLBigintType, IDLDate, IDLFunctionType, getQualifiedName, IDLObjectType, isConstant, isInNamespace, } from "../idl";
|
|
17
|
+
import { parseIDLFile } from "./deserialize";
|
|
18
18
|
import { Language } from "../Language";
|
|
19
19
|
import { warn } from "../util";
|
|
20
20
|
import { isInIdlize } from "../idl";
|
|
21
|
+
import { maybeRestoreThrows } from "../transformers/transformUtils";
|
|
21
22
|
export class CustomPrintVisitor {
|
|
22
23
|
constructor(resolver, language) {
|
|
23
24
|
this.resolver = resolver;
|
|
@@ -208,7 +209,7 @@ export class CustomPrintVisitor {
|
|
|
208
209
|
// Let's skip imported declarations
|
|
209
210
|
if (isTypedef(node) &&
|
|
210
211
|
hasExtAttribute(node, IDLExtendedAttributes.Import)) {
|
|
211
|
-
let definition = this.resolver(createReferenceType(node));
|
|
212
|
+
let definition = this.resolver.resolveTypeReference(createReferenceType(node));
|
|
212
213
|
// TODO: handle namespace case better!
|
|
213
214
|
// TODO: namespace-related-to-rework
|
|
214
215
|
//throw new Error("not implemented yet")
|
|
@@ -269,8 +270,10 @@ export class CustomPrintVisitor {
|
|
|
269
270
|
this.output.push(this.indented(value));
|
|
270
271
|
}
|
|
271
272
|
printTypeForTS(type, undefinedToVoid, sequenceToArrayInterface = false, isCommonMethod = false) {
|
|
273
|
+
var _a;
|
|
272
274
|
if (!type)
|
|
273
275
|
throw new Error("Missing type");
|
|
276
|
+
type = (_a = maybeRestoreThrows(type, this.resolver)) !== null && _a !== void 0 ? _a : type;
|
|
274
277
|
if (isOptionalType(type))
|
|
275
278
|
return `${this.printTypeForTS(type.type, undefinedToVoid, sequenceToArrayInterface)} | undefined`;
|
|
276
279
|
if (isPrimitiveType(type)) {
|
|
@@ -320,7 +323,7 @@ export class CustomPrintVisitor {
|
|
|
320
323
|
toTypeName(node) {
|
|
321
324
|
var _a, _b;
|
|
322
325
|
if (isReferenceType(node)) {
|
|
323
|
-
const decl = this.resolver(node);
|
|
326
|
+
const decl = this.resolver.resolveTypeReference(node);
|
|
324
327
|
if (decl) {
|
|
325
328
|
if (isSyntheticEntry(decl)) {
|
|
326
329
|
if (isInterface(decl)) {
|
|
@@ -365,7 +368,7 @@ export class CustomPrintVisitor {
|
|
|
365
368
|
}
|
|
366
369
|
}
|
|
367
370
|
export function idlToDtsString(name, content) {
|
|
368
|
-
let printer = new CustomPrintVisitor(
|
|
371
|
+
let printer = new CustomPrintVisitor({ resolveTypeReference: () => undefined, toDeclaration: () => IDLVoidType }, Language.TS);
|
|
369
372
|
const idlFile = parseIDLFile(name, content);
|
|
370
373
|
printer.printPackage(idlFile);
|
|
371
374
|
linearizeNamespaceMembers(idlFile.entries).forEach(it => {
|
|
@@ -31,7 +31,7 @@ interface Token {
|
|
|
31
31
|
value: string;
|
|
32
32
|
location: Location;
|
|
33
33
|
}
|
|
34
|
-
type ModifierToken = "static" | "readonly" | "async";
|
|
34
|
+
type ModifierToken = "static" | "readonly" | "async" | "optional";
|
|
35
35
|
type ModifiersContainer = {
|
|
36
36
|
[Key in ModifierToken]?: Token;
|
|
37
37
|
};
|
|
@@ -69,7 +69,7 @@ const unsupportedDeclarations = new Set(["deleter", "getter", "includes", "inher
|
|
|
69
69
|
const interfaceContent = new Set([idl.IDLKind.Constructor, idl.IDLKind.Const, idl.IDLKind.Property, idl.IDLKind.Method, idl.IDLKind.Callable]);
|
|
70
70
|
const globalContent = new Set([idl.IDLKind.Namespace, idl.IDLKind.Interface, idl.IDLKind.Enum, idl.IDLKind.Method, idl.IDLKind.Typedef, idl.IDLKind.Callback, idl.IDLKind.Import, idl.IDLKind.Version, idl.IDLKind.Const]);
|
|
71
71
|
const havingBlocks = new Set([idl.IDLKind.Namespace, idl.IDLKind.Interface, idl.IDLKind.Enum]);
|
|
72
|
-
const modifierTokens = new Set(["static", "readonly", "async"]);
|
|
72
|
+
const modifierTokens = new Set(["static", "readonly", "async", "optional"]);
|
|
73
73
|
// Uncomment in case of parser debugging
|
|
74
74
|
function trac(s) {
|
|
75
75
|
// console.log(s)
|
|
@@ -402,7 +402,7 @@ export class Parser {
|
|
|
402
402
|
}
|
|
403
403
|
switch (this.curValue) {
|
|
404
404
|
case "attribute":
|
|
405
|
-
this.assertPossibleModifiers("static", "readonly");
|
|
405
|
+
this.assertPossibleModifiers("static", "readonly", "optional");
|
|
406
406
|
return this.parseAttribute();
|
|
407
407
|
case "callback":
|
|
408
408
|
return this.parseCallback();
|
|
@@ -737,7 +737,7 @@ export class Parser {
|
|
|
737
737
|
const ext = this.consumeCurrentExtended();
|
|
738
738
|
const isReadonly = !!this.currentModifiers.readonly;
|
|
739
739
|
const isStatic = !!this.currentModifiers.static;
|
|
740
|
-
|
|
740
|
+
let isOptional = !!this.currentModifiers.optional || extractOptional(ext);
|
|
741
741
|
this.skip("attribute");
|
|
742
742
|
const type = this.parseType();
|
|
743
743
|
const name = this.parseSingleIdentifier();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Location } from "../diagnostictypes";
|
|
2
|
-
import { IDLCallable, IDLCallback, IDLConstant, IDLConstructor, IDLContainerKind, IDLContainerType, IDLEntry, IDLEnum, IDLEnumMember, IDLExtendedAttribute, IDLFile, IDLImport, IDLInterface, IDLInterfaceSubkind, IDLMethod, IDLNamespace, IDLOptionalType, IDLParameter, IDLPrimitiveType, IDLProperty, IDLReferenceType, IDLType, IDLTypedef, IDLTypeParameterType, IDLUnionType, IDLVersion } from "./node";
|
|
2
|
+
import { IDLCallable, IDLCallback, IDLConstant, IDLConstructor, IDLContainerKind, IDLContainerType, IDLEntry, IDLEnum, IDLEnumMember, IDLExtendedAttribute, IDLFile, IDLImport, IDLInterface, IDLInterfaceSubkind, IDLMethod, IDLNamespace, IDLNode, IDLOptionalType, IDLParameter, IDLPrimitiveType, IDLProperty, IDLReferenceType, IDLType, IDLTypedef, IDLTypeParameterType, IDLUnionType, IDLVersion } from "./node";
|
|
3
3
|
export type IDLNodeInitializer = {
|
|
4
4
|
extendedAttributes?: IDLExtendedAttribute[];
|
|
5
5
|
fileName?: string;
|
|
@@ -40,4 +40,39 @@ export declare function createCallback(name: string, parameters: IDLParameter[],
|
|
|
40
40
|
export declare function createTypeParameterReference(name: string, nodeInitializer?: IDLNodeInitializer): IDLTypeParameterType;
|
|
41
41
|
export declare function createTypedef(name: string, type: IDLType, typeParameters?: string[], nodeInitializer?: IDLNodeInitializer): IDLTypedef;
|
|
42
42
|
export declare function createConstant(name: string, type: IDLType, value?: string, nodeInitializer?: IDLNodeInitializer): IDLConstant;
|
|
43
|
+
export declare function generateSyntheticIdlNodeName(type: IDLType): string;
|
|
44
|
+
export declare function generateSyntheticUnionName(types: IDLType[]): string;
|
|
45
|
+
export declare const IDLPointerType: IDLPrimitiveType;
|
|
46
|
+
export declare const IDLVoidType: IDLPrimitiveType;
|
|
47
|
+
export declare const IDLBooleanType: IDLPrimitiveType;
|
|
48
|
+
export declare const IDLI8Type: IDLPrimitiveType;
|
|
49
|
+
export declare const IDLU8Type: IDLPrimitiveType;
|
|
50
|
+
export declare const IDLI16Type: IDLPrimitiveType;
|
|
51
|
+
export declare const IDLU16Type: IDLPrimitiveType;
|
|
52
|
+
export declare const IDLI32Type: IDLPrimitiveType;
|
|
53
|
+
export declare const IDLU32Type: IDLPrimitiveType;
|
|
54
|
+
export declare const IDLI64Type: IDLPrimitiveType;
|
|
55
|
+
export declare const IDLU64Type: IDLPrimitiveType;
|
|
56
|
+
export declare const IDLF16Type: IDLPrimitiveType;
|
|
57
|
+
export declare const IDLF32Type: IDLPrimitiveType;
|
|
58
|
+
export declare const IDLF64Type: IDLPrimitiveType;
|
|
59
|
+
export declare const IDLBigintType: IDLPrimitiveType;
|
|
60
|
+
export declare const IDLNumberType: IDLPrimitiveType;
|
|
61
|
+
export declare const IDLStringType: IDLPrimitiveType;
|
|
62
|
+
export declare const IDLAnyType: IDLPrimitiveType;
|
|
63
|
+
export declare const IDLUndefinedType: IDLPrimitiveType;
|
|
64
|
+
export declare const IDLUnknownType: IDLPrimitiveType;
|
|
65
|
+
export declare const IDLObjectType: IDLPrimitiveType;
|
|
66
|
+
export declare const IDLThisType: IDLPrimitiveType;
|
|
67
|
+
export declare const IDLDate: IDLPrimitiveType;
|
|
68
|
+
export declare const IDLBufferType: IDLPrimitiveType;
|
|
69
|
+
export declare const IDLUint8ArrayType: IDLContainerType;
|
|
70
|
+
export declare const IDLSerializerBuffer: IDLPrimitiveType;
|
|
71
|
+
export declare const IDLFunctionType: IDLPrimitiveType;
|
|
72
|
+
export declare const IDLCustomObjectType: IDLPrimitiveType;
|
|
73
|
+
export declare const IDLInteropReturnBufferType: IDLPrimitiveType;
|
|
74
|
+
export declare const IDLNullTypeName = "idlize.stdlib.Null";
|
|
75
|
+
export declare const IDLThrowsTypeName = "idlize.stdlib.Throws";
|
|
76
|
+
export declare function isUndefinedType(type: IDLNode): type is IDLPrimitiveType;
|
|
77
|
+
export declare function isVoidType(type: IDLNode): type is IDLPrimitiveType;
|
|
43
78
|
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
16
|
-
import { isOptionalType, getFQName } from "./discriminators";
|
|
15
|
+
import { capitalize } from "../util";
|
|
16
|
+
import { isOptionalType, getFQName, isContainerType, isNamedNode, isPrimitiveType } from "./discriminators";
|
|
17
17
|
import { IDLKind } from "./node";
|
|
18
18
|
const innerIdlSymbol = Symbol("innerIdlSymbol");
|
|
19
19
|
export function createPrimitiveType(name) {
|
|
@@ -132,4 +132,64 @@ export function createConstant(name, type, value, nodeInitializer = {}) {
|
|
|
132
132
|
type,
|
|
133
133
|
value }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
134
134
|
}
|
|
135
|
+
export function generateSyntheticIdlNodeName(type) {
|
|
136
|
+
if (isPrimitiveType(type))
|
|
137
|
+
return capitalize(type.name);
|
|
138
|
+
if (isContainerType(type)) {
|
|
139
|
+
const typeArgs = type.elementType.map(it => generateSyntheticIdlNodeName(it)).join("_").replaceAll(".", "_");
|
|
140
|
+
switch (type.containerKind) {
|
|
141
|
+
case "sequence": return "Array_" + typeArgs;
|
|
142
|
+
case "record": return "Map_" + typeArgs;
|
|
143
|
+
case "Promise": return "Promise_" + typeArgs;
|
|
144
|
+
default: throw new Error(`Unknown container type ${type.containerKind}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (isNamedNode(type))
|
|
148
|
+
return type.name.split('.').map(capitalize).join('_');
|
|
149
|
+
if (isOptionalType(type))
|
|
150
|
+
return `Opt_${generateSyntheticIdlNodeName(type.type)}`;
|
|
151
|
+
throw `Can not compute type name of ${IDLKind[type.kind]}`;
|
|
152
|
+
}
|
|
153
|
+
export function generateSyntheticUnionName(types) {
|
|
154
|
+
return `Union_${types.map(it => generateSyntheticIdlNodeName(it)).join("_").replaceAll(".", "_")}`;
|
|
155
|
+
}
|
|
156
|
+
/// STANDARD LIBRARY
|
|
157
|
+
export const IDLPointerType = createPrimitiveType('pointer');
|
|
158
|
+
export const IDLVoidType = createPrimitiveType('void');
|
|
159
|
+
export const IDLBooleanType = createPrimitiveType('boolean');
|
|
160
|
+
export const IDLI8Type = createPrimitiveType('i8');
|
|
161
|
+
export const IDLU8Type = createPrimitiveType('u8');
|
|
162
|
+
export const IDLI16Type = createPrimitiveType('i16');
|
|
163
|
+
export const IDLU16Type = createPrimitiveType('u16');
|
|
164
|
+
export const IDLI32Type = createPrimitiveType('i32');
|
|
165
|
+
export const IDLU32Type = createPrimitiveType('u32');
|
|
166
|
+
export const IDLI64Type = createPrimitiveType('i64');
|
|
167
|
+
export const IDLU64Type = createPrimitiveType('u64');
|
|
168
|
+
export const IDLF16Type = createPrimitiveType('f16');
|
|
169
|
+
export const IDLF32Type = createPrimitiveType('f32');
|
|
170
|
+
export const IDLF64Type = createPrimitiveType('f64');
|
|
171
|
+
export const IDLBigintType = createPrimitiveType("bigint");
|
|
172
|
+
export const IDLNumberType = createPrimitiveType('number');
|
|
173
|
+
export const IDLStringType = createPrimitiveType('String');
|
|
174
|
+
export const IDLAnyType = createPrimitiveType('any');
|
|
175
|
+
export const IDLUndefinedType = createPrimitiveType('undefined');
|
|
176
|
+
export const IDLUnknownType = createPrimitiveType('unknown');
|
|
177
|
+
export const IDLObjectType = createPrimitiveType('Object');
|
|
178
|
+
export const IDLThisType = createPrimitiveType('this');
|
|
179
|
+
export const IDLDate = createPrimitiveType('date');
|
|
180
|
+
export const IDLBufferType = createPrimitiveType('buffer');
|
|
181
|
+
export const IDLUint8ArrayType = createContainerType('sequence', [IDLU8Type]);
|
|
182
|
+
export const IDLSerializerBuffer = createPrimitiveType('SerializerBuffer');
|
|
183
|
+
// Stub for IdlPeerLibrary
|
|
184
|
+
export const IDLFunctionType = createPrimitiveType('Function');
|
|
185
|
+
export const IDLCustomObjectType = createPrimitiveType('CustomObject');
|
|
186
|
+
export const IDLInteropReturnBufferType = createPrimitiveType('InteropReturnBuffer');
|
|
187
|
+
export const IDLNullTypeName = "idlize.stdlib.Null";
|
|
188
|
+
export const IDLThrowsTypeName = "idlize.stdlib.Throws";
|
|
189
|
+
export function isUndefinedType(type) {
|
|
190
|
+
return isPrimitiveType(type) && type.name === IDLUndefinedType.name;
|
|
191
|
+
}
|
|
192
|
+
export function isVoidType(type) {
|
|
193
|
+
return isPrimitiveType(type) && type.name === IDLVoidType.name;
|
|
194
|
+
}
|
|
135
195
|
//# sourceMappingURL=builders.js.map
|
|
@@ -44,5 +44,8 @@ export interface IDLPrintOptions {
|
|
|
44
44
|
allowUnknownKinds: boolean;
|
|
45
45
|
}
|
|
46
46
|
export declare function toIDLString(file: IDLFile, options: Partial<IDLPrintOptions>): string;
|
|
47
|
+
export declare const DebugUtils: {
|
|
48
|
+
debugPrintType: (type: IDLType) => string;
|
|
49
|
+
};
|
|
47
50
|
export {};
|
|
48
51
|
//# sourceMappingURL=dump.d.ts.map
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
import { IndentedPrinter } from "../IndentedPrinter";
|
|
16
|
+
import { IDLNullTypeName, IDLStringType, IDLUndefinedType } from "./builders";
|
|
16
17
|
import { isInterface, isOptionalType, isPrimitiveType, isContainerType, isReferenceType, isUnionType, isTypeParameterType, hasExtAttribute } from "./discriminators";
|
|
17
18
|
import { IDLKeywords } from "./keywords";
|
|
18
19
|
import { IDLExtendedAttributes, IDLKind } from "./node";
|
|
19
|
-
import { IDLNullTypeName, IDLUndefinedType, IDLStringType } from "./stdlib";
|
|
20
20
|
export function escapeIDLKeyword(name) {
|
|
21
21
|
return name + (IDLKeywords.has(name) ? "_" : "");
|
|
22
22
|
}
|
|
@@ -43,8 +43,16 @@ export function printType(type, options) {
|
|
|
43
43
|
}
|
|
44
44
|
if (isPrimitiveType(type))
|
|
45
45
|
return type.name;
|
|
46
|
-
if (isContainerType(type))
|
|
47
|
-
|
|
46
|
+
if (isContainerType(type)) {
|
|
47
|
+
const maybeExtendedAttributes = type.extendedAttributes && type.extendedAttributes.length
|
|
48
|
+
? `[${quoteAttributeValues(type.extendedAttributes)}] `
|
|
49
|
+
: '';
|
|
50
|
+
const res = `${maybeExtendedAttributes}${type.containerKind}<${type.elementType.map(it => printType(it)).join(", ")}>`;
|
|
51
|
+
if (maybeExtendedAttributes.length) {
|
|
52
|
+
return `(${res})`;
|
|
53
|
+
}
|
|
54
|
+
return res;
|
|
55
|
+
}
|
|
48
56
|
if (isReferenceType(type)) {
|
|
49
57
|
const maybeExtendedAttributes = type.extendedAttributes && type.extendedAttributes.length
|
|
50
58
|
? `[${quoteAttributeValues(type.extendedAttributes)}] `
|
|
@@ -128,8 +136,9 @@ export class IDLWriter {
|
|
|
128
136
|
printProperty(idl) {
|
|
129
137
|
const staticMod = idl.isStatic ? "static " : "";
|
|
130
138
|
const readonlyMod = idl.isReadonly ? "readonly " : "";
|
|
139
|
+
const optional = idl.isOptional ? "optional " : "";
|
|
131
140
|
return this.printExtendedAttributes(idl)
|
|
132
|
-
.print(`${staticMod}${readonlyMod}attribute ${nameWithType(idl)};`);
|
|
141
|
+
.print(`${staticMod}${readonlyMod}${optional}attribute ${nameWithType(idl)};`);
|
|
133
142
|
}
|
|
134
143
|
printExtendedAttributes(idl) {
|
|
135
144
|
var _a;
|
|
@@ -324,4 +333,13 @@ export function toIDLString(file, options) {
|
|
|
324
333
|
file.entries.forEach(it => writer.printIDL(it, options));
|
|
325
334
|
return writer.getOutput().join("\n");
|
|
326
335
|
}
|
|
336
|
+
export const DebugUtils = {
|
|
337
|
+
debugPrintType: (type) => {
|
|
338
|
+
const filename = type.fileName ? `, fileName: '${type.fileName}'` : "";
|
|
339
|
+
if (isContainerType(type)) {
|
|
340
|
+
return `[IDLType, name: '${printType(type)}', kind: '${IDLKind[type.kind]}', elements: [${type.elementType.map(DebugUtils.debugPrintType).join(', ')}]${filename}]`;
|
|
341
|
+
}
|
|
342
|
+
return `[IDLType, name: '${printType(type)}', kind: '${IDLKind[type.kind]}'${filename}]`;
|
|
343
|
+
},
|
|
344
|
+
};
|
|
327
345
|
//# sourceMappingURL=dump.js.map
|
|
@@ -51,6 +51,7 @@ export var IDLExtendedAttributes;
|
|
|
51
51
|
IDLExtendedAttributes["Accessor"] = "Accessor";
|
|
52
52
|
IDLExtendedAttributes["Annotations"] = "Annotations";
|
|
53
53
|
IDLExtendedAttributes["Async"] = "Async";
|
|
54
|
+
IDLExtendedAttributes["AsRecord"] = "AsRecord";
|
|
54
55
|
IDLExtendedAttributes["CallSignature"] = "CallSignature";
|
|
55
56
|
IDLExtendedAttributes["CommonMethod"] = "CommonMethod";
|
|
56
57
|
IDLExtendedAttributes["Component"] = "Component";
|
|
@@ -29,6 +29,7 @@ export declare const IDLFunctionType: IDLPrimitiveType;
|
|
|
29
29
|
export declare const IDLCustomObjectType: IDLPrimitiveType;
|
|
30
30
|
export declare const IDLInteropReturnBufferType: IDLPrimitiveType;
|
|
31
31
|
export declare const IDLNullTypeName = "idlize.stdlib.Null";
|
|
32
|
+
export declare const IDLThrowsTypeName = "idlize.stdlib.Throws";
|
|
32
33
|
export declare function isUndefinedType(type: IDLNode): type is IDLPrimitiveType;
|
|
33
34
|
export declare function isVoidType(type: IDLNode): type is IDLPrimitiveType;
|
|
34
35
|
//# sourceMappingURL=stdlib.d.ts.map
|