@idlizer/core 2.0.15 → 2.0.17
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.js +17 -5
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -4
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +3 -1
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +5 -1
- package/build/lib/src/idl.js +1 -1
- package/build/lib/src/index.d.ts +5 -0
- package/build/lib/src/index.js +5 -0
- package/build/lib/src/languageSpecificKeywords.js +1 -1
- package/build/lib/src/peer-generation/BuilderClass.d.ts +22 -0
- package/build/lib/src/peer-generation/BuilderClass.js +76 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +58 -0
- package/build/lib/src/peer-generation/Materialized.js +150 -0
- package/build/lib/src/peer-generation/PeerClass.d.ts +29 -0
- package/build/lib/src/peer-generation/PeerClass.js +44 -0
- package/build/lib/src/peer-generation/PeerFile.d.ts +13 -0
- package/build/lib/src/peer-generation/PeerFile.js +38 -0
- package/build/lib/src/peer-generation/PeerMethod.d.ts +35 -0
- package/build/lib/src/peer-generation/PeerMethod.js +108 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +1 -1
- package/build/lib/src/peer-generation/idl/common.d.ts +1 -0
- package/build/lib/src/peer-generation/idl/common.js +5 -0
- package/build/lib/src/util.d.ts +8 -0
- package/build/lib/src/util.js +16 -0
- package/package.json +3 -7
|
@@ -123,7 +123,7 @@ export class StringConvertor extends BaseArgConvertor {
|
|
|
123
123
|
convertorArg(param, writer) {
|
|
124
124
|
return writer.language == Language.CPP
|
|
125
125
|
? writer.makeUnsafeCast_(writer.makeString(`&${param}`), this.idlType, PrintHint.AsConstPointer)
|
|
126
|
-
: param;
|
|
126
|
+
: writer.escapeKeyword(param);
|
|
127
127
|
}
|
|
128
128
|
convertorSerialize(param, value, writer) {
|
|
129
129
|
writer.writeMethodCall(`${param}Serializer`, `writeString`, [value]);
|
|
@@ -158,7 +158,7 @@ export class EnumConvertor extends BaseArgConvertor {
|
|
|
158
158
|
this.enumEntry = enumEntry;
|
|
159
159
|
}
|
|
160
160
|
convertorArg(param, writer) {
|
|
161
|
-
return writer.makeEnumCast(param, false, this);
|
|
161
|
+
return writer.makeEnumCast(writer.escapeKeyword(param), false, this);
|
|
162
162
|
}
|
|
163
163
|
convertorSerialize(param, value, writer) {
|
|
164
164
|
value =
|
|
@@ -199,7 +199,7 @@ export class NumberConvertor extends BaseArgConvertor {
|
|
|
199
199
|
convertorArg(param, writer) {
|
|
200
200
|
return writer.language == Language.CPP
|
|
201
201
|
? writer.makeUnsafeCast_(writer.makeString(`&${param}`), this.idlType, PrintHint.AsConstPointer)
|
|
202
|
-
: param;
|
|
202
|
+
: writer.escapeKeyword(param);
|
|
203
203
|
}
|
|
204
204
|
convertorSerialize(param, value, printer) {
|
|
205
205
|
printer.writeMethodCall(`${param}Serializer`, "writeNumber", [value]);
|
|
@@ -698,14 +698,26 @@ export class OptionConvertor extends BaseArgConvertor {
|
|
|
698
698
|
const valueType = `${value}_type`;
|
|
699
699
|
const serializedType = (printer.language == Language.JAVA ? undefined : idl.IDLI32Type);
|
|
700
700
|
printer.writeStatement(printer.makeAssign(valueType, serializedType, printer.makeRuntimeType(RuntimeType.UNDEFINED), true, false));
|
|
701
|
-
printer.
|
|
702
|
-
|
|
701
|
+
if (printer.language != Language.CJ) {
|
|
702
|
+
printer.runtimeType(this, valueType, value);
|
|
703
|
+
printer.writeMethodCall(`${param}Serializer`, "writeInt8", [printer.castToInt(valueType, 8)]);
|
|
704
|
+
}
|
|
703
705
|
printer.print(`if (${printer.makeRuntimeTypeCondition(valueType, false, RuntimeType.UNDEFINED, value).asString()}) {`);
|
|
704
706
|
printer.pushIndent();
|
|
707
|
+
if (printer.language == Language.CJ) {
|
|
708
|
+
printer.writeMethodCall(`${param}Serializer`, "writeInt8", ["RuntimeType.OBJECT.ordinal"]); // everything is object, except None<T>
|
|
709
|
+
}
|
|
705
710
|
printer.writeStatement(printer.makeAssign(`${value}_value`, undefined, printer.makeValueFromOption(value, this.typeConvertor), true));
|
|
706
711
|
this.typeConvertor.convertorSerialize(param, this.typeConvertor.getObjectAccessor(printer.language, `${value}_value`), printer);
|
|
707
712
|
printer.popIndent();
|
|
708
713
|
printer.print(`}`);
|
|
714
|
+
if (printer.language == Language.CJ) {
|
|
715
|
+
printer.print('else {');
|
|
716
|
+
printer.pushIndent();
|
|
717
|
+
printer.writeMethodCall(`${param}Serializer`, "writeInt8", ["RuntimeType.UNDEFINED.ordinal"]); // undefined
|
|
718
|
+
printer.popIndent();
|
|
719
|
+
printer.print('}');
|
|
720
|
+
}
|
|
709
721
|
}
|
|
710
722
|
convertorCArg(param) {
|
|
711
723
|
throw new Error("Must never be used");
|
|
@@ -273,6 +273,7 @@ export declare abstract class LanguageWriter {
|
|
|
273
273
|
writeStatement(stmt: LanguageStatement): void;
|
|
274
274
|
writeStatements(...statements: LanguageStatement[]): void;
|
|
275
275
|
writeExpressionStatement(smth: LanguageExpression): void;
|
|
276
|
+
writeStaticBlock(op: (writer: this) => void): void;
|
|
276
277
|
makeRef(type: idl.IDLType, _options?: MakeRefOptions): idl.IDLType;
|
|
277
278
|
makeThis(): LanguageExpression;
|
|
278
279
|
makeNull(value?: string): LanguageExpression;
|
|
@@ -281,11 +281,10 @@ export class LambdaExpression {
|
|
|
281
281
|
stmt.write(writer);
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
return writer.
|
|
285
|
-
.map(line => line.trim())
|
|
284
|
+
return writer.getOutput()
|
|
286
285
|
.filter(line => line !== "")
|
|
287
|
-
.map(line => line
|
|
288
|
-
.join("
|
|
286
|
+
.map(line => line.endsWith('{') || line.endsWith('}') || line.endsWith(';') ? line : `${line};`)
|
|
287
|
+
.join("\n");
|
|
289
288
|
}
|
|
290
289
|
}
|
|
291
290
|
////////////////////////////////////////////////////////////////
|
|
@@ -438,6 +437,13 @@ export class LanguageWriter {
|
|
|
438
437
|
writeExpressionStatement(smth) {
|
|
439
438
|
this.writeStatement(new ExpressionStatement(smth));
|
|
440
439
|
}
|
|
440
|
+
writeStaticBlock(op) {
|
|
441
|
+
this.print("static {");
|
|
442
|
+
this.pushIndent();
|
|
443
|
+
op(this);
|
|
444
|
+
this.popIndent();
|
|
445
|
+
this.print("}");
|
|
446
|
+
}
|
|
441
447
|
makeRef(type, _options) {
|
|
442
448
|
return type;
|
|
443
449
|
}
|
|
@@ -25,7 +25,9 @@ export class CppInteropConvertor extends InteropConvertor {
|
|
|
25
25
|
}
|
|
26
26
|
const conf = generatorConfiguration();
|
|
27
27
|
const typePrefix = conf.param("TypePrefix");
|
|
28
|
-
|
|
28
|
+
// TODO remove this ugly hack for CustomObject's
|
|
29
|
+
const convertedToCustomObject = result.text === idl.IDLCustomObjectType.name;
|
|
30
|
+
const libPrefix = idl.isPrimitiveType(type) || convertedToCustomObject ? "" : conf.param("LibraryPrefix");
|
|
29
31
|
return `${typePrefix}${libPrefix}${result.text}`;
|
|
30
32
|
}
|
|
31
33
|
convert(node) {
|
|
@@ -309,7 +309,7 @@ export class CJLanguageWriter extends LanguageWriter {
|
|
|
309
309
|
}
|
|
310
310
|
generateFunctionDeclaration(name, signature) {
|
|
311
311
|
const args = signature.args.map((it, index) => `${signature.argName(index)}: ${this.getNodeName(it)}`);
|
|
312
|
-
return `public func ${name}(${args.join(", ")})`;
|
|
312
|
+
return `public func ${name}(${args.join(", ")}): ${this.getNodeName(signature.returnType)}`;
|
|
313
313
|
}
|
|
314
314
|
writeMethodCall(receiver, method, params, nullable = false) {
|
|
315
315
|
params = params.map(argName => this.escapeKeyword(argName));
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import * as idl from '../../idl';
|
|
16
16
|
import { Language } from '../../Language';
|
|
17
17
|
import { IndentedPrinter } from "../../IndentedPrinter";
|
|
18
|
-
import { AssignStatement, CheckOptionalStatement, ExpressionStatement, FieldModifier, LambdaExpression, LanguageWriter, Method, MethodModifier, NamedMethodSignature, ReturnStatement, StringExpression } from "../LanguageWriter";
|
|
18
|
+
import { AssignStatement, BlockStatement, CheckOptionalStatement, ExpressionStatement, FieldModifier, IfStatement, LambdaExpression, LanguageWriter, Method, MethodModifier, NamedMethodSignature, NaryOpExpression, ReturnStatement, StringExpression } from "../LanguageWriter";
|
|
19
19
|
import { RuntimeType } from "../common";
|
|
20
20
|
import { throwException } from "../../util";
|
|
21
21
|
import { TSKeywords } from '../../languageSpecificKeywords';
|
|
@@ -193,6 +193,10 @@ export class TSLanguageWriter extends LanguageWriter {
|
|
|
193
193
|
}
|
|
194
194
|
writeNativeMethodDeclaration(name, signature, isNative) {
|
|
195
195
|
this.writeMethodImplementation(new Method(name, signature, [MethodModifier.STATIC]), writer => {
|
|
196
|
+
const selfCallExpression = writer.makeFunctionCall(`this.${name}`, signature.args.map((_, i) => writer.makeString(this.escapeKeyword(signature.argName(i)))));
|
|
197
|
+
writer.writeStatement(new IfStatement(new NaryOpExpression("==", [writer.makeFunctionCall("this._LoadOnce", []), writer.makeString("true")]), new BlockStatement([
|
|
198
|
+
writer.makeReturn(selfCallExpression)
|
|
199
|
+
]), undefined, undefined, undefined));
|
|
196
200
|
writer.writeStatement(writer.makeThrowError("Not implemented"));
|
|
197
201
|
});
|
|
198
202
|
}
|
package/build/lib/src/idl.js
CHANGED
|
@@ -517,7 +517,7 @@ export function createConstructor(parameters, returnType, nodeInitializer = {})
|
|
|
517
517
|
returnType }, nodeInitializer), { _idlNodeBrand: innerIdlSymbol, _idlEntryBrand: innerIdlSymbol, _idlNamedNodeBrand: innerIdlSymbol });
|
|
518
518
|
}
|
|
519
519
|
export function createCallback(name, parameters, returnType, nodeInitializer = {}, typeParameters = []) {
|
|
520
|
-
if (returnType === IDLThisType)
|
|
520
|
+
if (returnType === IDLThisType || isReferenceType(returnType) && returnType.name === "this")
|
|
521
521
|
returnType = IDLAnyType;
|
|
522
522
|
parameters = parameters.map(it => {
|
|
523
523
|
if (it.type && isNamedNode(it.type) && (it.type.name === "T" || it.type.name === "this"))
|
package/build/lib/src/index.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export * from "./LanguageWriters/writers/TsLanguageWriter";
|
|
|
24
24
|
export * from "./LanguageWriters/writers/ETSLanguageWriter";
|
|
25
25
|
export * from "./peer-generation/idl/IdlNameConvertor";
|
|
26
26
|
export * from "./peer-generation/PrimitiveType";
|
|
27
|
+
export * from "./peer-generation/PeerFile";
|
|
28
|
+
export * from "./peer-generation/PeerClass";
|
|
29
|
+
export * from "./peer-generation/PeerMethod";
|
|
30
|
+
export * from "./peer-generation/BuilderClass";
|
|
31
|
+
export * from "./peer-generation/Materialized";
|
|
27
32
|
export * from "./peer-generation/unions";
|
|
28
33
|
export * from "./LanguageWriters";
|
|
29
34
|
export * from "./peer-generation/ReferenceResolver";
|
package/build/lib/src/index.js
CHANGED
|
@@ -38,6 +38,11 @@ export * from "./LanguageWriters/writers/TsLanguageWriter";
|
|
|
38
38
|
export * from "./LanguageWriters/writers/ETSLanguageWriter";
|
|
39
39
|
export * from "./peer-generation/idl/IdlNameConvertor";
|
|
40
40
|
export * from "./peer-generation/PrimitiveType";
|
|
41
|
+
export * from "./peer-generation/PeerFile";
|
|
42
|
+
export * from "./peer-generation/PeerClass";
|
|
43
|
+
export * from "./peer-generation/PeerMethod";
|
|
44
|
+
export * from "./peer-generation/BuilderClass";
|
|
45
|
+
export * from "./peer-generation/Materialized";
|
|
41
46
|
export * from "./peer-generation/unions";
|
|
42
47
|
export * from "./LanguageWriters";
|
|
43
48
|
export * from "./peer-generation/ReferenceResolver";
|
|
@@ -35,7 +35,7 @@ export const CJKeywords = new Set([
|
|
|
35
35
|
'break', 'is', 'as', 'in', 'match',
|
|
36
36
|
'from', 'where', 'extend', 'spawn',
|
|
37
37
|
'synchronized', 'macro', 'quote', 'true',
|
|
38
|
-
'false', 'static', 'public', 'private',
|
|
38
|
+
/*'false', */ 'static', 'public', 'private',
|
|
39
39
|
'protected', 'override', 'redef', 'abstract',
|
|
40
40
|
'open', 'operator', 'foreign', 'inout',
|
|
41
41
|
'prop', 'mut', 'unsafe', 'get', 'set'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDLInterface, IDLReferenceType } from "../idl";
|
|
2
|
+
import { Field, Method } from "../LanguageWriters/LanguageWriter";
|
|
3
|
+
export declare class BuilderClass {
|
|
4
|
+
readonly declaration: IDLInterface;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly generics: string[] | undefined;
|
|
7
|
+
readonly isInterface: boolean;
|
|
8
|
+
readonly superClass: IDLReferenceType | undefined;
|
|
9
|
+
readonly fields: Field[];
|
|
10
|
+
readonly constructors: Method[];
|
|
11
|
+
readonly methods: Method[];
|
|
12
|
+
readonly needBeGenerated: boolean;
|
|
13
|
+
constructor(declaration: IDLInterface, name: string, generics: string[] | undefined, isInterface: boolean, superClass: IDLReferenceType | undefined, fields: Field[], constructors: Method[], methods: Method[], needBeGenerated?: boolean);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builder classes are classes with methods which have only one parameter and return only itself
|
|
17
|
+
*/
|
|
18
|
+
export declare function isBuilderClass(declaration: IDLInterface): boolean;
|
|
19
|
+
export declare const CUSTOM_BUILDER_CLASSES: BuilderClass[];
|
|
20
|
+
export declare function isCustomBuilderClass(name: string): boolean;
|
|
21
|
+
export declare function methodsGroupOverloads(methods: Method[]): Method[][];
|
|
22
|
+
//# sourceMappingURL=BuilderClass.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { generatorConfiguration } from "../config";
|
|
16
|
+
import { isDefined } from "../util";
|
|
17
|
+
export class BuilderClass {
|
|
18
|
+
constructor(declaration, name, generics, isInterface, superClass, fields, constructors, methods, needBeGenerated = true) {
|
|
19
|
+
this.declaration = declaration;
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.generics = generics;
|
|
22
|
+
this.isInterface = isInterface;
|
|
23
|
+
this.superClass = superClass;
|
|
24
|
+
this.fields = fields;
|
|
25
|
+
this.constructors = constructors;
|
|
26
|
+
this.methods = methods;
|
|
27
|
+
this.needBeGenerated = needBeGenerated;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builder classes are classes with methods which have only one parameter and return only itself
|
|
32
|
+
*/
|
|
33
|
+
export function isBuilderClass(declaration) {
|
|
34
|
+
const className = declaration.name;
|
|
35
|
+
if (generatorConfiguration().paramArray("builderClasses").includes(className)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (isCustomBuilderClass(className)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
// TBD: update builder class check condition.
|
|
42
|
+
// Only SubTabBarStyle, BottomTabBarStyle, DotIndicator, and DigitIndicator classes
|
|
43
|
+
// are used for now.
|
|
44
|
+
return false;
|
|
45
|
+
/*
|
|
46
|
+
if (PeerGeneratorConfig.isStandardNameIgnored(className)) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const methods: (ts.MethodSignature | ts.MethodDeclaration)[] = [
|
|
51
|
+
...ts.isClassDeclaration(declaration) ? declaration.members.filter(ts.isMethodDeclaration) : [],
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
if (methods.length === 0) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return methods.every(it => it.type && className == it.type.getText() && it.parameters.length === 1)
|
|
59
|
+
*/
|
|
60
|
+
}
|
|
61
|
+
export const CUSTOM_BUILDER_CLASSES = [];
|
|
62
|
+
export function isCustomBuilderClass(name) {
|
|
63
|
+
return isDefined(CUSTOM_BUILDER_CLASSES.find(it => it.name === name));
|
|
64
|
+
}
|
|
65
|
+
export function methodsGroupOverloads(methods) {
|
|
66
|
+
const seenNames = new Set();
|
|
67
|
+
const groups = [];
|
|
68
|
+
for (const method of methods) {
|
|
69
|
+
if (seenNames.has(method.name))
|
|
70
|
+
continue;
|
|
71
|
+
seenNames.add(method.name);
|
|
72
|
+
groups.push(methods.filter(it => it.name === method.name));
|
|
73
|
+
}
|
|
74
|
+
return groups;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=BuilderClass.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as idl from '../idl';
|
|
2
|
+
import { ArgConvertor } from '../LanguageWriters/ArgConvertors';
|
|
3
|
+
import { Field, Method } from '../LanguageWriters/LanguageWriter';
|
|
4
|
+
import { PeerClassBase } from './PeerClass';
|
|
5
|
+
import { PeerMethod } from './PeerMethod';
|
|
6
|
+
export declare class MaterializedField {
|
|
7
|
+
field: Field;
|
|
8
|
+
argConvertor: ArgConvertor;
|
|
9
|
+
outArgConvertor?: ArgConvertor | undefined;
|
|
10
|
+
isNullableOriginalTypeField?: boolean | undefined;
|
|
11
|
+
constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined);
|
|
12
|
+
}
|
|
13
|
+
export declare class MaterializedMethod extends PeerMethod {
|
|
14
|
+
implementationParentName: string;
|
|
15
|
+
outArgConvertor?: ArgConvertor | undefined;
|
|
16
|
+
constructor(originalParentName: string, implementationParentName: string, argConvertors: ArgConvertor[], returnType: idl.IDLType, isCallSignature: boolean, method: Method, outArgConvertor?: ArgConvertor | undefined);
|
|
17
|
+
get peerMethodName(): string;
|
|
18
|
+
get implNamespaceName(): string;
|
|
19
|
+
get toStringName(): string;
|
|
20
|
+
get dummyReturnValue(): string | undefined;
|
|
21
|
+
get receiverType(): string;
|
|
22
|
+
get apiCall(): string;
|
|
23
|
+
get apiKind(): string;
|
|
24
|
+
generateReceiver(): {
|
|
25
|
+
argName: string;
|
|
26
|
+
argType: string;
|
|
27
|
+
} | undefined;
|
|
28
|
+
getImplementationName(): string;
|
|
29
|
+
tsReturnType(): idl.IDLType | undefined;
|
|
30
|
+
getPrivateMethod(): MaterializedMethod;
|
|
31
|
+
}
|
|
32
|
+
export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
|
|
33
|
+
method?: Method;
|
|
34
|
+
}): MaterializedMethod;
|
|
35
|
+
export declare class MaterializedClass implements PeerClassBase {
|
|
36
|
+
readonly decl: idl.IDLInterface;
|
|
37
|
+
readonly className: string;
|
|
38
|
+
readonly isInterface: boolean;
|
|
39
|
+
readonly superClass: idl.IDLReferenceType | undefined;
|
|
40
|
+
readonly interfaces: idl.IDLReferenceType[] | undefined;
|
|
41
|
+
readonly generics: string[] | undefined;
|
|
42
|
+
readonly fields: MaterializedField[];
|
|
43
|
+
readonly ctor: MaterializedMethod;
|
|
44
|
+
readonly finalizer: MaterializedMethod;
|
|
45
|
+
readonly methods: MaterializedMethod[];
|
|
46
|
+
readonly needBeGenerated: boolean;
|
|
47
|
+
readonly taggedMethods: idl.IDLMethod[];
|
|
48
|
+
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctor: MaterializedMethod, finalizer: MaterializedMethod, methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
|
|
49
|
+
getComponentName(): string;
|
|
50
|
+
getImplementationName(): string;
|
|
51
|
+
generatedName(isCallSignature: boolean): string;
|
|
52
|
+
isGlobalScope(): boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function createDestroyPeerMethod(clazz: MaterializedClass): MaterializedMethod;
|
|
55
|
+
export declare function getInternalClassName(name: string): string;
|
|
56
|
+
export declare function getInternalClassQualifiedName(target: idl.IDLEntry): string;
|
|
57
|
+
export declare function getMaterializedFileName(name: string): string;
|
|
58
|
+
//# sourceMappingURL=Materialized.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import * as idl from '../idl';
|
|
16
|
+
import { copyMethod, Method, MethodModifier, NamedMethodSignature } from '../LanguageWriters/LanguageWriter';
|
|
17
|
+
import { capitalize } from '../util';
|
|
18
|
+
import { qualifiedName } from './idl/common';
|
|
19
|
+
import { PeerMethod } from './PeerMethod';
|
|
20
|
+
export class MaterializedField {
|
|
21
|
+
constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField) {
|
|
22
|
+
this.field = field;
|
|
23
|
+
this.argConvertor = argConvertor;
|
|
24
|
+
this.outArgConvertor = outArgConvertor;
|
|
25
|
+
this.isNullableOriginalTypeField = isNullableOriginalTypeField;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class MaterializedMethod extends PeerMethod {
|
|
29
|
+
constructor(originalParentName, implementationParentName, argConvertors, returnType, isCallSignature, method, outArgConvertor) {
|
|
30
|
+
super(originalParentName, argConvertors, returnType, isCallSignature, method, outArgConvertor);
|
|
31
|
+
this.implementationParentName = implementationParentName;
|
|
32
|
+
this.outArgConvertor = outArgConvertor;
|
|
33
|
+
}
|
|
34
|
+
get peerMethodName() {
|
|
35
|
+
return this.overloadedName;
|
|
36
|
+
}
|
|
37
|
+
get implNamespaceName() {
|
|
38
|
+
return `${capitalize(this.originalParentName)}Accessor`;
|
|
39
|
+
}
|
|
40
|
+
get toStringName() {
|
|
41
|
+
switch (this.method.name) {
|
|
42
|
+
case "ctor": return `new ${this.originalParentName}`;
|
|
43
|
+
case "destructor": return `delete ${this.originalParentName}`;
|
|
44
|
+
default: return super.toStringName;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
get dummyReturnValue() {
|
|
48
|
+
var _a;
|
|
49
|
+
if (this.method.name === "ctor")
|
|
50
|
+
return `(${this.originalParentName}Peer*) 100`;
|
|
51
|
+
if (this.method.name === "getFinalizer")
|
|
52
|
+
return `fnPtr<KNativePointer>(dummyClassFinalizer)`;
|
|
53
|
+
if ((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC)) {
|
|
54
|
+
if (this.method.signature.returnType === idl.IDLNumberType) {
|
|
55
|
+
return '100';
|
|
56
|
+
}
|
|
57
|
+
if (this.method.signature.returnType === idl.IDLBooleanType) {
|
|
58
|
+
return '0';
|
|
59
|
+
}
|
|
60
|
+
return `(void*) 300`;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
get receiverType() {
|
|
65
|
+
return `${this.originalParentName}Peer*`;
|
|
66
|
+
}
|
|
67
|
+
get apiCall() {
|
|
68
|
+
return "GetAccessors()";
|
|
69
|
+
}
|
|
70
|
+
get apiKind() {
|
|
71
|
+
return "Accessor";
|
|
72
|
+
}
|
|
73
|
+
generateReceiver() {
|
|
74
|
+
if (!this.hasReceiver())
|
|
75
|
+
return undefined;
|
|
76
|
+
return {
|
|
77
|
+
argName: 'peer',
|
|
78
|
+
argType: `${this.originalParentName}Peer*`
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
getImplementationName() {
|
|
82
|
+
return this.implementationParentName;
|
|
83
|
+
}
|
|
84
|
+
tsReturnType() {
|
|
85
|
+
return this.method.signature.returnType;
|
|
86
|
+
}
|
|
87
|
+
getPrivateMethod() {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
let privateMethod = this;
|
|
90
|
+
if (!((_a = privateMethod.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.PRIVATE))) {
|
|
91
|
+
privateMethod = copyMaterializedMethod(this, {
|
|
92
|
+
method: copyMethod(this.method, {
|
|
93
|
+
modifiers: ((_b = this.method.modifiers) !== null && _b !== void 0 ? _b : [])
|
|
94
|
+
.filter(it => it !== MethodModifier.PUBLIC)
|
|
95
|
+
.concat([MethodModifier.PRIVATE])
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return privateMethod;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function copyMaterializedMethod(method, overrides) {
|
|
103
|
+
var _a;
|
|
104
|
+
const copied = new MaterializedMethod(method.originalParentName, method.implementationParentName, method.argConvertors, method.returnType, method.isCallSignature, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method, method.outArgConvertor);
|
|
105
|
+
copied.setSameOverloadIndex(method);
|
|
106
|
+
return copied;
|
|
107
|
+
}
|
|
108
|
+
export class MaterializedClass {
|
|
109
|
+
constructor(decl, className, isInterface, superClass, interfaces, generics, fields, ctor, finalizer, methods, needBeGenerated = true, taggedMethods = []) {
|
|
110
|
+
this.decl = decl;
|
|
111
|
+
this.className = className;
|
|
112
|
+
this.isInterface = isInterface;
|
|
113
|
+
this.superClass = superClass;
|
|
114
|
+
this.interfaces = interfaces;
|
|
115
|
+
this.generics = generics;
|
|
116
|
+
this.fields = fields;
|
|
117
|
+
this.ctor = ctor;
|
|
118
|
+
this.finalizer = finalizer;
|
|
119
|
+
this.methods = methods;
|
|
120
|
+
this.needBeGenerated = needBeGenerated;
|
|
121
|
+
this.taggedMethods = taggedMethods;
|
|
122
|
+
PeerMethod.markAndGroupOverloads(methods);
|
|
123
|
+
}
|
|
124
|
+
getComponentName() {
|
|
125
|
+
return this.className;
|
|
126
|
+
}
|
|
127
|
+
getImplementationName() {
|
|
128
|
+
return this.isInterface ? getInternalClassName(this.className) : this.className;
|
|
129
|
+
}
|
|
130
|
+
generatedName(isCallSignature) {
|
|
131
|
+
return this.className;
|
|
132
|
+
}
|
|
133
|
+
isGlobalScope() {
|
|
134
|
+
return idl.hasExtAttribute(this.decl, idl.IDLExtendedAttributes.GlobalScope);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function createDestroyPeerMethod(clazz) {
|
|
138
|
+
return new MaterializedMethod(clazz.className, clazz.getImplementationName(), [], idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.className)], ['peer'])));
|
|
139
|
+
}
|
|
140
|
+
export function getInternalClassName(name) {
|
|
141
|
+
return `${name}Internal`;
|
|
142
|
+
}
|
|
143
|
+
export function getInternalClassQualifiedName(target) {
|
|
144
|
+
return getInternalClassName(qualifiedName(target, "."));
|
|
145
|
+
}
|
|
146
|
+
export function getMaterializedFileName(name) {
|
|
147
|
+
const pascalCase = name.split('_').map(x => capitalize(x)).join('');
|
|
148
|
+
return `Ark${pascalCase}Materialized`;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=Materialized.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IDLProperty } from "../idl";
|
|
2
|
+
import { PeerMethod } from "./PeerMethod";
|
|
3
|
+
import { PeerFile } from "./PeerFile";
|
|
4
|
+
export interface PeerClassBase {
|
|
5
|
+
generatedName(isCallSignature: boolean): string;
|
|
6
|
+
getComponentName(): string;
|
|
7
|
+
}
|
|
8
|
+
export declare class PeerClass implements PeerClassBase {
|
|
9
|
+
readonly file: PeerFile;
|
|
10
|
+
readonly componentName: string;
|
|
11
|
+
readonly originalFilename: string;
|
|
12
|
+
constructor(file: PeerFile, componentName: string, originalFilename: string);
|
|
13
|
+
generatedName(isCallSignature: boolean): string;
|
|
14
|
+
getComponentName(): string;
|
|
15
|
+
methods: PeerMethod[];
|
|
16
|
+
originalClassName: string | undefined;
|
|
17
|
+
originalInterfaceName: string | undefined;
|
|
18
|
+
originalParentName: string | undefined;
|
|
19
|
+
originalParentFilename: string | undefined;
|
|
20
|
+
parentComponentName: string | undefined;
|
|
21
|
+
attributesFields: IDLProperty[];
|
|
22
|
+
attributesTypes: {
|
|
23
|
+
typeName: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}[];
|
|
26
|
+
hasGenericType: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function createConstructPeerMethod(clazz: PeerClass): PeerMethod;
|
|
29
|
+
//# sourceMappingURL=PeerClass.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { IDLI32Type, IDLPointerType } from "../idl";
|
|
16
|
+
import { NumericConvertor } from "../LanguageWriters/ArgConvertors";
|
|
17
|
+
import { PeerMethod } from "./PeerMethod";
|
|
18
|
+
import { Method, MethodModifier, NamedMethodSignature } from "../LanguageWriters/LanguageWriter";
|
|
19
|
+
export class PeerClass {
|
|
20
|
+
constructor(file, componentName, originalFilename) {
|
|
21
|
+
this.file = file;
|
|
22
|
+
this.componentName = componentName;
|
|
23
|
+
this.originalFilename = originalFilename;
|
|
24
|
+
this.methods = [];
|
|
25
|
+
this.originalClassName = undefined;
|
|
26
|
+
this.originalInterfaceName = undefined;
|
|
27
|
+
this.originalParentName = undefined;
|
|
28
|
+
this.originalParentFilename = undefined;
|
|
29
|
+
this.parentComponentName = undefined;
|
|
30
|
+
this.attributesFields = [];
|
|
31
|
+
this.attributesTypes = [];
|
|
32
|
+
this.hasGenericType = false;
|
|
33
|
+
}
|
|
34
|
+
generatedName(isCallSignature) {
|
|
35
|
+
return isCallSignature ? this.originalInterfaceName : this.originalClassName;
|
|
36
|
+
}
|
|
37
|
+
getComponentName() {
|
|
38
|
+
return this.componentName;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function createConstructPeerMethod(clazz) {
|
|
42
|
+
return new PeerMethod(clazz.componentName, [new NumericConvertor('id', IDLI32Type), new NumericConvertor('flags', IDLI32Type)], IDLPointerType, false, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=PeerClass.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as idl from '../idl';
|
|
2
|
+
import { PeerClass } from "./PeerClass";
|
|
3
|
+
import { LibraryFileInterface } from '../LibraryInterface';
|
|
4
|
+
export declare class PeerFile implements LibraryFileInterface {
|
|
5
|
+
readonly originalFilename: string;
|
|
6
|
+
readonly entries: idl.IDLEntry[];
|
|
7
|
+
readonly isPredefined: boolean;
|
|
8
|
+
readonly peers: Map<string, PeerClass>;
|
|
9
|
+
constructor(originalFilename: string, entries: idl.IDLEntry[], isPredefined?: boolean);
|
|
10
|
+
packageName(): string;
|
|
11
|
+
get peersToGenerate(): PeerClass[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=PeerFile.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import * as idl from '../idl';
|
|
16
|
+
export class PeerFile {
|
|
17
|
+
constructor(originalFilename, entries, isPredefined = false) {
|
|
18
|
+
this.originalFilename = originalFilename;
|
|
19
|
+
this.entries = entries;
|
|
20
|
+
this.isPredefined = isPredefined;
|
|
21
|
+
this.peers = new Map();
|
|
22
|
+
}
|
|
23
|
+
packageName() {
|
|
24
|
+
let packageTag = this.entries.find(it => idl.isPackage(it));
|
|
25
|
+
if (packageTag === undefined) {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
if (packageTag.name.startsWith('"') && packageTag.name.endsWith('"')) {
|
|
29
|
+
return packageTag.name.slice(1, packageTag.name.length - 1);
|
|
30
|
+
}
|
|
31
|
+
return packageTag.name;
|
|
32
|
+
}
|
|
33
|
+
get peersToGenerate() {
|
|
34
|
+
const peers = Array.from(this.peers.values());
|
|
35
|
+
return peers;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=PeerFile.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IDLType } from "../idl";
|
|
2
|
+
import { IdlNameConvertor } from "../LanguageWriters";
|
|
3
|
+
import { ArgConvertor } from "../LanguageWriters/ArgConvertors";
|
|
4
|
+
import { Method } from "../LanguageWriters/LanguageWriter";
|
|
5
|
+
export declare class PeerMethod {
|
|
6
|
+
originalParentName: string;
|
|
7
|
+
argConvertors: ArgConvertor[];
|
|
8
|
+
returnType: IDLType;
|
|
9
|
+
isCallSignature: boolean;
|
|
10
|
+
method: Method;
|
|
11
|
+
outArgConvertor?: ArgConvertor | undefined;
|
|
12
|
+
private overloadIndex?;
|
|
13
|
+
constructor(originalParentName: string, argConvertors: ArgConvertor[], returnType: IDLType, isCallSignature: boolean, method: Method, outArgConvertor?: ArgConvertor | undefined);
|
|
14
|
+
get overloadedName(): string;
|
|
15
|
+
get fullMethodName(): string;
|
|
16
|
+
get peerMethodName(): string;
|
|
17
|
+
get implNamespaceName(): string;
|
|
18
|
+
get implName(): string;
|
|
19
|
+
get toStringName(): string;
|
|
20
|
+
get dummyReturnValue(): string | undefined;
|
|
21
|
+
get receiverType(): string;
|
|
22
|
+
get apiCall(): string;
|
|
23
|
+
get apiKind(): string;
|
|
24
|
+
get argAndOutConvertors(): ArgConvertor[];
|
|
25
|
+
hasReceiver(): boolean;
|
|
26
|
+
generateAPIParameters(converter: IdlNameConvertor): string[];
|
|
27
|
+
generateReceiver(): {
|
|
28
|
+
argName: string;
|
|
29
|
+
argType: string;
|
|
30
|
+
} | undefined;
|
|
31
|
+
getImplementationName(): string;
|
|
32
|
+
static markAndGroupOverloads(methods: PeerMethod[]): PeerMethod[];
|
|
33
|
+
setSameOverloadIndex(copyFrom: PeerMethod): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=PeerMethod.d.ts.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { mangleMethodName, MethodModifier } from "../LanguageWriters/LanguageWriter";
|
|
16
|
+
import { capitalize, isDefined } from "../util";
|
|
17
|
+
import { PrimitiveTypesInstance } from "./PrimitiveType";
|
|
18
|
+
export class PeerMethod {
|
|
19
|
+
constructor(originalParentName, argConvertors, returnType, isCallSignature, method, outArgConvertor) {
|
|
20
|
+
this.originalParentName = originalParentName;
|
|
21
|
+
this.argConvertors = argConvertors;
|
|
22
|
+
this.returnType = returnType;
|
|
23
|
+
this.isCallSignature = isCallSignature;
|
|
24
|
+
this.method = method;
|
|
25
|
+
this.outArgConvertor = outArgConvertor;
|
|
26
|
+
}
|
|
27
|
+
get overloadedName() {
|
|
28
|
+
return mangleMethodName(this.method, this.overloadIndex);
|
|
29
|
+
}
|
|
30
|
+
get fullMethodName() {
|
|
31
|
+
return this.isCallSignature ? this.overloadedName : this.peerMethodName;
|
|
32
|
+
}
|
|
33
|
+
get peerMethodName() {
|
|
34
|
+
const name = this.overloadedName;
|
|
35
|
+
if (!this.hasReceiver())
|
|
36
|
+
return name;
|
|
37
|
+
if (name.startsWith("set") ||
|
|
38
|
+
name.startsWith("get"))
|
|
39
|
+
return name;
|
|
40
|
+
return `set${capitalize(name)}`;
|
|
41
|
+
}
|
|
42
|
+
get implNamespaceName() {
|
|
43
|
+
return `${capitalize(this.originalParentName)}Modifier`;
|
|
44
|
+
}
|
|
45
|
+
get implName() {
|
|
46
|
+
return `${capitalize(this.overloadedName)}Impl`;
|
|
47
|
+
}
|
|
48
|
+
get toStringName() {
|
|
49
|
+
return this.method.name;
|
|
50
|
+
}
|
|
51
|
+
get dummyReturnValue() {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
get receiverType() {
|
|
55
|
+
return "Ark_NodeHandle";
|
|
56
|
+
}
|
|
57
|
+
get apiCall() {
|
|
58
|
+
return "GetNodeModifiers()";
|
|
59
|
+
}
|
|
60
|
+
get apiKind() {
|
|
61
|
+
return "Modifier";
|
|
62
|
+
}
|
|
63
|
+
get argAndOutConvertors() {
|
|
64
|
+
var _a;
|
|
65
|
+
return this.argConvertors.concat((_a = this.outArgConvertor) !== null && _a !== void 0 ? _a : []);
|
|
66
|
+
}
|
|
67
|
+
hasReceiver() {
|
|
68
|
+
var _a;
|
|
69
|
+
return !((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC));
|
|
70
|
+
}
|
|
71
|
+
generateAPIParameters(converter) {
|
|
72
|
+
const args = this.argAndOutConvertors.map(it => {
|
|
73
|
+
let isPointer = it.isPointerType();
|
|
74
|
+
return `${isPointer ? "const " : ""}${converter.convert(it.nativeType())}${isPointer ? "*" : ""} ${it.param}`;
|
|
75
|
+
});
|
|
76
|
+
const receiver = this.generateReceiver();
|
|
77
|
+
if (receiver)
|
|
78
|
+
return [`${receiver.argType} ${receiver.argName}`, ...args];
|
|
79
|
+
return args;
|
|
80
|
+
}
|
|
81
|
+
generateReceiver() {
|
|
82
|
+
if (!this.hasReceiver())
|
|
83
|
+
return undefined;
|
|
84
|
+
return {
|
|
85
|
+
argName: "node",
|
|
86
|
+
argType: PrimitiveTypesInstance.NativePointer.getText()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
getImplementationName() {
|
|
90
|
+
return this.originalParentName;
|
|
91
|
+
}
|
|
92
|
+
static markAndGroupOverloads(methods) {
|
|
93
|
+
let groupedMethods = [];
|
|
94
|
+
for (const peerMethod of methods) {
|
|
95
|
+
if (isDefined(peerMethod.overloadIndex))
|
|
96
|
+
continue;
|
|
97
|
+
const sameNamedMethods = methods.filter(it => it.method.name === peerMethod.method.name);
|
|
98
|
+
if (sameNamedMethods.length > 1)
|
|
99
|
+
sameNamedMethods.forEach((it, index) => it.overloadIndex = index);
|
|
100
|
+
groupedMethods = groupedMethods.concat(sameNamedMethods);
|
|
101
|
+
}
|
|
102
|
+
return groupedMethods;
|
|
103
|
+
}
|
|
104
|
+
setSameOverloadIndex(copyFrom) {
|
|
105
|
+
this.overloadIndex = copyFrom.overloadIndex;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=PeerMethod.js.map
|
|
@@ -54,7 +54,7 @@ export class ETSDeclarationNameConvertor extends DeclarationNameConvertor {
|
|
|
54
54
|
ETSDeclarationNameConvertor.I = new ETSDeclarationNameConvertor();
|
|
55
55
|
export class ETSFeatureNameConvertor extends DeclarationNameConvertor {
|
|
56
56
|
convertEnum(decl) {
|
|
57
|
-
const namespace = idl.getNamespacesPathFor(decl).join('');
|
|
57
|
+
const namespace = idl.getNamespacesPathFor(decl).map(it => it.name).join('');
|
|
58
58
|
return `${namespace ? `${namespace}_` : ``}${decl.name}`;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -5,5 +5,6 @@ export declare function qualifiedName(decl: idl.IDLNode, languageOrDelimiter: La
|
|
|
5
5
|
export declare function typeOrUnion(types: idl.IDLType[], name?: string): idl.IDLType;
|
|
6
6
|
export declare function generifiedTypeName(refType: idl.IDLReferenceType | undefined, refName?: string): string | undefined;
|
|
7
7
|
export declare function generateSyntheticUnionName(types: idl.IDLType[]): string;
|
|
8
|
+
export declare function generateSyntheticFunctionName(parameters: idl.IDLParameter[], returnType: idl.IDLType, isAsync?: boolean): string;
|
|
8
9
|
export declare function isImportAttr(decl: idl.IDLNode): boolean;
|
|
9
10
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -64,6 +64,11 @@ export function generifiedTypeName(refType, refName) {
|
|
|
64
64
|
export function generateSyntheticUnionName(types) {
|
|
65
65
|
return `Union_${types.map(it => generateSyntheticIdlNodeName(it)).join("_")}`;
|
|
66
66
|
}
|
|
67
|
+
export function generateSyntheticFunctionName(parameters, returnType, isAsync = false) {
|
|
68
|
+
let prefix = isAsync ? "AsyncCallback" : "Callback";
|
|
69
|
+
const names = parameters.map(it => `${generateSyntheticIdlNodeName(it.type)}`).concat(generateSyntheticIdlNodeName(returnType));
|
|
70
|
+
return `${prefix}_${names.join("_").replaceAll(".", "_")}`;
|
|
71
|
+
}
|
|
67
72
|
export function isImportAttr(decl) {
|
|
68
73
|
return idl.hasExtAttribute(decl, idl.IDLExtendedAttributes.Import);
|
|
69
74
|
}
|
package/build/lib/src/util.d.ts
CHANGED
|
@@ -72,4 +72,12 @@ export declare function hashCodeFromString(value: string): number;
|
|
|
72
72
|
export declare function forceWriteFile(filePath: string, content: string): void;
|
|
73
73
|
export declare function findVersion(): any;
|
|
74
74
|
export declare function zipMany<T>(...xs: T[][]): Array<Array<T | undefined>>;
|
|
75
|
+
export declare class Lazy<T> {
|
|
76
|
+
private readonly factory;
|
|
77
|
+
constructor(factory: () => T);
|
|
78
|
+
private instantiated;
|
|
79
|
+
private instance;
|
|
80
|
+
get value(): T;
|
|
81
|
+
}
|
|
82
|
+
export declare function lazy<T>(factory: () => T): Lazy<T>;
|
|
75
83
|
//# sourceMappingURL=util.d.ts.map
|
package/build/lib/src/util.js
CHANGED
|
@@ -619,4 +619,20 @@ export function zipMany(...xs) {
|
|
|
619
619
|
}
|
|
620
620
|
return result;
|
|
621
621
|
}
|
|
622
|
+
export class Lazy {
|
|
623
|
+
constructor(factory) {
|
|
624
|
+
this.instantiated = false;
|
|
625
|
+
this.factory = factory;
|
|
626
|
+
}
|
|
627
|
+
get value() {
|
|
628
|
+
if (!this.instantiated) {
|
|
629
|
+
this.instance = this.factory();
|
|
630
|
+
this.instantiated = true;
|
|
631
|
+
}
|
|
632
|
+
return this.instance;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
export function lazy(factory) {
|
|
636
|
+
return new Lazy(factory);
|
|
637
|
+
}
|
|
622
638
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "build/lib/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,13 +34,9 @@
|
|
|
34
34
|
},
|
|
35
35
|
"keywords": [],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@koalaui/interop": "2.0.
|
|
37
|
+
"@koalaui/interop": "2.0.17",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
|
-
"@types/node": "^18.0.0"
|
|
40
|
-
"commander": "^10.0.0",
|
|
41
|
-
"comment-parser": "^1.4.1",
|
|
42
|
-
"cross-env": "^7.0.3",
|
|
43
|
-
"minimist": "^1.2.8"
|
|
39
|
+
"@types/node": "^18.0.0"
|
|
44
40
|
},
|
|
45
41
|
"scripts": {
|
|
46
42
|
"clean": "rimraf -g build",
|