@idlizer/arktscgen 2.1.9-arktscgen-8 → 2.1.9-arktscgen-9
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/libarkts-copy/generator/options.json5 +27 -1
- package/build/libarkts-copy/native/src/bridges.cc +51 -13
- package/build/libarkts-copy/native/src/common.cc +6 -2
- package/build/libarkts-copy/native/src/common.h +1 -0
- package/build/libarkts-copy/native/src/generated/bridges.cc +30 -2
- package/build/libarkts-copy/package.json +4 -4
- package/build/libarkts-copy/src/Es2pandaNativeModule.ts +17 -5
- package/build/libarkts-copy/src/arkts-api/node-utilities/Program.ts +0 -11
- package/build/libarkts-copy/src/arkts-api/node-utilities/ScriptFunction.ts +7 -0
- package/build/libarkts-copy/src/arkts-api/peers/AstNode.ts +2 -2
- package/build/libarkts-copy/src/arkts-api/peers/ExternalSource.ts +4 -0
- package/build/libarkts-copy/src/arkts-api/plugins.ts +3 -4
- package/build/libarkts-copy/src/arkts-api/static/global.ts +1 -0
- package/build/libarkts-copy/src/arkts-api/utilities/extensions.ts +24 -1
- package/build/libarkts-copy/src/arkts-api/utilities/public.ts +68 -4
- package/build/libarkts-copy/src/arkts-api/visitor.ts +1 -0
- package/build/libarkts-copy/src/generated/Es2pandaEnums.ts +93 -91
- package/build/libarkts-copy/src/generated/Es2pandaNativeModule.ts +9 -0
- package/build/libarkts-copy/src/generated/factory.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/ClassDeclaration.ts +2 -2
- package/build/libarkts-copy/src/generated/peers/Program.ts +2 -0
- package/build/libarkts-copy/src/generated/peers/ScriptFunction.ts +12 -0
- package/build/libarkts-copy/src/plugin-utils.ts +13 -3
- package/build/libarkts-copy/src/reexport-for-generated.ts +3 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/index.ts +2 -1
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/Diagnostic.ts +2 -3
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/DiagnosticInfo.ts +3 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SourcePosition.ts +38 -0
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/peers/SuggestionInfo.ts +3 -2
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/types.ts +2 -19
- package/build/libarkts-copy/src/wrapper-compat/arkts-api/utilities/public.ts +4 -2
- package/lib/index.js +159 -94
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -3825,6 +3825,7 @@ var IDLExtendedAttributes;
|
|
|
3825
3825
|
IDLExtendedAttributes["DtsTag"] = "DtsTag";
|
|
3826
3826
|
IDLExtendedAttributes["Entity"] = "Entity";
|
|
3827
3827
|
IDLExtendedAttributes["Extends"] = "Extends";
|
|
3828
|
+
IDLExtendedAttributes["ExtensionMethod"] = "ExtensionMethod";
|
|
3828
3829
|
IDLExtendedAttributes["Import"] = "Import";
|
|
3829
3830
|
IDLExtendedAttributes["DefaultExport"] = "DefaultExport";
|
|
3830
3831
|
IDLExtendedAttributes["IndexSignature"] = "IndexSignature";
|
|
@@ -4890,6 +4891,7 @@ function linearizeNamespaceMembers(entries) {
|
|
|
4890
4891
|
return linearized;
|
|
4891
4892
|
}
|
|
4892
4893
|
|
|
4894
|
+
const modulesCache = new Map();
|
|
4893
4895
|
function isInModule(nodeOrPackage, module) {
|
|
4894
4896
|
if (typeof nodeOrPackage === 'object')
|
|
4895
4897
|
return isInModule(getPackageName(nodeOrPackage), module);
|
|
@@ -4903,14 +4905,27 @@ function getModuleFor(nodeOrPackage) {
|
|
|
4903
4905
|
if (typeof nodeOrPackage === "object")
|
|
4904
4906
|
return getModuleFor(getPackageName(nodeOrPackage));
|
|
4905
4907
|
const packageName = nodeOrPackage;
|
|
4908
|
+
let module = modulesCache.get(packageName);
|
|
4909
|
+
if (module)
|
|
4910
|
+
return module;
|
|
4911
|
+
module = getApplicableModuleFor(packageName);
|
|
4912
|
+
modulesCache.set(packageName, module);
|
|
4913
|
+
return module;
|
|
4914
|
+
}
|
|
4915
|
+
function getApplicableModuleFor(packageName) {
|
|
4906
4916
|
const config = generatorConfiguration();
|
|
4907
4917
|
const applicableModules = [...config.modules.values()].filter(module => isInModule(packageName, module));
|
|
4908
4918
|
if (applicableModules.length === 0) {
|
|
4909
|
-
if (
|
|
4919
|
+
if (packageName === '') {
|
|
4910
4920
|
console.error("WARNING: use current module for empty package");
|
|
4911
4921
|
return currentModule();
|
|
4912
4922
|
}
|
|
4913
|
-
|
|
4923
|
+
if (packageName.startsWith(`idlize.`)) {
|
|
4924
|
+
return currentModule();
|
|
4925
|
+
}
|
|
4926
|
+
const modules = [...config.modules.keys()].map(it => `"${it}"`).join(", ");
|
|
4927
|
+
throw new Error(`Package "${packageName}" is not listed in any module.`
|
|
4928
|
+
+ ` Add the "${packageName}" to the existed list of modules [${modules}] or new one in the configuration file`);
|
|
4914
4929
|
}
|
|
4915
4930
|
if (applicableModules.length > 1)
|
|
4916
4931
|
throw new Error(`Package ${packageName} listed in ${applicableModules.length} packages: ${applicableModules.map(it => it.name).join(", ")}`);
|
|
@@ -4924,10 +4939,11 @@ function currentModule() {
|
|
|
4924
4939
|
return result;
|
|
4925
4940
|
}
|
|
4926
4941
|
function isInCurrentModule(nodeOrPackage) {
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4942
|
+
// check the nodeOrPackage belongs to some module
|
|
4943
|
+
const module = typeof nodeOrPackage === 'string'
|
|
4944
|
+
? getModuleFor(nodeOrPackage)
|
|
4945
|
+
: getModuleFor(nodeOrPackage);
|
|
4946
|
+
return generatorConfiguration().moduleName == module.name;
|
|
4931
4947
|
}
|
|
4932
4948
|
|
|
4933
4949
|
/*
|
|
@@ -5091,13 +5107,14 @@ class ExpressionStatement {
|
|
|
5091
5107
|
}
|
|
5092
5108
|
}
|
|
5093
5109
|
class BlockStatement {
|
|
5094
|
-
constructor(statements, inScope = true) {
|
|
5110
|
+
constructor(statements, inScope = true, newLine = true) {
|
|
5095
5111
|
this.statements = statements;
|
|
5096
5112
|
this.inScope = inScope;
|
|
5113
|
+
this.newLine = newLine;
|
|
5097
5114
|
}
|
|
5098
5115
|
write(writer) {
|
|
5099
5116
|
if (this.inScope) {
|
|
5100
|
-
writer.print("{");
|
|
5117
|
+
this.newLine ? writer.print("{") : writer.printer.appendLastString(" {");
|
|
5101
5118
|
writer.pushIndent();
|
|
5102
5119
|
}
|
|
5103
5120
|
this.statements.forEach(s => s.write(writer));
|
|
@@ -5123,7 +5140,12 @@ class IfStatement {
|
|
|
5123
5140
|
}
|
|
5124
5141
|
});
|
|
5125
5142
|
if (this.elseStatement !== undefined) {
|
|
5126
|
-
|
|
5143
|
+
if ((this.thenStatement instanceof BlockStatement) && this.thenStatement.inScope) {
|
|
5144
|
+
writer.printer.appendLastString(" else");
|
|
5145
|
+
}
|
|
5146
|
+
else {
|
|
5147
|
+
writer.print("else");
|
|
5148
|
+
}
|
|
5127
5149
|
this.writeBody(writer, this.elseStatement, () => {
|
|
5128
5150
|
if (this.insideElseOp) {
|
|
5129
5151
|
this.insideElseOp();
|
|
@@ -5154,7 +5176,7 @@ class MultiBranchIfStatement {
|
|
|
5154
5176
|
writer.print(`if (${expr.asString()}) {`);
|
|
5155
5177
|
}
|
|
5156
5178
|
else {
|
|
5157
|
-
writer.
|
|
5179
|
+
writer.printer.appendLastString(` else if (${expr.asString()}) {`);
|
|
5158
5180
|
}
|
|
5159
5181
|
writer.pushIndent();
|
|
5160
5182
|
stmt.write(writer);
|
|
@@ -5162,7 +5184,7 @@ class MultiBranchIfStatement {
|
|
|
5162
5184
|
writer.print("}");
|
|
5163
5185
|
});
|
|
5164
5186
|
if (this.statements.length > 0 && this.elseStatement !== undefined) {
|
|
5165
|
-
writer.
|
|
5187
|
+
writer.printer.appendLastString(" else {");
|
|
5166
5188
|
writer.pushIndent();
|
|
5167
5189
|
this.elseStatement.write(writer);
|
|
5168
5190
|
writer.popIndent();
|
|
@@ -5216,21 +5238,17 @@ class LambdaExpression {
|
|
|
5216
5238
|
this.resolver = resolver;
|
|
5217
5239
|
this.body = body;
|
|
5218
5240
|
}
|
|
5219
|
-
bodyAsString() {
|
|
5220
|
-
var _a;
|
|
5241
|
+
bodyAsString(isScoped = false) {
|
|
5221
5242
|
const writer = this.originalWriter.fork();
|
|
5222
5243
|
if (this.body) {
|
|
5223
|
-
|
|
5224
|
-
stmt.write(writer);
|
|
5225
|
-
}
|
|
5244
|
+
writer.writeStatement(new BlockStatement(this.body, isScoped, false));
|
|
5226
5245
|
}
|
|
5227
5246
|
writer.features.forEach(([feature, module]) => {
|
|
5228
5247
|
this.originalWriter.addFeature(feature, module);
|
|
5229
5248
|
});
|
|
5230
|
-
return
|
|
5231
|
-
.
|
|
5232
|
-
.
|
|
5233
|
-
.join("\n"));
|
|
5249
|
+
return writer.getOutput()
|
|
5250
|
+
.map(line => (line.endsWith('{') || line.endsWith('}') || line.endsWith(';')) ? line : `${line};`)
|
|
5251
|
+
.join("\n");
|
|
5234
5252
|
}
|
|
5235
5253
|
}
|
|
5236
5254
|
////////////////////////////////////////////////////////////////
|
|
@@ -5665,9 +5683,9 @@ LanguageWriter._isReferenceRelativeToNamespaces = false;
|
|
|
5665
5683
|
* limitations under the License.
|
|
5666
5684
|
*/
|
|
5667
5685
|
class IndentedPrinter {
|
|
5668
|
-
constructor(output = []) {
|
|
5686
|
+
constructor(output = [], indent = 0) {
|
|
5669
5687
|
this.output = output;
|
|
5670
|
-
this.indent =
|
|
5688
|
+
this.indent = indent;
|
|
5671
5689
|
}
|
|
5672
5690
|
print(value) {
|
|
5673
5691
|
if (value != undefined)
|
|
@@ -5685,6 +5703,13 @@ class IndentedPrinter {
|
|
|
5685
5703
|
append(printer) {
|
|
5686
5704
|
this.output = [...this.output, ...printer.output];
|
|
5687
5705
|
}
|
|
5706
|
+
appendLastString(value) {
|
|
5707
|
+
if (value != undefined) {
|
|
5708
|
+
let last = this.output.pop();
|
|
5709
|
+
last = last ? last.concat(value) : value;
|
|
5710
|
+
this.output.push(last);
|
|
5711
|
+
}
|
|
5712
|
+
}
|
|
5688
5713
|
indented(input) {
|
|
5689
5714
|
return indentedBy(input, this.indent);
|
|
5690
5715
|
}
|
|
@@ -6603,7 +6628,7 @@ function toIDLFile(fileName, { content, inheritanceMode = 'multiple' } = {}) {
|
|
|
6603
6628
|
if (e.name == "WebIDLParseError") {
|
|
6604
6629
|
let tokens = e.tokens;
|
|
6605
6630
|
let range = tokens.length > 0 ? rangeForToken(offsets, tokens[0]) : undefined;
|
|
6606
|
-
ParsingErrorMessage.throwDiagnosticMessage([{ documentPath: fileName, range
|
|
6631
|
+
ParsingErrorMessage.throwDiagnosticMessage([{ documentPath: fileName, range, lines }], e.bareMessage);
|
|
6607
6632
|
}
|
|
6608
6633
|
UnknownErrorMessage.throwDiagnosticMessage([{ documentPath: fileName }], (_c = e.message) !== null && _c !== void 0 ? _c : "");
|
|
6609
6634
|
}
|
|
@@ -6922,18 +6947,18 @@ class CppMapResizeStatement {
|
|
|
6922
6947
|
}
|
|
6923
6948
|
}
|
|
6924
6949
|
class CppMapForEachStatement {
|
|
6925
|
-
constructor(map, key, value,
|
|
6950
|
+
constructor(map, key, value, body) {
|
|
6926
6951
|
this.map = map;
|
|
6927
6952
|
this.key = key;
|
|
6928
6953
|
this.value = value;
|
|
6929
|
-
this.
|
|
6954
|
+
this.body = body;
|
|
6930
6955
|
}
|
|
6931
6956
|
write(writer) {
|
|
6932
6957
|
writer.print(`for (int32_t i = 0; i < ${this.map}.size; i++) {`);
|
|
6933
6958
|
writer.pushIndent();
|
|
6934
6959
|
writer.print(`auto ${this.key} = ${this.map}.keys[i];`);
|
|
6935
6960
|
writer.print(`auto ${this.value} = ${this.map}.values[i];`);
|
|
6936
|
-
this.
|
|
6961
|
+
writer.writeStatement(new BlockStatement(this.body, false));
|
|
6937
6962
|
writer.popIndent();
|
|
6938
6963
|
writer.print(`}`);
|
|
6939
6964
|
}
|
|
@@ -6978,7 +7003,7 @@ class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
6978
7003
|
}
|
|
6979
7004
|
fork(options) {
|
|
6980
7005
|
var _a;
|
|
6981
|
-
return new CppLanguageWriter(new IndentedPrinter(), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.primitivesTypes);
|
|
7006
|
+
return new CppLanguageWriter(new IndentedPrinter([], this.indentDepth()), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.primitivesTypes);
|
|
6982
7007
|
}
|
|
6983
7008
|
writeDeclaration(name, signature, modifiers, postfix) {
|
|
6984
7009
|
const realName = this.classMode === 'normal' ? name : `${this.currentClass.at(0)}::${name}`;
|
|
@@ -7119,8 +7144,8 @@ class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
7119
7144
|
makeLoop(counter, limit, statement) {
|
|
7120
7145
|
return new CLikeLoopStatement(counter, limit, statement);
|
|
7121
7146
|
}
|
|
7122
|
-
makeMapForEach(map, key, value,
|
|
7123
|
-
return new CppMapForEachStatement(map, key, value,
|
|
7147
|
+
makeMapForEach(map, key, value, body) {
|
|
7148
|
+
return new CppMapForEachStatement(map, key, value, body);
|
|
7124
7149
|
}
|
|
7125
7150
|
makeArrayInit(type) {
|
|
7126
7151
|
return this.makeString(`{}`);
|
|
@@ -7315,7 +7340,7 @@ class TSLambdaExpression extends LambdaExpression {
|
|
|
7315
7340
|
const maybeOptional = isOptionalType(it) ? "?" : "";
|
|
7316
7341
|
return `${this.signature.argName(i)}${maybeOptional}: ${this.convertor.convert(it)}`;
|
|
7317
7342
|
});
|
|
7318
|
-
return `(${params.join(", ")}): ${this.convertor.convert(this.signature.returnType)}
|
|
7343
|
+
return `(${params.join(", ")}): ${this.convertor.convert(this.signature.returnType)} =>${this.bodyAsString(true)}`;
|
|
7319
7344
|
}
|
|
7320
7345
|
}
|
|
7321
7346
|
class TSCastExpression {
|
|
@@ -7372,16 +7397,16 @@ class TSLoopStatement {
|
|
|
7372
7397
|
}
|
|
7373
7398
|
}
|
|
7374
7399
|
class TSMapForEachStatement {
|
|
7375
|
-
constructor(map, key, value,
|
|
7400
|
+
constructor(map, key, value, body) {
|
|
7376
7401
|
this.map = map;
|
|
7377
7402
|
this.key = key;
|
|
7378
7403
|
this.value = value;
|
|
7379
|
-
this.
|
|
7404
|
+
this.body = body;
|
|
7380
7405
|
}
|
|
7381
7406
|
write(writer) {
|
|
7382
7407
|
writer.print(`for (const [${this.key}, ${this.value}] of ${this.map}) {`);
|
|
7383
7408
|
writer.pushIndent();
|
|
7384
|
-
this.
|
|
7409
|
+
writer.writeStatement(new BlockStatement(this.body, false));
|
|
7385
7410
|
writer.popIndent();
|
|
7386
7411
|
writer.print(`}`);
|
|
7387
7412
|
}
|
|
@@ -7412,7 +7437,7 @@ class TSLanguageWriter extends LanguageWriter {
|
|
|
7412
7437
|
}
|
|
7413
7438
|
fork(options) {
|
|
7414
7439
|
var _a;
|
|
7415
|
-
return new TSLanguageWriter(new IndentedPrinter(), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.language);
|
|
7440
|
+
return new TSLanguageWriter(new IndentedPrinter([], this.indentDepth()), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.language);
|
|
7416
7441
|
}
|
|
7417
7442
|
getNodeName(type) {
|
|
7418
7443
|
// another stub. Bad one.
|
|
@@ -7595,8 +7620,8 @@ class TSLanguageWriter extends LanguageWriter {
|
|
|
7595
7620
|
makeLoop(counter, limit, statement) {
|
|
7596
7621
|
return new TSLoopStatement(counter, limit, statement);
|
|
7597
7622
|
}
|
|
7598
|
-
makeMapForEach(map, key, value,
|
|
7599
|
-
return new TSMapForEachStatement(map, key, value,
|
|
7623
|
+
makeMapForEach(map, key, value, body) {
|
|
7624
|
+
return new TSMapForEachStatement(map, key, value, body);
|
|
7600
7625
|
}
|
|
7601
7626
|
writePrintLog(message) {
|
|
7602
7627
|
this.print(`console.log("${message}")`);
|
|
@@ -7812,6 +7837,23 @@ function createDeclarationNameConvertor(language) {
|
|
|
7812
7837
|
* limitations under the License.
|
|
7813
7838
|
*/
|
|
7814
7839
|
////////////////////////////////////////////////////////////////
|
|
7840
|
+
// EXPRESSIONS //
|
|
7841
|
+
////////////////////////////////////////////////////////////////
|
|
7842
|
+
class ETSStringExpression {
|
|
7843
|
+
constructor(value) {
|
|
7844
|
+
this.value = value;
|
|
7845
|
+
}
|
|
7846
|
+
changeQuotes(value) {
|
|
7847
|
+
return `'${value.substring(1, value.length - 1)}'`;
|
|
7848
|
+
}
|
|
7849
|
+
asString() {
|
|
7850
|
+
if (this.value.startsWith('"') && this.value.endsWith('"')) {
|
|
7851
|
+
return this.changeQuotes(this.value);
|
|
7852
|
+
}
|
|
7853
|
+
return this.value;
|
|
7854
|
+
}
|
|
7855
|
+
}
|
|
7856
|
+
////////////////////////////////////////////////////////////////
|
|
7815
7857
|
// STATEMENTS //
|
|
7816
7858
|
////////////////////////////////////////////////////////////////
|
|
7817
7859
|
class EtsAssignStatement {
|
|
@@ -7839,18 +7881,18 @@ class EtsAssignStatement {
|
|
|
7839
7881
|
}
|
|
7840
7882
|
}
|
|
7841
7883
|
class ArkTSMapForEachStatement {
|
|
7842
|
-
constructor(map, key, value,
|
|
7884
|
+
constructor(map, key, value, body) {
|
|
7843
7885
|
this.map = map;
|
|
7844
7886
|
this.key = key;
|
|
7845
7887
|
this.value = value;
|
|
7846
|
-
this.
|
|
7888
|
+
this.body = body;
|
|
7847
7889
|
}
|
|
7848
7890
|
write(writer) {
|
|
7849
7891
|
writer.print(`for (const pair of ${this.map}) {`);
|
|
7850
7892
|
writer.pushIndent();
|
|
7851
7893
|
writer.print(`const ${this.key} = pair[0]`);
|
|
7852
7894
|
writer.print(`const ${this.value} = pair[1]`);
|
|
7853
|
-
this.
|
|
7895
|
+
writer.writeStatement(new BlockStatement(this.body, false));
|
|
7854
7896
|
writer.popIndent();
|
|
7855
7897
|
writer.print(`}`);
|
|
7856
7898
|
}
|
|
@@ -7916,7 +7958,7 @@ class ETSLambdaExpression extends LambdaExpression {
|
|
|
7916
7958
|
isRetTypeCallback = resolved !== undefined && isCallback$1(resolved);
|
|
7917
7959
|
}
|
|
7918
7960
|
return `(${params.join(", ")})${isRetTypeCallback
|
|
7919
|
-
? "" : `:${this.convertor.convert(this.signature.returnType)}`}
|
|
7961
|
+
? "" : `:${this.convertor.convert(this.signature.returnType)}`} =>${this.bodyAsString(true)}`;
|
|
7920
7962
|
}
|
|
7921
7963
|
}
|
|
7922
7964
|
////////////////////////////////////////////////////////////////
|
|
@@ -7946,7 +7988,7 @@ class ETSLanguageWriter extends TSLanguageWriter {
|
|
|
7946
7988
|
}
|
|
7947
7989
|
fork(options) {
|
|
7948
7990
|
var _a;
|
|
7949
|
-
return new ETSLanguageWriter(new IndentedPrinter(), (_a = options === null || options === void 0 ? void 0 : options.resolver) !== null && _a !== void 0 ? _a : this.resolver, this.typeConvertor, this.arrayConvertor);
|
|
7991
|
+
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);
|
|
7950
7992
|
}
|
|
7951
7993
|
makeAssign(variableName, type, expr, isDeclared = true, isConst = true, options) {
|
|
7952
7994
|
return new EtsAssignStatement(variableName, type, expr, isDeclared, isConst, options);
|
|
@@ -7954,8 +7996,11 @@ class ETSLanguageWriter extends TSLanguageWriter {
|
|
|
7954
7996
|
makeLambda(signature, body) {
|
|
7955
7997
|
return new ETSLambdaExpression(this, this.typeConvertor, signature, this.resolver, body);
|
|
7956
7998
|
}
|
|
7957
|
-
|
|
7958
|
-
return new
|
|
7999
|
+
makeString(value) {
|
|
8000
|
+
return new ETSStringExpression(value);
|
|
8001
|
+
}
|
|
8002
|
+
makeMapForEach(map, key, value, body) {
|
|
8003
|
+
return new ArkTSMapForEachStatement(map, key, value, body);
|
|
7959
8004
|
}
|
|
7960
8005
|
makeMapSize(map) {
|
|
7961
8006
|
return this.makeString(`${super.makeMapSize(map).asString()}`); // TODO: cast really needed?
|
|
@@ -8184,12 +8229,16 @@ class AggregateConvertor extends BaseArgConvertor {
|
|
|
8184
8229
|
throw new Error("Do not use for aggregates");
|
|
8185
8230
|
}
|
|
8186
8231
|
convertorSerialize(param, value, printer) {
|
|
8187
|
-
this.memberConvertors.
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8232
|
+
const stmts = this.memberConvertors.flatMap((it, index) => {
|
|
8233
|
+
const memberName = this.members[index][0];
|
|
8234
|
+
const memberAccess = `${value}.${printer.escapeKeyword(memberName)}`;
|
|
8235
|
+
const memberMangledName = `${value}${capitalize(memberName)}`;
|
|
8236
|
+
return [
|
|
8237
|
+
printer.makeAssign(memberMangledName, undefined, printer.makeString(memberAccess), true),
|
|
8238
|
+
it.convertorSerialize(param, memberMangledName, printer)
|
|
8239
|
+
];
|
|
8192
8240
|
});
|
|
8241
|
+
return printer.makeBlock(stmts, false);
|
|
8193
8242
|
}
|
|
8194
8243
|
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
8195
8244
|
const statements = [];
|
|
@@ -8204,7 +8253,8 @@ class AggregateConvertor extends BaseArgConvertor {
|
|
|
8204
8253
|
for (let i = 0; i < this.decl.properties.length; i++) {
|
|
8205
8254
|
const prop = this.decl.properties[i];
|
|
8206
8255
|
const propConvertor = this.memberConvertors[i];
|
|
8207
|
-
|
|
8256
|
+
const propName = `${bufferName}${capitalize(prop.name)}`;
|
|
8257
|
+
statements.push(propConvertor.convertorDeserialize(`${propName}TempBuf`, deserializerName, (expr) => {
|
|
8208
8258
|
if (writer.language === Language.CPP) {
|
|
8209
8259
|
// prefix initialization for CPP, just easier. Waiting for easy work with nullables
|
|
8210
8260
|
return writer.makeAssign(`${bufferName}.${writer.escapeKeyword(prop.name)}`, undefined, expr, false);
|
|
@@ -8213,7 +8263,7 @@ class AggregateConvertor extends BaseArgConvertor {
|
|
|
8213
8263
|
* todo: check UnionType name creation for union of unnamed nodes (isNamedNode() == false)
|
|
8214
8264
|
*/
|
|
8215
8265
|
const memberType = maybeOptional(prop.type, prop.isOptional);
|
|
8216
|
-
return writer.makeAssign(
|
|
8266
|
+
return writer.makeAssign(propName, memberType, expr, true, true);
|
|
8217
8267
|
}, writer));
|
|
8218
8268
|
}
|
|
8219
8269
|
if (writer.language === Language.CPP) {
|
|
@@ -8231,7 +8281,7 @@ class AggregateConvertor extends BaseArgConvertor {
|
|
|
8231
8281
|
}
|
|
8232
8282
|
else {
|
|
8233
8283
|
const resultExpression = this.makeAssigneeExpression(this.decl.properties.map(prop => {
|
|
8234
|
-
return [prop.name, writer.makeString(`${bufferName}
|
|
8284
|
+
return [prop.name, writer.makeString(`${bufferName}${capitalize(prop.name)}`)];
|
|
8235
8285
|
}), writer);
|
|
8236
8286
|
statements.push(assigneer(resultExpression));
|
|
8237
8287
|
}
|
|
@@ -8267,10 +8317,10 @@ class InterfaceConvertor extends BaseArgConvertor {
|
|
|
8267
8317
|
convertorArg(param, writer) {
|
|
8268
8318
|
throw new Error("Must never be used");
|
|
8269
8319
|
}
|
|
8270
|
-
convertorSerialize(param, value,
|
|
8320
|
+
convertorSerialize(param, value, writer) {
|
|
8271
8321
|
const accessor = getSerializerName(this.declaration);
|
|
8272
|
-
|
|
8273
|
-
|
|
8322
|
+
writer.addFeature(accessor, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
|
|
8323
|
+
return writer.makeStatement(writer.makeStaticMethodCall(accessor, 'write', [writer.makeString(`${param}Serializer`), writer.makeString(value)]));
|
|
8274
8324
|
}
|
|
8275
8325
|
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
8276
8326
|
const accessor = getSerializerName(this.declaration);
|
|
@@ -8311,7 +8361,7 @@ class CustomTypeConvertor extends BaseArgConvertor {
|
|
|
8311
8361
|
}
|
|
8312
8362
|
/** todo: check */
|
|
8313
8363
|
convertorSerialize(param, value, printer) {
|
|
8314
|
-
printer.
|
|
8364
|
+
return printer.makeStatement(printer.makeMethodCall(`${param}Serializer`, `writeCustomObject`, [printer.makeString(`"${this.customTypeName}"`), printer.makeCastCustomObject(value, this.isGenericType)]));
|
|
8315
8365
|
}
|
|
8316
8366
|
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
8317
8367
|
const type = writer.language === Language.CPP
|
|
@@ -8336,13 +8386,13 @@ class FunctionConvertor extends BaseArgConvertor {
|
|
|
8336
8386
|
this.library = library;
|
|
8337
8387
|
}
|
|
8338
8388
|
convertorArg(param, writer) {
|
|
8339
|
-
|
|
8389
|
+
throw new Error('Shall not be used');
|
|
8340
8390
|
}
|
|
8341
8391
|
convertorSerialize(param, value, writer) {
|
|
8342
|
-
|
|
8392
|
+
throw new Error('Shall not be used');
|
|
8343
8393
|
}
|
|
8344
8394
|
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
8345
|
-
|
|
8395
|
+
throw new Error('Shall not be used');
|
|
8346
8396
|
}
|
|
8347
8397
|
nativeType() {
|
|
8348
8398
|
return IDLFunctionType;
|
|
@@ -8379,7 +8429,7 @@ class MaterializedClassConvertor extends BaseArgConvertor {
|
|
|
8379
8429
|
convertorSerialize(param, value, printer) {
|
|
8380
8430
|
const accessorRoot = getSerializerName(this.declaration);
|
|
8381
8431
|
printer.addFeature(accessorRoot, this.library.layout.resolve({ node: this.declaration, role: LayoutNodeRole.SERIALIZER }));
|
|
8382
|
-
printer.
|
|
8432
|
+
return printer.makeStatement(printer.makeStaticMethodCall(accessorRoot, 'write', [printer.makeString(`${param}Serializer`), printer.makeString(value)]));
|
|
8383
8433
|
}
|
|
8384
8434
|
convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
|
|
8385
8435
|
const accessorRoot = getSerializerName(this.declaration);
|
|
@@ -8951,10 +9001,9 @@ D.object({
|
|
|
8951
9001
|
forceResource: T.stringArray(),
|
|
8952
9002
|
forceContext: T.stringArray(),
|
|
8953
9003
|
hooks: D.map(D.string(), D.map(D.string(), HookMethodSchema)).onMerge('replace'),
|
|
8954
|
-
externalTypes: D.map(D.string(), D.string()).onMerge('replace'),
|
|
8955
|
-
externalPackages: T.stringArray(),
|
|
8956
9004
|
moduleName: D.string(),
|
|
8957
9005
|
modules: D.map(D.string(), ModuleConfigurationSchema).onMerge('replace'),
|
|
9006
|
+
libraryNameMapping: D.maybe(D.map(D.string(), D.map(D.string(), D.string())).onMerge('replace')),
|
|
8958
9007
|
globalPackages: T.stringArray()
|
|
8959
9008
|
});
|
|
8960
9009
|
const defaultCoreConfiguration = {
|
|
@@ -8972,10 +9021,9 @@ const defaultCoreConfiguration = {
|
|
|
8972
9021
|
forceResource: [],
|
|
8973
9022
|
forceContext: [],
|
|
8974
9023
|
hooks: new Map(),
|
|
8975
|
-
externalTypes: new Map(),
|
|
8976
|
-
externalPackages: [],
|
|
8977
9024
|
moduleName: "",
|
|
8978
9025
|
modules: new Map(),
|
|
9026
|
+
libraryNameMapping: new Map(),
|
|
8979
9027
|
globalPackages: []
|
|
8980
9028
|
};
|
|
8981
9029
|
let currentConfig = defaultCoreConfiguration;
|
|
@@ -11169,6 +11217,10 @@ function nodeType(node) {
|
|
|
11169
11217
|
var _a, _b;
|
|
11170
11218
|
return (_b = (_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.find(it => it.name === Config.nodeTypeAttribute)) === null || _b === void 0 ? void 0 : _b.value;
|
|
11171
11219
|
}
|
|
11220
|
+
function nativeType(node) {
|
|
11221
|
+
var _a, _b;
|
|
11222
|
+
return (_b = (_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.find(it => it.name === 'c_type')) === null || _b === void 0 ? void 0 : _b.value;
|
|
11223
|
+
}
|
|
11172
11224
|
function nodeNamespace(node) {
|
|
11173
11225
|
var _a;
|
|
11174
11226
|
return (_a = getNamespacesPathFor(node)[0]) === null || _a === void 0 ? void 0 : _a.name;
|
|
@@ -11283,6 +11335,16 @@ class Typechecker {
|
|
|
11283
11335
|
declaration.inheritance.forEach(parent => {
|
|
11284
11336
|
isHeir || (isHeir = this.isHeir(parent.name, ancestor));
|
|
11285
11337
|
});
|
|
11338
|
+
// TODO: Should be fixed or moved to config
|
|
11339
|
+
const objects = [
|
|
11340
|
+
"Program", "ArkTsConfig", "AstDumper", "SrcDumper",
|
|
11341
|
+
"FunctionSignature", "ValidationInfo"
|
|
11342
|
+
];
|
|
11343
|
+
if (!isHeir) {
|
|
11344
|
+
if (ancestor === Config.defaultAncestor &&
|
|
11345
|
+
objects.includes(declaration.name))
|
|
11346
|
+
return true;
|
|
11347
|
+
}
|
|
11286
11348
|
return isHeir;
|
|
11287
11349
|
}
|
|
11288
11350
|
isPeer(node) {
|
|
@@ -11294,11 +11356,6 @@ class Typechecker {
|
|
|
11294
11356
|
return true;
|
|
11295
11357
|
if (this.isHeir(node, Config.defaultAncestor))
|
|
11296
11358
|
return true;
|
|
11297
|
-
// TODO: fix
|
|
11298
|
-
if (node === "Program")
|
|
11299
|
-
return true;
|
|
11300
|
-
if (node === "ArkTsConfig")
|
|
11301
|
-
return true;
|
|
11302
11359
|
return false;
|
|
11303
11360
|
}
|
|
11304
11361
|
isReferenceTo(type, isTarget) {
|
|
@@ -12390,13 +12447,13 @@ class BindingReturnValueTypeConvertor extends TopLevelTypeConvertor {
|
|
|
12390
12447
|
string: (type) => wrap(PeersConstructions.receiveString),
|
|
12391
12448
|
reference: (type) => this.typechecker.isHeir(type.name, Config.astNodeCommonAncestor)
|
|
12392
12449
|
? wrap(PeersConstructions.unpackNonNullable)
|
|
12393
|
-
: wrap(type.name),
|
|
12450
|
+
: wrap(baseNameString(type.name)),
|
|
12394
12451
|
optional: (type) => {
|
|
12395
12452
|
if (isReferenceType(type.type)) {
|
|
12396
12453
|
if (this.typechecker.isHeir(type.type.name, Config.astNodeCommonAncestor)) {
|
|
12397
12454
|
return wrap(PeersConstructions.unpackNullable);
|
|
12398
12455
|
}
|
|
12399
|
-
return wrap(PeersConstructions.newOf(type.type.name));
|
|
12456
|
+
return wrap(PeersConstructions.newOf(baseNameString(type.type.name)));
|
|
12400
12457
|
}
|
|
12401
12458
|
throwException(`unexpected optional of non-reference type`);
|
|
12402
12459
|
},
|
|
@@ -12453,7 +12510,7 @@ class PeerPrinter extends SingleFilePrinter {
|
|
|
12453
12510
|
});
|
|
12454
12511
|
}
|
|
12455
12512
|
printPeer() {
|
|
12456
|
-
this.writer.writeClass(this.node.name, () => this.printBody(), this.parent ? this.importer.withPeerImport(this.parent) : undefined);
|
|
12513
|
+
this.writer.writeClass(this.node.name, () => this.printBody(), this.parent ? this.importer.withPeerImport(baseNameString(this.parent)) : undefined);
|
|
12457
12514
|
}
|
|
12458
12515
|
printBody() {
|
|
12459
12516
|
this.printConstructor();
|
|
@@ -12487,7 +12544,9 @@ class PeerPrinter extends SingleFilePrinter {
|
|
|
12487
12544
|
printMethods() {
|
|
12488
12545
|
this.node.methods.forEach(it => {
|
|
12489
12546
|
if (isCreateOrUpdate(it.name)) {
|
|
12490
|
-
|
|
12547
|
+
// TODO: This condition is not clear - classes with c_type attribute
|
|
12548
|
+
// is not abstract too, is it?
|
|
12549
|
+
if (isAbstract(this.node) && nativeType(this.node) === undefined) {
|
|
12491
12550
|
return;
|
|
12492
12551
|
}
|
|
12493
12552
|
return this.printCreateOrUpdate(it);
|
|
@@ -12859,12 +12918,12 @@ class BaseInterfaceFilterTransformer extends Transformer {
|
|
|
12859
12918
|
this.typechecker = new Typechecker(this.file.entries);
|
|
12860
12919
|
}
|
|
12861
12920
|
transformInterface(entry) {
|
|
12862
|
-
if (this.shouldFilterOutInterface(entry
|
|
12921
|
+
if (this.shouldFilterOutInterface(entry)) {
|
|
12863
12922
|
return undefined;
|
|
12864
12923
|
}
|
|
12865
12924
|
return createUpdatedInterface(entry, entry.methods
|
|
12866
12925
|
.filter(it => !this.shouldFilterOutMethod(entry.name, it.name))
|
|
12867
|
-
.filter(it => !this.isReferringForbiddenOrMissing(it, (
|
|
12926
|
+
.filter(it => !this.isReferringForbiddenOrMissing(it, (iface) => this.shouldFilterOutInterface(iface))), entry.name, entry.inheritance, entry.extendedAttributes, entry.properties
|
|
12868
12927
|
.filter(it => !this.shouldFilterOutProperty(entry.name, it.name)));
|
|
12869
12928
|
}
|
|
12870
12929
|
isReferringForbiddenOrMissing(node, predicate) {
|
|
@@ -12874,10 +12933,8 @@ class BaseInterfaceFilterTransformer extends Transformer {
|
|
|
12874
12933
|
.map(innerTypeIfContainer)
|
|
12875
12934
|
.filter(it => {
|
|
12876
12935
|
if (isReferenceType(it)) {
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
}
|
|
12880
|
-
if (this.typechecker.findRealDeclaration(it.name) === undefined) {
|
|
12936
|
+
const decl = this.typechecker.findRealDeclaration(it.name);
|
|
12937
|
+
if (!decl || isInterface$1(decl) && predicate(decl)) {
|
|
12881
12938
|
return true;
|
|
12882
12939
|
}
|
|
12883
12940
|
}
|
|
@@ -12905,8 +12962,10 @@ class OptionsFilterTransformer extends BaseInterfaceFilterTransformer {
|
|
|
12905
12962
|
super(file);
|
|
12906
12963
|
this.config = config;
|
|
12907
12964
|
}
|
|
12908
|
-
shouldFilterOutInterface(
|
|
12909
|
-
|
|
12965
|
+
shouldFilterOutInterface(entry) {
|
|
12966
|
+
var _a;
|
|
12967
|
+
const ns = (_a = nodeNamespace(entry)) !== null && _a !== void 0 ? _a : '';
|
|
12968
|
+
return this.config.ignore.isIgnoredInterface(entry.name, ns);
|
|
12910
12969
|
}
|
|
12911
12970
|
shouldFilterOutMethod(node, name) {
|
|
12912
12971
|
return this.config.ignore.isIgnoredMethod(node, name);
|
|
@@ -13126,17 +13185,12 @@ class AstNodeFilterTransformer extends BaseInterfaceFilterTransformer {
|
|
|
13126
13185
|
constructor(idl) {
|
|
13127
13186
|
super(idl, true);
|
|
13128
13187
|
}
|
|
13129
|
-
shouldFilterOutInterface(
|
|
13130
|
-
if (this.typechecker.isHeir(name, Config.astNodeCommonAncestor))
|
|
13131
|
-
return false;
|
|
13132
|
-
if (this.typechecker.isHeir(name, Config.defaultAncestor))
|
|
13133
|
-
return false;
|
|
13134
|
-
// TODO: fix
|
|
13135
|
-
if (name === "Program")
|
|
13188
|
+
shouldFilterOutInterface(node) {
|
|
13189
|
+
if (this.typechecker.isHeir(node.name, Config.astNodeCommonAncestor))
|
|
13136
13190
|
return false;
|
|
13137
|
-
if (name
|
|
13191
|
+
if (this.typechecker.isHeir(node.name, Config.defaultAncestor))
|
|
13138
13192
|
return false;
|
|
13139
|
-
console.log(`FILTERED (AST) ${name}`);
|
|
13193
|
+
console.log(`FILTERED (AST) ${node.name}`);
|
|
13140
13194
|
return true;
|
|
13141
13195
|
}
|
|
13142
13196
|
shouldFilterOutMethod(node, name) {
|
|
@@ -13514,14 +13568,24 @@ class DynamicEmitter {
|
|
|
13514
13568
|
class IgnoreOptions {
|
|
13515
13569
|
constructor(filePath) {
|
|
13516
13570
|
var _a, _b;
|
|
13517
|
-
this.full = [];
|
|
13518
13571
|
this.partial = [];
|
|
13572
|
+
this.ignored = new Map();
|
|
13519
13573
|
if (filePath === undefined) {
|
|
13520
13574
|
return;
|
|
13521
13575
|
}
|
|
13522
13576
|
const ignore = lib.parse(fs__namespace$1.readFileSync(filePath).toString()).ignore;
|
|
13523
|
-
this.
|
|
13524
|
-
|
|
13577
|
+
this.partial = (_a = ignore === null || ignore === void 0 ? void 0 : ignore.partial) !== null && _a !== void 0 ? _a : [];
|
|
13578
|
+
const full = (_b = ignore === null || ignore === void 0 ? void 0 : ignore.full) !== null && _b !== void 0 ? _b : [];
|
|
13579
|
+
full.forEach((fqName) => {
|
|
13580
|
+
const parts = fqName.split('.');
|
|
13581
|
+
const [ns, name] = parts.length === 1 ? ['', parts.at(0)] : parts;
|
|
13582
|
+
if (!this.ignored.has(ns)) {
|
|
13583
|
+
this.ignored.set(ns, new Map());
|
|
13584
|
+
}
|
|
13585
|
+
const last = name.at(-1);
|
|
13586
|
+
const key = last === '-' || last === '+' ? name.slice(0, -1) : name;
|
|
13587
|
+
this.ignored.get(ns).set(key, last !== '+');
|
|
13588
|
+
});
|
|
13525
13589
|
}
|
|
13526
13590
|
isIgnoredMethod(iface, method) {
|
|
13527
13591
|
var _a;
|
|
@@ -13531,8 +13595,9 @@ class IgnoreOptions {
|
|
|
13531
13595
|
var _a;
|
|
13532
13596
|
return (_a = this.partial) === null || _a === void 0 ? void 0 : _a.some(it => { var _a; return it.interface === iface && ((_a = it.properties) === null || _a === void 0 ? void 0 : _a.includes(name)); });
|
|
13533
13597
|
}
|
|
13534
|
-
isIgnoredInterface(name) {
|
|
13535
|
-
|
|
13598
|
+
isIgnoredInterface(name, ns = '') {
|
|
13599
|
+
var _a, _b;
|
|
13600
|
+
return (_b = (_a = this.ignored.get(ns)) === null || _a === void 0 ? void 0 : _a.get(name)) !== null && _b !== void 0 ? _b : false;
|
|
13536
13601
|
}
|
|
13537
13602
|
}
|
|
13538
13603
|
// TODO: remove when interfaces fixed!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/arktscgen",
|
|
3
|
-
"version": "2.1.9-arktscgen-
|
|
3
|
+
"version": "2.1.9-arktscgen-9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": "lib/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"keywords": [],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@idlizer/core": "2.1.9-arktscgen-
|
|
22
|
+
"@idlizer/core": "2.1.9-arktscgen-9",
|
|
23
23
|
"@types/node": "^18.0.0",
|
|
24
24
|
"commander": "^10.0.0",
|
|
25
25
|
"typescript": "^4.9.5"
|