@idlizer/core 2.0.22 → 2.0.23
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/convertors/CppConvertors.js +3 -3
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +2 -2
- package/build/lib/src/config.d.ts +8 -3
- package/build/lib/src/config.js +4 -7
- package/build/lib/src/from-idl/DtsPrinter.js +1 -1
- package/build/lib/src/index.d.ts +0 -1
- package/build/lib/src/index.js +0 -1
- package/build/lib/src/inheritance.js +2 -2
- package/build/lib/src/peer-generation/BuilderClass.js +2 -2
- package/build/lib/src/peer-generation/Materialized.js +1 -1
- package/build/lib/src/peer-generation/PrimitiveType.js +1 -1
- package/package.json +2 -2
|
@@ -21,15 +21,15 @@ export class CppInteropConvertor extends InteropConvertor {
|
|
|
21
21
|
unwrap(type, result) {
|
|
22
22
|
const conf = generatorConfiguration();
|
|
23
23
|
if (idl.isType(type) && idl.isOptionalType(type)) {
|
|
24
|
-
return `${conf.
|
|
24
|
+
return `${conf.OptionalPrefix}${result.text}`;
|
|
25
25
|
}
|
|
26
26
|
if (result.noPrefix) {
|
|
27
27
|
return result.text;
|
|
28
28
|
}
|
|
29
|
-
const typePrefix = conf.
|
|
29
|
+
const typePrefix = conf.TypePrefix;
|
|
30
30
|
// TODO remove this ugly hack for CustomObject's
|
|
31
31
|
const convertedToCustomObject = result.text === idl.IDLCustomObjectType.name;
|
|
32
|
-
const libPrefix = idl.isPrimitiveType(type) || convertedToCustomObject ? "" : conf.
|
|
32
|
+
const libPrefix = idl.isPrimitiveType(type) || convertedToCustomObject ? "" : conf.LibraryPrefix;
|
|
33
33
|
return `${typePrefix}${libPrefix}${result.text}`;
|
|
34
34
|
}
|
|
35
35
|
convert(node) {
|
|
@@ -57,7 +57,7 @@ export class InteropConvertor {
|
|
|
57
57
|
return this.make(node.name);
|
|
58
58
|
}
|
|
59
59
|
convertCallback(node) {
|
|
60
|
-
return this.make(generatorConfiguration().
|
|
60
|
+
return this.make(generatorConfiguration().LibraryPrefix + node.name, true);
|
|
61
61
|
}
|
|
62
62
|
convertMethod(node) {
|
|
63
63
|
return this.make(node.name);
|
|
@@ -98,7 +98,7 @@ export class InteropConvertor {
|
|
|
98
98
|
case "Object":
|
|
99
99
|
return this.make('CustomObject');
|
|
100
100
|
}
|
|
101
|
-
if (generatorConfiguration().
|
|
101
|
+
if (generatorConfiguration().param("parameterized").includes(refName)) {
|
|
102
102
|
return this.make('CustomObject');
|
|
103
103
|
}
|
|
104
104
|
let decl = this.resolver.toDeclaration(type);
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
export interface GeneratorConfiguration {
|
|
2
2
|
param<T>(name: string): T;
|
|
3
|
-
|
|
3
|
+
readonly params: Record<string, any>;
|
|
4
|
+
TypePrefix: string;
|
|
5
|
+
LibraryPrefix: string;
|
|
6
|
+
OptionalPrefix: string;
|
|
4
7
|
}
|
|
5
8
|
export declare class BaseGeneratorConfiguration implements GeneratorConfiguration {
|
|
6
|
-
|
|
9
|
+
readonly params: Record<string, any>;
|
|
7
10
|
constructor(params?: Record<string, any>);
|
|
8
11
|
param<T>(name: string): T;
|
|
9
|
-
|
|
12
|
+
get TypePrefix(): string;
|
|
13
|
+
get LibraryPrefix(): string;
|
|
14
|
+
get OptionalPrefix(): string;
|
|
10
15
|
}
|
|
11
16
|
export declare function setDefaultConfiguration(config: GeneratorConfiguration): void;
|
|
12
17
|
export declare function generatorConfiguration(): GeneratorConfiguration;
|
package/build/lib/src/config.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
export class BaseGeneratorConfiguration {
|
|
16
16
|
constructor(params = {}) {
|
|
17
17
|
this.params = {};
|
|
18
|
-
Object.assign(this.params, params);
|
|
18
|
+
Object.assign(this.params, Object.assign({ TypePrefix: "", LibraryPrefix: "", OptionalPrefix: "" }, params));
|
|
19
19
|
}
|
|
20
20
|
param(name) {
|
|
21
21
|
if (name in this.params) {
|
|
@@ -23,12 +23,9 @@ export class BaseGeneratorConfiguration {
|
|
|
23
23
|
}
|
|
24
24
|
throw new Error(`${name} is unknown`);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
throw new Error(`${name} is unknown`);
|
|
31
|
-
}
|
|
26
|
+
get TypePrefix() { return this.param("TypePrefix"); }
|
|
27
|
+
get LibraryPrefix() { return this.param("LibraryPrefix"); }
|
|
28
|
+
get OptionalPrefix() { return this.param("OptionalPrefix"); }
|
|
32
29
|
}
|
|
33
30
|
let currentConfig = new BaseGeneratorConfiguration();
|
|
34
31
|
export function setDefaultConfiguration(config) {
|
|
@@ -168,7 +168,7 @@ export class CustomPrintVisitor {
|
|
|
168
168
|
let isProtected = hasExtAttribute(node, IDLExtendedAttributes.Protected);
|
|
169
169
|
if (isCommonMethod) {
|
|
170
170
|
// TODO: not very clean, but we don't need to print these so far.
|
|
171
|
-
// if (
|
|
171
|
+
// if (peerGeneratorConfiguration().ignorePeerMethod.includes(node.name)) return
|
|
172
172
|
const typeParams = (_a = this.currentInterface) === null || _a === void 0 ? void 0 : _a.typeParameters;
|
|
173
173
|
const returnType = typeParams && typeParams.length > 0 ? typeParams[0] : this.currentInterface.name;
|
|
174
174
|
this.print(`${getName(node)}(value: ${this.printTypeForTS(node.type, undefined, undefined, isCommonMethod)}): ${returnType};`);
|
package/build/lib/src/index.d.ts
CHANGED
package/build/lib/src/index.js
CHANGED
|
@@ -39,9 +39,9 @@ export function isCommonMethodOrSubclass(typeChecker, decl) {
|
|
|
39
39
|
return isSubclass;
|
|
40
40
|
}
|
|
41
41
|
export function determineInheritanceRole(name) {
|
|
42
|
-
if (generatorConfiguration().
|
|
42
|
+
if (generatorConfiguration().param("rootComponents").includes(name))
|
|
43
43
|
return InheritanceRole.Root;
|
|
44
|
-
if (generatorConfiguration().
|
|
44
|
+
if (generatorConfiguration().param("standaloneComponents").includes(name))
|
|
45
45
|
return InheritanceRole.Standalone;
|
|
46
46
|
return InheritanceRole.Heir;
|
|
47
47
|
}
|
|
@@ -32,7 +32,7 @@ export class BuilderClass {
|
|
|
32
32
|
*/
|
|
33
33
|
export function isBuilderClass(declaration) {
|
|
34
34
|
const className = declaration.name;
|
|
35
|
-
if (generatorConfiguration().
|
|
35
|
+
if (generatorConfiguration().param("builderClasses").includes(className)) {
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
if (isCustomBuilderClass(className)) {
|
|
@@ -43,7 +43,7 @@ export function isBuilderClass(declaration) {
|
|
|
43
43
|
// are used for now.
|
|
44
44
|
return false;
|
|
45
45
|
/*
|
|
46
|
-
if (
|
|
46
|
+
if (peerGeneratorConfiguration().isStandardNameIgnored(className)) {
|
|
47
47
|
return false
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -26,7 +26,7 @@ export function isMaterialized(declaration, resolver) {
|
|
|
26
26
|
declaration.subkind === idl.IDLInterfaceSubkind.Tuple) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
|
-
for (const ignore of generatorConfiguration().
|
|
29
|
+
for (const ignore of generatorConfiguration().param("ignoreMaterialized")) {
|
|
30
30
|
if (declaration.name.endsWith(ignore))
|
|
31
31
|
return false;
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idlizer/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.23",
|
|
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.
|
|
37
|
+
"@koalaui/interop": "1.5.0",
|
|
38
38
|
"typescript": "4.9.5",
|
|
39
39
|
"@types/node": "^18.0.0"
|
|
40
40
|
},
|