@idlizer/core 2.0.15 → 2.0.19
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/CJConvertors.d.ts +30 -0
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +154 -0
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +5 -3
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +13 -0
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +118 -0
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +32 -0
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +175 -0
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +27 -0
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +173 -0
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +5 -1
- package/build/lib/src/LibraryInterface.d.ts +2 -0
- package/build/lib/src/config.js +14 -0
- package/build/lib/src/configMerge.d.ts +2 -0
- package/build/lib/src/configMerge.js +42 -0
- package/build/lib/src/from-idl/common.d.ts +1 -1
- package/build/lib/src/from-idl/common.js +20 -11
- package/build/lib/src/idl.d.ts +6 -3
- package/build/lib/src/idl.js +15 -11
- package/build/lib/src/idlize.d.ts +1 -1
- package/build/lib/src/idlize.js +57 -13
- package/build/lib/src/index.d.ts +12 -0
- package/build/lib/src/index.js +12 -0
- package/build/lib/src/languageSpecificKeywords.js +1 -1
- package/build/lib/src/options.d.ts +1 -0
- 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/LanguageWriters/index.d.ts +2 -0
- package/build/lib/src/peer-generation/LanguageWriters/index.js +2 -0
- package/build/lib/src/peer-generation/LanguageWriters/nameConvertor.d.ts +25 -0
- package/build/lib/src/peer-generation/LanguageWriters/nameConvertor.js +55 -0
- package/build/lib/src/peer-generation/LayoutManager.d.ts +15 -0
- package/build/lib/src/peer-generation/LayoutManager.js +32 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +60 -0
- package/build/lib/src/peer-generation/Materialized.js +178 -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/PeerLibrary.d.ts +53 -0
- package/build/lib/src/peer-generation/PeerLibrary.js +340 -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.d.ts +1 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +4 -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
- package/webidl2.js/LICENSE +0 -21
- package/webidl2.js/README.md +0 -827
- package/webidl2.js/dist/package.json +0 -3
|
@@ -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,25 @@
|
|
|
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
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IDLNode } from "../idl";
|
|
2
|
+
export declare enum LayoutNodeRole {
|
|
3
|
+
PEER = 0,
|
|
4
|
+
INTERFACE = 1
|
|
5
|
+
}
|
|
6
|
+
export interface LayoutManagerStrategy {
|
|
7
|
+
resolve(node: IDLNode, role: LayoutNodeRole): string;
|
|
8
|
+
}
|
|
9
|
+
export declare class LayoutManager {
|
|
10
|
+
private strategy;
|
|
11
|
+
constructor(strategy: LayoutManagerStrategy);
|
|
12
|
+
resolve(node: IDLNode, role: LayoutNodeRole): string;
|
|
13
|
+
static Empty(): LayoutManager;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=LayoutManager.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
export var LayoutNodeRole;
|
|
16
|
+
(function (LayoutNodeRole) {
|
|
17
|
+
LayoutNodeRole[LayoutNodeRole["PEER"] = 0] = "PEER";
|
|
18
|
+
LayoutNodeRole[LayoutNodeRole["INTERFACE"] = 1] = "INTERFACE";
|
|
19
|
+
})(LayoutNodeRole || (LayoutNodeRole = {}));
|
|
20
|
+
export class LayoutManager {
|
|
21
|
+
constructor(strategy) {
|
|
22
|
+
this.strategy = strategy;
|
|
23
|
+
}
|
|
24
|
+
resolve(node, role) {
|
|
25
|
+
return this.strategy.resolve(node, role);
|
|
26
|
+
}
|
|
27
|
+
////////////////////////////////////////////////////////////////////
|
|
28
|
+
static Empty() {
|
|
29
|
+
return new LayoutManager({ resolve: () => '' });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=LayoutManager.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import { ReferenceResolver } from './ReferenceResolver';
|
|
7
|
+
export declare function isMaterialized(declaration: idl.IDLInterface, resolver: ReferenceResolver): boolean;
|
|
8
|
+
export declare class MaterializedField {
|
|
9
|
+
field: Field;
|
|
10
|
+
argConvertor: ArgConvertor;
|
|
11
|
+
outArgConvertor?: ArgConvertor | undefined;
|
|
12
|
+
isNullableOriginalTypeField?: boolean | undefined;
|
|
13
|
+
constructor(field: Field, argConvertor: ArgConvertor, outArgConvertor?: ArgConvertor | undefined, isNullableOriginalTypeField?: boolean | undefined);
|
|
14
|
+
}
|
|
15
|
+
export declare class MaterializedMethod extends PeerMethod {
|
|
16
|
+
implementationParentName: string;
|
|
17
|
+
outArgConvertor?: ArgConvertor | undefined;
|
|
18
|
+
constructor(originalParentName: string, implementationParentName: string, argConvertors: ArgConvertor[], returnType: idl.IDLType, isCallSignature: boolean, method: Method, outArgConvertor?: ArgConvertor | undefined);
|
|
19
|
+
get peerMethodName(): string;
|
|
20
|
+
get implNamespaceName(): string;
|
|
21
|
+
get toStringName(): string;
|
|
22
|
+
get dummyReturnValue(): string | undefined;
|
|
23
|
+
get receiverType(): string;
|
|
24
|
+
get apiCall(): string;
|
|
25
|
+
get apiKind(): string;
|
|
26
|
+
generateReceiver(): {
|
|
27
|
+
argName: string;
|
|
28
|
+
argType: string;
|
|
29
|
+
} | undefined;
|
|
30
|
+
getImplementationName(): string;
|
|
31
|
+
tsReturnType(): idl.IDLType | undefined;
|
|
32
|
+
getPrivateMethod(): MaterializedMethod;
|
|
33
|
+
}
|
|
34
|
+
export declare function copyMaterializedMethod(method: MaterializedMethod, overrides: {
|
|
35
|
+
method?: Method;
|
|
36
|
+
}): MaterializedMethod;
|
|
37
|
+
export declare class MaterializedClass implements PeerClassBase {
|
|
38
|
+
readonly decl: idl.IDLInterface;
|
|
39
|
+
readonly className: string;
|
|
40
|
+
readonly isInterface: boolean;
|
|
41
|
+
readonly superClass: idl.IDLReferenceType | undefined;
|
|
42
|
+
readonly interfaces: idl.IDLReferenceType[] | undefined;
|
|
43
|
+
readonly generics: string[] | undefined;
|
|
44
|
+
readonly fields: MaterializedField[];
|
|
45
|
+
readonly ctor: MaterializedMethod;
|
|
46
|
+
readonly finalizer: MaterializedMethod;
|
|
47
|
+
readonly methods: MaterializedMethod[];
|
|
48
|
+
readonly needBeGenerated: boolean;
|
|
49
|
+
readonly taggedMethods: idl.IDLMethod[];
|
|
50
|
+
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[]);
|
|
51
|
+
getComponentName(): string;
|
|
52
|
+
getImplementationName(): string;
|
|
53
|
+
generatedName(isCallSignature: boolean): string;
|
|
54
|
+
isGlobalScope(): boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function createDestroyPeerMethod(clazz: MaterializedClass): MaterializedMethod;
|
|
57
|
+
export declare function getInternalClassName(name: string): string;
|
|
58
|
+
export declare function getInternalClassQualifiedName(target: idl.IDLEntry): string;
|
|
59
|
+
export declare function getMaterializedFileName(name: string): string;
|
|
60
|
+
//# sourceMappingURL=Materialized.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
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 * as idl from '../idl';
|
|
17
|
+
import { copyMethod, Method, MethodModifier, NamedMethodSignature } from '../LanguageWriters/LanguageWriter';
|
|
18
|
+
import { capitalize } from '../util';
|
|
19
|
+
import { isBuilderClass } from './BuilderClass';
|
|
20
|
+
import { qualifiedName } from './idl/common';
|
|
21
|
+
import { PeerMethod } from './PeerMethod';
|
|
22
|
+
export function isMaterialized(declaration, resolver) {
|
|
23
|
+
if (idl.isHandwritten(declaration) ||
|
|
24
|
+
isBuilderClass(declaration) ||
|
|
25
|
+
declaration.subkind === idl.IDLInterfaceSubkind.AnonymousInterface ||
|
|
26
|
+
declaration.subkind === idl.IDLInterfaceSubkind.Tuple) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
for (const ignore of generatorConfiguration().paramArray("ignoreMaterialized")) {
|
|
30
|
+
if (declaration.name.endsWith(ignore))
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
// A materialized class is a class or an interface with methods
|
|
34
|
+
// excluding components and related classes
|
|
35
|
+
if (declaration.methods.length > 0)
|
|
36
|
+
return true;
|
|
37
|
+
// Or a class or an interface derived from materialized class
|
|
38
|
+
if (idl.hasSuperType(declaration)) {
|
|
39
|
+
const superType = resolver.resolveTypeReference(idl.getSuperType(declaration));
|
|
40
|
+
if (!superType || !idl.isInterface(superType)) {
|
|
41
|
+
console.log(`Unable to resolve ${idl.getSuperType(declaration).name} type, consider ${declaration.name} to be not materialized`);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return isMaterialized(superType, resolver);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
export class MaterializedField {
|
|
49
|
+
constructor(field, argConvertor, outArgConvertor, isNullableOriginalTypeField) {
|
|
50
|
+
this.field = field;
|
|
51
|
+
this.argConvertor = argConvertor;
|
|
52
|
+
this.outArgConvertor = outArgConvertor;
|
|
53
|
+
this.isNullableOriginalTypeField = isNullableOriginalTypeField;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class MaterializedMethod extends PeerMethod {
|
|
57
|
+
constructor(originalParentName, implementationParentName, argConvertors, returnType, isCallSignature, method, outArgConvertor) {
|
|
58
|
+
super(originalParentName, argConvertors, returnType, isCallSignature, method, outArgConvertor);
|
|
59
|
+
this.implementationParentName = implementationParentName;
|
|
60
|
+
this.outArgConvertor = outArgConvertor;
|
|
61
|
+
}
|
|
62
|
+
get peerMethodName() {
|
|
63
|
+
return this.overloadedName;
|
|
64
|
+
}
|
|
65
|
+
get implNamespaceName() {
|
|
66
|
+
return `${capitalize(this.originalParentName)}Accessor`;
|
|
67
|
+
}
|
|
68
|
+
get toStringName() {
|
|
69
|
+
switch (this.method.name) {
|
|
70
|
+
case "ctor": return `new ${this.originalParentName}`;
|
|
71
|
+
case "destructor": return `delete ${this.originalParentName}`;
|
|
72
|
+
default: return super.toStringName;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
get dummyReturnValue() {
|
|
76
|
+
var _a;
|
|
77
|
+
if (this.method.name === "ctor")
|
|
78
|
+
return `(${this.originalParentName}Peer*) 100`;
|
|
79
|
+
if (this.method.name === "getFinalizer")
|
|
80
|
+
return `fnPtr<KNativePointer>(dummyClassFinalizer)`;
|
|
81
|
+
if ((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC)) {
|
|
82
|
+
if (this.method.signature.returnType === idl.IDLNumberType) {
|
|
83
|
+
return '100';
|
|
84
|
+
}
|
|
85
|
+
if (this.method.signature.returnType === idl.IDLBooleanType) {
|
|
86
|
+
return '0';
|
|
87
|
+
}
|
|
88
|
+
return `(void*) 300`;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
get receiverType() {
|
|
93
|
+
return `${this.originalParentName}Peer*`;
|
|
94
|
+
}
|
|
95
|
+
get apiCall() {
|
|
96
|
+
return "GetAccessors()";
|
|
97
|
+
}
|
|
98
|
+
get apiKind() {
|
|
99
|
+
return "Accessor";
|
|
100
|
+
}
|
|
101
|
+
generateReceiver() {
|
|
102
|
+
if (!this.hasReceiver())
|
|
103
|
+
return undefined;
|
|
104
|
+
return {
|
|
105
|
+
argName: 'peer',
|
|
106
|
+
argType: `${this.originalParentName}Peer*`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
getImplementationName() {
|
|
110
|
+
return this.implementationParentName;
|
|
111
|
+
}
|
|
112
|
+
tsReturnType() {
|
|
113
|
+
return this.method.signature.returnType;
|
|
114
|
+
}
|
|
115
|
+
getPrivateMethod() {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
let privateMethod = this;
|
|
118
|
+
if (!((_a = privateMethod.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.PRIVATE))) {
|
|
119
|
+
privateMethod = copyMaterializedMethod(this, {
|
|
120
|
+
method: copyMethod(this.method, {
|
|
121
|
+
modifiers: ((_b = this.method.modifiers) !== null && _b !== void 0 ? _b : [])
|
|
122
|
+
.filter(it => it !== MethodModifier.PUBLIC)
|
|
123
|
+
.concat([MethodModifier.PRIVATE])
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return privateMethod;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function copyMaterializedMethod(method, overrides) {
|
|
131
|
+
var _a;
|
|
132
|
+
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);
|
|
133
|
+
copied.setSameOverloadIndex(method);
|
|
134
|
+
return copied;
|
|
135
|
+
}
|
|
136
|
+
export class MaterializedClass {
|
|
137
|
+
constructor(decl, className, isInterface, superClass, interfaces, generics, fields, ctor, finalizer, methods, needBeGenerated = true, taggedMethods = []) {
|
|
138
|
+
this.decl = decl;
|
|
139
|
+
this.className = className;
|
|
140
|
+
this.isInterface = isInterface;
|
|
141
|
+
this.superClass = superClass;
|
|
142
|
+
this.interfaces = interfaces;
|
|
143
|
+
this.generics = generics;
|
|
144
|
+
this.fields = fields;
|
|
145
|
+
this.ctor = ctor;
|
|
146
|
+
this.finalizer = finalizer;
|
|
147
|
+
this.methods = methods;
|
|
148
|
+
this.needBeGenerated = needBeGenerated;
|
|
149
|
+
this.taggedMethods = taggedMethods;
|
|
150
|
+
PeerMethod.markAndGroupOverloads(methods);
|
|
151
|
+
}
|
|
152
|
+
getComponentName() {
|
|
153
|
+
return this.className;
|
|
154
|
+
}
|
|
155
|
+
getImplementationName() {
|
|
156
|
+
return this.isInterface ? getInternalClassName(this.className) : this.className;
|
|
157
|
+
}
|
|
158
|
+
generatedName(isCallSignature) {
|
|
159
|
+
return this.className;
|
|
160
|
+
}
|
|
161
|
+
isGlobalScope() {
|
|
162
|
+
return idl.hasExtAttribute(this.decl, idl.IDLExtendedAttributes.GlobalScope);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export function createDestroyPeerMethod(clazz) {
|
|
166
|
+
return new MaterializedMethod(clazz.className, clazz.getImplementationName(), [], idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.className)], ['peer'])));
|
|
167
|
+
}
|
|
168
|
+
export function getInternalClassName(name) {
|
|
169
|
+
return `${name}Internal`;
|
|
170
|
+
}
|
|
171
|
+
export function getInternalClassQualifiedName(target) {
|
|
172
|
+
return getInternalClassName(qualifiedName(target, "."));
|
|
173
|
+
}
|
|
174
|
+
export function getMaterializedFileName(name) {
|
|
175
|
+
const pascalCase = name.split('_').map(x => capitalize(x)).join('');
|
|
176
|
+
return `Ark${pascalCase}Materialized`;
|
|
177
|
+
}
|
|
178
|
+
//# 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,53 @@
|
|
|
1
|
+
import * as idl from '../idl';
|
|
2
|
+
import { Language } from '../Language';
|
|
3
|
+
import { IdlNameConvertor } from '../LanguageWriters';
|
|
4
|
+
import { ArgConvertor } from "../LanguageWriters/ArgConvertors";
|
|
5
|
+
import { LibraryInterface } from '../LibraryInterface';
|
|
6
|
+
import { BuilderClass } from './BuilderClass';
|
|
7
|
+
import { MaterializedClass } from './Materialized';
|
|
8
|
+
import { PeerFile } from './PeerFile';
|
|
9
|
+
import { LayoutManager, LayoutManagerStrategy } from './LayoutManager';
|
|
10
|
+
export declare class PeerLibrary implements LibraryInterface {
|
|
11
|
+
language: Language;
|
|
12
|
+
layout: LayoutManager;
|
|
13
|
+
private _syntheticEntries;
|
|
14
|
+
/** @deprecated PeerLibrary should contain only SDK entries */
|
|
15
|
+
get syntheticEntries(): idl.IDLEntry[];
|
|
16
|
+
initSyntheticEntries(entries: idl.IDLEntry[]): void;
|
|
17
|
+
readonly files: PeerFile[];
|
|
18
|
+
readonly builderClasses: Map<string, BuilderClass>;
|
|
19
|
+
get buildersToGenerate(): BuilderClass[];
|
|
20
|
+
readonly materializedClasses: Map<string, MaterializedClass>;
|
|
21
|
+
get materializedToGenerate(): MaterializedClass[];
|
|
22
|
+
readonly predefinedDeclarations: idl.IDLInterface[];
|
|
23
|
+
readonly globalScopeInterfaces: idl.IDLInterface[];
|
|
24
|
+
constructor(language: Language);
|
|
25
|
+
name: string;
|
|
26
|
+
readonly customComponentMethods: string[];
|
|
27
|
+
createTypeNameConvertor(language: Language): IdlNameConvertor;
|
|
28
|
+
protected readonly targetNameConvertorInstance: IdlNameConvertor;
|
|
29
|
+
private readonly interopNameConvertorInstance;
|
|
30
|
+
get libraryPrefix(): string;
|
|
31
|
+
createContinuationParameters(continuationType: idl.IDLType): idl.IDLParameter[];
|
|
32
|
+
createContinuationCallbackReference(continuationType: idl.IDLType): idl.IDLReferenceType;
|
|
33
|
+
private context;
|
|
34
|
+
getCurrentContext(): string | undefined;
|
|
35
|
+
setCurrentContext(context: string | undefined): void;
|
|
36
|
+
findFileByOriginalFilename(filename: string): PeerFile | undefined;
|
|
37
|
+
mapType(type: idl.IDLType): string;
|
|
38
|
+
resolveTypeReference(type: idl.IDLReferenceType, pointOfView?: idl.IDLEntry, rootEntries?: idl.IDLEntry[]): idl.IDLEntry | undefined;
|
|
39
|
+
typeConvertor(param: string, type: idl.IDLType, isOptionalParam?: boolean): ArgConvertor;
|
|
40
|
+
declarationConvertor(param: string, type: idl.IDLReferenceType, declaration: idl.IDLEntry | undefined): ArgConvertor;
|
|
41
|
+
private customConvertor;
|
|
42
|
+
getInteropName(node: idl.IDLNode): string;
|
|
43
|
+
toDeclaration(type: idl.IDLType | idl.IDLTypedef | idl.IDLCallback | idl.IDLEnum | idl.IDLInterface): idl.IDLEntry | idl.IDLType;
|
|
44
|
+
setFileLayout(strategy: LayoutManagerStrategy): void;
|
|
45
|
+
}
|
|
46
|
+
export declare const ArkInt32: idl.IDLPrimitiveType;
|
|
47
|
+
export declare const ArkInt64: idl.IDLPrimitiveType;
|
|
48
|
+
export declare const ArkFunction: idl.IDLPrimitiveType;
|
|
49
|
+
export declare const ArkLength: idl.IDLPrimitiveType;
|
|
50
|
+
export declare const ArkDate: idl.IDLPrimitiveType;
|
|
51
|
+
export declare const ArkCustomObject: idl.IDLPrimitiveType;
|
|
52
|
+
export declare function cleanPrefix(name: string, prefix: string): string;
|
|
53
|
+
//# sourceMappingURL=PeerLibrary.d.ts.map
|