@idlizer/core 2.1.9-arktscgen-8 → 2.1.10-arktscgen-2

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 (51) hide show
  1. package/build/lib/src/IndentedPrinter.d.ts +2 -1
  2. package/build/lib/src/IndentedPrinter.js +9 -2
  3. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +35 -26
  4. package/build/lib/src/LanguageWriters/ArgConvertors.js +152 -117
  5. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +5 -4
  6. package/build/lib/src/LanguageWriters/LanguageWriter.js +16 -15
  7. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +1 -1
  8. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +1 -1
  9. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +6 -6
  10. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +1 -1
  11. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +6 -6
  12. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.d.ts +8 -1
  13. package/build/lib/src/LanguageWriters/writers/ETSLanguageWriter.js +28 -8
  14. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.d.ts +1 -1
  15. package/build/lib/src/LanguageWriters/writers/JavaLanguageWriter.js +8 -8
  16. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.d.ts +1 -1
  17. package/build/lib/src/LanguageWriters/writers/KotlinLanguageWriter.js +6 -6
  18. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +1 -1
  19. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +7 -7
  20. package/build/lib/src/config.d.ts +132 -132
  21. package/build/lib/src/config.js +4 -4
  22. package/build/lib/src/configDescriber.js +1 -1
  23. package/build/lib/src/diagnosticmessages.d.ts +18 -12
  24. package/build/lib/src/diagnosticmessages.js +22 -14
  25. package/build/lib/src/diagnostictypes.d.ts +3 -9
  26. package/build/lib/src/formatter.d.ts +2 -1
  27. package/build/lib/src/formatter.js +3 -3
  28. package/build/lib/src/from-idl/deserialize.js +138 -6
  29. package/build/lib/src/from-idl/parser.d.ts +99 -0
  30. package/build/lib/src/from-idl/parser.js +939 -0
  31. package/build/lib/src/idl.d.ts +13 -1
  32. package/build/lib/src/idl.js +6 -0
  33. package/build/lib/src/index.d.ts +1 -0
  34. package/build/lib/src/index.js +1 -0
  35. package/build/lib/src/peer-generation/LayoutManager.d.ts +1 -1
  36. package/build/lib/src/peer-generation/Materialized.d.ts +1 -1
  37. package/build/lib/src/peer-generation/Materialized.js +4 -4
  38. package/build/lib/src/peer-generation/PeerClass.d.ts +5 -0
  39. package/build/lib/src/peer-generation/PeerClass.js +2 -1
  40. package/build/lib/src/peer-generation/PeerLibrary.d.ts +1 -0
  41. package/build/lib/src/peer-generation/PeerLibrary.js +8 -2
  42. package/build/lib/src/peer-generation/PeerMethod.d.ts +8 -2
  43. package/build/lib/src/peer-generation/PeerMethod.js +22 -4
  44. package/build/lib/src/peer-generation/modules.js +21 -6
  45. package/build/lib/src/util.d.ts +1 -0
  46. package/build/lib/src/util.js +5 -0
  47. package/package.json +10 -3
  48. package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.d.ts +0 -24
  49. package/build/lib/src/LanguageWriters/convertors/KotlinConvertor.js +0 -69
  50. package/build/lib/src/peer-generation/isExternalType.d.ts +0 -4
  51. package/build/lib/src/peer-generation/isExternalType.js +0 -15
@@ -35,17 +35,20 @@ export declare enum IDLEntity {
35
35
  }
36
36
  export declare enum IDLExtendedAttributes {
37
37
  Accessor = "Accessor",
38
+ Annotations = "Annotations",
38
39
  Async = "Async",
39
40
  CallSignature = "CallSignature",
40
41
  CommonMethod = "CommonMethod",
41
42
  Component = "Component",
42
43
  ComponentInterface = "ComponentInterface",
44
+ ComponentModifier = "ComponentModifier",
43
45
  Deprecated = "Deprecated",
44
46
  Documentation = "Documentation",
45
47
  DtsName = "DtsName",
46
48
  DtsTag = "DtsTag",
47
49
  Entity = "Entity",
48
50
  Extends = "Extends",
51
+ ExtensionMethod = "ExtensionMethod",
49
52
  Import = "Import",
50
53
  DefaultExport = "DefaultExport",
51
54
  IndexSignature = "IndexSignature",
@@ -59,11 +62,14 @@ export declare enum IDLExtendedAttributes {
59
62
  Synthetic = "Synthetic",
60
63
  Throws = "Throws",
61
64
  TraceKey = "TraceKey",
65
+ TypeAnnotations = "TypeAnnotations",
62
66
  TypeArguments = "TypeArguments",
63
67
  TypeParameters = "TypeParameters",
64
68
  VerbatimDts = "VerbatimDts",
65
69
  HandWrittenImplementation = "HandWrittenImplementation",
66
- ExtraMethod = "ExtraMethod"
70
+ ExtraMethod = "ExtraMethod",
71
+ OverloadAlias = "OverloadAlias",
72
+ OverloadPriority = "OverloadPriority"
67
73
  }
68
74
  export declare enum IDLAccessorAttribute {
69
75
  Getter = "Getter",
@@ -72,6 +78,9 @@ export declare enum IDLAccessorAttribute {
72
78
  export interface IDLExtendedAttribute {
73
79
  name: string;
74
80
  value?: string;
81
+ typesValue?: IDLType[];
82
+ nameLocation?: Location;
83
+ valueLocation?: Location;
75
84
  }
76
85
  export interface IDLNode {
77
86
  _idlNodeBrand: any;
@@ -295,6 +304,9 @@ export type IDLNodeInitializer = {
295
304
  extendedAttributes?: IDLExtendedAttribute[];
296
305
  fileName?: string;
297
306
  documentation?: string;
307
+ nodeLocation?: Location;
308
+ nameLocation?: Location;
309
+ valueLocation?: Location;
298
310
  };
299
311
  export declare function createNamespace(name: string, members?: IDLEntry[], nodeInitializer?: IDLNodeInitializer): IDLNamespace;
300
312
  export declare function linkParentBack<T extends IDLNode>(node: T): T;
@@ -54,17 +54,20 @@ export var IDLEntity;
54
54
  export var IDLExtendedAttributes;
55
55
  (function (IDLExtendedAttributes) {
56
56
  IDLExtendedAttributes["Accessor"] = "Accessor";
57
+ IDLExtendedAttributes["Annotations"] = "Annotations";
57
58
  IDLExtendedAttributes["Async"] = "Async";
58
59
  IDLExtendedAttributes["CallSignature"] = "CallSignature";
59
60
  IDLExtendedAttributes["CommonMethod"] = "CommonMethod";
60
61
  IDLExtendedAttributes["Component"] = "Component";
61
62
  IDLExtendedAttributes["ComponentInterface"] = "ComponentInterface";
63
+ IDLExtendedAttributes["ComponentModifier"] = "ComponentModifier";
62
64
  IDLExtendedAttributes["Deprecated"] = "Deprecated";
63
65
  IDLExtendedAttributes["Documentation"] = "Documentation";
64
66
  IDLExtendedAttributes["DtsName"] = "DtsName";
65
67
  IDLExtendedAttributes["DtsTag"] = "DtsTag";
66
68
  IDLExtendedAttributes["Entity"] = "Entity";
67
69
  IDLExtendedAttributes["Extends"] = "Extends";
70
+ IDLExtendedAttributes["ExtensionMethod"] = "ExtensionMethod";
68
71
  IDLExtendedAttributes["Import"] = "Import";
69
72
  IDLExtendedAttributes["DefaultExport"] = "DefaultExport";
70
73
  IDLExtendedAttributes["IndexSignature"] = "IndexSignature";
@@ -78,11 +81,14 @@ export var IDLExtendedAttributes;
78
81
  IDLExtendedAttributes["Synthetic"] = "Synthetic";
79
82
  IDLExtendedAttributes["Throws"] = "Throws";
80
83
  IDLExtendedAttributes["TraceKey"] = "TraceKey";
84
+ IDLExtendedAttributes["TypeAnnotations"] = "TypeAnnotations";
81
85
  IDLExtendedAttributes["TypeArguments"] = "TypeArguments";
82
86
  IDLExtendedAttributes["TypeParameters"] = "TypeParameters";
83
87
  IDLExtendedAttributes["VerbatimDts"] = "VerbatimDts";
84
88
  IDLExtendedAttributes["HandWrittenImplementation"] = "HandWrittenImplementation";
85
89
  IDLExtendedAttributes["ExtraMethod"] = "ExtraMethod";
90
+ IDLExtendedAttributes["OverloadAlias"] = "OverloadAlias";
91
+ IDLExtendedAttributes["OverloadPriority"] = "OverloadPriority";
86
92
  })(IDLExtendedAttributes || (IDLExtendedAttributes = {}));
87
93
  export var IDLAccessorAttribute;
88
94
  (function (IDLAccessorAttribute) {
@@ -58,5 +58,6 @@ export * from "./from-idl/IDLLinter";
58
58
  export { fromIDL, scanIDL } from "./from-idl/common";
59
59
  export { idlToDtsString, CustomPrintVisitor } from "./from-idl/DtsPrinter";
60
60
  export { toIDLFile, addSyntheticType, resolveSyntheticType, IDLTokenInfoMap } from "./from-idl/deserialize";
61
+ export { Parser, FatalParserException } from "./from-idl/parser";
61
62
  export { D, ConfigTypeInfer, ConfigSchema, inspectSchema } from './configDescriber';
62
63
  //# sourceMappingURL=index.d.ts.map
@@ -72,5 +72,6 @@ export * from "./from-idl/IDLLinter";
72
72
  export { fromIDL, scanIDL } from "./from-idl/common";
73
73
  export { idlToDtsString, CustomPrintVisitor } from "./from-idl/DtsPrinter";
74
74
  export { toIDLFile, addSyntheticType, resolveSyntheticType } from "./from-idl/deserialize";
75
+ export { Parser, FatalParserException } from "./from-idl/parser";
75
76
  export { D, inspectSchema } from './configDescriber';
76
77
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@ export declare enum LayoutNodeRole {
6
6
  COMPONENT = 3,
7
7
  SERIALIZER = 4
8
8
  }
9
- export type LayoutTargetDescriptionHint = 'component.implementation' | 'component.interface' | 'component.function';
9
+ export type LayoutTargetDescriptionHint = 'component.implementation' | 'component.interface' | 'component.function' | 'component.modifier';
10
10
  export interface LayoutTargetDescription {
11
11
  node: IDLEntry;
12
12
  role: LayoutNodeRole;
@@ -14,7 +14,7 @@ export declare class MaterializedField {
14
14
  }
15
15
  export declare class MaterializedMethod extends PeerMethod {
16
16
  implementationParentName: string;
17
- constructor(sig: PeerMethodSignature, originalParentName: string, implementationParentName: string, returnType: idl.IDLType, isCallSignature: boolean, method: Method);
17
+ constructor(sig: PeerMethodSignature, originalParentName: string, implementationParentName: string, returnType: idl.IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
18
18
  tsReturnType(): idl.IDLType | undefined;
19
19
  getPrivateMethod(): MaterializedMethod;
20
20
  withReturnType(returnType: idl.IDLType): MaterializedMethod;
@@ -27,8 +27,8 @@ export class MaterializedField {
27
27
  }
28
28
  }
29
29
  export class MaterializedMethod extends PeerMethod {
30
- constructor(sig, originalParentName, implementationParentName, returnType, isCallSignature, method) {
31
- super(sig, originalParentName, returnType, isCallSignature, method);
30
+ constructor(sig, originalParentName, implementationParentName, returnType, isCallSignature, uniqueOverloadName, method) {
31
+ super(sig, originalParentName, returnType, isCallSignature, uniqueOverloadName, method);
32
32
  this.implementationParentName = implementationParentName;
33
33
  }
34
34
  tsReturnType() {
@@ -59,7 +59,7 @@ export class MaterializedMethod extends PeerMethod {
59
59
  }
60
60
  export function copyMaterializedMethod(method, overrides) {
61
61
  var _a;
62
- return new MaterializedMethod(method.sig, method.originalParentName, method.implementationParentName, method.returnType, method.isCallSignature, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method);
62
+ return new MaterializedMethod(method.sig, method.originalParentName, method.implementationParentName, method.returnType, method.isCallSignature, method.uniqueOverloadName, (_a = overrides.method) !== null && _a !== void 0 ? _a : method.method);
63
63
  }
64
64
  export class MaterializedClass {
65
65
  constructor(decl, className, isInterface, isStaticMaterialized, superClass, interfaces, generics, fields, ctors, // zero size when used for global functions
@@ -97,7 +97,7 @@ export function createDestroyPeerMethod(clazz) {
97
97
  if (clazz.isGlobalScope() || clazz.isStaticMaterialized) {
98
98
  return undefined;
99
99
  }
100
- return new MaterializedMethod(new PeerMethodSignature(PeerMethodSignature.DESTROY, '%NEVER_USED$', [], idl.IDLVoidType, clazz.decl), idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), idl.IDLVoidType, false, new Method('destroyPeer', new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
100
+ return new MaterializedMethod(new PeerMethodSignature(PeerMethodSignature.DESTROY, '%NEVER_USED$', [], idl.IDLVoidType, clazz.decl), idl.getQualifiedName(clazz.decl, "namespace.name").split('.').join('_'), clazz.getImplementationName(), idl.IDLVoidType, false, PeerMethodSignature.DESTROY, new Method(PeerMethodSignature.DESTROY, new NamedMethodSignature(idl.IDLVoidType, [idl.createReferenceType(clazz.decl)], ['peer'])));
101
101
  }
102
102
  export function getInternalClassName(name) {
103
103
  return `${name}Internal`;
@@ -3,6 +3,10 @@ import { PeerMethod } from "./PeerMethod";
3
3
  export interface PeerClassBase {
4
4
  generatedName(isCallSignature: boolean): string;
5
5
  }
6
+ export interface ComponentBuilderInfo {
7
+ uniqueOverloadName: string;
8
+ peerMethodName: string;
9
+ }
6
10
  export declare class PeerClass implements PeerClassBase {
7
11
  readonly file: IDLFile;
8
12
  readonly componentName: string;
@@ -10,6 +14,7 @@ export declare class PeerClass implements PeerClassBase {
10
14
  constructor(file: IDLFile, componentName: string, originalFilename: string);
11
15
  generatedName(isCallSignature: boolean): string;
12
16
  methods: PeerMethod[];
17
+ componentBuilderInfos: ComponentBuilderInfo[];
13
18
  originalClassName: string | undefined;
14
19
  originalInterfaceName: string | undefined;
15
20
  originalParentName: string | undefined;
@@ -21,6 +21,7 @@ export class PeerClass {
21
21
  this.componentName = componentName;
22
22
  this.originalFilename = originalFilename;
23
23
  this.methods = [];
24
+ this.componentBuilderInfos = [];
24
25
  this.originalClassName = undefined;
25
26
  this.originalInterfaceName = undefined;
26
27
  this.originalParentName = undefined;
@@ -36,6 +37,6 @@ export class PeerClass {
36
37
  export function createConstructPeerMethod(clazz) {
37
38
  // TODO here is class FQName needed, but can not calculate if from current PeerClass data
38
39
  const classFQN = [clazz.componentName];
39
- return new PeerMethod(new PeerMethodSignature(PeerMethodSignature.CTOR, classFQN.concat(PeerMethodSignature.CTOR).join('_'), [new PeerMethodArg('id', IDLI32Type), new PeerMethodArg('flags', IDLI32Type)], IDLPointerType), clazz.componentName, IDLPointerType, false, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
40
+ return new PeerMethod(new PeerMethodSignature(PeerMethodSignature.CTOR, classFQN.concat(PeerMethodSignature.CTOR).join('_'), [new PeerMethodArg('id', IDLI32Type), new PeerMethodArg('flags', IDLI32Type)], IDLPointerType), clazz.componentName, IDLPointerType, false, PeerMethodSignature.CTOR, new Method('construct', new NamedMethodSignature(IDLPointerType, [IDLI32Type, IDLI32Type], ['id', 'flags']), [MethodModifier.STATIC]));
40
41
  }
41
42
  //# sourceMappingURL=PeerClass.js.map
@@ -10297,6 +10297,7 @@ export declare class PeerLibrary implements LibraryInterface {
10297
10297
  getInteropName(node: idl.IDLNode): string;
10298
10298
  toDeclaration(type: idl.IDLType | idl.IDLTypedef | idl.IDLCallback | idl.IDLEnum | idl.IDLInterface): idl.IDLEntry | idl.IDLType;
10299
10299
  setFileLayout(strategy: LayoutManagerStrategy): void;
10300
+ withFileLayout(strategy: LayoutManagerStrategy, op: () => void): void;
10300
10301
  }
10301
10302
  export declare const ArkInt32: idl.IDLPrimitiveType;
10302
10303
  export declare const ArkInt64: idl.IDLPrimitiveType;
@@ -17,7 +17,7 @@ import * as idl from '../idl';
17
17
  import { resolveNamedNode } from '../resolveNamedNode';
18
18
  import { Language } from '../Language';
19
19
  import { createLanguageWriter } from '../LanguageWriters';
20
- import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, ObjectConvertor, } from "../LanguageWriters/ArgConvertors";
20
+ import { BufferConvertor, CallbackConvertor, DateConvertor, MapConvertor, PointerConvertor, TupleConvertor, TypeAliasConvertor, AggregateConvertor, StringConvertor, ClassConvertor, ArrayConvertor, FunctionConvertor, OptionConvertor, NumberConvertor, NumericConvertor, CustomTypeConvertor, UnionConvertor, MaterializedClassConvertor, BooleanConvertor, EnumConvertor, UndefinedConvertor, VoidConvertor, ImportTypeConvertor, InterfaceConvertor, BigIntToU64Convertor, ObjectConvertor, DoubleConvertor, } from "../LanguageWriters/ArgConvertors";
21
21
  import { CppNameConvertor } from '../LanguageWriters/convertors/CppConvertors';
22
22
  import { CJTypeNameConvertor } from '../LanguageWriters/convertors/CJConvertors';
23
23
  import { CppConvertor } from '../LanguageWriters/convertors/CppConvertors';
@@ -297,7 +297,7 @@ export class PeerLibrary {
297
297
  case idl.IDLU64Type: return new NumericConvertor(param, type);
298
298
  case idl.IDLF16Type: return new NumericConvertor(param, type);
299
299
  case idl.IDLF32Type: return new NumericConvertor(param, type);
300
- case idl.IDLF64Type: return new NumericConvertor(param, type);
300
+ case idl.IDLF64Type: return new DoubleConvertor(param);
301
301
  case idl.IDLBigintType: return new BigIntToU64Convertor(param);
302
302
  case idl.IDLSerializerBuffer: new PointerConvertor(param);
303
303
  case idl.IDLPointerType: return new PointerConvertor(param);
@@ -474,6 +474,12 @@ export class PeerLibrary {
474
474
  setFileLayout(strategy) {
475
475
  this.layout = new LayoutManager(strategy);
476
476
  }
477
+ withFileLayout(strategy, op) {
478
+ const old = this.layout;
479
+ this.layout = new LayoutManager(strategy);
480
+ op();
481
+ this.layout = old;
482
+ }
477
483
  }
478
484
  export const ArkInt32 = idl.IDLI32Type;
479
485
  export const ArkInt64 = idl.IDLI64Type;
@@ -8,6 +8,11 @@ export declare class PeerMethodArg {
8
8
  readonly type: idl.IDLType;
9
9
  constructor(name: string, type: idl.IDLType);
10
10
  }
11
+ export type OverloadInfo = {
12
+ postfix: string;
13
+ alias?: string;
14
+ priority?: number;
15
+ };
11
16
  export declare class PeerMethodSignature {
12
17
  readonly name: string;
13
18
  readonly fqname: string;
@@ -16,7 +21,7 @@ export declare class PeerMethodSignature {
16
21
  readonly context: idl.IDLEntry | undefined;
17
22
  readonly modifiers: (MethodModifier.FORCE_CONTEXT | MethodModifier.THROWS)[];
18
23
  constructor(name: string, fqname: string, args: PeerMethodArg[], returnType: idl.IDLType, context?: idl.IDLEntry | undefined, modifiers?: (MethodModifier.FORCE_CONTEXT | MethodModifier.THROWS)[]);
19
- static generateOverloadPostfix(decl: idl.IDLConstructor | idl.IDLMethod | idl.IDLCallable | idl.IDLProperty): string;
24
+ static mangleOverloadedName(decl: idl.IDLConstructor | idl.IDLMethod | idl.IDLCallable | idl.IDLProperty): OverloadInfo;
20
25
  static get CTOR(): string;
21
26
  static get GET_FINALIZER(): string;
22
27
  static get DESTROY(): string;
@@ -26,8 +31,9 @@ export declare class PeerMethod {
26
31
  originalParentName: string;
27
32
  returnType: IDLType;
28
33
  isCallSignature: boolean;
34
+ uniqueOverloadName: string;
29
35
  method: Method;
30
- constructor(sig: PeerMethodSignature, originalParentName: string, returnType: IDLType, isCallSignature: boolean, method: Method);
36
+ constructor(sig: PeerMethodSignature, originalParentName: string, returnType: IDLType, isCallSignature: boolean, uniqueOverloadName: string, method: Method);
31
37
  argConvertors(library: PeerLibrary): ArgConvertor[];
32
38
  argAndOutConvertors(library: PeerLibrary): ArgConvertor[];
33
39
  }
@@ -36,9 +36,15 @@ export class PeerMethodSignature {
36
36
  this.context = context;
37
37
  this.modifiers = modifiers;
38
38
  }
39
- static generateOverloadPostfix(decl) {
39
+ static mangleOverloadedName(decl) {
40
40
  if (!decl.parent)
41
- return ``;
41
+ return { postfix: "", };
42
+ let alias;
43
+ let forcedPriority;
44
+ if (idl.hasExtAttribute(decl, idl.IDLExtendedAttributes.OverloadAlias)) {
45
+ alias = idl.getExtAttribute(decl, idl.IDLExtendedAttributes.OverloadAlias);
46
+ forcedPriority = Number.parseInt(idl.getExtAttribute(decl, idl.IDLExtendedAttributes.OverloadPriority));
47
+ }
42
48
  let sameNamed = [];
43
49
  if (idl.isMethod(decl) || idl.isProperty(decl)) {
44
50
  let members = [];
@@ -59,19 +65,31 @@ export class PeerMethodSignature {
59
65
  else {
60
66
  throw new Error("unexpected type of declaration");
61
67
  }
62
- return sameNamed.length > 1 ? sameNamed.indexOf(decl).toString() : '';
68
+ return sameNamed.length > 1 ? {
69
+ postfix: sameNamed.indexOf(decl).toString(),
70
+ alias,
71
+ priority: forcedPriority !== null && forcedPriority !== void 0 ? forcedPriority : sameNamed.indexOf(decl)
72
+ } : {
73
+ postfix: '',
74
+ alias,
75
+ priority: forcedPriority,
76
+ };
63
77
  }
64
78
  static get CTOR() { return "construct"; }
65
79
  static get GET_FINALIZER() { return "getFinalizer"; }
66
80
  static get DESTROY() { return "destroyPeer"; }
67
81
  }
68
82
  export class PeerMethod {
69
- constructor(sig, originalParentName, returnType, isCallSignature, method) {
83
+ constructor(sig, originalParentName, returnType, isCallSignature,
84
+ // arkts specific feature, where overloads - are different functions grouped by overload keyword.
85
+ // Must be moved to interface description as so as `method` field
86
+ uniqueOverloadName, method) {
70
87
  var _a, _b;
71
88
  this.sig = sig;
72
89
  this.originalParentName = originalParentName;
73
90
  this.returnType = returnType;
74
91
  this.isCallSignature = isCallSignature;
92
+ this.uniqueOverloadName = uniqueOverloadName;
75
93
  this.method = method;
76
94
  // todo remove me
77
95
  if ((_a = method.modifiers) === null || _a === void 0 ? void 0 : _a.includes(MethodModifier.FORCE_CONTEXT))
@@ -1,5 +1,6 @@
1
1
  import { generatorConfiguration } from "../config";
2
2
  import * as idl from "../idl";
3
+ const modulesCache = new Map();
3
4
  export function isInModule(nodeOrPackage, module) {
4
5
  if (typeof nodeOrPackage === 'object')
5
6
  return isInModule(idl.getPackageName(nodeOrPackage), module);
@@ -13,14 +14,27 @@ export function getModuleFor(nodeOrPackage) {
13
14
  if (typeof nodeOrPackage === "object")
14
15
  return getModuleFor(idl.getPackageName(nodeOrPackage));
15
16
  const packageName = nodeOrPackage;
17
+ let module = modulesCache.get(packageName);
18
+ if (module)
19
+ return module;
20
+ module = getApplicableModuleFor(packageName);
21
+ modulesCache.set(packageName, module);
22
+ return module;
23
+ }
24
+ function getApplicableModuleFor(packageName) {
16
25
  const config = generatorConfiguration();
17
26
  const applicableModules = [...config.modules.values()].filter(module => isInModule(packageName, module));
18
27
  if (applicableModules.length === 0) {
19
- if (nodeOrPackage === '') {
28
+ if (packageName === '') {
20
29
  console.error("WARNING: use current module for empty package");
21
30
  return currentModule();
22
31
  }
23
- throw new Error(`Package ${packageName} is not listed in any module`);
32
+ if (packageName.startsWith(`idlize.`)) {
33
+ return currentModule();
34
+ }
35
+ const modules = [...config.modules.keys()].map(it => `"${it}"`).join(", ");
36
+ throw new Error(`Package "${packageName}" is not listed in any module.`
37
+ + ` Add the "${packageName}" to the existed list of modules [${modules}] or new one in the configuration file`);
24
38
  }
25
39
  if (applicableModules.length > 1)
26
40
  throw new Error(`Package ${packageName} listed in ${applicableModules.length} packages: ${applicableModules.map(it => it.name).join(", ")}`);
@@ -34,9 +48,10 @@ export function currentModule() {
34
48
  return result;
35
49
  }
36
50
  export function isInCurrentModule(nodeOrPackage) {
37
- if (typeof nodeOrPackage === 'string')
38
- return isInModule(nodeOrPackage, currentModule());
39
- else
40
- return isInModule(nodeOrPackage, currentModule());
51
+ // check the nodeOrPackage belongs to some module
52
+ const module = typeof nodeOrPackage === 'string'
53
+ ? getModuleFor(nodeOrPackage)
54
+ : getModuleFor(nodeOrPackage);
55
+ return generatorConfiguration().moduleName == module.name;
41
56
  }
42
57
  //# sourceMappingURL=modules.js.map
@@ -90,6 +90,7 @@ type StringProperties<T> = {
90
90
  [Property in keyof T as (T[Property] extends string ? Property : never)]: T[Property];
91
91
  };
92
92
  export declare function sorted<T, N extends keyof StringProperties<T>>(array: T[], key: ((value: T) => string) | N): T[];
93
+ export declare function mapLibraryName(node: idl.IDLEntry, lang: Language, mapping?: Map<string, Map<string, string>>, prefix?: string): string;
93
94
  export declare function getExtractor(target: idl.IDLInterface, lang: Language, toPtr?: boolean): {
94
95
  receiver?: string;
95
96
  method: string;
@@ -691,6 +691,11 @@ export function sorted(array, key) {
691
691
  return array.map(it => it)
692
692
  .sort((a, b) => comparator.compare(a[key], b[key]));
693
693
  }
694
+ export function mapLibraryName(node, lang, mapping, prefix = "@") {
695
+ var _a, _b;
696
+ const packageName = idl.getPackageName(node);
697
+ return (_b = (_a = mapping === null || mapping === void 0 ? void 0 : mapping.get(packageName)) === null || _a === void 0 ? void 0 : _a.get(lang.name)) !== null && _b !== void 0 ? _b : `${prefix}${packageName}`;
698
+ }
694
699
  function getExtractorClass(target, toPtr = true) {
695
700
  if (isInExternalModule(target)) {
696
701
  const qualifiedName = idl.getQualifiedName(target, "namespace.name");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idlizer/core",
3
- "version": "2.1.9-arktscgen-8",
3
+ "version": "2.1.10-arktscgen-2",
4
4
  "description": "",
5
5
  "types": "build/lib/src/index.d.ts",
6
6
  "exports": {
@@ -27,18 +27,25 @@
27
27
  "webidl2.js/dist/**/*.js",
28
28
  "webidl2.js/package.json"
29
29
  ],
30
- "type": "module",
31
30
  "engines": {
32
31
  "npm": ">= 8",
33
32
  "node": ">= 18"
34
33
  },
35
34
  "keywords": [],
36
35
  "dependencies": {
37
- "@koalaui/interop": "1.7.6",
36
+ "@koalaui/interop": "1.7.9",
38
37
  "typescript": "4.9.5",
39
38
  "@types/node": "^18.0.0"
40
39
  },
40
+ "devDependencies": {
41
+ "@koalaui/harness": "1.7.6+devel",
42
+ "@koalaui/ets-tsc": "4.9.5-r5",
43
+ "@types/mocha": "^9.1.0",
44
+ "mocha": "^9.2.2",
45
+ "ts-node": "^10.9.2"
46
+ },
41
47
  "scripts": {
48
+ "test": "mocha",
42
49
  "clean": "rimraf -g build",
43
50
  "compile": "tsc -b ."
44
51
  }
@@ -1,24 +0,0 @@
1
- import * as idl from '../../idl';
2
- import { ReferenceResolver } from '../../peer-generation/ReferenceResolver';
3
- import { IdlNameConvertor, NodeConvertor } from '../nameConvertor';
4
- export declare class KotlinTypeNameConvertor implements NodeConvertor<string>, IdlNameConvertor {
5
- protected resolver: ReferenceResolver;
6
- constructor(resolver: ReferenceResolver);
7
- convert(node: idl.IDLNode): string;
8
- convertNamespace(node: idl.IDLNamespace): string;
9
- convertInterface(node: idl.IDLInterface): string;
10
- convertEnum(node: idl.IDLEnum): string;
11
- convertTypedef(node: idl.IDLTypedef): string;
12
- convertCallback(node: idl.IDLCallback): string;
13
- convertMethod(node: idl.IDLMethod): string;
14
- convertConstant(node: idl.IDLConstant): string;
15
- convertOptional(type: idl.IDLOptionalType): string;
16
- convertUnion(type: idl.IDLUnionType): string;
17
- convertContainer(type: idl.IDLContainerType): string;
18
- convertImport(type: idl.IDLImport): string;
19
- convertTypeReferenceAsImport(type: idl.IDLReferenceType, importClause: string): string;
20
- convertTypeReference(type: idl.IDLReferenceType): string;
21
- convertTypeParameter(type: idl.IDLTypeParameterType): string;
22
- convertPrimitiveType(type: idl.IDLPrimitiveType): string;
23
- }
24
- //# sourceMappingURL=KotlinConvertor.d.ts.map
@@ -1,69 +0,0 @@
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
- import { convertNode } from '../nameConvertor';
16
- export class KotlinTypeNameConvertor {
17
- constructor(resolver) {
18
- this.resolver = resolver;
19
- }
20
- convert(node) {
21
- return convertNode(this, node);
22
- }
23
- convertNamespace(node) {
24
- throw new Error("Not implemented");
25
- }
26
- convertInterface(node) {
27
- throw new Error("Not implemented");
28
- }
29
- convertEnum(node) {
30
- throw new Error("Not implemented");
31
- }
32
- convertTypedef(node) {
33
- throw new Error("Not implemented");
34
- }
35
- convertCallback(node) {
36
- throw new Error("Not implemented");
37
- }
38
- convertMethod(node) {
39
- throw new Error("Not implemented");
40
- }
41
- convertConstant(node) {
42
- throw new Error("Not implemented");
43
- }
44
- convertOptional(type) {
45
- throw new Error("Not implemented");
46
- }
47
- convertUnion(type) {
48
- throw new Error("Not implemented");
49
- }
50
- convertContainer(type) {
51
- throw new Error("Not implemented");
52
- }
53
- convertImport(type) {
54
- throw new Error("Not implemented");
55
- }
56
- convertTypeReferenceAsImport(type, importClause) {
57
- throw new Error("Not implemented");
58
- }
59
- convertTypeReference(type) {
60
- throw new Error("Not implemented");
61
- }
62
- convertTypeParameter(type) {
63
- throw new Error("Not implemented");
64
- }
65
- convertPrimitiveType(type) {
66
- throw new Error("Not implemented");
67
- }
68
- }
69
- //# sourceMappingURL=KotlinConvertor.js.map
@@ -1,4 +0,0 @@
1
- import * as idl from '../idl';
2
- import { ReferenceResolver } from './ReferenceResolver';
3
- export declare function isExternalType(declaration: idl.IDLInterface, resolver: ReferenceResolver): boolean;
4
- //# sourceMappingURL=isExternalType.d.ts.map
@@ -1,15 +0,0 @@
1
- import * as idl from '../idl';
2
- import { generatorConfiguration } from '../config';
3
- export function isExternalType(declaration, resolver) {
4
- // declarations outside of the generator input dirs
5
- if (generatorConfiguration().externalTypes.get(declaration.name) != undefined)
6
- return true;
7
- // treat as external types only declarations with methods
8
- if (declaration.methods.length == 0)
9
- return false;
10
- const pack = idl.getPackageName(declaration);
11
- if (generatorConfiguration().externalPackages.includes(pack))
12
- return true;
13
- return false;
14
- }
15
- //# sourceMappingURL=isExternalType.js.map