@idlizer/core 2.1.10-arktscgen-4 → 2.1.10-arktscgen-6
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.d.ts +0 -1
- package/build/lib/src/Language.js +1 -3
- package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +18 -7
- package/build/lib/src/LanguageWriters/ArgConvertors.js +95 -103
- package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +13 -7
- package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -2
- 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/CJConvertors.d.ts +0 -1
- package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +1 -3
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +14 -8
- package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +88 -36
- 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/KotlinConvertors.js +9 -5
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +4 -4
- package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +98 -44
- package/build/lib/src/LanguageWriters/index.d.ts +5 -4
- package/build/lib/src/LanguageWriters/index.js +8 -15
- 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/CJLanguageWriter.d.ts +2 -0
- package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +13 -1
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +2 -0
- package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +8 -2
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -10
- package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +52 -92
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +8 -0
- package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +75 -27
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +5 -0
- package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +58 -18
- package/build/lib/src/LibraryInterface.d.ts +0 -1
- 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 +13 -6
- 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 +30 -642
- 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 +5 -6
- package/build/lib/src/index.js +6 -7
- package/build/lib/src/inheritance.d.ts +0 -2
- package/build/lib/src/inheritance.js +0 -17
- 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/ConflictingDeclarations.d.ts +6 -0
- package/build/lib/src/peer-generation/ConflictingDeclarations.js +43 -0
- package/build/lib/src/peer-generation/LayoutManager.d.ts +3 -1
- package/build/lib/src/peer-generation/LayoutManager.js +15 -0
- package/build/lib/src/peer-generation/Materialized.d.ts +8 -0
- package/build/lib/src/peer-generation/Materialized.js +26 -1
- package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -18
- package/build/lib/src/peer-generation/PeerLibrary.js +63 -227
- 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/IdlNameConvertor.d.ts +6 -0
- package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +15 -3
- 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 +9 -39
- package/build/lib/src/util.js +65 -369
- package/package.json +44 -49
- 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 -83
- package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -295
- 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 -439
- package/build/lib/src/idl.js +0 -1367
- 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
|
@@ -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
|