@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.
Files changed (122) hide show
  1. package/build/lib/src/Language.d.ts +0 -1
  2. package/build/lib/src/Language.js +1 -3
  3. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +18 -7
  4. package/build/lib/src/LanguageWriters/ArgConvertors.js +95 -103
  5. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +13 -7
  6. package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -2
  7. package/build/lib/src/LanguageWriters/common.d.ts +1 -0
  8. package/build/lib/src/LanguageWriters/common.js +2 -1
  9. package/build/lib/src/LanguageWriters/convertors/CJConvertors.d.ts +0 -1
  10. package/build/lib/src/LanguageWriters/convertors/CJConvertors.js +1 -3
  11. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +14 -8
  12. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +88 -36
  13. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.d.ts +1 -0
  14. package/build/lib/src/LanguageWriters/convertors/ETSConvertors.js +10 -8
  15. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +1 -1
  16. package/build/lib/src/LanguageWriters/convertors/KotlinConvertors.js +9 -5
  17. package/build/lib/src/LanguageWriters/convertors/TSConvertors.d.ts +4 -4
  18. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +98 -44
  19. package/build/lib/src/LanguageWriters/index.d.ts +5 -4
  20. package/build/lib/src/LanguageWriters/index.js +8 -15
  21. package/build/lib/src/LanguageWriters/nameConvertor.d.ts +2 -0
  22. package/build/lib/src/LanguageWriters/nameConvertor.js +11 -0
  23. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +2 -0
  24. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +13 -1
  25. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +2 -0
  26. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +8 -2
  27. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +2 -10
  28. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +52 -92
  29. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +8 -0
  30. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +75 -27
  31. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +5 -0
  32. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +58 -18
  33. package/build/lib/src/LibraryInterface.d.ts +0 -1
  34. package/build/lib/src/config.d.ts +2 -1461
  35. package/build/lib/src/config.js +16 -32
  36. package/build/lib/src/configMerge.d.ts +3 -0
  37. package/build/lib/src/configMerge.js +63 -0
  38. package/build/lib/src/diagnostictypes.d.ts +1 -5
  39. package/build/lib/src/diagnostictypes.js +1 -27
  40. package/build/lib/src/from-idl/DtsPrinter.js +13 -6
  41. package/build/lib/src/from-idl/IDLLinter.d.ts +3 -4
  42. package/build/lib/src/from-idl/IDLLinter.js +30 -32
  43. package/build/lib/src/from-idl/deserialize.d.ts +3 -4
  44. package/build/lib/src/from-idl/deserialize.js +30 -642
  45. package/build/lib/src/from-idl/parser.d.ts +20 -2
  46. package/build/lib/src/from-idl/parser.js +97 -29
  47. package/build/lib/src/idl/builders.d.ts +43 -0
  48. package/build/lib/src/idl/builders.js +135 -0
  49. package/build/lib/src/idl/discriminators.d.ts +53 -0
  50. package/build/lib/src/idl/discriminators.js +232 -0
  51. package/build/lib/src/idl/dump.d.ts +48 -0
  52. package/build/lib/src/idl/dump.js +327 -0
  53. package/build/lib/src/idl/index.d.ts +9 -0
  54. package/build/lib/src/idl/index.js +23 -0
  55. package/build/lib/src/idl/keywords.d.ts +2 -0
  56. package/build/lib/src/{options.js → idl/keywords.js} +7 -3
  57. package/build/lib/src/idl/node.d.ts +233 -0
  58. package/build/lib/src/idl/node.js +103 -0
  59. package/build/lib/src/idl/stdlib.d.ts +34 -0
  60. package/build/lib/src/idl/stdlib.js +54 -0
  61. package/build/lib/src/idl/utils.d.ts +44 -0
  62. package/build/lib/src/idl/utils.js +215 -0
  63. package/build/lib/src/idl/visitors.d.ts +15 -0
  64. package/build/lib/src/idl/visitors.js +593 -0
  65. package/build/lib/src/index.d.ts +5 -6
  66. package/build/lib/src/index.js +6 -7
  67. package/build/lib/src/inheritance.d.ts +0 -2
  68. package/build/lib/src/inheritance.js +0 -17
  69. package/build/lib/src/inputPaths.d.ts +11 -0
  70. package/build/lib/src/inputPaths.js +81 -0
  71. package/build/lib/src/languageSpecificKeywords.d.ts +0 -1
  72. package/build/lib/src/languageSpecificKeywords.js +0 -5
  73. package/build/lib/src/peer-generation/ConflictingDeclarations.d.ts +6 -0
  74. package/build/lib/src/peer-generation/ConflictingDeclarations.js +43 -0
  75. package/build/lib/src/peer-generation/LayoutManager.d.ts +3 -1
  76. package/build/lib/src/peer-generation/LayoutManager.js +15 -0
  77. package/build/lib/src/peer-generation/Materialized.d.ts +8 -0
  78. package/build/lib/src/peer-generation/Materialized.js +26 -1
  79. package/build/lib/src/peer-generation/PeerLibrary.d.ts +10 -18
  80. package/build/lib/src/peer-generation/PeerLibrary.js +63 -227
  81. package/build/lib/src/peer-generation/ReferenceResolver.d.ts +6 -1
  82. package/build/lib/src/peer-generation/ReferenceResolver.js +93 -2
  83. package/build/lib/src/peer-generation/idl/IdlNameConvertor.d.ts +6 -0
  84. package/build/lib/src/peer-generation/idl/IdlNameConvertor.js +15 -3
  85. package/build/lib/src/peer-generation/idl/common.d.ts +6 -2
  86. package/build/lib/src/peer-generation/idl/common.js +7 -7
  87. package/build/lib/src/peer-generation/isMaterialized.js +2 -3
  88. package/build/lib/src/peer-generation/modules.js +2 -0
  89. package/build/lib/src/peer-generation/toDeclaration.d.ts +4 -0
  90. package/build/lib/src/peer-generation/toDeclaration.js +53 -0
  91. package/build/lib/src/peer-generation/unions.d.ts +1 -1
  92. package/build/lib/src/peer-generation/unions.js +15 -7
  93. package/build/lib/src/resolveNamedNode.d.ts +1 -0
  94. package/build/lib/src/resolveNamedNode.js +7 -0
  95. package/build/lib/src/transformers/FqnTransformer.d.ts +1 -1
  96. package/build/lib/src/transformers/FqnTransformer.js +20 -12
  97. package/build/lib/src/transformers/GenericTransformer.d.ts +4 -3
  98. package/build/lib/src/transformers/GenericTransformer.js +252 -158
  99. package/build/lib/src/transformers/IdlTransformer.d.ts +6 -0
  100. package/build/lib/src/transformers/IdlTransformer.js +7 -0
  101. package/build/lib/src/transformers/NullTransformer.d.ts +1 -1
  102. package/build/lib/src/transformers/NullTransformer.js +27 -21
  103. package/build/lib/src/transformers/OnSerializeTransformer.d.ts +1 -1
  104. package/build/lib/src/transformers/OnSerializeTransformer.js +28 -13
  105. package/build/lib/src/util.d.ts +9 -39
  106. package/build/lib/src/util.js +65 -369
  107. package/package.json +44 -49
  108. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.d.ts +0 -37
  109. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +0 -210
  110. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +0 -83
  111. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +0 -295
  112. package/build/lib/src/from-idl/webidl2-utils.d.ts +0 -21
  113. package/build/lib/src/from-idl/webidl2-utils.js +0 -87
  114. package/build/lib/src/idl.d.ts +0 -439
  115. package/build/lib/src/idl.js +0 -1367
  116. package/build/lib/src/idlize.d.ts +0 -25
  117. package/build/lib/src/idlize.js +0 -198
  118. package/build/lib/src/options.d.ts +0 -13
  119. package/build/lib/src/peer-generation/BuilderClass.d.ts +0 -20
  120. package/build/lib/src/peer-generation/BuilderClass.js +0 -68
  121. package/webidl2.js/dist/webidl2.js +0 -4622
  122. 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
- if (!refType)
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, isAsync = false) {
85
- let prefix = isAsync ? "AsyncCallback" : "Callback";
86
- const names = parameters.map(generateSyntheticFunctionParameterName).concat(generateSyntheticIdlNodeName(returnType));
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) || isBuilderClass(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.getFQName(declaration))) {
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,4 @@
1
+ import { ReferenceResolver } from "./ReferenceResolver";
2
+ import * as idl from "../idl";
3
+ export declare function toDeclaration(type: idl.IDLType | idl.IDLEntry, resolver: ReferenceResolver): idl.IDLEntry | idl.IDLType;
4
+ //# sourceMappingURL=toDeclaration.d.ts.map
@@ -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
- const convertor = this.convertors[convertorIndex];
89
- if (this.conflictingConvertors.has(convertor) && writer.language === Language.TS) {
90
- const discriminator = convertor.unionDiscriminator(value, convertorIndex, writer, this.duplicateMembers);
91
- if (discriminator)
92
- return discriminator;
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 inplaceFQN(node: idl.IDLNode, resolver: ReferenceResolver): void;
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
- export function inplaceFQN(node, resolver) {
3
- if (idl.isReferenceType(node))
4
- inplaceReferenceFQN(node, resolver);
5
- idl.forEachChild(node, (child) => {
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
- function inplaceReferenceFQN(ref, resolver) {
11
- const resolved = resolver.resolveTypeReference(ref);
12
- if (resolved === undefined) {
13
- throw new Error("Can not expand FQN for " + ref.name);
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 inplaceGenerics(node: idl.IDLNode, resolver: ReferenceResolver, options?: {
4
- ignore?: ((node: idl.IDLNode) => boolean)[];
5
- }): void;
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