@idlizer/core 2.0.35 → 2.0.36
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 +2 -2
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +4 -0
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +3 -0
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +3 -0
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +1 -0
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +3 -0
- package/build/lib/src/peer-generation/PeerMethod.js +4 -1
- package/package.json +2 -2
- package/build/lib/src/LanguageWriters/InteropConvertor.d.ts +0 -36
- package/build/lib/src/LanguageWriters/InteropConvertor.js +0 -174
- package/build/lib/src/configMerge.d.ts +0 -2
- package/build/lib/src/configMerge.js +0 -42
- package/build/lib/src/peer-generation/LanguageWriters/index.d.ts +0 -2
- package/build/lib/src/peer-generation/LanguageWriters/index.js +0 -2
- package/build/lib/src/peer-generation/LanguageWriters/nameConvertor.d.ts +0 -25
- package/build/lib/src/peer-generation/LanguageWriters/nameConvertor.js +0 -55
|
@@ -16,7 +16,7 @@ import * as idl from "../idl";
|
|
|
16
16
|
import { Language } from "../Language";
|
|
17
17
|
import { PrintHint, BlockStatement, StringExpression } from "./LanguageWriter";
|
|
18
18
|
import { RuntimeType } from "./common";
|
|
19
|
-
import {
|
|
19
|
+
import { generatorTypePrefix } from "../config";
|
|
20
20
|
import { hashCodeFromString, warn } from "../util";
|
|
21
21
|
import { UnionRuntimeTypeChecker } from "../peer-generation/unions";
|
|
22
22
|
import { CppNameConvertor } from "./convertors/CppConvertors";
|
|
@@ -894,7 +894,7 @@ export class MaterializedClassConvertor extends BaseArgConvertor {
|
|
|
894
894
|
convertorArg(param, writer) {
|
|
895
895
|
switch (writer.language) {
|
|
896
896
|
case Language.CPP:
|
|
897
|
-
return `static_cast<${
|
|
897
|
+
return `static_cast<${generatorTypePrefix()}${this.declaration.name}>(${param})`;
|
|
898
898
|
case Language.JAVA:
|
|
899
899
|
case Language.CJ:
|
|
900
900
|
return `MaterializedBase.toPeerPtr(${param})`;
|
|
@@ -236,6 +236,7 @@ export declare abstract class LanguageWriter {
|
|
|
236
236
|
abstract writeMethodImplementation(method: Method, op: (writer: this) => void): void;
|
|
237
237
|
abstract writeProperty(propName: string, propType: idl.IDLType, mutable?: boolean, getterLambda?: (writer: this) => void, setterLambda?: (writer: this) => void): void;
|
|
238
238
|
abstract writeTypeDeclaration(decl: idl.IDLTypedef): void;
|
|
239
|
+
abstract writeConstant(constName: string, constType: idl.IDLType, constVal?: string): void;
|
|
239
240
|
abstract makeAssign(variableName: string, type: idl.IDLType | undefined, expr: LanguageExpression | undefined, isDeclared: boolean, isConst?: boolean, options?: MakeAssignOptions): LanguageStatement;
|
|
240
241
|
abstract makeLambda(signature: MethodSignature, body?: LanguageStatement[]): LanguageExpression;
|
|
241
242
|
abstract makeThrowError(message: string): LanguageStatement;
|
|
@@ -91,6 +91,7 @@ export declare class CJLanguageWriter extends LanguageWriter {
|
|
|
91
91
|
writeConstructorImplementation(className: string, signature: MethodSignature, op: (writer: this) => void, superCall?: Method, modifiers?: MethodModifier[]): void;
|
|
92
92
|
writeProperty(propName: string, propType: idl.IDLType, mutable?: boolean, getterLambda?: (writer: this) => void, setterLambda?: (writer: this) => void): void;
|
|
93
93
|
writeTypeDeclaration(decl: idl.IDLTypedef): void;
|
|
94
|
+
writeConstant(constName: string, constType: idl.IDLType, constVal?: string): void;
|
|
94
95
|
writeMethodImplementation(method: Method, op: (writer: this) => void): void;
|
|
95
96
|
writeCJForeign(op: (writer: CJLanguageWriter) => void): void;
|
|
96
97
|
private writeDeclaration;
|
|
@@ -376,6 +376,10 @@ export class CJLanguageWriter extends LanguageWriter {
|
|
|
376
376
|
writeTypeDeclaration(decl) {
|
|
377
377
|
throw new Error(`writeTypeDeclaration not implemented`);
|
|
378
378
|
}
|
|
379
|
+
writeConstant(constName, constType, constVal) {
|
|
380
|
+
const namespacePrefix = this.namespaceStack.join('_');
|
|
381
|
+
this.print(`const ${namespacePrefix}${constName}: ${this.getNodeName(constType)} = ${constVal !== null && constVal !== void 0 ? constVal : ''}`);
|
|
382
|
+
}
|
|
379
383
|
writeMethodImplementation(method, op) {
|
|
380
384
|
this.writeDeclaration(method.name, method.signature, method.modifiers, " {");
|
|
381
385
|
this.pushIndent();
|
|
@@ -47,6 +47,7 @@ export declare class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
47
47
|
writeConstructorImplementation(className: string, signature: MethodSignature, op: (writer: this) => void, superCall?: Method, modifiers?: MethodModifier[]): void;
|
|
48
48
|
writeProperty(propName: string, propType: IDLType, mutable?: boolean): void;
|
|
49
49
|
writeTypeDeclaration(decl: IDLTypedef): void;
|
|
50
|
+
writeConstant(constName: string, constType: IDLType, constVal?: string): void;
|
|
50
51
|
/**
|
|
51
52
|
* Writes multiline comments decorated with stars
|
|
52
53
|
*/
|
|
@@ -223,6 +223,9 @@ export class CppLanguageWriter extends CLikeLanguageWriter {
|
|
|
223
223
|
writeTypeDeclaration(decl) {
|
|
224
224
|
throw new Error(`writeTypeDeclaration not implemented`);
|
|
225
225
|
}
|
|
226
|
+
writeConstant(constName, constType, constVal) {
|
|
227
|
+
this.print(`${this.getNodeName(constType)} ${constName}${constVal ? ' = ' + constVal : ''};`);
|
|
228
|
+
}
|
|
226
229
|
/**
|
|
227
230
|
* Writes multiline comments decorated with stars
|
|
228
231
|
*/
|
|
@@ -42,6 +42,7 @@ export declare class JavaLanguageWriter extends CLikeLanguageWriter {
|
|
|
42
42
|
writeConstructorImplementation(className: string, signature: MethodSignature, op: (writer: this) => void, superCall?: Method, modifiers?: MethodModifier[]): void;
|
|
43
43
|
writeProperty(propName: string, propType: idl.IDLType): void;
|
|
44
44
|
writeTypeDeclaration(decl: idl.IDLTypedef): void;
|
|
45
|
+
writeConstant(constName: string, constType: idl.IDLType, constVal?: string): void;
|
|
45
46
|
makeAssign(variableName: string, type: idl.IDLType | undefined, expr: LanguageExpression, isDeclared?: boolean, isConst?: boolean): LanguageStatement;
|
|
46
47
|
makeLambda(signature: MethodSignature, body?: LanguageStatement[]): LanguageExpression;
|
|
47
48
|
makeReturn(expr: LanguageExpression): LanguageStatement;
|
|
@@ -155,6 +155,9 @@ export class JavaLanguageWriter extends CLikeLanguageWriter {
|
|
|
155
155
|
writeTypeDeclaration(decl) {
|
|
156
156
|
throw new Error(`Type declarations do not exist in Java, use something else`);
|
|
157
157
|
}
|
|
158
|
+
writeConstant(constName, constType, constVal) {
|
|
159
|
+
throw new Error("writeConstant for Java is not implemented yet.");
|
|
160
|
+
}
|
|
158
161
|
makeAssign(variableName, type, expr, isDeclared = true, isConst = true) {
|
|
159
162
|
return new JavaAssignStatement(variableName, type, expr, isDeclared, isConst);
|
|
160
163
|
}
|
|
@@ -55,6 +55,7 @@ export declare class TSLanguageWriter extends LanguageWriter {
|
|
|
55
55
|
writeMethodImplementation(method: Method, op: (writer: this) => void): void;
|
|
56
56
|
writeProperty(propName: string, propType: idl.IDLType): void;
|
|
57
57
|
writeTypeDeclaration(decl: idl.IDLTypedef): void;
|
|
58
|
+
writeConstant(constName: string, constType: idl.IDLType, constVal?: string): void;
|
|
58
59
|
private writeDeclaration;
|
|
59
60
|
makeNull(): LanguageExpression;
|
|
60
61
|
makeAssign(variableName: string, type: idl.IDLType | undefined, expr: LanguageExpression | undefined, isDeclared?: boolean, isConst?: boolean, options?: MakeAssignOptions): LanguageStatement;
|
|
@@ -240,6 +240,9 @@ export class TSLanguageWriter extends LanguageWriter {
|
|
|
240
240
|
const typeParams = ((_a = decl.typeParameters) === null || _a === void 0 ? void 0 : _a.length) ? `<${decl.typeParameters.join(",").replace("[]", "")}>` : "";
|
|
241
241
|
this.print(`export type ${decl.name}${typeParams} = ${type};`);
|
|
242
242
|
}
|
|
243
|
+
writeConstant(constName, constType, constVal) {
|
|
244
|
+
this.print(`export const ${constName}: ${this.getNodeName(constType)}${constVal ? ' = ' + constVal : ''}`);
|
|
245
|
+
}
|
|
243
246
|
writeDeclaration(name, signature, needReturn, needBracket, modifiers, generics) {
|
|
244
247
|
var _a;
|
|
245
248
|
let prefix = !modifiers ? undefined : this.supportedModifiers
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
15
|
import { generatorTypePrefix } from "../config";
|
|
16
|
+
import { asPromise } from "../idl";
|
|
16
17
|
import { mangleMethodName, MethodModifier } from "../LanguageWriters/LanguageWriter";
|
|
17
18
|
import { capitalize, isDefined } from "../util";
|
|
18
19
|
import { PrimitiveTypesInstance } from "./PrimitiveType";
|
|
@@ -78,7 +79,9 @@ export class PeerMethod {
|
|
|
78
79
|
const receiver = this.generateReceiver();
|
|
79
80
|
if (receiver)
|
|
80
81
|
args.unshift(`${receiver.argType} ${receiver.argName}`);
|
|
81
|
-
if ((
|
|
82
|
+
if (!!asPromise(this.method.signature.returnType))
|
|
83
|
+
args.unshift(`${generatorTypePrefix()}AsyncWorkerPtr asyncWorker`);
|
|
84
|
+
if (!!asPromise(this.method.signature.returnType) || ((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.THROWS)))
|
|
82
85
|
args.unshift(`${generatorTypePrefix()}VMContext vmContext`);
|
|
83
86
|
return args;
|
|
84
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.36",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "build/lib/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"keywords": [],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@koalaui/interop": "1.5.
|
|
37
|
+
"@koalaui/interop": "1.5.7",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
39
|
"@types/node": "^18.0.0"
|
|
40
40
|
},
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as idl from '../idl';
|
|
2
|
-
import { IdlNameConvertor, NodeConvertor } from "./nameConvertor";
|
|
3
|
-
import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
|
|
4
|
-
export interface ConvertResult {
|
|
5
|
-
text: string;
|
|
6
|
-
noPrefix: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare class InteropConvertor implements NodeConvertor<ConvertResult> {
|
|
9
|
-
protected resolver: ReferenceResolver;
|
|
10
|
-
constructor(resolver: ReferenceResolver);
|
|
11
|
-
private make;
|
|
12
|
-
convertNode(node: idl.IDLNode): ConvertResult;
|
|
13
|
-
convertNamespace(node: idl.IDLNamespace): ConvertResult;
|
|
14
|
-
convertInterface(node: idl.IDLInterface): ConvertResult;
|
|
15
|
-
convertEnum(node: idl.IDLEnum): ConvertResult;
|
|
16
|
-
convertTypedef(node: idl.IDLTypedef): ConvertResult;
|
|
17
|
-
convertCallback(node: idl.IDLCallback): ConvertResult;
|
|
18
|
-
convertMethod(node: idl.IDLMethod): ConvertResult;
|
|
19
|
-
convertConstant(node: idl.IDLConstant): ConvertResult;
|
|
20
|
-
convertOptional(type: idl.IDLOptionalType): ConvertResult;
|
|
21
|
-
convertUnion(type: idl.IDLUnionType): ConvertResult;
|
|
22
|
-
convertContainer(type: idl.IDLContainerType): ConvertResult;
|
|
23
|
-
convertImport(type: idl.IDLReferenceType, _: string): ConvertResult;
|
|
24
|
-
convertTypeReference(type: idl.IDLReferenceType): ConvertResult;
|
|
25
|
-
convertTypeParameter(type: idl.IDLTypeParameterType): ConvertResult;
|
|
26
|
-
convertPrimitiveType(type: idl.IDLPrimitiveType): ConvertResult;
|
|
27
|
-
private enumName;
|
|
28
|
-
private computeTargetTypeLiteralName;
|
|
29
|
-
}
|
|
30
|
-
export declare class InteropNameConvertor implements IdlNameConvertor {
|
|
31
|
-
protected resolver: ReferenceResolver;
|
|
32
|
-
private readonly interopConvertor;
|
|
33
|
-
constructor(resolver: ReferenceResolver);
|
|
34
|
-
convert(node: idl.IDLNode): string;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=InteropConvertor.d.ts.map
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 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 { convertNode } from "./nameConvertor";
|
|
17
|
-
import { generatorConfiguration } from '../config';
|
|
18
|
-
import { capitalize } from '../util';
|
|
19
|
-
import { qualifiedName } from '../peer-generation/idl/common';
|
|
20
|
-
import { maybeTransformManagedCallback } from './ArgConvertors';
|
|
21
|
-
export class InteropConvertor {
|
|
22
|
-
constructor(resolver) {
|
|
23
|
-
this.resolver = resolver;
|
|
24
|
-
}
|
|
25
|
-
make(text, noPrefix = false) {
|
|
26
|
-
return { text, noPrefix };
|
|
27
|
-
}
|
|
28
|
-
convertNode(node) {
|
|
29
|
-
return convertNode(this, node);
|
|
30
|
-
}
|
|
31
|
-
convertNamespace(node) {
|
|
32
|
-
throw new Error("Internal error: namespaces are not allowed on the interop layer");
|
|
33
|
-
}
|
|
34
|
-
convertInterface(node) {
|
|
35
|
-
switch (node.subkind) {
|
|
36
|
-
case idl.IDLInterfaceSubkind.AnonymousInterface:
|
|
37
|
-
return node.name
|
|
38
|
-
? this.make(node.name)
|
|
39
|
-
: this.make(this.computeTargetTypeLiteralName(node), true);
|
|
40
|
-
case idl.IDLInterfaceSubkind.Interface:
|
|
41
|
-
case idl.IDLInterfaceSubkind.Class:
|
|
42
|
-
if (idl.hasExtAttribute(node, idl.IDLExtendedAttributes.Predefined)) {
|
|
43
|
-
return this.make(node.name, true);
|
|
44
|
-
}
|
|
45
|
-
return this.make(node.name);
|
|
46
|
-
case idl.IDLInterfaceSubkind.Tuple:
|
|
47
|
-
return node.name
|
|
48
|
-
? this.make(node.name)
|
|
49
|
-
: this.make(`Tuple_${node.properties.map(it => this.convertNode(idl.maybeOptional(it.type, it.isOptional)).text).join("_")}`, true);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
convertEnum(node) {
|
|
53
|
-
return this.make(this.enumName(node));
|
|
54
|
-
}
|
|
55
|
-
convertTypedef(node) {
|
|
56
|
-
return this.make(node.name);
|
|
57
|
-
}
|
|
58
|
-
convertCallback(node) {
|
|
59
|
-
return this.make(generatorConfiguration().param("LibraryPrefix") + node.name, true);
|
|
60
|
-
}
|
|
61
|
-
convertMethod(node) {
|
|
62
|
-
return this.make(node.name);
|
|
63
|
-
}
|
|
64
|
-
convertConstant(node) {
|
|
65
|
-
return this.make(node.name);
|
|
66
|
-
}
|
|
67
|
-
/////////////////////////////////////////////////////////////////////////////////////////
|
|
68
|
-
convertOptional(type) {
|
|
69
|
-
return this.convertNode(type.type);
|
|
70
|
-
}
|
|
71
|
-
convertUnion(type) {
|
|
72
|
-
return this.make(type.name, false);
|
|
73
|
-
}
|
|
74
|
-
convertContainer(type) {
|
|
75
|
-
if (idl.IDLContainerUtils.isPromise(type)) {
|
|
76
|
-
return this.make(`Promise_${this.convertNode(type.elementType[0]).text}`);
|
|
77
|
-
}
|
|
78
|
-
if (idl.IDLContainerUtils.isSequence(type)) {
|
|
79
|
-
if (type.elementType[0] === idl.IDLU8Type) {
|
|
80
|
-
return this.make(`uint8_t*`, true);
|
|
81
|
-
}
|
|
82
|
-
return this.make(`Array_${this.convertNode(type.elementType[0]).text}`, true);
|
|
83
|
-
}
|
|
84
|
-
if (idl.IDLContainerUtils.isRecord(type)) {
|
|
85
|
-
return this.make(`Map_${this.convertNode(type.elementType[0]).text}_${this.convertNode(type.elementType[1]).text}`, true);
|
|
86
|
-
}
|
|
87
|
-
throw new Error(`Unmapped container type ${idl.DebugUtils.debugPrintType(type)}`);
|
|
88
|
-
}
|
|
89
|
-
convertImport(type, _) {
|
|
90
|
-
return this.make(idl.IDLCustomObjectType.name);
|
|
91
|
-
}
|
|
92
|
-
convertTypeReference(type) {
|
|
93
|
-
var _a;
|
|
94
|
-
const refName = type.name;
|
|
95
|
-
switch (refName) {
|
|
96
|
-
case "object":
|
|
97
|
-
case "Object":
|
|
98
|
-
return this.make('CustomObject');
|
|
99
|
-
}
|
|
100
|
-
if (generatorConfiguration().paramArray("knownParameterized").includes(refName)) {
|
|
101
|
-
return this.make('CustomObject');
|
|
102
|
-
}
|
|
103
|
-
let decl = this.resolver.toDeclaration(type);
|
|
104
|
-
if (idl.isCallback(decl)) {
|
|
105
|
-
decl = (_a = maybeTransformManagedCallback(decl)) !== null && _a !== void 0 ? _a : decl;
|
|
106
|
-
}
|
|
107
|
-
if (idl.isType(decl)) {
|
|
108
|
-
if (idl.isReferenceType(decl)) {
|
|
109
|
-
return this.make(`${capitalize(decl.name)}`);
|
|
110
|
-
}
|
|
111
|
-
return this.convertNode(decl);
|
|
112
|
-
}
|
|
113
|
-
let res = this.convertNode(decl);
|
|
114
|
-
if (type.name === "Optional")
|
|
115
|
-
res = this.make("Opt_" + res.text, true);
|
|
116
|
-
return res;
|
|
117
|
-
}
|
|
118
|
-
convertTypeParameter(type) {
|
|
119
|
-
return this.make('CustomObject');
|
|
120
|
-
}
|
|
121
|
-
convertPrimitiveType(type) {
|
|
122
|
-
switch (type) {
|
|
123
|
-
case idl.IDLVoidType: return this.make('void', true);
|
|
124
|
-
case idl.IDLI8Type: return this.make(`Int8`);
|
|
125
|
-
case idl.IDLU8Type: return this.make(`UInt8`);
|
|
126
|
-
case idl.IDLI16Type: return this.make(`Int16`);
|
|
127
|
-
case idl.IDLU16Type: return this.make(`UInt16`);
|
|
128
|
-
case idl.IDLI32Type: return this.make(`Int32`);
|
|
129
|
-
case idl.IDLU32Type: return this.make(`UInt32`);
|
|
130
|
-
case idl.IDLI64Type: return this.make(`Int64`);
|
|
131
|
-
case idl.IDLU64Type: return this.make(`UInt64`);
|
|
132
|
-
case idl.IDLF32Type: return this.make(`Float32`);
|
|
133
|
-
case idl.IDLF64Type: return this.make(`Float64`);
|
|
134
|
-
case idl.IDLNumberType: return this.make(`Number`);
|
|
135
|
-
case idl.IDLStringType: return this.make(`String`);
|
|
136
|
-
case idl.IDLBooleanType: return this.make(`Boolean`);
|
|
137
|
-
case idl.IDLPointerType: return this.make('NativePointer');
|
|
138
|
-
case idl.IDLUnknownType:
|
|
139
|
-
case idl.IDLCustomObjectType:
|
|
140
|
-
case idl.IDLAnyType: return this.make(`CustomObject`);
|
|
141
|
-
case idl.IDLUndefinedType: return this.make(`Undefined`);
|
|
142
|
-
case idl.IDLLengthType: return this.make(`Length`);
|
|
143
|
-
case idl.IDLFunctionType: return this.make(`Function`);
|
|
144
|
-
case idl.IDLDate: return this.make(`Date`);
|
|
145
|
-
case idl.IDLBufferType: return this.make('Buffer');
|
|
146
|
-
case idl.IDLPointerType: return this.make('Pointer');
|
|
147
|
-
}
|
|
148
|
-
throw new Error(`Unmapped primitive type ${idl.DebugUtils.debugPrintType(type)}`);
|
|
149
|
-
}
|
|
150
|
-
enumName(target) {
|
|
151
|
-
return qualifiedName(target, "_");
|
|
152
|
-
}
|
|
153
|
-
computeTargetTypeLiteralName(decl) {
|
|
154
|
-
const map = new Map();
|
|
155
|
-
for (const prop of decl.properties) {
|
|
156
|
-
const type = this.convertNode(prop.type);
|
|
157
|
-
const values = map.has(type.text) ? map.get(type.text) : [];
|
|
158
|
-
values.push(prop.name);
|
|
159
|
-
map.set(type.text, values);
|
|
160
|
-
}
|
|
161
|
-
const names = Array.from(map.keys()).map(key => `${key}_${map.get(key).join('_')}`);
|
|
162
|
-
return `Literal_${names.join('_')}`;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
export class InteropNameConvertor {
|
|
166
|
-
constructor(resolver) {
|
|
167
|
-
this.resolver = resolver;
|
|
168
|
-
this.interopConvertor = new InteropConvertor(resolver);
|
|
169
|
-
}
|
|
170
|
-
convert(node) {
|
|
171
|
-
return this.interopConvertor.convertNode(node).text;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=InteropConvertor.js.map
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 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
|
-
function isObject(i) {
|
|
16
|
-
if (typeof i !== 'object')
|
|
17
|
-
return false;
|
|
18
|
-
if (Array.isArray(i))
|
|
19
|
-
return false;
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
export function deepMergeConfig(defaults, custom) {
|
|
23
|
-
if (custom === undefined)
|
|
24
|
-
return defaults;
|
|
25
|
-
const result = Object.assign({}, defaults);
|
|
26
|
-
for (const key in custom) {
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(custom, key)) {
|
|
28
|
-
const defaultValue = result[key];
|
|
29
|
-
const customValue = custom[key];
|
|
30
|
-
if (isObject(defaultValue) && isObject(customValue)) {
|
|
31
|
-
Object.assign(result, { [key]: deepMergeConfig(defaultValue, customValue) });
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
if (isObject(defaultValue))
|
|
35
|
-
throw new Error("Replacing default object value with custom non-object");
|
|
36
|
-
Object.assign(result, { [key]: customValue });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=configMerge.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as idl from '../../idl';
|
|
2
|
-
export interface IdlNameConvertor {
|
|
3
|
-
convert(node: idl.IDLNode): string;
|
|
4
|
-
}
|
|
5
|
-
export interface TypeConvertor<T> {
|
|
6
|
-
convertOptional(type: idl.IDLOptionalType): T;
|
|
7
|
-
convertUnion(type: idl.IDLUnionType): T;
|
|
8
|
-
convertContainer(type: idl.IDLContainerType): T;
|
|
9
|
-
convertImport(type: idl.IDLReferenceType, importClause: string): T;
|
|
10
|
-
convertTypeReference(type: idl.IDLReferenceType): T;
|
|
11
|
-
convertTypeParameter(type: idl.IDLTypeParameterType): T;
|
|
12
|
-
convertPrimitiveType(type: idl.IDLPrimitiveType): T;
|
|
13
|
-
}
|
|
14
|
-
export declare function convertType<T>(convertor: TypeConvertor<T>, type: idl.IDLType): T;
|
|
15
|
-
export interface DeclarationConvertor<T> {
|
|
16
|
-
convertInterface(node: idl.IDLInterface): T;
|
|
17
|
-
convertEnum(node: idl.IDLEnum): T;
|
|
18
|
-
convertTypedef(node: idl.IDLTypedef): T;
|
|
19
|
-
convertCallback(node: idl.IDLCallback): T;
|
|
20
|
-
}
|
|
21
|
-
export declare function convertDeclaration<T>(convertor: DeclarationConvertor<T>, decl: idl.IDLEntry): T;
|
|
22
|
-
export interface NodeConvertor<T> extends TypeConvertor<T>, DeclarationConvertor<T> {
|
|
23
|
-
}
|
|
24
|
-
export declare function convertNode<T>(convertor: NodeConvertor<T>, node: idl.IDLNode): T;
|
|
25
|
-
//# sourceMappingURL=nameConvertor.d.ts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
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 function convertType(convertor, type) {
|
|
17
|
-
if (idl.isOptionalType(type))
|
|
18
|
-
return convertor.convertOptional(type);
|
|
19
|
-
if (idl.isUnionType(type))
|
|
20
|
-
return convertor.convertUnion(type);
|
|
21
|
-
if (idl.isContainerType(type))
|
|
22
|
-
return convertor.convertContainer(type);
|
|
23
|
-
if (idl.isReferenceType(type)) {
|
|
24
|
-
const importAttr = idl.getExtAttribute(type, idl.IDLExtendedAttributes.Import);
|
|
25
|
-
return importAttr
|
|
26
|
-
? convertor.convertImport(type, importAttr)
|
|
27
|
-
: convertor.convertTypeReference(type);
|
|
28
|
-
}
|
|
29
|
-
if (idl.isTypeParameterType(type))
|
|
30
|
-
return convertor.convertTypeParameter(type);
|
|
31
|
-
if (idl.isPrimitiveType(type))
|
|
32
|
-
return convertor.convertPrimitiveType(type);
|
|
33
|
-
throw new Error(`Unknown type ${idl.IDLKind[type.kind]}`);
|
|
34
|
-
}
|
|
35
|
-
export function convertDeclaration(convertor, decl) {
|
|
36
|
-
if (idl.isInterface(decl))
|
|
37
|
-
return convertor.convertInterface(decl);
|
|
38
|
-
if (idl.isEnum(decl))
|
|
39
|
-
return convertor.convertEnum(decl);
|
|
40
|
-
if (idl.isEnumMember(decl))
|
|
41
|
-
return convertor.convertEnum(decl.parent);
|
|
42
|
-
if (idl.isTypedef(decl))
|
|
43
|
-
return convertor.convertTypedef(decl);
|
|
44
|
-
if (idl.isCallback(decl))
|
|
45
|
-
return convertor.convertCallback(decl);
|
|
46
|
-
throw new Error(`Unknown declaration type ${decl.kind ? idl.IDLKind[decl.kind] : "(undefined kind)"}`);
|
|
47
|
-
}
|
|
48
|
-
export function convertNode(convertor, node) {
|
|
49
|
-
if (idl.isEntry(node))
|
|
50
|
-
return convertDeclaration(convertor, node);
|
|
51
|
-
if (idl.isType(node))
|
|
52
|
-
return convertType(convertor, node);
|
|
53
|
-
throw new Error(`Unknown node type ${idl.IDLKind[node.kind]}`);
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=nameConvertor.js.map
|