@idlizer/core 2.1.10-arktscgen-5 → 2.1.10-arktscgen-7
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/Language.js +1 -1
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +16 -6
- package/build/lib/src/LanguageWriters/ArgConvertors.js +80 -92
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +8 -7
- package/build/lib/src/LanguageWriters/LanguageWriter.js +35 -22
- package/build/lib/src/LanguageWriters/common.d.ts +1 -0
- package/build/lib/src/LanguageWriters/common.js +2 -1
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +7 -1
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +53 -15
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -0
- package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +10 -8
- package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -1
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +26 -14
- package/build/lib/src/LanguageWriters/index.d.ts +4 -3
- package/build/lib/src/LanguageWriters/index.js +9 -11
- package/build/lib/src/LanguageWriters/nameConvertor.d.ts +2 -0
- package/build/lib/src/LanguageWriters/nameConvertor.js +11 -0
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +1 -1
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -22
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +34 -113
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +3 -0
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +33 -9
- package/build/lib/src/config.d.ts +2 -1461
- package/build/lib/src/config.js +16 -32
- package/build/lib/src/configMerge.d.ts +3 -0
- package/build/lib/src/configMerge.js +63 -0
- package/build/lib/src/diagnostictypes.d.ts +1 -5
- package/build/lib/src/diagnostictypes.js +1 -27
- package/build/lib/src/from-idl/DtsPrinter.js +12 -5
- package/build/lib/src/from-idl/IDLLinter.d.ts +3 -4
- package/build/lib/src/from-idl/IDLLinter.js +30 -32
- package/build/lib/src/from-idl/deserialize.d.ts +3 -4
- package/build/lib/src/from-idl/deserialize.js +29 -641
- package/build/lib/src/from-idl/parser.d.ts +20 -2
- package/build/lib/src/from-idl/parser.js +97 -29
- package/build/lib/src/idl/builders.d.ts +43 -0
- package/build/lib/src/idl/builders.js +135 -0
- package/build/lib/src/idl/discriminators.d.ts +53 -0
- package/build/lib/src/idl/discriminators.js +232 -0
- package/build/lib/src/idl/dump.d.ts +48 -0
- package/build/lib/src/idl/dump.js +327 -0
- package/build/lib/src/idl/index.d.ts +9 -0
- package/build/lib/src/idl/index.js +23 -0
- package/build/lib/src/idl/keywords.d.ts +2 -0
- package/build/lib/src/{options.js → idl/keywords.js} +7 -3
- package/build/lib/src/idl/node.d.ts +233 -0
- package/build/lib/src/idl/node.js +103 -0
- package/build/lib/src/idl/stdlib.d.ts +34 -0
- package/build/lib/src/idl/stdlib.js +54 -0
- package/build/lib/src/idl/utils.d.ts +44 -0
- package/build/lib/src/idl/utils.js +215 -0
- package/build/lib/src/idl/visitors.d.ts +15 -0
- package/build/lib/src/idl/visitors.js +593 -0
- package/build/lib/src/index.d.ts +4 -2
- package/build/lib/src/index.js +5 -3
- package/build/lib/src/inputPaths.d.ts +11 -0
- package/build/lib/src/inputPaths.js +81 -0
- package/build/lib/src/languageSpecificKeywords.d.ts +0 -1
- package/build/lib/src/languageSpecificKeywords.js +0 -5
- package/build/lib/src/peer-generation/LayoutManager.d.ts +1 -1
- package/build/lib/src/peer-generation/Materialized.d.ts +8 -2
- package/build/lib/src/peer-generation/Materialized.js +24 -12
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -15
- package/build/lib/src/peer-generation/PeerLibrary.js +35 -215
- package/build/lib/src/peer-generation/ReferenceResolver.d.ts +6 -1
- package/build/lib/src/peer-generation/ReferenceResolver.js +93 -2
- package/build/lib/src/peer-generation/idl/common.d.ts +6 -2
- package/build/lib/src/peer-generation/idl/common.js +7 -7
- package/build/lib/src/peer-generation/isMaterialized.js +2 -3
- package/build/lib/src/peer-generation/modules.js +2 -0
- package/build/lib/src/peer-generation/toDeclaration.d.ts +4 -0
- package/build/lib/src/peer-generation/toDeclaration.js +53 -0
- package/build/lib/src/peer-generation/unions.d.ts +1 -1
- package/build/lib/src/peer-generation/unions.js +15 -7
- package/build/lib/src/resolveNamedNode.d.ts +1 -0
- package/build/lib/src/resolveNamedNode.js +7 -0
- package/build/lib/src/transformers/FqnTransformer.d.ts +1 -1
- package/build/lib/src/transformers/FqnTransformer.js +20 -12
- package/build/lib/src/transformers/GenericTransformer.d.ts +4 -3
- package/build/lib/src/transformers/GenericTransformer.js +252 -158
- package/build/lib/src/transformers/IdlTransformer.d.ts +6 -0
- package/build/lib/src/transformers/IdlTransformer.js +7 -0
- package/build/lib/src/transformers/NullTransformer.d.ts +1 -1
- package/build/lib/src/transformers/NullTransformer.js +27 -21
- package/build/lib/src/transformers/OnSerializeTransformer.d.ts +1 -1
- package/build/lib/src/transformers/OnSerializeTransformer.js +28 -13
- package/build/lib/src/util.d.ts +5 -0
- package/build/lib/src/util.js +25 -0
- package/package.json +6 -7
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +0 -37
- package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +0 -210
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +0 -85
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -306
- package/build/lib/src/from-idl/webidl2-utils.d.ts +0 -21
- package/build/lib/src/from-idl/webidl2-utils.js +0 -87
- package/build/lib/src/idl.d.ts +0 -444
- package/build/lib/src/idl.js +0 -1385
- package/build/lib/src/idlize.d.ts +0 -25
- package/build/lib/src/idlize.js +0 -198
- package/build/lib/src/options.d.ts +0 -13
- package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -20
- package/build/lib/src/peer-generation/BuilderClass.js +0 -68
- package/webidl2.js/dist/webidl2.js +0 -4622
- package/webidl2.js/package.json +0 -55
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
|
+
import * as idl from '../idl';
|
|
16
|
+
import { getPov, resolveNamedNode } from '../resolveNamedNode';
|
|
17
|
+
import { consoleWarn } from '../util';
|
|
15
18
|
export function createEmptyReferenceResolver() {
|
|
16
19
|
return {
|
|
17
20
|
resolveTypeReference() {
|
|
@@ -25,13 +28,101 @@ export function createEmptyReferenceResolver() {
|
|
|
25
28
|
/** Please do not store any global instances */
|
|
26
29
|
export function createAlternativeReferenceResolver(mainResolver, alternatives) {
|
|
27
30
|
return {
|
|
28
|
-
resolveTypeReference(type,
|
|
31
|
+
resolveTypeReference(type, options) {
|
|
29
32
|
var _a;
|
|
30
|
-
return (_a = mainResolver.resolveTypeReference(type,
|
|
33
|
+
return (_a = mainResolver.resolveTypeReference(type, options)) !== null && _a !== void 0 ? _a : alternatives.get(type.name);
|
|
31
34
|
},
|
|
32
35
|
toDeclaration(type) {
|
|
33
36
|
return mainResolver.toDeclaration(type);
|
|
34
37
|
},
|
|
35
38
|
};
|
|
36
39
|
}
|
|
40
|
+
export function createAlgotithmicReferenceResolver(files, useFallback = false) {
|
|
41
|
+
const resolveFallback = (type) => {
|
|
42
|
+
const target = type.name.split('.');
|
|
43
|
+
const resolveds = new Set();
|
|
44
|
+
for (let file of files) {
|
|
45
|
+
const result = resolveNamedNode([...file.packageClause, ...target], undefined, files);
|
|
46
|
+
if (result && idl.isEntry(result)) {
|
|
47
|
+
// too much spam
|
|
48
|
+
// console.warn(`WARNING: Type reference '${qualifiedName}' is not resolved from ${povAsReadableString} but resolved from some package '${file.packageClause().join(".")}'`)
|
|
49
|
+
resolveds.add(result);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// and from each namespace
|
|
53
|
+
const traverseNamespaces = (entry) => {
|
|
54
|
+
if (entry && idl.isNamespace(entry) && entry.members.length) {
|
|
55
|
+
const resolved = resolveNamedNode([...idl.getNamespacesPathFor(entry).map(it => it.name), ...target], undefined, files);
|
|
56
|
+
if (resolved) {
|
|
57
|
+
console.warn(`WARNING: Name '${type.name}' resolved by fallback from some namespace: '${idl.getNamespacesPathFor(resolved).map(obj => obj.name).join(".")}'`);
|
|
58
|
+
resolveds.add(resolved);
|
|
59
|
+
}
|
|
60
|
+
entry.members.forEach(traverseNamespaces);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
files.forEach(file => file.entries.forEach(traverseNamespaces));
|
|
64
|
+
if (resolveds.size > 1)
|
|
65
|
+
console.error(`Resolved multiple possible declarations by ${idl.DebugUtils.debugPrintType(type)}`);
|
|
66
|
+
return resolveds.size ? resolveds.values().next().value : undefined;
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
resolveTypeReference(type, options) {
|
|
70
|
+
var _a;
|
|
71
|
+
let result = (_a = resolveNamedNode(type.name.split("."), getPov(type), files)) !== null && _a !== void 0 ? _a : (useFallback ? resolveFallback(type) : undefined);
|
|
72
|
+
if (!(options === null || options === void 0 ? void 0 : options.terminalImports)) {
|
|
73
|
+
const seen = new Set;
|
|
74
|
+
while (result) {
|
|
75
|
+
let nextResult = undefined;
|
|
76
|
+
if (idl.isImport(result))
|
|
77
|
+
nextResult = resolveNamedNode(result.clause, undefined, files);
|
|
78
|
+
if (!nextResult)
|
|
79
|
+
break;
|
|
80
|
+
if (seen.has(nextResult)) {
|
|
81
|
+
console.warn(`Cyclic referenceType: ${type.name}, seen: [${[...seen.values()].map(idl.getFQName).join(", ")}]`);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
seen.add(nextResult);
|
|
85
|
+
result = nextResult;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (result) {
|
|
89
|
+
if (!idl.isEntry(result)) {
|
|
90
|
+
throw new Error(`Resolved reference ${idl.DebugUtils.debugPrintType(type)} to not entry type`);
|
|
91
|
+
}
|
|
92
|
+
if (idl.isNamespace(result)) {
|
|
93
|
+
throw new Error(`Resolved reference ${idl.DebugUtils.debugPrintType(type)} to namespace`);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
},
|
|
99
|
+
toDeclaration(type) {
|
|
100
|
+
throw new Error("To declaration is not available for default references resolver");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function createCachedReferenceResolver(files) {
|
|
105
|
+
const cache = new Map();
|
|
106
|
+
for (const file of files) {
|
|
107
|
+
idl.forEachChild(file, node => {
|
|
108
|
+
if (idl.isEnum(node) || idl.isCallback(node) || idl.isInterface(node) || idl.isTypedef(node)) {
|
|
109
|
+
const fqn = idl.getFQName(node);
|
|
110
|
+
if (cache.has(fqn))
|
|
111
|
+
consoleWarn(`WARNING: multiple entries with FQN=${fqn} found`);
|
|
112
|
+
else
|
|
113
|
+
cache.set(fqn, node);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
resolveTypeReference(type, options) {
|
|
119
|
+
if (!(options === null || options === void 0 ? void 0 : options.unresolvedOk) && !cache.has(type.name))
|
|
120
|
+
consoleWarn(`WARNING: reference ${idl.DebugUtils.debugPrintType(type)} was not found`);
|
|
121
|
+
return cache.get(type.name);
|
|
122
|
+
},
|
|
123
|
+
toDeclaration(type) {
|
|
124
|
+
throw new Error("Not implemented");
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
37
128
|
//# sourceMappingURL=ReferenceResolver.js.map
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as idl from "../../idl";
|
|
2
2
|
import { Language } from "../../Language";
|
|
3
|
+
import { IdlNameConvertor } from "../../LanguageWriters";
|
|
3
4
|
export declare function generateSyntheticIdlNodeName(type: idl.IDLType): string;
|
|
4
5
|
export declare function qualifiedName(decl: idl.IDLNode, languageOrDelimiter: Language | string, pattern: idl.QNPattern): string;
|
|
5
6
|
export declare function collapseTypes(types: idl.IDLType[], name?: string): idl.IDLType;
|
|
6
|
-
export declare function generifiedTypeName(refType: idl.IDLReferenceType
|
|
7
|
+
export declare function generifiedTypeName(refType: idl.IDLReferenceType, nameConvertor: IdlNameConvertor, refName?: string): string;
|
|
7
8
|
export declare function sanitizeGenerics(genericDeclarationString: string): string;
|
|
8
9
|
export declare function generateSyntheticUnionName(types: idl.IDLType[]): string;
|
|
9
10
|
export declare function generateSyntheticFunctionParameterName(parameter: idl.IDLParameter): string;
|
|
10
|
-
export declare function generateSyntheticFunctionName(parameters: idl.IDLParameter[], returnType: idl.IDLType,
|
|
11
|
+
export declare function generateSyntheticFunctionName(parameters: idl.IDLParameter[], returnType: idl.IDLType, options?: {
|
|
12
|
+
isAsync?: boolean;
|
|
13
|
+
nameConvertor?: IdlNameConvertor;
|
|
14
|
+
}): string;
|
|
11
15
|
export declare function isImportAttr(decl: idl.IDLNode): boolean;
|
|
12
16
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -54,11 +54,9 @@ export function collapseTypes(types, name) {
|
|
|
54
54
|
});
|
|
55
55
|
return uniqueTypes.length === 1 ? uniqueTypes[0] : idl.createUnionType(uniqueTypes, name);
|
|
56
56
|
}
|
|
57
|
-
export function generifiedTypeName(refType, refName) {
|
|
57
|
+
export function generifiedTypeName(refType, nameConvertor, refName) {
|
|
58
58
|
var _a;
|
|
59
|
-
|
|
60
|
-
return undefined;
|
|
61
|
-
const typeArgs = (_a = refType.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => idl.printType(it) /* FIXME: BUG! */).join(",");
|
|
59
|
+
const typeArgs = (_a = refType.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => nameConvertor.convert(it)).join(",");
|
|
62
60
|
return `${refName ? refName : refType.name}${typeArgs ? `<${typeArgs}>` : ``}`;
|
|
63
61
|
}
|
|
64
62
|
export function sanitizeGenerics(genericDeclarationString) {
|
|
@@ -81,9 +79,11 @@ export function generateSyntheticFunctionParameterName(parameter) {
|
|
|
81
79
|
}
|
|
82
80
|
return generateSyntheticIdlNodeName(parameter.type);
|
|
83
81
|
}
|
|
84
|
-
export function generateSyntheticFunctionName(parameters, returnType,
|
|
85
|
-
let prefix = isAsync ? "AsyncCallback" : "Callback";
|
|
86
|
-
const names =
|
|
82
|
+
export function generateSyntheticFunctionName(parameters, returnType, options) {
|
|
83
|
+
let prefix = (options === null || options === void 0 ? void 0 : options.isAsync) ? "AsyncCallback" : "Callback";
|
|
84
|
+
const names = (options === null || options === void 0 ? void 0 : options.nameConvertor) !== undefined
|
|
85
|
+
? parameters.map(it => options.nameConvertor.convert(it.type)).concat(options.nameConvertor.convert(returnType))
|
|
86
|
+
: parameters.map(generateSyntheticFunctionParameterName).concat(generateSyntheticIdlNodeName(returnType));
|
|
87
87
|
return `${prefix}_${names.join("_").replaceAll(".", "_")}`;
|
|
88
88
|
}
|
|
89
89
|
export function isImportAttr(decl) {
|
|
@@ -14,18 +14,17 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { generatorConfiguration } from '../config';
|
|
16
16
|
import * as idl from '../idl';
|
|
17
|
-
import { isBuilderClass } from './BuilderClass';
|
|
18
17
|
import { getSuper } from './getSuperType';
|
|
19
18
|
export function isMaterialized(declaration, resolver) {
|
|
20
19
|
var _a;
|
|
21
20
|
if (!idl.isInterfaceSubkind(declaration) && !idl.isClassSubkind(declaration))
|
|
22
21
|
return false;
|
|
23
|
-
if (idl.isHandwritten(declaration)
|
|
22
|
+
if (idl.isHandwritten(declaration))
|
|
24
23
|
return false;
|
|
25
24
|
if (generatorConfiguration().forceResource.includes(declaration.name)) {
|
|
26
25
|
return false;
|
|
27
26
|
}
|
|
28
|
-
if (generatorConfiguration().forceMaterialized.some(r => r === idl.
|
|
27
|
+
if (generatorConfiguration().forceMaterialized.some(r => r === idl.getFQNameSafe(declaration))) {
|
|
29
28
|
return true;
|
|
30
29
|
}
|
|
31
30
|
// TODO: rework this
|
|
@@ -51,6 +51,8 @@ function getApplicableModuleFor(packageName) {
|
|
|
51
51
|
if (packageName.startsWith(`idlize.`)) {
|
|
52
52
|
return currentModule();
|
|
53
53
|
}
|
|
54
|
+
if (packageName === `synthetic`)
|
|
55
|
+
return currentModule();
|
|
54
56
|
const modules = [...config.modules.keys()].map(it => `"${it}"`).join(", ");
|
|
55
57
|
throw new Error(`Package "${packageName}" is not listed in any module.`
|
|
56
58
|
+ ` Add the "${packageName}" to the existed list of modules [${modules}] or new one in the configuration file`);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as idl from "../idl";
|
|
2
|
+
import { ArkCustomObject, ArkDate, ArkFunction, forceTypedefAsResource } from "./PeerLibrary";
|
|
3
|
+
import { warn } from "../util";
|
|
4
|
+
import { toIdlType } from "../from-idl/deserialize";
|
|
5
|
+
import { isImportAttr } from "./idl/common";
|
|
6
|
+
export function toDeclaration(type, resolver) {
|
|
7
|
+
switch (type) {
|
|
8
|
+
case idl.IDLAnyType: return ArkCustomObject;
|
|
9
|
+
case idl.IDLVoidType: return idl.IDLVoidType;
|
|
10
|
+
case idl.IDLUndefinedType: return idl.IDLUndefinedType;
|
|
11
|
+
case idl.IDLUnknownType: return ArkCustomObject;
|
|
12
|
+
// case idl.IDLObjectType: return ArkCustomObject
|
|
13
|
+
}
|
|
14
|
+
const typeName = idl.isNamedNode(type) ? type.name : undefined;
|
|
15
|
+
switch (typeName) {
|
|
16
|
+
case "object":
|
|
17
|
+
case "Object": return idl.IDLObjectType;
|
|
18
|
+
}
|
|
19
|
+
if (idl.isReferenceType(type)) {
|
|
20
|
+
// TODO: remove all this!
|
|
21
|
+
if (type.name === 'Date') {
|
|
22
|
+
return ArkDate;
|
|
23
|
+
}
|
|
24
|
+
if (type.name === 'AnimationRange') {
|
|
25
|
+
return ArkCustomObject;
|
|
26
|
+
}
|
|
27
|
+
if (type.name === 'Function') {
|
|
28
|
+
return ArkFunction;
|
|
29
|
+
}
|
|
30
|
+
if (type.name === 'Optional') {
|
|
31
|
+
return toDeclaration(type.typeArguments[0], resolver);
|
|
32
|
+
}
|
|
33
|
+
const decl = resolver.resolveTypeReference(type);
|
|
34
|
+
if (!decl) {
|
|
35
|
+
warn(`undeclared type ${idl.DebugUtils.debugPrintType(type)}`);
|
|
36
|
+
}
|
|
37
|
+
if (decl && idl.isTypedef(decl) && forceTypedefAsResource(resolver, type, decl)) {
|
|
38
|
+
return idl.IDLObjectType;
|
|
39
|
+
}
|
|
40
|
+
if (decl && idl.hasExtAttribute(decl, idl.IDLExtendedAttributes.TransformOnSerialize)) {
|
|
41
|
+
const type = toIdlType("", idl.getExtAttribute(decl, idl.IDLExtendedAttributes.TransformOnSerialize));
|
|
42
|
+
return toDeclaration(type, resolver);
|
|
43
|
+
}
|
|
44
|
+
return !decl ? ArkCustomObject // assume some builtin type
|
|
45
|
+
: idl.isTypedef(decl) ? toDeclaration(decl.type, resolver)
|
|
46
|
+
: decl;
|
|
47
|
+
}
|
|
48
|
+
if (isImportAttr(type)) {
|
|
49
|
+
return ArkCustomObject;
|
|
50
|
+
}
|
|
51
|
+
return type;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=toDeclaration.js.map
|
|
@@ -22,7 +22,7 @@ export declare class UnionRuntimeTypeChecker {
|
|
|
22
22
|
private duplicateMembers;
|
|
23
23
|
constructor(convertors: ArgConvertor[]);
|
|
24
24
|
private checkConflicts;
|
|
25
|
-
makeDiscriminator(value: string, convertorIndex: number, writer: LanguageWriter): LanguageExpression;
|
|
25
|
+
makeDiscriminator(value: string, convertorIndex: number, writer: LanguageWriter, library: LibraryInterface, type?: IDLType): LanguageExpression;
|
|
26
26
|
}
|
|
27
27
|
export declare function flattenUnionType(library: LibraryInterface, type: IDLType): IDLType;
|
|
28
28
|
//# sourceMappingURL=unions.d.ts.map
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* See the License for the specific language governing permissions and
|
|
13
13
|
* limitations under the License.
|
|
14
14
|
*/
|
|
15
|
+
import * as idl from '../idl';
|
|
15
16
|
import { convertType } from "../LanguageWriters";
|
|
16
17
|
import { IDLCustomObjectType, IDLUndefinedType, isType, isUnionType } from '../idl';
|
|
17
18
|
import { collapseTypes } from "./idl/common";
|
|
@@ -84,14 +85,21 @@ export class UnionRuntimeTypeChecker {
|
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
makeDiscriminator(value, convertorIndex, writer) {
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
|
|
88
|
+
makeDiscriminator(value, convertorIndex, writer, library, type) {
|
|
89
|
+
let convertor = this.convertors[convertorIndex];
|
|
90
|
+
if (writer.language === Language.TS) {
|
|
91
|
+
const isArray = idl.IDLContainerUtils.isSequence(convertor.idlType);
|
|
92
|
+
if (isArray || this.conflictingConvertors.has(convertor)) {
|
|
93
|
+
// Check elements inside array
|
|
94
|
+
if (type && convertor.idlType != type) {
|
|
95
|
+
convertor = library.typeConvertor("", type);
|
|
96
|
+
}
|
|
97
|
+
const discriminator = convertor.unionDiscriminator(value, convertorIndex, writer, this.duplicateMembers);
|
|
98
|
+
if (discriminator)
|
|
99
|
+
return discriminator;
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
|
-
return writer.makeString(writer.discriminate(value, convertorIndex, convertor.idlType, convertor.runtimeTypes));
|
|
102
|
+
return writer.makeString(writer.discriminate(value, convertorIndex, type !== null && type !== void 0 ? type : convertor.idlType, convertor.runtimeTypes));
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
105
|
export function flattenUnionType(library, type) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IDLFile, IDLNode, IDLNamedNode } from "./idl";
|
|
2
|
+
export declare function getPov(node: IDLNode): IDLNode | undefined;
|
|
2
3
|
export declare function resolveNamedNode(target: string[], pov: IDLNode | undefined, corpus: IDLFile[]): IDLNamedNode | undefined;
|
|
3
4
|
//# sourceMappingURL=resolveNamedNode.d.ts.map
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { isReferenceType, hasExtAttribute, IDLExtendedAttributes } from "./idl";
|
|
16
16
|
import { isFile, isNamedNode, isNamespace, isEnum, isInterface, isImport } from "./idl";
|
|
17
|
+
export function getPov(node) {
|
|
18
|
+
let result = node;
|
|
19
|
+
while (result && !(isFile(result) || isNamespace(result))) {
|
|
20
|
+
result = result.parent;
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
17
24
|
export function resolveNamedNode(target, pov, corpus) {
|
|
18
25
|
let result;
|
|
19
26
|
let povScope = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as idl from "../idl";
|
|
2
2
|
import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function fqnTransformer(corpus: idl.IDLFile[], resolver: ReferenceResolver): idl.IDLFile[];
|
|
4
4
|
//# sourceMappingURL=FqnTransformer.d.ts.map
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import * as idl from "../idl";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (idl.isReferenceType(child))
|
|
7
|
-
inplaceReferenceFQN(child, resolver);
|
|
8
|
-
});
|
|
2
|
+
import { IdlTransformer } from "./IdlTransformer";
|
|
3
|
+
export function fqnTransformer(corpus, resolver) {
|
|
4
|
+
const transformer = new FqnTransformer(resolver);
|
|
5
|
+
return corpus.map(file => transformer.visit(file)).map(idl.linkParentBack);
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
class FqnTransformer extends IdlTransformer {
|
|
8
|
+
constructor(resolver) {
|
|
9
|
+
super();
|
|
10
|
+
this.resolver = resolver;
|
|
11
|
+
}
|
|
12
|
+
visit(node) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (idl.isReferenceType(node)) {
|
|
15
|
+
const resolved = this.resolver.resolveTypeReference(node);
|
|
16
|
+
if (resolved === undefined) {
|
|
17
|
+
this.resolver.resolveTypeReference(node);
|
|
18
|
+
throw new Error("Can not expand FQN for " + idl.DebugUtils.debugPrintType(node));
|
|
19
|
+
}
|
|
20
|
+
return idl.createReferenceType(idl.getFQName(resolved), (_a = node.typeArguments) === null || _a === void 0 ? void 0 : _a.map(it => this.visit(it)), idl.cloneNodeInitializer(node));
|
|
21
|
+
}
|
|
22
|
+
return this.visitEachChild(node);
|
|
14
23
|
}
|
|
15
|
-
ref.name = idl.getFQName(resolved);
|
|
16
24
|
}
|
|
17
25
|
//# sourceMappingURL=FqnTransformer.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as idl from "../idl";
|
|
2
2
|
import { ReferenceResolver } from "../peer-generation/ReferenceResolver";
|
|
3
|
-
export declare function
|
|
4
|
-
ignore
|
|
5
|
-
|
|
3
|
+
export declare function genericsTransformer(files: idl.IDLFile[], options: {
|
|
4
|
+
ignore: ((node: idl.IDLNode) => boolean)[];
|
|
5
|
+
ignoreGenerics: string[];
|
|
6
|
+
}): idl.IDLFile[];
|
|
6
7
|
export declare function isInplacedGeneric(entry: idl.IDLEntry): boolean;
|
|
7
8
|
export declare function maybeRestoreGenerics(maybeTransformedGeneric: idl.IDLReferenceType | idl.IDLEntry, resolver: ReferenceResolver): idl.IDLReferenceType | undefined;
|
|
8
9
|
//# sourceMappingURL=GenericTransformer.d.ts.map
|