@idlizer/core 2.1.10-arktscgen-2 → 2.1.10-arktscgen-3a
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 +2 -11
- package/build/lib/src/LanguageWriters/ArgConvertors.js +6 -31
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +9 -7
- package/build/lib/src/LanguageWriters/LanguageWriter.js +4 -2
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +2 -1
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +2 -0
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +3 -0
- package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +2 -0
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +11 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +3 -6
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +9 -9
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +1 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -1
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +6 -0
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +2 -5
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +4 -7
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +12 -2
- package/build/lib/src/from-idl/deserialize.js +1 -0
- package/build/lib/src/from-idl/parser.d.ts +6 -6
- package/build/lib/src/from-idl/parser.js +11 -7
- package/build/lib/src/idl.d.ts +3 -0
- package/build/lib/src/idl.js +3 -0
- package/build/lib/src/index.d.ts +1 -0
- package/build/lib/src/index.js +1 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +5 -3
- package/build/lib/src/peer-generation/Materialized.js +10 -7
- package/build/lib/src/peer-generation/PeerClass.d.ts +3 -2
- package/build/lib/src/peer-generation/PeerClass.js +3 -2
- package/build/lib/src/peer-generation/PeerLibrary.js +6 -5
- package/build/lib/src/peer-generation/PeerMethod.d.ts +2 -1
- package/build/lib/src/peer-generation/PeerMethod.js +2 -1
- package/build/lib/src/peer-generation/getSuperType.d.ts +1 -0
- package/build/lib/src/peer-generation/getSuperType.js +9 -0
- package/build/lib/src/peer-generation/modules.d.ts +8 -0
- package/build/lib/src/peer-generation/modules.js +13 -1
- package/build/lib/src/transformers/NullTransformer.d.ts +4 -0
- package/build/lib/src/transformers/NullTransformer.js +34 -0
- package/package.json +4 -3
|
@@ -115,15 +115,6 @@ export declare class NumericConvertor extends BaseArgConvertor {
|
|
|
115
115
|
interopType(): idl.IDLType;
|
|
116
116
|
isPointerType(): boolean;
|
|
117
117
|
}
|
|
118
|
-
export declare class DoubleConvertor extends BaseArgConvertor {
|
|
119
|
-
constructor(param: string);
|
|
120
|
-
convertorArg(param: string, writer: LanguageWriter): string;
|
|
121
|
-
convertorSerialize(param: string, value: string, writer: LanguageWriter): LanguageStatement;
|
|
122
|
-
convertorDeserialize(bufferName: string, deserializerName: string, assigneer: ExpressionAssigner, writer: LanguageWriter): LanguageStatement;
|
|
123
|
-
nativeType(): idl.IDLType;
|
|
124
|
-
interopType(): idl.IDLType;
|
|
125
|
-
isPointerType(): boolean;
|
|
126
|
-
}
|
|
127
118
|
export declare class BigIntToU64Convertor extends BaseArgConvertor {
|
|
128
119
|
constructor(param: string);
|
|
129
120
|
convertorArg(param: string, writer: LanguageWriter): string;
|
|
@@ -274,9 +265,9 @@ export declare class CustomTypeConvertor extends BaseArgConvertor {
|
|
|
274
265
|
isPointerType(): boolean;
|
|
275
266
|
}
|
|
276
267
|
export declare class OptionConvertor extends BaseArgConvertor {
|
|
277
|
-
type: idl.
|
|
268
|
+
type: idl.IDLOptionalType;
|
|
278
269
|
private readonly typeConvertor;
|
|
279
|
-
constructor(library: LibraryInterface, param: string, type: idl.
|
|
270
|
+
constructor(library: LibraryInterface, param: string, type: idl.IDLOptionalType);
|
|
280
271
|
convertorArg(param: string, writer: LanguageWriter): string;
|
|
281
272
|
convertorSerialize(param: string, value: string, printer: LanguageWriter): LanguageStatement;
|
|
282
273
|
convertorCArg(param: string): string;
|
|
@@ -322,31 +322,6 @@ export class NumericConvertor extends BaseArgConvertor {
|
|
|
322
322
|
return false;
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
// TODO use NumericConvertor when double is implemented as interop type
|
|
326
|
-
export class DoubleConvertor extends BaseArgConvertor {
|
|
327
|
-
constructor(param) {
|
|
328
|
-
// check numericPrimitiveTypes.include(type)
|
|
329
|
-
super(idl.IDLF64Type, [RuntimeType.NUMBER], false, true, param);
|
|
330
|
-
}
|
|
331
|
-
convertorArg(param, writer) {
|
|
332
|
-
return param;
|
|
333
|
-
}
|
|
334
|
-
convertorSerialize(param, value, writer) {
|
|
335
|
-
return writer.makeStatement(writer.makeMethodCall(`${param}Serializer`, `writeFloat64`, [writer.makeString(value)]));
|
|
336
|
-
}
|
|
337
|
-
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
338
|
-
return assigneer(writer.makeString(`${deserializerName}.readFloat64()`));
|
|
339
|
-
}
|
|
340
|
-
nativeType() {
|
|
341
|
-
return this.idlType;
|
|
342
|
-
}
|
|
343
|
-
interopType() {
|
|
344
|
-
return this.idlType;
|
|
345
|
-
}
|
|
346
|
-
isPointerType() {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
325
|
export class BigIntToU64Convertor extends BaseArgConvertor {
|
|
351
326
|
constructor(param) {
|
|
352
327
|
super(idl.IDLBigintType, [RuntimeType.BIGINT], false, false, param);
|
|
@@ -518,7 +493,7 @@ export class AggregateConvertor extends BaseArgConvertor {
|
|
|
518
493
|
statements.push(assigneer(writer.makeString(bufferName)));
|
|
519
494
|
}
|
|
520
495
|
else if (writer.language == Language.CJ) {
|
|
521
|
-
const resultExpression = writer.makeString(`${writer.getNodeName(this.idlType)}(${this.decl.properties.map(prop => `${bufferName}
|
|
496
|
+
const resultExpression = writer.makeString(`${writer.getNodeName(this.idlType)}(${this.decl.properties.map(prop => `${bufferName}${capitalize(prop.name)}`).join(", ")})`);
|
|
522
497
|
statements.push(assigneer(resultExpression));
|
|
523
498
|
}
|
|
524
499
|
else if (writer.language == Language.KOTLIN) {
|
|
@@ -876,7 +851,7 @@ export class CustomTypeConvertor extends BaseArgConvertor {
|
|
|
876
851
|
export class OptionConvertor extends BaseArgConvertor {
|
|
877
852
|
// TODO: be smarter here, and for smth like Length|undefined or number|undefined pass without serializer.
|
|
878
853
|
constructor(library, param, type) {
|
|
879
|
-
let conv = library.typeConvertor(param, type);
|
|
854
|
+
let conv = library.typeConvertor(param, type.type);
|
|
880
855
|
let currentConv = conv;
|
|
881
856
|
while (currentConv instanceof ProxyConvertor) {
|
|
882
857
|
currentConv = currentConv.convertor;
|
|
@@ -897,7 +872,7 @@ export class OptionConvertor extends BaseArgConvertor {
|
|
|
897
872
|
}
|
|
898
873
|
convertorSerialize(param, value, printer) {
|
|
899
874
|
const valueValue = `${value}TmpValue`.replaceAll('.', '_');
|
|
900
|
-
return printer.makeCondition(printer.makeDefinedCheck(value), new BlockStatement([
|
|
875
|
+
return printer.makeCondition(printer.makeDefinedCheck(value, this.type), new BlockStatement([
|
|
901
876
|
printer.makeStatement(printer.makeMethodCall(`${param}Serializer`, "writeInt8", [printer.makeRuntimeType(RuntimeType.OBJECT)])),
|
|
902
877
|
printer.makeAssign(valueValue, undefined, printer.makeValueFromOption(value, this.typeConvertor), true),
|
|
903
878
|
this.typeConvertor.convertorSerialize(param, this.typeConvertor.getObjectAccessor(printer.language, valueValue), printer)
|
|
@@ -911,7 +886,7 @@ export class OptionConvertor extends BaseArgConvertor {
|
|
|
911
886
|
const statements = [];
|
|
912
887
|
statements.push(writer.makeAssign(runtimeBufferName, undefined, writer.makeCast(writer.makeString(`${deserializerName}.readInt8()`), writer.getRuntimeType()), true));
|
|
913
888
|
const bufferType = this.nativeType();
|
|
914
|
-
statements.push(writer.makeAssign(bufferName, bufferType,
|
|
889
|
+
statements.push(writer.makeAssign(bufferName, bufferType, writer.language === Language.CPP ? undefined : writer.makeNull(this.type), true, false)); // maybe change to generic None
|
|
915
890
|
const thenStatement = new BlockStatement([
|
|
916
891
|
this.typeConvertor.convertorDeserialize(`${bufferName}_`, deserializerName, (expr) => {
|
|
917
892
|
const receiver = writer.language === Language.CPP
|
|
@@ -925,10 +900,10 @@ export class OptionConvertor extends BaseArgConvertor {
|
|
|
925
900
|
return writer.makeBlock(statements, false);
|
|
926
901
|
}
|
|
927
902
|
nativeType() {
|
|
928
|
-
return
|
|
903
|
+
return this.type;
|
|
929
904
|
}
|
|
930
905
|
interopType() {
|
|
931
|
-
return
|
|
906
|
+
return this.type;
|
|
932
907
|
}
|
|
933
908
|
isPointerType() {
|
|
934
909
|
return true;
|
|
@@ -230,6 +230,11 @@ export interface ObjectArgs {
|
|
|
230
230
|
export interface PrinterLike {
|
|
231
231
|
getOutput(): string[];
|
|
232
232
|
}
|
|
233
|
+
export interface NamespaceOptions {
|
|
234
|
+
ident: boolean;
|
|
235
|
+
isDeclared?: boolean;
|
|
236
|
+
isDefault?: boolean;
|
|
237
|
+
}
|
|
233
238
|
export declare abstract class LanguageWriter {
|
|
234
239
|
printer: IndentedPrinter;
|
|
235
240
|
resolver: ReferenceResolver;
|
|
@@ -298,7 +303,7 @@ export declare abstract class LanguageWriter {
|
|
|
298
303
|
}): LanguageWriter;
|
|
299
304
|
concat(other: PrinterLike): this;
|
|
300
305
|
printTo(file: string): void;
|
|
301
|
-
writeLines(lines: string): void;
|
|
306
|
+
writeLines(lines: string | stringOrNone[]): void;
|
|
302
307
|
writeGetterImplementation(method: Method, op: (writer: this) => void): void;
|
|
303
308
|
writeSetterImplementation(method: Method, op: (writer: this) => void): void;
|
|
304
309
|
writeSuperCall(params: string[]): void;
|
|
@@ -311,7 +316,7 @@ export declare abstract class LanguageWriter {
|
|
|
311
316
|
writeStaticBlock(op: (writer: this) => void): void;
|
|
312
317
|
makeRef(type: idl.IDLType, _options?: MakeRefOptions): idl.IDLType;
|
|
313
318
|
makeThis(): LanguageExpression;
|
|
314
|
-
makeNull(
|
|
319
|
+
makeNull(type?: idl.IDLOptionalType): LanguageExpression;
|
|
315
320
|
makeVoid(): LanguageExpression;
|
|
316
321
|
makeLambdaReturn(expr?: LanguageExpression): LanguageStatement;
|
|
317
322
|
makeRuntimeTypeCondition(typeVarName: string, equals: boolean, type: RuntimeType, varName?: string): LanguageExpression;
|
|
@@ -325,7 +330,7 @@ export declare abstract class LanguageWriter {
|
|
|
325
330
|
makeNativeCall(nativeModule: NativeModuleType, method: string, params: LanguageExpression[], nullable?: boolean): LanguageExpression;
|
|
326
331
|
makeBlock(statements: LanguageStatement[], inScope?: boolean): BlockStatement;
|
|
327
332
|
nativeReceiver(nativeModule: NativeModuleType): string;
|
|
328
|
-
abstract makeDefinedCheck(value: string, isTag?: boolean): LanguageExpression;
|
|
333
|
+
abstract makeDefinedCheck(value: string, type?: idl.IDLOptionalType, isTag?: boolean): LanguageExpression;
|
|
329
334
|
makeRuntimeTypeDefinedCheck(runtimeType: string): LanguageExpression;
|
|
330
335
|
makeCondition(condition: LanguageExpression, thenStatement: LanguageStatement, elseStatement?: LanguageStatement, insideIfOp?: () => void, insideElseOp?: () => void): LanguageStatement;
|
|
331
336
|
makeMultiBranchCondition(conditions: BranchStatement[], elseStatement?: LanguageStatement): LanguageStatement;
|
|
@@ -381,10 +386,7 @@ export declare abstract class LanguageWriter {
|
|
|
381
386
|
* Writes `namespace <namespace> {` and adds extra indent
|
|
382
387
|
* @param namespace Namespace to begin
|
|
383
388
|
*/
|
|
384
|
-
pushNamespace(namespace: string, options:
|
|
385
|
-
ident: boolean;
|
|
386
|
-
isDeclared?: boolean;
|
|
387
|
-
}): void;
|
|
389
|
+
pushNamespace(namespace: string, options: NamespaceOptions): void;
|
|
388
390
|
/**
|
|
389
391
|
* Writes closing brace of namespace block and removes one level of indent
|
|
390
392
|
*/
|
|
@@ -440,7 +440,9 @@ export class LanguageWriter {
|
|
|
440
440
|
fs.writeFileSync(file, this.getOutput().join("\n"));
|
|
441
441
|
}
|
|
442
442
|
writeLines(lines) {
|
|
443
|
-
|
|
443
|
+
if (typeof lines === 'string')
|
|
444
|
+
lines = lines.split("\n");
|
|
445
|
+
lines.forEach(it => this.print(it));
|
|
444
446
|
}
|
|
445
447
|
writeGetterImplementation(method, op) {
|
|
446
448
|
var _a;
|
|
@@ -486,7 +488,7 @@ export class LanguageWriter {
|
|
|
486
488
|
makeThis() {
|
|
487
489
|
return new StringExpression("this");
|
|
488
490
|
}
|
|
489
|
-
makeNull(
|
|
491
|
+
makeNull(type) {
|
|
490
492
|
return new StringExpression("null");
|
|
491
493
|
}
|
|
492
494
|
makeVoid() {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import * as idl from '../../idl';
|
|
16
16
|
import { CJKeywords } from '../../languageSpecificKeywords';
|
|
17
|
+
import { generateSyntheticIdlNodeName } from '../../peer-generation/idl/common';
|
|
17
18
|
import { convertNode, convertType } from '../nameConvertor';
|
|
18
19
|
import { InteropArgConvertor } from './InteropConvertors';
|
|
19
20
|
export class CJTypeNameConvertor {
|
|
@@ -33,7 +34,7 @@ export class CJTypeNameConvertor {
|
|
|
33
34
|
return `Option<${this.convert(type.type)}>`;
|
|
34
35
|
}
|
|
35
36
|
convertUnion(type) {
|
|
36
|
-
return type.
|
|
37
|
+
return "Union_" + type.types.map(it => generateSyntheticIdlNodeName(it)).join("_");
|
|
37
38
|
}
|
|
38
39
|
convertContainer(type) {
|
|
39
40
|
if (idl.IDLContainerUtils.isSequence(type)) {
|
|
@@ -122,9 +122,11 @@ export class InteropArgConvertor {
|
|
|
122
122
|
switch (type) {
|
|
123
123
|
case idl.IDLI64Type: return "KLong";
|
|
124
124
|
case idl.IDLU64Type: return "KLong";
|
|
125
|
+
case idl.IDLU8Type: return "KInt";
|
|
125
126
|
case idl.IDLI32Type: return "KInt";
|
|
126
127
|
case idl.IDLU32Type: return "KInt";
|
|
127
128
|
case idl.IDLF32Type: return "KFloat";
|
|
129
|
+
case idl.IDLF64Type: return "KDouble";
|
|
128
130
|
case idl.IDLNumberType: return 'KInteropNumber';
|
|
129
131
|
case idl.IDLBigintType: return 'KLong';
|
|
130
132
|
case idl.IDLSerializerBuffer: return 'KSerializerBuffer';
|
|
@@ -154,6 +154,8 @@ export class JavaTypeNameConvertor {
|
|
|
154
154
|
case 'KLong': return 'long';
|
|
155
155
|
case 'float32':
|
|
156
156
|
case 'KFloat': return 'float';
|
|
157
|
+
case 'float64':
|
|
158
|
+
case 'KDouble': return 'double';
|
|
157
159
|
case 'KUint8ArrayPtr': return 'byte[]';
|
|
158
160
|
case 'KInt32ArrayPtr': return 'int[]';
|
|
159
161
|
case 'KFloat32ArrayPtr': return 'float[]';
|
|
@@ -191,6 +193,7 @@ export class JavaInteropArgConvertor extends InteropArgConvertor {
|
|
|
191
193
|
case idl.IDLI32Type: return "int";
|
|
192
194
|
case idl.IDLU32Type: return "int";
|
|
193
195
|
case idl.IDLF32Type: return "float";
|
|
196
|
+
case idl.IDLF64Type: return "double";
|
|
194
197
|
case idl.IDLBigintType: return "long";
|
|
195
198
|
case idl.IDLSerializerBuffer: return "long";
|
|
196
199
|
case idl.IDLFunctionType: return "int";
|
|
@@ -133,6 +133,7 @@ const KBoolean = "KBoolean";
|
|
|
133
133
|
const KInt = "KInt";
|
|
134
134
|
const KLong = "KLong";
|
|
135
135
|
const KFloat = "KFloat";
|
|
136
|
+
const KDouble = "KDouble";
|
|
136
137
|
const KNativePointer = "KNativePointer";
|
|
137
138
|
const KInteropNumber = "KInteropNumber";
|
|
138
139
|
const KStringPtr = "KStringPtr";
|
|
@@ -216,6 +217,7 @@ export class KotlinCInteropArgConvertor {
|
|
|
216
217
|
case idl.IDLI32Type: return KInt;
|
|
217
218
|
case idl.IDLU32Type: return KInt;
|
|
218
219
|
case idl.IDLF32Type: return KFloat;
|
|
220
|
+
case idl.IDLF64Type: return KDouble;
|
|
219
221
|
case idl.IDLNumberType: return KInteropNumber;
|
|
220
222
|
case idl.IDLBigintType: return KLong;
|
|
221
223
|
case idl.IDLSerializerBuffer: return KSerializerBuffer;
|
|
@@ -46,7 +46,15 @@ export class TSTypeNameConvertor {
|
|
|
46
46
|
return node.name;
|
|
47
47
|
}
|
|
48
48
|
convertOptional(type) {
|
|
49
|
-
|
|
49
|
+
if (idl.hasExtAttribute(type, idl.IDLExtendedAttributes.UnionOnlyNull)) {
|
|
50
|
+
return `${this.convert(type.type)} | null`;
|
|
51
|
+
}
|
|
52
|
+
else if (idl.hasExtAttribute(type, idl.IDLExtendedAttributes.UnionWithNull)) {
|
|
53
|
+
return `${this.convert(type.type)} | null | undefined`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return `${this.convert(type.type)} | undefined`;
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
convertUnion(type) {
|
|
52
60
|
return type.types.
|
|
@@ -248,9 +256,11 @@ export class TSInteropArgConvertor {
|
|
|
248
256
|
switch (type) {
|
|
249
257
|
case idl.IDLI64Type: return "KLong";
|
|
250
258
|
case idl.IDLU64Type: return "KLong";
|
|
259
|
+
case idl.IDLU8Type: return "KInt";
|
|
251
260
|
case idl.IDLI32Type: return "KInt";
|
|
252
261
|
case idl.IDLU32Type: return "KInt";
|
|
253
262
|
case idl.IDLF32Type: return "KFloat";
|
|
263
|
+
case idl.IDLF64Type: return "KDouble";
|
|
254
264
|
case idl.IDLNumberType: return 'number';
|
|
255
265
|
case idl.IDLBigintType: return 'bigint';
|
|
256
266
|
case idl.IDLBooleanType:
|
|
@@ -2,7 +2,7 @@ import * as idl from "../../idl";
|
|
|
2
2
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
3
3
|
import { ArgConvertor, BaseArgConvertor } from "../ArgConvertors";
|
|
4
4
|
import { RuntimeType } from "../common";
|
|
5
|
-
import { AssignStatement, DelegationCall, FieldModifier, LanguageExpression, LanguageStatement, LanguageWriter, MakeCastOptions, Method, MethodModifier, MethodSignature, ObjectArgs } from "../LanguageWriter";
|
|
5
|
+
import { AssignStatement, DelegationCall, FieldModifier, LanguageExpression, LanguageStatement, LanguageWriter, MakeCastOptions, Method, MethodModifier, MethodSignature, NamespaceOptions, ObjectArgs } from "../LanguageWriter";
|
|
6
6
|
import { IdlNameConvertor } from "../nameConvertor";
|
|
7
7
|
import { Language } from "../../Language";
|
|
8
8
|
import { ReferenceResolver } from "../../peer-generation/ReferenceResolver";
|
|
@@ -136,7 +136,7 @@ export declare class CJLanguageWriter extends LanguageWriter {
|
|
|
136
136
|
makeRuntimeType(rt: RuntimeType): LanguageExpression;
|
|
137
137
|
protected makeRuntimeTypeGetterCall(value: string): LanguageExpression;
|
|
138
138
|
makeMapInsert(keyAccessor: string, key: string, valueAccessor: string, value: string): LanguageStatement;
|
|
139
|
-
makeNull(
|
|
139
|
+
makeNull(): LanguageExpression;
|
|
140
140
|
getTagType(): idl.IDLType;
|
|
141
141
|
getRuntimeType(): idl.IDLType;
|
|
142
142
|
makeTupleAssign(receiver: string, fields: string[]): LanguageStatement;
|
|
@@ -154,10 +154,7 @@ export declare class CJLanguageWriter extends LanguageWriter {
|
|
|
154
154
|
makeEquals(args: LanguageExpression[]): LanguageExpression;
|
|
155
155
|
runtimeType(param: ArgConvertor, valueType: string, value: string): void;
|
|
156
156
|
escapeKeyword(word: string): string;
|
|
157
|
-
pushNamespace(namespace: string, options:
|
|
158
|
-
ident: boolean;
|
|
159
|
-
isDeclared?: boolean;
|
|
160
|
-
}): void;
|
|
157
|
+
pushNamespace(namespace: string, options: NamespaceOptions): void;
|
|
161
158
|
popNamespace(options: {
|
|
162
159
|
ident: boolean;
|
|
163
160
|
}): void;
|
|
@@ -16,7 +16,7 @@ import * as idl from "../../idl";
|
|
|
16
16
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
17
17
|
import { CJKeywords } from "../../languageSpecificKeywords";
|
|
18
18
|
import { RuntimeType } from "../common";
|
|
19
|
-
import { AssignStatement, BlockStatement, ExpressionStatement, FieldModifier, LambdaExpression, LanguageWriter, MethodModifier, MethodSignature, ReturnStatement
|
|
19
|
+
import { AssignStatement, BlockStatement, DelegationType, ExpressionStatement, FieldModifier, LambdaExpression, LanguageWriter, MethodModifier, MethodSignature, ReturnStatement } from "../LanguageWriter";
|
|
20
20
|
import { Language } from "../../Language";
|
|
21
21
|
import { indentedBy, isDefined } from "../../util";
|
|
22
22
|
////////////////////////////////////////////////////////////////
|
|
@@ -40,7 +40,7 @@ export class CJCheckDefinedExpression {
|
|
|
40
40
|
this.value = value;
|
|
41
41
|
}
|
|
42
42
|
asString() {
|
|
43
|
-
return
|
|
43
|
+
return `let Some(${this.value}) <- ${this.value}`;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
export class CJCastExpression {
|
|
@@ -328,22 +328,22 @@ export class CJLanguageWriter extends LanguageWriter {
|
|
|
328
328
|
let i = 1;
|
|
329
329
|
while (signature.isArgOptional(signature.args.length - i)) {
|
|
330
330
|
let smallerSignature = signature.args.slice(0, -i);
|
|
331
|
-
this.printer.print(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') + ' ' : ''}init
|
|
331
|
+
this.printer.print(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') + ' ' : ''}init(${smallerSignature.map((it, index) => `${this.escapeKeyword(signature.argName(index))}: ${this.getNodeName(it)}`).join(", ")}) {`);
|
|
332
332
|
this.pushIndent();
|
|
333
333
|
let lessArgs = (_a = signature.args) === null || _a === void 0 ? void 0 : _a.slice(0, -i).map((_, i) => this.escapeKeyword(signature.argName(i))).join(', ');
|
|
334
334
|
for (let idx = 0; idx < i; idx++) {
|
|
335
335
|
lessArgs = lessArgs.concat(`${i == signature.args.length && idx == 0 ? '' : ', '}Option.None`);
|
|
336
336
|
}
|
|
337
|
-
this.print(
|
|
337
|
+
this.print(`this(${lessArgs})`);
|
|
338
338
|
this.popIndent();
|
|
339
339
|
this.printer.print(`}`);
|
|
340
340
|
i += 1;
|
|
341
341
|
}
|
|
342
|
-
this.printer.print(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') + ' ' : ''}
|
|
342
|
+
this.printer.print(`${modifiers ? modifiers.map((it) => MethodModifier[it].toLowerCase()).join(' ') + ' ' : ''}init(${signature.args.map((it, index) => `${this.escapeKeyword(signature.argName(index))}: ${this.getNodeName(idl.maybeOptional(it, signature.isArgOptional(index)))}`).join(", ")}) {`);
|
|
343
343
|
this.pushIndent();
|
|
344
344
|
if (delegationCall) {
|
|
345
|
-
|
|
346
|
-
this.print(
|
|
345
|
+
const delegationType = ((delegationCall === null || delegationCall === void 0 ? void 0 : delegationCall.delegationType) == DelegationType.THIS) ? "this" : "super";
|
|
346
|
+
this.print(`${delegationType}(${delegationCall.delegationArgs.map(it => it.asString()).join(", ")})`);
|
|
347
347
|
}
|
|
348
348
|
op(this);
|
|
349
349
|
this.popIndent();
|
|
@@ -527,8 +527,8 @@ export class CJLanguageWriter extends LanguageWriter {
|
|
|
527
527
|
makeMapInsert(keyAccessor, key, valueAccessor, value) {
|
|
528
528
|
return this.makeStatement(this.makeMethodCall(keyAccessor, "add", [this.makeString(key), this.makeString(value)]));
|
|
529
529
|
}
|
|
530
|
-
makeNull(
|
|
531
|
-
return
|
|
530
|
+
makeNull() {
|
|
531
|
+
return this.makeUndefined();
|
|
532
532
|
}
|
|
533
533
|
getTagType() {
|
|
534
534
|
return idl.createReferenceType("Tags");
|
|
@@ -101,7 +101,7 @@ export declare class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
101
101
|
makeCast(expr: LanguageExpression, node: IDLNode, options?: MakeCastOptions): LanguageExpression;
|
|
102
102
|
makePointerPropertyAccessExpression(expression: string, name: string): CppPointerPropertyAccessExpression;
|
|
103
103
|
writePrintLog(message: string): void;
|
|
104
|
-
makeDefinedCheck(value: string, isTag?: boolean): LanguageExpression;
|
|
104
|
+
makeDefinedCheck(value: string, type?: idl.IDLOptionalType, isTag?: boolean): LanguageExpression;
|
|
105
105
|
makeSetUnionSelector(value: string, index: string): LanguageStatement;
|
|
106
106
|
makeSetOptionTag(value: string, tag: LanguageExpression): LanguageStatement;
|
|
107
107
|
getObjectAccessor(convertor: BaseArgConvertor, value: string, args?: ObjectArgs): string;
|
|
@@ -347,7 +347,7 @@ export class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
347
347
|
writePrintLog(message) {
|
|
348
348
|
this.print(`printf("${message}\\n");`);
|
|
349
349
|
}
|
|
350
|
-
makeDefinedCheck(value, isTag) {
|
|
350
|
+
makeDefinedCheck(value, type, isTag) {
|
|
351
351
|
return this.makeString(isTag ? `${value} != ${PrimitiveTypeList.UndefinedTag}`
|
|
352
352
|
: `runtimeType(${value}) != ${PrimitiveTypeList.UndefinedRuntime}`);
|
|
353
353
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
2
|
-
import { LambdaExpression, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature } from "../LanguageWriter";
|
|
2
|
+
import { LambdaExpression, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature, NamespaceOptions } from "../LanguageWriter";
|
|
3
3
|
import { TSLanguageWriter } from "./TsLanguageWriter";
|
|
4
4
|
import { IDLEnum, IDLType } from '../../idl';
|
|
5
5
|
import { ArgConvertor } from "../ArgConvertors";
|
|
@@ -45,6 +45,7 @@ export declare function makeArrayTypeCheckCall(valueAccessor: string, typeName:
|
|
|
45
45
|
export declare class ETSLanguageWriter extends TSLanguageWriter {
|
|
46
46
|
private arrayConvertor;
|
|
47
47
|
constructor(printer: IndentedPrinter, resolver: ReferenceResolver, typeConvertor: IdlNameConvertor, arrayConvertor: IdlNameConvertor);
|
|
48
|
+
pushNamespace(namespace: string, options: NamespaceOptions): void;
|
|
48
49
|
fork(options?: {
|
|
49
50
|
resolver?: ReferenceResolver;
|
|
50
51
|
}): LanguageWriter;
|
|
@@ -175,6 +175,12 @@ export class ETSLanguageWriter extends TSLanguageWriter {
|
|
|
175
175
|
super(printer, resolver, typeConvertor, Language.ARKTS);
|
|
176
176
|
this.arrayConvertor = arrayConvertor;
|
|
177
177
|
}
|
|
178
|
+
pushNamespace(namespace, options) {
|
|
179
|
+
if (options.isDefault) {
|
|
180
|
+
this.print(`export default ${namespace}`);
|
|
181
|
+
}
|
|
182
|
+
super.pushNamespace(namespace, options);
|
|
183
|
+
}
|
|
178
184
|
fork(options) {
|
|
179
185
|
var _a;
|
|
180
186
|
return new ETSLanguageWriter(new IndentedPrinter([], this.indentDepth()), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.arrayConvertor);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as idl from '../../idl';
|
|
2
2
|
import { Language } from '../../Language';
|
|
3
3
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
4
|
-
import { AssignStatement, DelegationCall, FieldModifier, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature, ObjectArgs } from "../LanguageWriter";
|
|
4
|
+
import { AssignStatement, DelegationCall, FieldModifier, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature, NamespaceOptions, ObjectArgs } from "../LanguageWriter";
|
|
5
5
|
import { ArgConvertor } from "../ArgConvertors";
|
|
6
6
|
import { IdlNameConvertor } from "../nameConvertor";
|
|
7
7
|
import { RuntimeType } from "../common";
|
|
@@ -141,10 +141,7 @@ export declare class KotlinLanguageWriter extends LanguageWriter {
|
|
|
141
141
|
makeNewObject(objectName: string, params?: LanguageExpression[]): LanguageExpression;
|
|
142
142
|
escapeKeyword(keyword: string): string;
|
|
143
143
|
makeStaticBlock(op: (writer: LanguageWriter) => void): void;
|
|
144
|
-
pushNamespace(namespace: string, options:
|
|
145
|
-
ident: boolean;
|
|
146
|
-
isDeclared?: boolean;
|
|
147
|
-
}): void;
|
|
144
|
+
pushNamespace(namespace: string, options: NamespaceOptions): void;
|
|
148
145
|
popNamespace(options: {
|
|
149
146
|
ident: boolean;
|
|
150
147
|
}): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as idl from '../../idl';
|
|
2
2
|
import { Language } from '../../Language';
|
|
3
3
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
4
|
-
import { DelegationCall, FieldModifier, LambdaExpression, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature, ObjectArgs, ReturnStatement } from "../LanguageWriter";
|
|
4
|
+
import { DelegationCall, FieldModifier, LambdaExpression, LanguageExpression, LanguageStatement, LanguageWriter, MakeAssignOptions, MakeCastOptions, Method, MethodModifier, MethodSignature, NamespaceOptions, ObjectArgs, ReturnStatement } from "../LanguageWriter";
|
|
5
5
|
import { ArgConvertor } from "../ArgConvertors";
|
|
6
6
|
import { IdlNameConvertor } from "../nameConvertor";
|
|
7
7
|
import { RuntimeType } from "../common";
|
|
@@ -32,10 +32,7 @@ export declare class TSLanguageWriter extends LanguageWriter {
|
|
|
32
32
|
protected typeConvertor: IdlNameConvertor;
|
|
33
33
|
constructor(printer: IndentedPrinter, resolver: ReferenceResolver, typeConvertor: IdlNameConvertor, language?: Language);
|
|
34
34
|
maybeSemicolon(): string;
|
|
35
|
-
pushNamespace(namespace: string, options:
|
|
36
|
-
ident: boolean;
|
|
37
|
-
isDeclared?: boolean;
|
|
38
|
-
}): void;
|
|
35
|
+
pushNamespace(namespace: string, options: NamespaceOptions): void;
|
|
39
36
|
fork(options?: {
|
|
40
37
|
resolver?: ReferenceResolver;
|
|
41
38
|
}): LanguageWriter;
|
|
@@ -69,7 +66,7 @@ export declare class TSLanguageWriter extends LanguageWriter {
|
|
|
69
66
|
writeTypeDeclaration(decl: idl.IDLTypedef): void;
|
|
70
67
|
writeConstant(constName: string, constType: idl.IDLType, constVal?: string): void;
|
|
71
68
|
private writeDeclaration;
|
|
72
|
-
makeNull(): LanguageExpression;
|
|
69
|
+
makeNull(type?: idl.IDLOptionalType): LanguageExpression;
|
|
73
70
|
makeAssign(variableName: string, type: idl.IDLType | undefined, expr: LanguageExpression | undefined, isDeclared?: boolean, isConst?: boolean, options?: MakeAssignOptions): LanguageStatement;
|
|
74
71
|
makeLambda(signature: MethodSignature, body?: LanguageStatement[]): LanguageExpression;
|
|
75
72
|
makeThrowError(message: string): LanguageStatement;
|
|
@@ -83,7 +80,7 @@ export declare class TSLanguageWriter extends LanguageWriter {
|
|
|
83
80
|
getObjectAccessor(convertor: ArgConvertor, value: string, args?: ObjectArgs): string;
|
|
84
81
|
makeUndefined(): LanguageExpression;
|
|
85
82
|
makeRuntimeType(rt: RuntimeType): LanguageExpression;
|
|
86
|
-
makeDefinedCheck(value: string): LanguageExpression;
|
|
83
|
+
makeDefinedCheck(value: string, type?: idl.IDLOptionalType): LanguageExpression;
|
|
87
84
|
makeTupleAlloc(option: string): LanguageStatement;
|
|
88
85
|
makeArrayInit(type: idl.IDLContainerType, size?: number): LanguageExpression;
|
|
89
86
|
makeClassInit(type: idl.IDLType, paramenters: LanguageExpression[]): LanguageExpression;
|
|
@@ -295,7 +295,9 @@ export class TSLanguageWriter extends LanguageWriter {
|
|
|
295
295
|
const normalizedArgs = signature.args.map((it, i) => idl.isOptionalType(it) && signature.isArgOptional(i) ? idl.maybeUnwrapOptionalType(it) : it);
|
|
296
296
|
this.printer.print(`${prefix}${name}${typeParams}(${normalizedArgs.map((it, index) => `${this.escapeKeyword(signature.argName(index))}${signature.isArgOptional(index) ? "?" : ``}: ${this.getNodeName(it)}${signature.argDefault(index) ? ' = ' + signature.argDefault(index) : ""}`).join(", ")})${needReturn ? ": " + this.getNodeName(signature.returnType) : ""}${needBracket ? " {" : ""}`);
|
|
297
297
|
}
|
|
298
|
-
makeNull() {
|
|
298
|
+
makeNull(type) {
|
|
299
|
+
if (type && idl.hasExtAttribute(type, idl.IDLExtendedAttributes.UnionOnlyNull))
|
|
300
|
+
return new StringExpression("null");
|
|
299
301
|
return new StringExpression("undefined");
|
|
300
302
|
}
|
|
301
303
|
makeAssign(variableName, type, expr, isDeclared = true, isConst = true, options) {
|
|
@@ -352,7 +354,15 @@ export class TSLanguageWriter extends LanguageWriter {
|
|
|
352
354
|
makeRuntimeType(rt) {
|
|
353
355
|
return this.makeString(`RuntimeType.${RuntimeType[rt]}`);
|
|
354
356
|
}
|
|
355
|
-
makeDefinedCheck(value) {
|
|
357
|
+
makeDefinedCheck(value, type) {
|
|
358
|
+
if (type) {
|
|
359
|
+
if (idl.hasExtAttribute(type, idl.IDLExtendedAttributes.UnionWithNull)) {
|
|
360
|
+
return this.makeString(`${value} !== undefined && ${value} !== null`);
|
|
361
|
+
}
|
|
362
|
+
else if (idl.hasExtAttribute(type, idl.IDLExtendedAttributes.UnionOnlyNull)) {
|
|
363
|
+
return this.makeString(`${value} !== null`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
356
366
|
return this.makeString(`${value} !== undefined`);
|
|
357
367
|
}
|
|
358
368
|
makeTupleAlloc(option) {
|
|
@@ -289,6 +289,7 @@ class IDLDeserializer {
|
|
|
289
289
|
toIDLConstructor(file, node) {
|
|
290
290
|
return this.withInfo(node, idl.createConstructor(node.arguments.map(it => this.toIDLParameter(file, it)), undefined, {
|
|
291
291
|
documentation: this.makeDocs(node),
|
|
292
|
+
extendedAttributes: this.toExtendedAttributes(node.extAttrs),
|
|
292
293
|
}));
|
|
293
294
|
}
|
|
294
295
|
toIDLParameter(file, node) {
|
|
@@ -5,12 +5,12 @@ export declare class FatalParserException extends Error {
|
|
|
5
5
|
constructor(diagnosticMessages?: DiagnosticMessage[]);
|
|
6
6
|
}
|
|
7
7
|
declare enum TokenKind {
|
|
8
|
-
Words =
|
|
9
|
-
Literal =
|
|
10
|
-
Symbol =
|
|
11
|
-
Comment =
|
|
12
|
-
Whitespace =
|
|
13
|
-
End =
|
|
8
|
+
Words = 0,
|
|
9
|
+
Literal = 1,
|
|
10
|
+
Symbol = 2,
|
|
11
|
+
Comment = 3,
|
|
12
|
+
Whitespace = 4,
|
|
13
|
+
End = 5
|
|
14
14
|
}
|
|
15
15
|
interface Token {
|
|
16
16
|
kind: TokenKind;
|
|
@@ -39,12 +39,12 @@ export class FatalParserException extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
var TokenKind;
|
|
41
41
|
(function (TokenKind) {
|
|
42
|
-
TokenKind["Words"] = "Words";
|
|
43
|
-
TokenKind["Literal"] = "Literal";
|
|
44
|
-
TokenKind["Symbol"] = "Symbol";
|
|
45
|
-
TokenKind["Comment"] = "Comment";
|
|
46
|
-
TokenKind["Whitespace"] = "
|
|
47
|
-
TokenKind["End"] = "End";
|
|
42
|
+
TokenKind[TokenKind["Words"] = 0] = "Words";
|
|
43
|
+
TokenKind[TokenKind["Literal"] = 1] = "Literal";
|
|
44
|
+
TokenKind[TokenKind["Symbol"] = 2] = "Symbol";
|
|
45
|
+
TokenKind[TokenKind["Comment"] = 3] = "Comment";
|
|
46
|
+
TokenKind[TokenKind["Whitespace"] = 4] = "Whitespace";
|
|
47
|
+
TokenKind[TokenKind["End"] = 5] = "End";
|
|
48
48
|
})(TokenKind || (TokenKind = {}));
|
|
49
49
|
const supportedDeclarations = new Set(["attribute", "callback", "const", "constructor", "dictionary",
|
|
50
50
|
"enum", "import", "interface", "namespace", "package", "typedef", "version"]);
|
|
@@ -97,13 +97,17 @@ export class Parser {
|
|
|
97
97
|
}
|
|
98
98
|
parseIDL() {
|
|
99
99
|
var _a;
|
|
100
|
+
trac("parseIDL");
|
|
100
101
|
const previousDiagnosticsCount = DiagnosticMessageGroup.allGroupsEntries.length;
|
|
101
102
|
try {
|
|
102
|
-
trac("parseIDL");
|
|
103
103
|
this._lexerNext();
|
|
104
104
|
this._prevToken = this._curToken;
|
|
105
105
|
let file = this.parseFile();
|
|
106
106
|
file.text = this.content;
|
|
107
|
+
if (DiagnosticMessageGroup.allGroupsEntries.length != previousDiagnosticsCount) {
|
|
108
|
+
// Empty for now, messages will be added in following `catch`.
|
|
109
|
+
throw new FatalParserException();
|
|
110
|
+
}
|
|
107
111
|
return file;
|
|
108
112
|
}
|
|
109
113
|
catch (e) {
|
package/build/lib/src/idl.d.ts
CHANGED
|
@@ -55,10 +55,13 @@ export declare enum IDLExtendedAttributes {
|
|
|
55
55
|
Interfaces = "Interfaces",
|
|
56
56
|
NativeModule = "NativeModule",
|
|
57
57
|
Optional = "Optional",
|
|
58
|
+
UnionOnlyNull = "OptionalOnlyNull",
|
|
59
|
+
UnionWithNull = "OptionalWithNull",
|
|
58
60
|
OriginalEnumMemberName = "OriginalEnumMemberName",
|
|
59
61
|
OriginalGenericName = "OriginalGenericName",
|
|
60
62
|
Predefined = "Predefined",
|
|
61
63
|
Protected = "Protected",
|
|
64
|
+
Abstract = "Abstract",
|
|
62
65
|
Synthetic = "Synthetic",
|
|
63
66
|
Throws = "Throws",
|
|
64
67
|
TraceKey = "TraceKey",
|
package/build/lib/src/idl.js
CHANGED
|
@@ -74,10 +74,13 @@ export var IDLExtendedAttributes;
|
|
|
74
74
|
IDLExtendedAttributes["Interfaces"] = "Interfaces";
|
|
75
75
|
IDLExtendedAttributes["NativeModule"] = "NativeModule";
|
|
76
76
|
IDLExtendedAttributes["Optional"] = "Optional";
|
|
77
|
+
IDLExtendedAttributes["UnionOnlyNull"] = "OptionalOnlyNull";
|
|
78
|
+
IDLExtendedAttributes["UnionWithNull"] = "OptionalWithNull";
|
|
77
79
|
IDLExtendedAttributes["OriginalEnumMemberName"] = "OriginalEnumMemberName";
|
|
78
80
|
IDLExtendedAttributes["OriginalGenericName"] = "OriginalGenericName";
|
|
79
81
|
IDLExtendedAttributes["Predefined"] = "Predefined";
|
|
80
82
|
IDLExtendedAttributes["Protected"] = "Protected";
|
|
83
|
+
IDLExtendedAttributes["Abstract"] = "Abstract";
|
|
81
84
|
IDLExtendedAttributes["Synthetic"] = "Synthetic";
|
|
82
85
|
IDLExtendedAttributes["Throws"] = "Throws";
|
|
83
86
|
IDLExtendedAttributes["TraceKey"] = "TraceKey";
|
package/build/lib/src/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export * from "./peer-generation/unions";
|
|
|
51
51
|
export * from "./peer-generation/getSuperType";
|
|
52
52
|
export * from "./transformers/FqnTransformer";
|
|
53
53
|
export * from "./transformers/GenericTransformer";
|
|
54
|
+
export * from "./transformers/NullTransformer";
|
|
54
55
|
export * from "./LanguageWriters";
|
|
55
56
|
export * from "./peer-generation/ReferenceResolver";
|
|
56
57
|
export * from "./peer-generation/idl/common";
|
package/build/lib/src/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export * from "./peer-generation/unions";
|
|
|
65
65
|
export * from "./peer-generation/getSuperType";
|
|
66
66
|
export * from "./transformers/FqnTransformer";
|
|
67
67
|
export * from "./transformers/GenericTransformer";
|
|
68
|
+
export * from "./transformers/NullTransformer";
|
|
68
69
|
export * from "./LanguageWriters";
|
|
69
70
|
export * from "./peer-generation/ReferenceResolver";
|
|
70
71
|
export * from "./peer-generation/idl/common";
|
|
@@ -13,10 +13,11 @@ export declare class MaterializedField {
|
|
|
13
13
|
constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined, extraMethodName?: string | undefined);
|
|
14
14
|
}
|
|
15
15
|
export declare class MaterializedMethod extends PeerMethod {
|
|
16
|
+
decl: idl.IDLConstructor | idl.IDLMethod | undefined;
|
|
16
17
|
implementationParentName: string;
|
|
17
|
-
constructor(sig: PeerMethodSignature, originalParentName: string, implementationParentName: string, returnType: idl.IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
|
|
18
|
+
constructor(decl: idl.IDLConstructor | idl.IDLMethod | undefined, sig: PeerMethodSignature, originalParentName: string, implementationParentName: string, returnType: idl.IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
|
|
18
19
|
tsReturnType(): idl.IDLType | undefined;
|
|
19
|
-
getPrivateMethod(): MaterializedMethod;
|
|
20
|
+
getPrivateMethod(asProtected?: boolean): MaterializedMethod;
|
|
20
21
|
withReturnType(returnType: idl.IDLType): MaterializedMethod;
|
|
21
22
|
}
|
|
22
23
|
export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
|
|
@@ -36,9 +37,10 @@ export declare class MaterializedClass implements PeerClassBase {
|
|
|
36
37
|
readonly methods: MaterializedMethod[];
|
|
37
38
|
readonly needBeGenerated: boolean;
|
|
38
39
|
readonly taggedMethods: idl.IDLMethod[];
|
|
40
|
+
readonly isRefCounted: boolean;
|
|
39
41
|
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
|
|
40
42
|
finalizer: MaterializedMethod | undefined, // undefined when used for global functions
|
|
41
|
-
methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
|
|
43
|
+
methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[], isRefCounted?: boolean);
|
|
42
44
|
getImplementationName(): string;
|
|
43
45
|
generatedName(isCallSignature: boolean): string;
|
|
44
46
|
private _isGlobal;
|
|
@@ -27,14 +27,15 @@ export class MaterializedField {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
export class MaterializedMethod extends PeerMethod {
|
|
30
|
-
constructor(sig, originalParentName, implementationParentName, returnType, isCallSignature, uniqueOverloadName, method) {
|
|
31
|
-
super(sig, originalParentName, returnType, isCallSignature, uniqueOverloadName, method);
|
|
30
|
+
constructor(decl, sig, originalParentName, implementationParentName, returnType, isCallSignature, uniqueOverloadName, method) {
|
|
31
|
+
super(decl, sig, originalParentName, returnType, isCallSignature, uniqueOverloadName, method);
|
|
32
|
+
this.decl = decl;
|
|
32
33
|
this.implementationParentName = implementationParentName;
|
|
33
34
|
}
|
|
34
35
|
tsReturnType() {
|
|
35
36
|
return this.method.signature.returnType;
|
|
36
37
|
}
|
|
37
|
-
getPrivateMethod() {
|
|
38
|
+
getPrivateMethod(asProtected = false) {
|
|
38
39
|
var _a, _b;
|
|
39
40
|
let privateMethod = this;
|
|
40
41
|
if (!((_a = privateMethod.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.PRIVATE))) {
|
|
@@ -43,7 +44,8 @@ export class MaterializedMethod extends PeerMethod {
|
|
|
43
44
|
modifiers: ((_b = this.method.modifiers) !== null && _b !== void 0 ? _b : [])
|
|
44
45
|
.filter(it => it !== MethodModifier.PUBLIC)
|
|
45
46
|
.filter(it => it !== MethodModifier.OVERRIDE)
|
|
46
|
-
.
|
|
47
|
+
.filter(it => !asProtected || (it !== MethodModifier.PRIVATE))
|
|
48
|
+
.concat([asProtected ? MethodModifier.PROTECTED : MethodModifier.PRIVATE])
|
|
47
49
|
})
|
|
48
50
|
});
|
|
49
51
|
}
|
|
@@ -59,12 +61,12 @@ export class MaterializedMethod extends PeerMethod {
|
|
|
59
61
|
}
|
|
60
62
|
export function copyMaterializedMethod(method, overrides) {
|
|
61
63
|
var _a;
|
|
62
|
-
return new MaterializedMethod(method.sig, method.originalParentName, method.implementationParentName, method.returnType, method.isCallSignature, method.uniqueOverloadName, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method);
|
|
64
|
+
return new MaterializedMethod(method.decl, method.sig, method.originalParentName, method.implementationParentName, method.returnType, method.isCallSignature, method.uniqueOverloadName, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method);
|
|
63
65
|
}
|
|
64
66
|
export class MaterializedClass {
|
|
65
67
|
constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctors, // zero size when used for global functions
|
|
66
68
|
finalizer, // undefined when used for global functions
|
|
67
|
-
methods, needBeGenerated = true, taggedMethods = []) {
|
|
69
|
+
methods, needBeGenerated = true, taggedMethods = [], isRefCounted = false) {
|
|
68
70
|
this.decl = decl;
|
|
69
71
|
this.className = className;
|
|
70
72
|
this.isInterface = isInterface;
|
|
@@ -78,6 +80,7 @@ export class MaterializedClass {
|
|
|
78
80
|
this.methods = methods;
|
|
79
81
|
this.needBeGenerated = needBeGenerated;
|
|
80
82
|
this.taggedMethods = taggedMethods;
|
|
83
|
+
this.isRefCounted = isRefCounted;
|
|
81
84
|
this._isGlobal = false;
|
|
82
85
|
}
|
|
83
86
|
getImplementationName() {
|
|
@@ -97,7 +100,7 @@ export function createDestroyPeerMethod(clazz) {
|
|
|
97
100
|
if (clazz.isGlobalScope() || clazz.isStaticMaterialized) {
|
|
98
101
|
return undefined;
|
|
99
102
|
}
|
|
100
|
-
return new MaterializedMethod(new PeerMethodSignature(PeerMethodSignature.DESTROY, '%NEVER_USED$', [], idl.IDLVoidType, clazz.decl), idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), idl.IDLVoidType, false, PeerMethodSignature.DESTROY, new Method(PeerMethodSignature.DESTROY, new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
|
|
103
|
+
return new MaterializedMethod(undefined, new PeerMethodSignature(PeerMethodSignature.DESTROY, '%NEVER_USED$', [], idl.IDLVoidType, clazz.decl), idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), idl.IDLVoidType, false, PeerMethodSignature.DESTROY, new Method(PeerMethodSignature.DESTROY, new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
|
|
101
104
|
}
|
|
102
105
|
export function getInternalClassName(name) {
|
|
103
106
|
return `${name}Internal`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDLFile, IDLProperty } from "../idl";
|
|
1
|
+
import { IDLFile, IDLInterface, IDLProperty } from "../idl";
|
|
2
2
|
import { PeerMethod } from "./PeerMethod";
|
|
3
3
|
export interface PeerClassBase {
|
|
4
4
|
generatedName(isCallSignature: boolean): string;
|
|
@@ -8,10 +8,11 @@ export interface ComponentBuilderInfo {
|
|
|
8
8
|
peerMethodName: string;
|
|
9
9
|
}
|
|
10
10
|
export declare class PeerClass implements PeerClassBase {
|
|
11
|
+
readonly decl: IDLInterface;
|
|
11
12
|
readonly file: IDLFile;
|
|
12
13
|
readonly componentName: string;
|
|
13
14
|
readonly originalFilename: string;
|
|
14
|
-
constructor(file: IDLFile, componentName: string, originalFilename: string);
|
|
15
|
+
constructor(decl: IDLInterface, file: IDLFile, componentName: string, originalFilename: string);
|
|
15
16
|
generatedName(isCallSignature: boolean): string;
|
|
16
17
|
methods: PeerMethod[];
|
|
17
18
|
componentBuilderInfos: ComponentBuilderInfo[];
|
|
@@ -16,7 +16,8 @@ import { IDLI32Type, IDLPointerType } from "../idl";
|
|
|
16
16
|
import { PeerMethod, PeerMethodArg, PeerMethodSignature } from "./PeerMethod";
|
|
17
17
|
import { Method, MethodModifier, NamedMethodSignature } from "../LanguageWriters/LanguageWriter";
|
|
18
18
|
export class PeerClass {
|
|
19
|
-
constructor(file, componentName, originalFilename) {
|
|
19
|
+
constructor(decl, file, componentName, originalFilename) {
|
|
20
|
+
this.decl = decl;
|
|
20
21
|
this.file = file;
|
|
21
22
|
this.componentName = componentName;
|
|
22
23
|
this.originalFilename = originalFilename;
|
|
@@ -37,6 +38,6 @@ export class PeerClass {
|
|
|
37
38
|
export function createConstructPeerMethod(clazz) {
|
|
38
39
|
// TODO here is class FQName needed, but can not calculate if from current PeerClass data
|
|
39
40
|
const classFQN = [clazz.componentName];
|
|
40
|
-
return new PeerMethod(new PeerMethodSignature(PeerMethodSignature.CTOR, classFQN.concat(PeerMethodSignature.CTOR).join('_'), [new PeerMethodArg('id', IDLI32Type), new PeerMethodArg('flags', IDLI32Type)], IDLPointerType), clazz.componentName, IDLPointerType, false, PeerMethodSignature.CTOR, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
|
|
41
|
+
return new PeerMethod(undefined, new PeerMethodSignature(PeerMethodSignature.CTOR, classFQN.concat(PeerMethodSignature.CTOR).join('_'), [new PeerMethodArg('id', IDLI32Type), new PeerMethodArg('flags', IDLI32Type)], IDLPointerType), clazz.componentName, IDLPointerType, false, PeerMethodSignature.CTOR, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
|
|
41
42
|
}
|
|
42
43
|
//# sourceMappingURL=PeerClass.js.map
|
|
@@ -17,7 +17,7 @@ import * as idl from '../idl';
|
|
|
17
17
|
import { resolveNamedNode } from '../resolveNamedNode';
|
|
18
18
|
import { Language } from '../Language';
|
|
19
19
|
import { createLanguageWriter } from '../LanguageWriters';
|
|
20
|
-
import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, ObjectConvertor,
|
|
20
|
+
import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, ObjectConvertor, } from "../LanguageWriters/ArgConvertors";
|
|
21
21
|
import { CppNameConvertor } from '../LanguageWriters/convertors/CppConvertors';
|
|
22
22
|
import { CJTypeNameConvertor } from '../LanguageWriters/convertors/CJConvertors';
|
|
23
23
|
import { CppConvertor } from '../LanguageWriters/convertors/CppConvertors';
|
|
@@ -280,10 +280,10 @@ export class PeerLibrary {
|
|
|
280
280
|
}
|
|
281
281
|
typeConvertor(param, type, isOptionalParam = false) {
|
|
282
282
|
if (isOptionalParam) {
|
|
283
|
-
return new OptionConvertor(this, param, idl.
|
|
283
|
+
return new OptionConvertor(this, param, idl.isOptionalType(type) ? type : idl.createOptionalType(type));
|
|
284
284
|
}
|
|
285
285
|
if (idl.isOptionalType(type)) {
|
|
286
|
-
return new OptionConvertor(this, param, type
|
|
286
|
+
return new OptionConvertor(this, param, type);
|
|
287
287
|
}
|
|
288
288
|
if (idl.isPrimitiveType(type)) {
|
|
289
289
|
switch (type) {
|
|
@@ -297,7 +297,7 @@ export class PeerLibrary {
|
|
|
297
297
|
case idl.IDLU64Type: return new NumericConvertor(param, type);
|
|
298
298
|
case idl.IDLF16Type: return new NumericConvertor(param, type);
|
|
299
299
|
case idl.IDLF32Type: return new NumericConvertor(param, type);
|
|
300
|
-
case idl.IDLF64Type: return new
|
|
300
|
+
case idl.IDLF64Type: return new NumericConvertor(param, type);
|
|
301
301
|
case idl.IDLBigintType: return new BigIntToU64Convertor(param);
|
|
302
302
|
case idl.IDLSerializerBuffer: new PointerConvertor(param);
|
|
303
303
|
case idl.IDLPointerType: return new PointerConvertor(param);
|
|
@@ -420,7 +420,8 @@ export class PeerLibrary {
|
|
|
420
420
|
case `Record`:
|
|
421
421
|
return new CustomTypeConvertor(param, "Record", false, "Record<string, string>");
|
|
422
422
|
case `Optional`:
|
|
423
|
-
|
|
423
|
+
throw new Error("Not expected to have reference type named Optional");
|
|
424
|
+
// return new OptionConvertor(this, param, type.typeArguments![0])
|
|
424
425
|
}
|
|
425
426
|
return undefined;
|
|
426
427
|
}
|
|
@@ -27,13 +27,14 @@ export declare class PeerMethodSignature {
|
|
|
27
27
|
static get DESTROY(): string;
|
|
28
28
|
}
|
|
29
29
|
export declare class PeerMethod {
|
|
30
|
+
decl: idl.IDLConstructor | idl.IDLMethod | idl.IDLCallable | idl.IDLProperty | undefined;
|
|
30
31
|
sig: PeerMethodSignature;
|
|
31
32
|
originalParentName: string;
|
|
32
33
|
returnType: IDLType;
|
|
33
34
|
isCallSignature: boolean;
|
|
34
35
|
uniqueOverloadName: string;
|
|
35
36
|
method: Method;
|
|
36
|
-
constructor(sig: PeerMethodSignature, originalParentName: string, returnType: IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
|
|
37
|
+
constructor(decl: idl.IDLConstructor | idl.IDLMethod | idl.IDLCallable | idl.IDLProperty | undefined, sig: PeerMethodSignature, originalParentName: string, returnType: IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
|
|
37
38
|
argConvertors(library: PeerLibrary): ArgConvertor[];
|
|
38
39
|
argAndOutConvertors(library: PeerLibrary): ArgConvertor[];
|
|
39
40
|
}
|
|
@@ -80,11 +80,12 @@ export class PeerMethodSignature {
|
|
|
80
80
|
static get DESTROY() { return "destroyPeer"; }
|
|
81
81
|
}
|
|
82
82
|
export class PeerMethod {
|
|
83
|
-
constructor(sig, originalParentName, returnType, isCallSignature,
|
|
83
|
+
constructor(decl, sig, originalParentName, returnType, isCallSignature,
|
|
84
84
|
// arkts specific feature, where overloads - are different functions grouped by overload keyword.
|
|
85
85
|
// Must be moved to interface description as so as `method` field
|
|
86
86
|
uniqueOverloadName, method) {
|
|
87
87
|
var _a, _b;
|
|
88
|
+
this.decl = decl;
|
|
88
89
|
this.sig = sig;
|
|
89
90
|
this.originalParentName = originalParentName;
|
|
90
91
|
this.returnType = returnType;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as idl from '../idl';
|
|
2
2
|
import { ReferenceResolver } from './ReferenceResolver';
|
|
3
|
+
export declare function getExtendsChain(declaration: idl.IDLInterface, resolver: ReferenceResolver): idl.IDLReferenceType[];
|
|
3
4
|
export declare function getSuper(declaration: idl.IDLInterface, resolver: ReferenceResolver): idl.IDLInterface | undefined;
|
|
4
5
|
export declare function getSuperType(declaration: idl.IDLInterface, resolver: ReferenceResolver): idl.IDLReferenceType | undefined;
|
|
5
6
|
//# sourceMappingURL=getSuperType.d.ts.map
|
|
@@ -44,6 +44,15 @@ function getSuperTuple(declaration, resolver) {
|
|
|
44
44
|
}
|
|
45
45
|
return [resolved, fst];
|
|
46
46
|
}
|
|
47
|
+
export function getExtendsChain(declaration, resolver) {
|
|
48
|
+
let extendsChain = [];
|
|
49
|
+
let resolved = getSuperTuple(declaration, resolver);
|
|
50
|
+
while (resolved) {
|
|
51
|
+
extendsChain.push(resolved[1]);
|
|
52
|
+
resolved = getSuperTuple(resolved[0], resolver);
|
|
53
|
+
}
|
|
54
|
+
return extendsChain;
|
|
55
|
+
}
|
|
47
56
|
export function getSuper(declaration, resolver) {
|
|
48
57
|
var _a;
|
|
49
58
|
return (_a = getSuperTuple(declaration, resolver)) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { ModuleConfiguration } from "../config";
|
|
2
2
|
import * as idl from "../idl";
|
|
3
|
+
/**
|
|
4
|
+
* Is source submodule of target.
|
|
5
|
+
* Every source is submodule if target is empty string
|
|
6
|
+
* @example `isSubmodule("a.b.c", "a") === true`
|
|
7
|
+
* @example `isSubmodule("a", "a.b.c") === false`
|
|
8
|
+
* @example `isSubmodule("a.b.cd", "a.b.c") === false`
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSubmodule(source: string, target: string): boolean;
|
|
3
11
|
export declare function isInModule(node: idl.IDLNode, module: ModuleConfiguration): boolean;
|
|
4
12
|
export declare function isInModule(packageName: string, module: ModuleConfiguration): boolean;
|
|
5
13
|
export declare function isInExternalModule(node: idl.IDLNode): boolean;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { generatorConfiguration } from "../config";
|
|
2
2
|
import * as idl from "../idl";
|
|
3
3
|
const modulesCache = new Map();
|
|
4
|
+
/**
|
|
5
|
+
* Is source submodule of target.
|
|
6
|
+
* Every source is submodule if target is empty string
|
|
7
|
+
* @example `isSubmodule("a.b.c", "a") === true`
|
|
8
|
+
* @example `isSubmodule("a", "a.b.c") === false`
|
|
9
|
+
* @example `isSubmodule("a.b.cd", "a.b.c") === false`
|
|
10
|
+
*/
|
|
11
|
+
export function isSubmodule(source, target) {
|
|
12
|
+
return source === target
|
|
13
|
+
|| target === ""
|
|
14
|
+
|| source.startsWith(target + '.');
|
|
15
|
+
}
|
|
4
16
|
export function isInModule(nodeOrPackage, module) {
|
|
5
17
|
if (typeof nodeOrPackage === 'object')
|
|
6
18
|
return isInModule(idl.getPackageName(nodeOrPackage), module);
|
|
7
|
-
return module.packages.some(modulePackage => nodeOrPackage
|
|
19
|
+
return module.packages.some(modulePackage => isSubmodule(nodeOrPackage, modulePackage));
|
|
8
20
|
}
|
|
9
21
|
export function isInExternalModule(node) {
|
|
10
22
|
var _a;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as idl from "../idl";
|
|
2
|
+
import { generateSyntheticUnionName } from "../peer-generation/idl/common";
|
|
3
|
+
export const NULL_REFERENCE = "idlize.stdlib.Null";
|
|
4
|
+
export function inplaceNullsAsUndefined(node) {
|
|
5
|
+
idl.updateEachChild(node, (child) => {
|
|
6
|
+
var _a;
|
|
7
|
+
if (idl.isOptionalType(child)) {
|
|
8
|
+
if (idl.isUnionType(child.type) && child.type.types.some(isNullReference)) {
|
|
9
|
+
child.type.types = child.type.types.filter(it => !isNullReference(it));
|
|
10
|
+
child.type.name = generateSyntheticUnionName(child.type.types);
|
|
11
|
+
if (child.type.types.length === 1) {
|
|
12
|
+
child.type = child.type.types[0];
|
|
13
|
+
}
|
|
14
|
+
(_a = child.extendedAttributes) !== null && _a !== void 0 ? _a : (child.extendedAttributes = []);
|
|
15
|
+
child.extendedAttributes.push({ name: idl.IDLExtendedAttributes.UnionWithNull });
|
|
16
|
+
return child;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (idl.isUnionType(child)) {
|
|
20
|
+
if (child.types.some(isNullReference)) {
|
|
21
|
+
child.types = child.types.filter(it => !isNullReference(it));
|
|
22
|
+
child.name = generateSyntheticUnionName(child.types);
|
|
23
|
+
return idl.createOptionalType(child.types.length > 1 ? child : child.types[0], { extendedAttributes: [{
|
|
24
|
+
name: idl.IDLExtendedAttributes.UnionOnlyNull
|
|
25
|
+
}] });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return child;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function isNullReference(node) {
|
|
32
|
+
return idl.isReferenceType(node) && node.name === NULL_REFERENCE;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=NullTransformer.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.1.10-arktscgen-
|
|
3
|
+
"version": "2.1.10-arktscgen-3a",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "build/lib/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"keywords": [],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@koalaui/interop": "1.7.
|
|
36
|
+
"@koalaui/interop": "1.7.10",
|
|
37
37
|
"typescript": "4.9.5",
|
|
38
38
|
"@types/node": "^18.0.0"
|
|
39
39
|
},
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "mocha",
|
|
49
49
|
"clean": "rimraf -g build",
|
|
50
|
-
"compile": "tsc -b ."
|
|
50
|
+
"compile:self": "tsc -b .",
|
|
51
|
+
"compile": "npm run compile:self"
|
|
51
52
|
}
|
|
52
53
|
}
|