@idlizer/core 2.0.41 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +4 -1
- package/build/lib/src/LanguageWriters/ArgConvertors.js +61 -13
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +7 -5
- package/build/lib/src/LanguageWriters/LanguageWriter.js +8 -3
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +2 -1
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +27 -12
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +3 -1
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +3 -1
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +4 -4
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +11 -1
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +44 -1
- package/build/lib/src/LanguageWriters/index.d.ts +2 -2
- package/build/lib/src/LanguageWriters/index.js +4 -5
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +4 -4
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +6 -5
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +4 -3
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +5 -8
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +6 -5
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +26 -30
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +3 -3
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +4 -4
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +3 -3
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +21 -12
- package/build/lib/src/config.d.ts +958 -12
- package/build/lib/src/config.js +24 -2
- package/build/lib/src/configDescriber.d.ts +85 -0
- package/build/lib/src/configDescriber.js +297 -0
- package/build/lib/src/from-idl/DtsPrinter.js +4 -2
- package/build/lib/src/from-idl/IDLLinter.d.ts +24 -0
- package/build/lib/src/from-idl/IDLLinter.js +81 -0
- package/build/lib/src/from-idl/deserialize.js +41 -4
- package/build/lib/src/from-idl/webidl2-utils.d.ts +1 -0
- package/build/lib/src/from-idl/webidl2-utils.js +3 -0
- package/build/lib/src/idl.d.ts +23 -26
- package/build/lib/src/idl.js +31 -29
- package/build/lib/src/idlize.d.ts +10 -1
- package/build/lib/src/idlize.js +54 -26
- package/build/lib/src/index.d.ts +2 -0
- package/build/lib/src/index.js +2 -0
- package/build/lib/src/options.d.ts +1 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +2 -1
- package/build/lib/src/peer-generation/Materialized.js +3 -2
- package/build/lib/src/peer-generation/PeerFile.d.ts +1 -2
- package/build/lib/src/peer-generation/PeerFile.js +1 -2
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +0 -1
- package/build/lib/src/peer-generation/PeerLibrary.js +16 -3
- package/build/lib/src/peer-generation/PeerMethod.js +2 -16
- package/build/lib/src/peer-generation/idl/common.js +2 -2
- package/build/lib/src/peer-generation/isMaterialized.d.ts +1 -0
- package/build/lib/src/peer-generation/isMaterialized.js +21 -0
- package/build/lib/src/util.d.ts +1 -0
- package/build/lib/src/util.js +9 -0
- package/package.json +2 -2
package/build/lib/src/idl.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { stringOrNone } from "./util";
|
|
2
2
|
export declare enum IDLKind {
|
|
3
|
-
Interface =
|
|
4
|
-
Import =
|
|
5
|
-
Callback =
|
|
6
|
-
Const =
|
|
7
|
-
Property =
|
|
8
|
-
Parameter =
|
|
9
|
-
Method =
|
|
10
|
-
Callable =
|
|
11
|
-
Constructor =
|
|
12
|
-
Enum =
|
|
13
|
-
EnumMember =
|
|
14
|
-
Typedef =
|
|
15
|
-
PrimitiveType =
|
|
16
|
-
ContainerType =
|
|
17
|
-
UnspecifiedGenericType =
|
|
18
|
-
ReferenceType =
|
|
19
|
-
UnionType =
|
|
20
|
-
TypeParameterType =
|
|
21
|
-
OptionalType =
|
|
22
|
-
Version =
|
|
23
|
-
Namespace =
|
|
24
|
-
File =
|
|
3
|
+
Interface = "Interface",
|
|
4
|
+
Import = "Import",
|
|
5
|
+
Callback = "Callback",
|
|
6
|
+
Const = "Const",
|
|
7
|
+
Property = "Property",
|
|
8
|
+
Parameter = "Parameter",
|
|
9
|
+
Method = "Method",
|
|
10
|
+
Callable = "Callable",
|
|
11
|
+
Constructor = "Constructor",
|
|
12
|
+
Enum = "Enum",
|
|
13
|
+
EnumMember = "EnumMember",
|
|
14
|
+
Typedef = "Typedef",
|
|
15
|
+
PrimitiveType = "PrimitiveType",
|
|
16
|
+
ContainerType = "ContainerType",
|
|
17
|
+
UnspecifiedGenericType = "UnspecifiedGenericType",
|
|
18
|
+
ReferenceType = "ReferenceType",
|
|
19
|
+
UnionType = "UnionType",
|
|
20
|
+
TypeParameterType = "TypeParameterType",
|
|
21
|
+
OptionalType = "OptionalType",
|
|
22
|
+
Version = "Version",
|
|
23
|
+
Namespace = "Namespace",
|
|
24
|
+
File = "File"
|
|
25
25
|
}
|
|
26
26
|
export declare enum IDLEntity {
|
|
27
27
|
Class = "Class",
|
|
@@ -35,13 +35,10 @@ export declare enum IDLEntity {
|
|
|
35
35
|
export declare enum IDLExtendedAttributes {
|
|
36
36
|
Accessor = "Accessor",
|
|
37
37
|
Async = "Async",
|
|
38
|
-
ArkTSType = "ArkTSType",
|
|
39
38
|
CallSignature = "CallSignature",
|
|
40
|
-
CJType = "CJType",
|
|
41
39
|
CommonMethod = "CommonMethod",
|
|
42
40
|
Component = "Component",
|
|
43
41
|
ComponentInterface = "ComponentInterface",
|
|
44
|
-
CPPType = "CPPType",
|
|
45
42
|
Deprecated = "Deprecated",
|
|
46
43
|
Documentation = "Documentation",
|
|
47
44
|
DtsName = "DtsName",
|
|
@@ -57,7 +54,6 @@ export declare enum IDLExtendedAttributes {
|
|
|
57
54
|
Protected = "Protected",
|
|
58
55
|
Synthetic = "Synthetic",
|
|
59
56
|
Throws = "Throws",
|
|
60
|
-
TSType = "TSType",
|
|
61
57
|
TypeArguments = "TypeArguments",
|
|
62
58
|
TypeParameters = "TypeParameters",
|
|
63
59
|
VerbatimDts = "VerbatimDts",
|
|
@@ -300,6 +296,7 @@ export declare function getFileFor(entry: IDLNode): IDLFile | undefined;
|
|
|
300
296
|
export declare function isEqualByQualifedName(a?: IDLEntry, b?: IDLEntry): boolean;
|
|
301
297
|
export declare function getPackageClause(entry: IDLFile | IDLEntry): string[];
|
|
302
298
|
export declare function getPackageName(entry: IDLFile | IDLEntry): string;
|
|
299
|
+
export declare function isInPackage(entry: IDLEntry | IDLFile, packageName: string, exactMatch?: boolean): boolean;
|
|
303
300
|
export declare function getNamespaceName(a: IDLEntry): string;
|
|
304
301
|
export declare function getFQName(a: IDLEntry): string;
|
|
305
302
|
export declare function createVersion(value: string[], extendedAttributes?: IDLExtendedAttribute[], fileName?: string): IDLVersion;
|
package/build/lib/src/idl.js
CHANGED
|
@@ -18,28 +18,28 @@ import { generateSyntheticIdlNodeName } from "./peer-generation/idl/common";
|
|
|
18
18
|
import { IDLKeywords } from "./languageSpecificKeywords";
|
|
19
19
|
export var IDLKind;
|
|
20
20
|
(function (IDLKind) {
|
|
21
|
-
IDLKind[
|
|
22
|
-
IDLKind[
|
|
23
|
-
IDLKind[
|
|
24
|
-
IDLKind[
|
|
25
|
-
IDLKind[
|
|
26
|
-
IDLKind[
|
|
27
|
-
IDLKind[
|
|
28
|
-
IDLKind[
|
|
29
|
-
IDLKind[
|
|
30
|
-
IDLKind[
|
|
31
|
-
IDLKind[
|
|
32
|
-
IDLKind[
|
|
33
|
-
IDLKind[
|
|
34
|
-
IDLKind[
|
|
35
|
-
IDLKind[
|
|
36
|
-
IDLKind[
|
|
37
|
-
IDLKind[
|
|
38
|
-
IDLKind[
|
|
39
|
-
IDLKind[
|
|
40
|
-
IDLKind[
|
|
41
|
-
IDLKind[
|
|
42
|
-
IDLKind[
|
|
21
|
+
IDLKind["Interface"] = "Interface";
|
|
22
|
+
IDLKind["Import"] = "Import";
|
|
23
|
+
IDLKind["Callback"] = "Callback";
|
|
24
|
+
IDLKind["Const"] = "Const";
|
|
25
|
+
IDLKind["Property"] = "Property";
|
|
26
|
+
IDLKind["Parameter"] = "Parameter";
|
|
27
|
+
IDLKind["Method"] = "Method";
|
|
28
|
+
IDLKind["Callable"] = "Callable";
|
|
29
|
+
IDLKind["Constructor"] = "Constructor";
|
|
30
|
+
IDLKind["Enum"] = "Enum";
|
|
31
|
+
IDLKind["EnumMember"] = "EnumMember";
|
|
32
|
+
IDLKind["Typedef"] = "Typedef";
|
|
33
|
+
IDLKind["PrimitiveType"] = "PrimitiveType";
|
|
34
|
+
IDLKind["ContainerType"] = "ContainerType";
|
|
35
|
+
IDLKind["UnspecifiedGenericType"] = "UnspecifiedGenericType";
|
|
36
|
+
IDLKind["ReferenceType"] = "ReferenceType";
|
|
37
|
+
IDLKind["UnionType"] = "UnionType";
|
|
38
|
+
IDLKind["TypeParameterType"] = "TypeParameterType";
|
|
39
|
+
IDLKind["OptionalType"] = "OptionalType";
|
|
40
|
+
IDLKind["Version"] = "Version";
|
|
41
|
+
IDLKind["Namespace"] = "Namespace";
|
|
42
|
+
IDLKind["File"] = "File";
|
|
43
43
|
})(IDLKind || (IDLKind = {}));
|
|
44
44
|
export var IDLEntity;
|
|
45
45
|
(function (IDLEntity) {
|
|
@@ -55,13 +55,10 @@ export var IDLExtendedAttributes;
|
|
|
55
55
|
(function (IDLExtendedAttributes) {
|
|
56
56
|
IDLExtendedAttributes["Accessor"] = "Accessor";
|
|
57
57
|
IDLExtendedAttributes["Async"] = "Async";
|
|
58
|
-
IDLExtendedAttributes["ArkTSType"] = "ArkTSType";
|
|
59
58
|
IDLExtendedAttributes["CallSignature"] = "CallSignature";
|
|
60
|
-
IDLExtendedAttributes["CJType"] = "CJType";
|
|
61
59
|
IDLExtendedAttributes["CommonMethod"] = "CommonMethod";
|
|
62
60
|
IDLExtendedAttributes["Component"] = "Component";
|
|
63
61
|
IDLExtendedAttributes["ComponentInterface"] = "ComponentInterface";
|
|
64
|
-
IDLExtendedAttributes["CPPType"] = "CPPType";
|
|
65
62
|
IDLExtendedAttributes["Deprecated"] = "Deprecated";
|
|
66
63
|
IDLExtendedAttributes["Documentation"] = "Documentation";
|
|
67
64
|
IDLExtendedAttributes["DtsName"] = "DtsName";
|
|
@@ -77,7 +74,6 @@ export var IDLExtendedAttributes;
|
|
|
77
74
|
IDLExtendedAttributes["Protected"] = "Protected";
|
|
78
75
|
IDLExtendedAttributes["Synthetic"] = "Synthetic";
|
|
79
76
|
IDLExtendedAttributes["Throws"] = "Throws";
|
|
80
|
-
IDLExtendedAttributes["TSType"] = "TSType";
|
|
81
77
|
IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
|
|
82
78
|
IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
|
|
83
79
|
IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
|
|
@@ -398,6 +394,12 @@ export function getPackageClause(entry) {
|
|
|
398
394
|
export function getPackageName(entry) {
|
|
399
395
|
return getPackageClause(entry).join(".");
|
|
400
396
|
}
|
|
397
|
+
export function isInPackage(entry, packageName, exactMatch = false) {
|
|
398
|
+
const entryPackageName = getPackageName(entry);
|
|
399
|
+
return exactMatch
|
|
400
|
+
? entryPackageName === packageName
|
|
401
|
+
: entryPackageName.startsWith(packageName);
|
|
402
|
+
}
|
|
401
403
|
export function getNamespaceName(a) {
|
|
402
404
|
return getNamespacesPathFor(a).map(it => it.name).join('.');
|
|
403
405
|
}
|
|
@@ -945,12 +947,12 @@ export function forEachFunction(node, cb) {
|
|
|
945
947
|
}
|
|
946
948
|
export function asPromise(type) {
|
|
947
949
|
if (!type)
|
|
948
|
-
return;
|
|
950
|
+
return undefined;
|
|
949
951
|
if (!isContainerType(type))
|
|
950
|
-
return;
|
|
952
|
+
return undefined;
|
|
951
953
|
const container = type;
|
|
952
954
|
if (!IDLContainerUtils.isPromise(container))
|
|
953
|
-
return;
|
|
955
|
+
return undefined;
|
|
954
956
|
return container;
|
|
955
957
|
}
|
|
956
958
|
export function transformMethodsAsync2ReturnPromise(entry) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
+
import * as idl from "./idl";
|
|
2
3
|
import { GenerateOptions } from "./options";
|
|
4
|
+
export declare function scanDirectory(dir: string, fileFilter: (file: string) => boolean, recursive?: boolean): string[];
|
|
5
|
+
export declare function scanInputDirs(inputDirs: string[]): string[];
|
|
6
|
+
export declare function scanInputDirs(inputDirs: string[], fileExtension: string): string[];
|
|
7
|
+
export declare function scanInputDirs(inputDirs: string[], fileFilter: (file: string) => boolean, recursive: boolean): string[];
|
|
3
8
|
export interface GenerateVisitor<T> {
|
|
4
9
|
visitPhase1(): T;
|
|
5
10
|
visitPhase2?(siblings: {
|
|
@@ -10,5 +15,9 @@ export interface GenerateVisitor<T> {
|
|
|
10
15
|
};
|
|
11
16
|
}): T;
|
|
12
17
|
}
|
|
13
|
-
export declare function generate<T>(
|
|
18
|
+
export declare function generate<T>(inputFiles: string[], outputDir: string, visitorFactory: (sourceFile: ts.SourceFile, program: ts.Program, compilerHost: ts.CompilerHost) => GenerateVisitor<T>, options: GenerateOptions<T>): void;
|
|
19
|
+
export declare function isInIdlize(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
20
|
+
export declare function isInIdlizeInterop(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
21
|
+
export declare function isInIdlizeInternal(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
22
|
+
export declare function isInIdlizeStdlib(entry: idl.IDLEntry | idl.IDLFile): boolean;
|
|
14
23
|
//# sourceMappingURL=idlize.d.ts.map
|
package/build/lib/src/idlize.js
CHANGED
|
@@ -15,38 +15,55 @@
|
|
|
15
15
|
import * as ts from "typescript";
|
|
16
16
|
import * as fs from "fs";
|
|
17
17
|
import * as path from "path";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import * as idl from "./idl";
|
|
19
|
+
export function scanDirectory(dir, fileFilter, recursive = false) {
|
|
20
|
+
const dirsToVisit = [path.resolve(dir)];
|
|
21
|
+
const result = [];
|
|
22
|
+
while (dirsToVisit.length > 0) {
|
|
23
|
+
let dir = dirsToVisit.pop();
|
|
24
|
+
let dirents = fs.readdirSync(dir, { withFileTypes: true });
|
|
25
|
+
for (const entry of dirents) {
|
|
26
|
+
const fullPath = path.join(dir, entry.name);
|
|
27
|
+
if (entry.isFile()) {
|
|
28
|
+
if (fileFilter(fullPath)) {
|
|
29
|
+
result.push(fullPath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (recursive && entry.isDirectory()) {
|
|
33
|
+
dirsToVisit.push(fullPath);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
export function scanInputDirs(inputDirs, fileFilter = undefined, recursive = false) {
|
|
40
|
+
if (typeof fileFilter === 'undefined')
|
|
41
|
+
return scanInputDirs(inputDirs, (_) => true, recursive);
|
|
42
|
+
if (typeof fileFilter === 'string')
|
|
43
|
+
return scanInputDirs(inputDirs, (file) => file.endsWith(fileFilter), recursive);
|
|
44
|
+
const resolvedInputDirs = inputDirs.map(dir => path.resolve(dir));
|
|
45
|
+
console.log("Resolved input directories:", resolvedInputDirs);
|
|
46
|
+
return resolvedInputDirs.flatMap(dir => {
|
|
47
|
+
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
|
|
48
|
+
console.log(`Processing all .d.ts from directory: ${dir}`);
|
|
49
|
+
return scanDirectory(dir, fileFilter, recursive);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.warn(`Warning: Directory does not exist or is not a directory: ${dir}`);
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
21
56
|
}
|
|
22
|
-
export function generate(
|
|
57
|
+
export function generate(inputFiles, outputDir, visitorFactory, options) {
|
|
23
58
|
var _a, _b, _c;
|
|
24
59
|
if (options.enableLog) {
|
|
25
60
|
console.log("Starting generation process...");
|
|
26
61
|
}
|
|
27
|
-
if (
|
|
28
|
-
console.error("Error: No input specified
|
|
62
|
+
if (inputFiles.length === 0) {
|
|
63
|
+
console.error("Error: No input files specified.");
|
|
29
64
|
process.exit(1);
|
|
30
65
|
}
|
|
31
|
-
const resolvedInputDirs = inputDirs.map(dir => path.resolve(dir));
|
|
32
|
-
if (options.enableLog) {
|
|
33
|
-
console.log("Resolved input directories:", resolvedInputDirs);
|
|
34
|
-
}
|
|
35
66
|
let input = [];
|
|
36
|
-
if (resolvedInputDirs.length > 0) {
|
|
37
|
-
resolvedInputDirs.forEach(dir => {
|
|
38
|
-
if (fs.existsSync(dir) && fs.statSync(dir).isDirectory()) {
|
|
39
|
-
if (options.enableLog) {
|
|
40
|
-
console.log(`Processing all .d.ts from directory: ${dir}`);
|
|
41
|
-
}
|
|
42
|
-
const files = readdir(dir).filter(file => file.endsWith(".d.ts"));
|
|
43
|
-
input = input.concat(files);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.warn(`Warning: Directory does not exist or is not a directory: ${dir}`);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
67
|
if (inputFiles.length > 0) {
|
|
51
68
|
inputFiles.forEach(file => {
|
|
52
69
|
const fullPath = path.resolve(file);
|
|
@@ -74,9 +91,8 @@ export function generate(inputDirs, inputFiles, outputDir, visitorFactory, optio
|
|
|
74
91
|
const dtsFileName2Visitor = {};
|
|
75
92
|
for (const sourceFile of program.getSourceFiles()) {
|
|
76
93
|
const resolvedSourceFileName = path.resolve(sourceFile.fileName);
|
|
77
|
-
const isInDir = resolvedInputDirs.some(dir => resolvedSourceFileName.startsWith(dir));
|
|
78
94
|
const isExplicitFile = input.some(f => path.resolve(f) === resolvedSourceFileName);
|
|
79
|
-
if (!
|
|
95
|
+
if (!isExplicitFile) {
|
|
80
96
|
if (options.enableLog) {
|
|
81
97
|
console.log(`Skipping file: ${resolvedSourceFileName}`);
|
|
82
98
|
}
|
|
@@ -108,4 +124,16 @@ export function generate(inputDirs, inputFiles, outputDir, visitorFactory, optio
|
|
|
108
124
|
console.log("Generation completed.");
|
|
109
125
|
}
|
|
110
126
|
}
|
|
127
|
+
export function isInIdlize(entry) {
|
|
128
|
+
return idl.isInPackage(entry, "idlize");
|
|
129
|
+
}
|
|
130
|
+
export function isInIdlizeInterop(entry) {
|
|
131
|
+
return idl.isInPackage(entry, "idlize.internal.interop");
|
|
132
|
+
}
|
|
133
|
+
export function isInIdlizeInternal(entry) {
|
|
134
|
+
return idl.isInPackage(entry, "idlize.internal");
|
|
135
|
+
}
|
|
136
|
+
export function isInIdlizeStdlib(entry) {
|
|
137
|
+
return idl.isInPackage(entry, "idlize.stdlib");
|
|
138
|
+
}
|
|
111
139
|
//# sourceMappingURL=idlize.js.map
|
package/build/lib/src/index.d.ts
CHANGED
|
@@ -43,7 +43,9 @@ export * from "./peer-generation/unions";
|
|
|
43
43
|
export * from "./LanguageWriters";
|
|
44
44
|
export * from "./peer-generation/ReferenceResolver";
|
|
45
45
|
export * from "./peer-generation/idl/common";
|
|
46
|
+
export * from "./from-idl/IDLLinter";
|
|
46
47
|
export { fromIDL } from "./from-idl/common";
|
|
47
48
|
export { idlToDtsString, CustomPrintVisitor } from "./from-idl/DtsPrinter";
|
|
48
49
|
export { toIDLFile, addSyntheticType, resolveSyntheticType } from "./from-idl/deserialize";
|
|
50
|
+
export { D, ConfigTypeInfer, ConfigSchema } from './configDescriber';
|
|
49
51
|
//# sourceMappingURL=index.d.ts.map
|
package/build/lib/src/index.js
CHANGED
|
@@ -57,7 +57,9 @@ export * from "./peer-generation/unions";
|
|
|
57
57
|
export * from "./LanguageWriters";
|
|
58
58
|
export * from "./peer-generation/ReferenceResolver";
|
|
59
59
|
export * from "./peer-generation/idl/common";
|
|
60
|
+
export * from "./from-idl/IDLLinter";
|
|
60
61
|
export { fromIDL } from "./from-idl/common";
|
|
61
62
|
export { idlToDtsString, CustomPrintVisitor } from "./from-idl/DtsPrinter";
|
|
62
63
|
export { toIDLFile, addSyntheticType, resolveSyntheticType } from "./from-idl/deserialize";
|
|
64
|
+
export { D } from './configDescriber';
|
|
63
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -37,6 +37,7 @@ export declare class MaterializedClass implements PeerClassBase {
|
|
|
37
37
|
readonly decl: idl.IDLInterface;
|
|
38
38
|
readonly className: string;
|
|
39
39
|
readonly isInterface: boolean;
|
|
40
|
+
readonly isStaticMaterialized: boolean;
|
|
40
41
|
readonly superClass: idl.IDLReferenceType | undefined;
|
|
41
42
|
readonly interfaces: idl.IDLReferenceType[] | undefined;
|
|
42
43
|
readonly generics: string[] | undefined;
|
|
@@ -46,7 +47,7 @@ export declare class MaterializedClass implements PeerClassBase {
|
|
|
46
47
|
readonly methods: MaterializedMethod[];
|
|
47
48
|
readonly needBeGenerated: boolean;
|
|
48
49
|
readonly taggedMethods: idl.IDLMethod[];
|
|
49
|
-
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctor: MaterializedMethod | undefined, // undefined when used for global functions
|
|
50
|
+
constructor(decl: idl.IDLInterface, className: string, isInterface: boolean, isStaticMaterialized: boolean, superClass: idl.IDLReferenceType | undefined, interfaces: idl.IDLReferenceType[] | undefined, generics: string[] | undefined, fields: MaterializedField[], ctor: MaterializedMethod | undefined, // undefined when used for global functions
|
|
50
51
|
finalizer: MaterializedMethod | undefined, // undefined when used for global functions
|
|
51
52
|
methods: MaterializedMethod[], needBeGenerated?: boolean, taggedMethods?: idl.IDLMethod[]);
|
|
52
53
|
getComponentName(): string;
|
|
@@ -96,12 +96,13 @@ export function copyMaterializedMethod(method, overrides) {
|
|
|
96
96
|
return copied;
|
|
97
97
|
}
|
|
98
98
|
export class MaterializedClass {
|
|
99
|
-
constructor(decl, className, isInterface, superClass, interfaces, generics, fields, ctor, // undefined when used for global functions
|
|
99
|
+
constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctor, // undefined when used for global functions
|
|
100
100
|
finalizer, // undefined when used for global functions
|
|
101
101
|
methods, needBeGenerated = true, taggedMethods = []) {
|
|
102
102
|
this.decl = decl;
|
|
103
103
|
this.className = className;
|
|
104
104
|
this.isInterface = isInterface;
|
|
105
|
+
this.isStaticMaterialized = isStaticMaterialized;
|
|
105
106
|
this.superClass = superClass;
|
|
106
107
|
this.interfaces = interfaces;
|
|
107
108
|
this.generics = generics;
|
|
@@ -131,7 +132,7 @@ export class MaterializedClass {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
export function createDestroyPeerMethod(clazz) {
|
|
134
|
-
if (clazz.isGlobalScope()) {
|
|
135
|
+
if (clazz.isGlobalScope() || clazz.isStaticMaterialized) {
|
|
135
136
|
return undefined;
|
|
136
137
|
}
|
|
137
138
|
return new MaterializedMethod(clazz.className, clazz.getImplementationName(), [], idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.className)], ['peer'])));
|
|
@@ -3,9 +3,8 @@ import { PeerClass } from "./PeerClass";
|
|
|
3
3
|
import { LibraryFileInterface } from '../LibraryInterface';
|
|
4
4
|
export declare class PeerFile implements LibraryFileInterface {
|
|
5
5
|
readonly file: idl.IDLFile;
|
|
6
|
-
readonly isPredefined: boolean;
|
|
7
6
|
readonly peers: Map<string, PeerClass>;
|
|
8
|
-
constructor(file: idl.IDLFile
|
|
7
|
+
constructor(file: idl.IDLFile);
|
|
9
8
|
packageName(): string;
|
|
10
9
|
packageClause(): string[];
|
|
11
10
|
get peersToGenerate(): PeerClass[];
|
|
@@ -10266,7 +10266,6 @@ export declare class PeerLibrary implements LibraryInterface {
|
|
|
10266
10266
|
get buildersToGenerate(): BuilderClass[];
|
|
10267
10267
|
readonly materializedClasses: Map<string, MaterializedClass>;
|
|
10268
10268
|
get materializedToGenerate(): MaterializedClass[];
|
|
10269
|
-
readonly predefinedDeclarations: idl.IDLInterface[];
|
|
10270
10269
|
constructor(language: Language, libraryPackages: string[] | undefined);
|
|
10271
10270
|
name: string;
|
|
10272
10271
|
readonly customComponentMethods: string[];
|
|
@@ -28,6 +28,7 @@ import { generateSyntheticFunctionName, isImportAttr } from './idl/common';
|
|
|
28
28
|
import { LayoutManager } from './LayoutManager';
|
|
29
29
|
import { lib, query } from '../library';
|
|
30
30
|
import { isMaterialized } from './isMaterialized';
|
|
31
|
+
import { isInIdlizeInternal } from '../idlize';
|
|
31
32
|
export const lenses = {
|
|
32
33
|
globals: lib.lens(lib.select.files())
|
|
33
34
|
.pipe(lib.select.nodes())
|
|
@@ -89,7 +90,6 @@ export class PeerLibrary {
|
|
|
89
90
|
this.files = [];
|
|
90
91
|
this.builderClasses = new Map();
|
|
91
92
|
this.materializedClasses = new Map();
|
|
92
|
-
this.predefinedDeclarations = [];
|
|
93
93
|
this.name = "";
|
|
94
94
|
this.customComponentMethods = [];
|
|
95
95
|
this.targetNameConvertorInstance = this.createTypeNameConvertor(this.language);
|
|
@@ -152,10 +152,11 @@ export class PeerLibrary {
|
|
|
152
152
|
return entry;
|
|
153
153
|
const qualifiedName = type.name.split(".");
|
|
154
154
|
let pointOfViewNamespace = idl.fetchNamespaceFrom(type.parent);
|
|
155
|
+
// TODO: Choose what to do if `rootEntries.some(it => idl.isNamespace(it))`
|
|
156
|
+
// One of possible options - `rootEntries = rootEntries.flatMap(it => idl.isNamespace(it) ? it.members : it)` - cause error
|
|
155
157
|
rootEntries !== null && rootEntries !== void 0 ? rootEntries : (rootEntries = this.files.flatMap(it => it.entries));
|
|
156
158
|
if (1 === qualifiedName.length) {
|
|
157
|
-
const predefined = rootEntries.filter(it =>
|
|
158
|
-
predefined.push(...this.predefinedDeclarations);
|
|
159
|
+
const predefined = rootEntries.filter(it => isInIdlizeInternal(it));
|
|
159
160
|
const found = predefined.find(it => it.name === qualifiedName[0]);
|
|
160
161
|
if (found)
|
|
161
162
|
return found;
|
|
@@ -242,12 +243,24 @@ export class PeerLibrary {
|
|
|
242
243
|
case idl.IDLVoidType: return new VoidConvertor(param);
|
|
243
244
|
case idl.IDLUnknownType:
|
|
244
245
|
case idl.IDLAnyType: return new CustomTypeConvertor(param, "Any", false, "Object");
|
|
246
|
+
case idl.IDLDate: return new DateConvertor(param);
|
|
245
247
|
default: throw new Error(`Unconverted primitive ${idl.DebugUtils.debugPrintType(type)}`);
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
if (idl.isReferenceType(type)) {
|
|
249
251
|
if (isImportAttr(type))
|
|
250
252
|
return new ImportTypeConvertor(param, this.targetNameConvertorInstance.convert(type));
|
|
253
|
+
// TODO: special cases for interop types.
|
|
254
|
+
switch (type.name) {
|
|
255
|
+
case 'KBoolean': return new BooleanConvertor(param);
|
|
256
|
+
case 'KInt': return new NumericConvertor(param, idl.IDLI32Type);
|
|
257
|
+
case 'KFloat': return new NumericConvertor(param, idl.IDLF32Type);
|
|
258
|
+
case 'KLong': return new NumericConvertor(param, idl.IDLI64Type);
|
|
259
|
+
case 'KDouble': return new NumericConvertor(param, idl.IDLF64Type);
|
|
260
|
+
case 'KStringPtr': return new StringConvertor(param);
|
|
261
|
+
case 'number': return new NumberConvertor(param);
|
|
262
|
+
case 'KPointer': return new PointerConvertor(param);
|
|
263
|
+
}
|
|
251
264
|
const decl = this.resolveTypeReference(type);
|
|
252
265
|
return this.declarationConvertor(param, type, decl);
|
|
253
266
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
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
1
|
import { generatorTypePrefix } from "../config";
|
|
16
2
|
import { asPromise } from "../idl";
|
|
3
|
+
import { isVMContextMethod } from "../LanguageWriters/ArgConvertors";
|
|
17
4
|
import { mangleMethodName, MethodModifier } from "../LanguageWriters/LanguageWriter";
|
|
18
5
|
import { capitalize, isDefined } from "../util";
|
|
19
6
|
import { PrimitiveTypesInstance } from "./PrimitiveType";
|
|
@@ -71,7 +58,6 @@ export class PeerMethod {
|
|
|
71
58
|
return !((_a = this.method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.STATIC));
|
|
72
59
|
}
|
|
73
60
|
generateAPIParameters(converter) {
|
|
74
|
-
var _a;
|
|
75
61
|
const args = this.argAndOutConvertors.map(it => {
|
|
76
62
|
let isPointer = it.isPointerType();
|
|
77
63
|
return `${isPointer ? "const " : ""}${converter.convert(it.nativeType())}${isPointer ? "*" : ""} ${it.param}`;
|
|
@@ -81,7 +67,7 @@ export class PeerMethod {
|
|
|
81
67
|
args.unshift(`${receiver.argType} ${receiver.argName}`);
|
|
82
68
|
if (!!asPromise(this.method.signature.returnType))
|
|
83
69
|
args.unshift(`${generatorTypePrefix()}AsyncWorkerPtr asyncWorker`);
|
|
84
|
-
if (
|
|
70
|
+
if (isVMContextMethod(this.method))
|
|
85
71
|
args.unshift(`${generatorTypePrefix()}VMContext vmContext`);
|
|
86
72
|
return args;
|
|
87
73
|
}
|
|
@@ -19,7 +19,7 @@ export function generateSyntheticIdlNodeName(type) {
|
|
|
19
19
|
if (idl.isPrimitiveType(type))
|
|
20
20
|
return capitalize(type.name);
|
|
21
21
|
if (idl.isContainerType(type)) {
|
|
22
|
-
const typeArgs = type.elementType.map(it => generateSyntheticIdlNodeName(it)).join("_");
|
|
22
|
+
const typeArgs = type.elementType.map(it => generateSyntheticIdlNodeName(it)).join("_").replaceAll(".", "_");
|
|
23
23
|
switch (type.containerKind) {
|
|
24
24
|
case "sequence": return "Array_" + typeArgs;
|
|
25
25
|
case "record": return "Map_" + typeArgs;
|
|
@@ -62,7 +62,7 @@ export function generifiedTypeName(refType, refName) {
|
|
|
62
62
|
return `${refName ? refName : refType.name}${typeArgs ? `<${typeArgs}>` : ``}`;
|
|
63
63
|
}
|
|
64
64
|
export function generateSyntheticUnionName(types) {
|
|
65
|
-
return `Union_${types.map(it => generateSyntheticIdlNodeName(it)).join("_")}`;
|
|
65
|
+
return `Union_${types.map(it => generateSyntheticIdlNodeName(it)).join("_").replaceAll(".", "_")}`;
|
|
66
66
|
}
|
|
67
67
|
export function generateSyntheticFunctionName(parameters, returnType, isAsync = false) {
|
|
68
68
|
let prefix = isAsync ? "AsyncCallback" : "Callback";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as idl from '../idl';
|
|
2
2
|
import { ReferenceResolver } from './ReferenceResolver';
|
|
3
3
|
export declare function isMaterialized(declaration: idl.IDLInterface, resolver: ReferenceResolver): boolean;
|
|
4
|
+
export declare function isStaticMaterialized(declaration: idl.IDLInterface, resolver: ReferenceResolver): boolean;
|
|
4
5
|
export declare function isMaterializedType(type: idl.IDLType, resolver: ReferenceResolver): boolean;
|
|
5
6
|
//# sourceMappingURL=isMaterialized.d.ts.map
|
|
@@ -24,6 +24,9 @@ export function isMaterialized(declaration, resolver) {
|
|
|
24
24
|
if (declaration.name == forceMaterialized)
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
|
+
if (generatorConfiguration().forceCallback.includes(declaration.name)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
27
30
|
for (const ignore of generatorConfiguration().ignoreMaterialized) {
|
|
28
31
|
if (declaration.name.endsWith(ignore))
|
|
29
32
|
return false;
|
|
@@ -43,6 +46,24 @@ export function isMaterialized(declaration, resolver) {
|
|
|
43
46
|
}
|
|
44
47
|
return false;
|
|
45
48
|
}
|
|
49
|
+
export function isStaticMaterialized(declaration, resolver) {
|
|
50
|
+
if (isMaterialized(declaration, resolver)) {
|
|
51
|
+
if (declaration.properties.length || declaration.constructors.length)
|
|
52
|
+
return false;
|
|
53
|
+
if (!declaration.methods.every(it => it.isStatic))
|
|
54
|
+
return false;
|
|
55
|
+
if (idl.hasSuperType(declaration)) {
|
|
56
|
+
const superType = resolver.resolveTypeReference(idl.getSuperType(declaration));
|
|
57
|
+
if (!superType || !idl.isInterface(superType)) {
|
|
58
|
+
console.log(`Unable to resolve ${idl.getSuperType(declaration).name} type, consider ${declaration.name} to be not materialized`);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return isStaticMaterialized(superType, resolver);
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
46
67
|
export function isMaterializedType(type, resolver) {
|
|
47
68
|
if (!idl.isReferenceType(type))
|
|
48
69
|
return false;
|
package/build/lib/src/util.d.ts
CHANGED
|
@@ -82,4 +82,5 @@ export declare class Lazy<T> {
|
|
|
82
82
|
}
|
|
83
83
|
export declare function lazy<T>(factory: () => T): Lazy<T>;
|
|
84
84
|
export declare function isInNamespace(node: idl.IDLEntry): boolean;
|
|
85
|
+
export declare function rightmostIndexOf<T>(array: T[], predicate: (value: T) => boolean): number;
|
|
85
86
|
//# sourceMappingURL=util.d.ts.map
|
package/build/lib/src/util.js
CHANGED
|
@@ -639,4 +639,13 @@ export function lazy(factory) {
|
|
|
639
639
|
export function isInNamespace(node) {
|
|
640
640
|
return idl.getNamespacesPathFor(node).length > 0;
|
|
641
641
|
}
|
|
642
|
+
export function rightmostIndexOf(array, predicate) {
|
|
643
|
+
let result = -1;
|
|
644
|
+
array.forEach((it, index) => {
|
|
645
|
+
if (predicate(it)) {
|
|
646
|
+
result = index;
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
return result;
|
|
650
|
+
}
|
|
642
651
|
//# 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.1.0",
|
|
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.9",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
39
|
"@types/node": "^18.0.0"
|
|
40
40
|
},
|