@idlizer/core 2.0.26 → 2.0.28

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 (46) hide show
  1. package/build/lib/src/LanguageWriters/ArgConvertors.d.ts +1 -1
  2. package/build/lib/src/LanguageWriters/ArgConvertors.js +7 -7
  3. package/build/lib/src/LanguageWriters/LanguageWriter.d.ts +4 -3
  4. package/build/lib/src/LanguageWriters/LanguageWriter.js +10 -5
  5. package/build/lib/src/LanguageWriters/convertors/CppConvertors.d.ts +45 -5
  6. package/build/lib/src/LanguageWriters/convertors/CppConvertors.js +200 -9
  7. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.d.ts +4 -35
  8. package/build/lib/src/LanguageWriters/convertors/InteropConvertors.js +24 -169
  9. package/build/lib/src/LanguageWriters/convertors/JavaConvertors.js +1 -0
  10. package/build/lib/src/LanguageWriters/convertors/TSConvertors.js +2 -0
  11. package/build/lib/src/LanguageWriters/index.js +3 -3
  12. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.d.ts +4 -1
  13. package/build/lib/src/LanguageWriters/writers/CJLanguageWriter.js +13 -9
  14. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.d.ts +1 -1
  15. package/build/lib/src/LanguageWriters/writers/CppLanguageWriter.js +7 -3
  16. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.d.ts +1 -1
  17. package/build/lib/src/LanguageWriters/writers/TsLanguageWriter.js +2 -2
  18. package/build/lib/src/LibraryInterface.d.ts +1 -0
  19. package/build/lib/src/config.d.ts +13 -16
  20. package/build/lib/src/config.js +13 -17
  21. package/build/lib/src/idl.d.ts +1 -1
  22. package/build/lib/src/idl.js +4 -19
  23. package/build/lib/src/index.d.ts +2 -0
  24. package/build/lib/src/index.js +2 -0
  25. package/build/lib/src/inheritance.js +2 -2
  26. package/build/lib/src/languageSpecificKeywords.js +1 -1
  27. package/build/lib/src/library.d.ts +5 -4
  28. package/build/lib/src/library.js +3 -0
  29. package/build/lib/src/peer-generation/BuilderClass.js +1 -1
  30. package/build/lib/src/peer-generation/LayoutManager.d.ts +2 -1
  31. package/build/lib/src/peer-generation/LayoutManager.js +1 -0
  32. package/build/lib/src/peer-generation/Materialized.d.ts +0 -1
  33. package/build/lib/src/peer-generation/Materialized.js +3 -48
  34. package/build/lib/src/peer-generation/PeerFile.d.ts +1 -0
  35. package/build/lib/src/peer-generation/PeerFile.js +4 -1
  36. package/build/lib/src/peer-generation/PeerLibrary.d.ts +10246 -2
  37. package/build/lib/src/peer-generation/PeerLibrary.js +48 -10
  38. package/build/lib/src/peer-generation/PrimitiveType.d.ts +1 -0
  39. package/build/lib/src/peer-generation/PrimitiveType.js +1 -0
  40. package/build/lib/src/peer-generation/isMaterialized.d.ts +4 -0
  41. package/build/lib/src/peer-generation/isMaterialized.js +46 -0
  42. package/build/lib/src/peer-generation/isStructureType.d.ts +4 -0
  43. package/build/lib/src/peer-generation/isStructureType.js +25 -0
  44. package/build/lib/src/peer-generation/unions.d.ts +1 -1
  45. package/build/lib/src/peer-generation/unions.js +14 -3
  46. package/package.json +2 -2
@@ -236,7 +236,7 @@ export declare class TypeAliasConvertor extends ProxyConvertor {
236
236
  export declare class CustomTypeConvertor extends BaseArgConvertor {
237
237
  readonly customTypeName: string;
238
238
  private readonly isGenericType;
239
- constructor(param: string, customTypeName: string, isGenericType?: boolean, tsType?: string);
239
+ constructor(param: string, customTypeName: string, isGenericType: boolean, tsType: string);
240
240
  convertorArg(param: string, writer: LanguageWriter): string;
241
241
  /** todo: check */
242
242
  convertorSerialize(param: string, value: string, printer: LanguageWriter): void;
@@ -19,9 +19,9 @@ import { RuntimeType } from "./common";
19
19
  import { generatorTypePrefix } from "../config";
20
20
  import { hashCodeFromString, warn } from "../util";
21
21
  import { UnionRuntimeTypeChecker } from "../peer-generation/unions";
22
- import { InteropNameConvertor } from "./convertors/InteropConvertors";
22
+ import { CppNameConvertor } from "./convertors/CppConvertors";
23
23
  import { createEmptyReferenceResolver } from "../peer-generation/ReferenceResolver";
24
- import { CppInteropConvertor } from "./convertors/CppConvertors";
24
+ import { CppConvertor } from "./convertors/CppConvertors";
25
25
  import { PrimitiveTypesInstance } from "../peer-generation/PrimitiveType";
26
26
  export class BaseArgConvertor {
27
27
  constructor(idlType, runtimeTypes, isScoped, useArray, param) {
@@ -221,7 +221,7 @@ export class NumericConvertor extends BaseArgConvertor {
221
221
  constructor(param, type) {
222
222
  // check numericPrimitiveTypes.include(type)
223
223
  super(type, [RuntimeType.NUMBER], false, false, param);
224
- this.interopNameConvertor = new InteropNameConvertor(createEmptyReferenceResolver());
224
+ this.interopNameConvertor = new CppNameConvertor(createEmptyReferenceResolver());
225
225
  }
226
226
  convertorArg(param, writer) {
227
227
  return param;
@@ -672,11 +672,11 @@ export class TypeAliasConvertor extends ProxyConvertor {
672
672
  }
673
673
  }
674
674
  export class CustomTypeConvertor extends BaseArgConvertor {
675
- constructor(param, customTypeName, isGenericType = false, tsType) {
675
+ constructor(param, customTypeName, isGenericType, tsType) {
676
676
  super(idl.createReferenceType(tsType !== null && tsType !== void 0 ? tsType : "Object"), [RuntimeType.OBJECT], false, true, param);
677
677
  this.customTypeName = customTypeName;
678
678
  this.isGenericType = isGenericType;
679
- warnCustomObject(`${tsType}`);
679
+ warnCustomObject(`${customTypeName}: ${tsType}`);
680
680
  }
681
681
  convertorArg(param, writer) {
682
682
  throw new Error("Must never be used");
@@ -811,7 +811,7 @@ export class UnionConvertor extends BaseArgConvertor {
811
811
  printer.popIndent();
812
812
  printer.print(`}`);
813
813
  });
814
- this.unionChecker.reportConflicts((_a = this.library.getCurrentContext()) !== null && _a !== void 0 ? _a : "<unknown context>");
814
+ this.unionChecker.reportConflicts((_a = this.library.getCurrentContext()) !== null && _a !== void 0 ? _a : "<unknown context>", printer);
815
815
  }
816
816
  convertorDeserialize(bufferName, deserializerName, assigneer, writer) {
817
817
  const statements = [];
@@ -1028,7 +1028,7 @@ export function generateCallbackKindValue(callback) {
1028
1028
  return hashCodeFromString(name);
1029
1029
  }
1030
1030
  export function generateCallbackAPIArguments(library, callback) {
1031
- const nameConvertor = new CppInteropConvertor(library);
1031
+ const nameConvertor = new CppConvertor(library);
1032
1032
  const args = [`const ${PrimitiveTypesInstance.Int32.getText()} resourceId`];
1033
1033
  args.push(...callback.parameters.map(it => {
1034
1034
  const target = library.toDeclaration(it.type);
@@ -212,9 +212,10 @@ export interface PrinterLike {
212
212
  }
213
213
  export declare abstract class LanguageWriter {
214
214
  printer: IndentedPrinter;
215
- protected resolver: ReferenceResolver;
215
+ resolver: ReferenceResolver;
216
216
  language: Language;
217
- constructor(printer: IndentedPrinter, resolver: ReferenceResolver, language: Language);
217
+ constructor(printer: IndentedPrinter, resolver: ReferenceResolver, // TODO make protected again
218
+ language: Language);
218
219
  indentDepth(): number;
219
220
  maybeSemicolon(): string;
220
221
  abstract writeClass(name: string, op: (writer: this) => void, superClass?: string, interfaces?: string[], generics?: string[], isDeclared?: boolean, isExport?: boolean): void;
@@ -319,7 +320,7 @@ export declare abstract class LanguageWriter {
319
320
  makeSignature(returnType: idl.IDLType, parameters: idl.IDLParameter[]): MethodSignature;
320
321
  makeNamedSignature(returnType: idl.IDLType, parameters: idl.IDLParameter[]): NamedMethodSignature;
321
322
  makeNativeMethodNamedSignature(returnType: idl.IDLType, parameters: idl.IDLParameter[]): NamedMethodSignature;
322
- makeSerializerConstructorSignature(): NamedMethodSignature | undefined;
323
+ makeSerializerConstructorSignatures(): NamedMethodSignature[] | undefined;
323
324
  mapFieldModifier(modifier: FieldModifier): string;
324
325
  mapMethodModifier(modifier: MethodModifier): string;
325
326
  /**
@@ -13,6 +13,7 @@
13
13
  * limitations under the License.
14
14
  */
15
15
  import * as idl from "../idl";
16
+ import { indentedBy } from "../util";
16
17
  import * as fs from "fs";
17
18
  import { RuntimeType } from "./common";
18
19
  export class TernaryExpression {
@@ -31,6 +32,8 @@ export class NaryOpExpression {
31
32
  this.args = args;
32
33
  }
33
34
  asString() {
35
+ if (this.args.length === 1)
36
+ return this.args[0].asString();
34
37
  return `${this.args.map(arg => `(${arg.asString()})`).join(` ${this.op} `)}`;
35
38
  }
36
39
  }
@@ -275,16 +278,17 @@ export class LambdaExpression {
275
278
  this.body = body;
276
279
  }
277
280
  bodyAsString() {
281
+ var _a;
278
282
  const writer = this.originalWriter.fork();
279
283
  if (this.body) {
280
284
  for (const stmt of this.body) {
281
285
  stmt.write(writer);
282
286
  }
283
287
  }
284
- return writer.getOutput()
288
+ return (this.body ? ((_a = this.body) === null || _a === void 0 ? void 0 : _a.length) > 1 ? '\n' : '' : '').concat(writer.getOutput()
285
289
  .filter(line => line !== "")
286
- .map(line => line.endsWith('{') || line.endsWith('}') || line.endsWith(';') ? line : `${line};`)
287
- .join("\n");
290
+ .map(line => indentedBy(line.endsWith('{') || line.endsWith('}') || line.endsWith(';') ? line : `${line};`, 1))
291
+ .join("\n"));
288
292
  }
289
293
  }
290
294
  ////////////////////////////////////////////////////////////////
@@ -387,7 +391,8 @@ export class NamedMethodSignature extends MethodSignature {
387
391
  // LANGUAGE WRITER //
388
392
  ////////////////////////////////////////////////////////////////
389
393
  export class LanguageWriter {
390
- constructor(printer, resolver, language) {
394
+ constructor(printer, resolver, // TODO make protected again
395
+ language) {
391
396
  this.printer = printer;
392
397
  this.resolver = resolver;
393
398
  this.language = language;
@@ -588,7 +593,7 @@ export class LanguageWriter {
588
593
  makeNativeMethodNamedSignature(returnType, parameters) {
589
594
  return this.makeNamedSignature(returnType, parameters);
590
595
  }
591
- makeSerializerConstructorSignature() {
596
+ makeSerializerConstructorSignatures() {
592
597
  return undefined;
593
598
  }
594
599
  mapFieldModifier(modifier) {
@@ -1,20 +1,60 @@
1
1
  import * as idl from '../../idl';
2
- import { IdlNameConvertor } from "../nameConvertor";
3
- import { InteropConvertor, InteropReturnTypeConvertor } from './InteropConvertors';
2
+ import { IdlNameConvertor, NodeConvertor, TypeConvertor } from "../nameConvertor";
4
3
  import { InteropArgConvertor } from './InteropConvertors';
5
4
  import { ReferenceResolver } from '../../peer-generation/ReferenceResolver';
6
- export declare class CppInteropConvertor extends InteropConvertor implements IdlNameConvertor {
5
+ export interface ConvertResult {
6
+ text: string;
7
+ noPrefix: boolean;
8
+ }
9
+ export declare class GenericCppConvertor implements NodeConvertor<ConvertResult> {
10
+ protected resolver: ReferenceResolver;
11
+ constructor(resolver: ReferenceResolver);
12
+ private make;
13
+ convertNode(node: idl.IDLNode): ConvertResult;
14
+ convertNamespace(node: idl.IDLNamespace): ConvertResult;
15
+ convertInterface(node: idl.IDLInterface): ConvertResult;
16
+ convertEnum(node: idl.IDLEnum): ConvertResult;
17
+ convertTypedef(node: idl.IDLTypedef): ConvertResult;
18
+ convertCallback(node: idl.IDLCallback): ConvertResult;
19
+ convertMethod(node: idl.IDLMethod): ConvertResult;
20
+ convertConstant(node: idl.IDLConstant): ConvertResult;
21
+ convertOptional(type: idl.IDLOptionalType): ConvertResult;
22
+ convertUnion(type: idl.IDLUnionType): ConvertResult;
23
+ convertContainer(type: idl.IDLContainerType): ConvertResult;
24
+ convertImport(type: idl.IDLReferenceType, _: string): ConvertResult;
25
+ convertTypeReference(type: idl.IDLReferenceType): ConvertResult;
26
+ convertTypeParameter(type: idl.IDLTypeParameterType): ConvertResult;
27
+ convertPrimitiveType(type: idl.IDLPrimitiveType): ConvertResult;
28
+ private enumName;
29
+ private computeTargetTypeLiteralName;
30
+ }
31
+ export declare class CppConvertor extends GenericCppConvertor implements IdlNameConvertor {
7
32
  private unwrap;
8
33
  convert(node: idl.IDLNode): string;
9
34
  }
35
+ export declare class CppNameConvertor implements IdlNameConvertor {
36
+ protected resolver: ReferenceResolver;
37
+ private readonly cppConvertor;
38
+ constructor(resolver: ReferenceResolver);
39
+ convert(node: idl.IDLNode): string;
40
+ }
10
41
  export declare class CppInteropArgConvertor extends InteropArgConvertor {
11
42
  static INSTANCE: CppInteropArgConvertor;
12
43
  convertOptional(type: idl.IDLOptionalType): string;
13
44
  convertPrimitiveType(type: idl.IDLPrimitiveType): string;
14
45
  }
15
- export declare class CppReturnTypeConvertor extends InteropReturnTypeConvertor {
16
- protected resolver: ReferenceResolver;
46
+ export declare class CppReturnTypeConvertor implements TypeConvertor<string> {
47
+ private resolver;
48
+ private convertor;
17
49
  constructor(resolver: ReferenceResolver);
50
+ isVoid(returnType: idl.IDLType): boolean;
51
+ convert(type: idl.IDLType): string;
52
+ convertContainer(type: idl.IDLContainerType): string;
53
+ convertImport(type: idl.IDLReferenceType, importClause: string): string;
54
+ convertOptional(type: idl.IDLOptionalType): string;
55
+ convertPrimitiveType(type: idl.IDLPrimitiveType): string;
56
+ convertTypeParameter(type: idl.IDLTypeParameterType): string;
18
57
  convertTypeReference(type: idl.IDLReferenceType): string;
58
+ convertUnion(type: idl.IDLUnionType): string;
19
59
  }
20
60
  //# sourceMappingURL=CppConvertors.d.ts.map
@@ -14,11 +14,159 @@
14
14
  */
15
15
  import * as idl from '../../idl';
16
16
  import { generatorConfiguration } from "../../config";
17
- import { InteropConvertor, InteropReturnTypeConvertor } from './InteropConvertors';
17
+ import { convertNode, convertType } from "../nameConvertor";
18
18
  import { PrimitiveTypesInstance } from '../../peer-generation/PrimitiveType';
19
19
  import { InteropArgConvertor } from './InteropConvertors';
20
- import { isMaterialized } from '../../peer-generation/Materialized';
21
- export class CppInteropConvertor extends InteropConvertor {
20
+ import { maybeTransformManagedCallback } from '../ArgConvertors';
21
+ import { qualifiedName } from '../../peer-generation/idl/common';
22
+ import { capitalize } from '../../util';
23
+ import { isMaterialized } from '../../peer-generation/isMaterialized';
24
+ export class GenericCppConvertor {
25
+ constructor(resolver) {
26
+ this.resolver = resolver;
27
+ }
28
+ make(text, noPrefix = false) {
29
+ return { text, noPrefix };
30
+ }
31
+ convertNode(node) {
32
+ return convertNode(this, node);
33
+ }
34
+ convertNamespace(node) {
35
+ throw new Error("Internal error: namespaces are not allowed on the interop layer");
36
+ }
37
+ convertInterface(node) {
38
+ switch (node.subkind) {
39
+ case idl.IDLInterfaceSubkind.AnonymousInterface:
40
+ return node.name
41
+ ? this.make(node.name)
42
+ : this.make(this.computeTargetTypeLiteralName(node), true);
43
+ case idl.IDLInterfaceSubkind.Interface:
44
+ case idl.IDLInterfaceSubkind.Class:
45
+ if (idl.hasExtAttribute(node, idl.IDLExtendedAttributes.Predefined)) {
46
+ return this.make(node.name, true);
47
+ }
48
+ return this.make(node.name);
49
+ case idl.IDLInterfaceSubkind.Tuple:
50
+ return node.name
51
+ ? this.make(node.name)
52
+ : this.make(`Tuple_${node.properties.map(it => this.convertNode(idl.maybeOptional(it.type, it.isOptional)).text).join("_")}`, true);
53
+ }
54
+ }
55
+ convertEnum(node) {
56
+ return this.make(this.enumName(node));
57
+ }
58
+ convertTypedef(node) {
59
+ return this.make(node.name);
60
+ }
61
+ convertCallback(node) {
62
+ return this.make(generatorConfiguration().LibraryPrefix + node.name, true);
63
+ }
64
+ convertMethod(node) {
65
+ return this.make(node.name);
66
+ }
67
+ convertConstant(node) {
68
+ return this.make(node.name);
69
+ }
70
+ /////////////////////////////////////////////////////////////////////////////////////////
71
+ convertOptional(type) {
72
+ return this.convertNode(type.type);
73
+ }
74
+ convertUnion(type) {
75
+ return this.make(type.name, false);
76
+ }
77
+ convertContainer(type) {
78
+ if (idl.IDLContainerUtils.isPromise(type)) {
79
+ return this.make(`Promise_${this.convertNode(type.elementType[0]).text}`);
80
+ }
81
+ if (idl.IDLContainerUtils.isSequence(type)) {
82
+ if (type.elementType[0] === idl.IDLU8Type) {
83
+ return this.make(`uint8_t*`, true);
84
+ }
85
+ return this.make(`Array_${this.convertNode(type.elementType[0]).text}`, true);
86
+ }
87
+ if (idl.IDLContainerUtils.isRecord(type)) {
88
+ return this.make(`Map_${this.convertNode(type.elementType[0]).text}_${this.convertNode(type.elementType[1]).text}`, true);
89
+ }
90
+ throw new Error(`Unmapped container type ${idl.DebugUtils.debugPrintType(type)}`);
91
+ }
92
+ convertImport(type, _) {
93
+ return this.make(idl.IDLCustomObjectType.name);
94
+ }
95
+ convertTypeReference(type) {
96
+ var _a;
97
+ const refName = type.name;
98
+ switch (refName) {
99
+ case "object":
100
+ case "Object":
101
+ return this.make('CustomObject');
102
+ }
103
+ if (generatorConfiguration().parameterized.includes(refName)) {
104
+ return this.make('CustomObject');
105
+ }
106
+ let decl = this.resolver.toDeclaration(type);
107
+ if (idl.isCallback(decl)) {
108
+ decl = (_a = maybeTransformManagedCallback(decl)) !== null && _a !== void 0 ? _a : decl;
109
+ }
110
+ if (idl.isType(decl)) {
111
+ if (idl.isReferenceType(decl)) {
112
+ return this.make(`${capitalize(decl.name)}`);
113
+ }
114
+ return this.convertNode(decl);
115
+ }
116
+ let res = this.convertNode(decl);
117
+ if (type.name === "Optional")
118
+ res = this.make("Opt_" + res.text, true);
119
+ return res;
120
+ }
121
+ convertTypeParameter(type) {
122
+ return this.make('CustomObject');
123
+ }
124
+ convertPrimitiveType(type) {
125
+ switch (type) {
126
+ case idl.IDLVoidType: return this.make('void', true);
127
+ case idl.IDLI8Type: return this.make(`Int8`);
128
+ case idl.IDLU8Type: return this.make(`UInt8`);
129
+ case idl.IDLI16Type: return this.make(`Int16`);
130
+ case idl.IDLU16Type: return this.make(`UInt16`);
131
+ case idl.IDLI32Type: return this.make(`Int32`);
132
+ case idl.IDLU32Type: return this.make(`UInt32`);
133
+ case idl.IDLI64Type: return this.make(`Int64`);
134
+ case idl.IDLU64Type: return this.make(`UInt64`);
135
+ case idl.IDLF32Type: return this.make(`Float32`);
136
+ case idl.IDLF64Type: return this.make(`Float64`);
137
+ case idl.IDLNumberType: return this.make(`Number`);
138
+ case idl.IDLStringType: return this.make(`String`);
139
+ case idl.IDLBooleanType: return this.make(`Boolean`);
140
+ case idl.IDLBigintType: return this.make(`UInt64`); // TODO add arbitrary precision numeric type
141
+ case idl.IDLPointerType: return this.make('NativePointer');
142
+ case idl.IDLUnknownType:
143
+ case idl.IDLCustomObjectType:
144
+ case idl.IDLAnyType: return this.make(`CustomObject`);
145
+ case idl.IDLUndefinedType: return this.make(`Undefined`);
146
+ case idl.IDLLengthType: return this.make(`Length`);
147
+ case idl.IDLFunctionType: return this.make(`Function`);
148
+ case idl.IDLDate: return this.make(`Date`);
149
+ case idl.IDLBufferType: return this.make('Buffer');
150
+ case idl.IDLPointerType: return this.make('Pointer');
151
+ }
152
+ throw new Error(`Unmapped primitive type ${idl.DebugUtils.debugPrintType(type)}`);
153
+ }
154
+ enumName(target) {
155
+ return qualifiedName(target, "_");
156
+ }
157
+ computeTargetTypeLiteralName(decl) {
158
+ const map = new Map();
159
+ for (const prop of decl.properties) {
160
+ const type = this.convertNode(prop.type);
161
+ const values = map.has(type.text) ? map.get(type.text) : [];
162
+ values.push(prop.name);
163
+ map.set(type.text, values);
164
+ }
165
+ const names = Array.from(map.keys()).map(key => `${key}_${map.get(key).join('_')}`);
166
+ return `Literal_${names.join('_')}`;
167
+ }
168
+ }
169
+ export class CppConvertor extends GenericCppConvertor {
22
170
  unwrap(type, result) {
23
171
  const conf = generatorConfiguration();
24
172
  if (idl.isType(type) && idl.isOptionalType(type)) {
@@ -37,6 +185,15 @@ export class CppInteropConvertor extends InteropConvertor {
37
185
  return this.unwrap(node, this.convertNode(node));
38
186
  }
39
187
  }
188
+ export class CppNameConvertor {
189
+ constructor(resolver) {
190
+ this.resolver = resolver;
191
+ this.cppConvertor = new GenericCppConvertor(resolver);
192
+ }
193
+ convert(node) {
194
+ return this.cppConvertor.convertNode(node).text;
195
+ }
196
+ }
40
197
  export class CppInteropArgConvertor extends InteropArgConvertor {
41
198
  convertOptional(type) {
42
199
  return PrimitiveTypesInstance.NativePointer.getText();
@@ -56,16 +213,50 @@ export class CppInteropArgConvertor extends InteropArgConvertor {
56
213
  }
57
214
  }
58
215
  CppInteropArgConvertor.INSTANCE = new CppInteropArgConvertor();
59
- export class CppReturnTypeConvertor extends InteropReturnTypeConvertor {
216
+ export class CppReturnTypeConvertor {
60
217
  constructor(resolver) {
61
- super();
62
218
  this.resolver = resolver;
219
+ this.convertor = new CppConvertor(resolver);
220
+ }
221
+ isVoid(returnType) {
222
+ return this.convert(returnType) == 'void';
223
+ }
224
+ convert(type) {
225
+ return convertType(this, type);
226
+ }
227
+ convertContainer(type) {
228
+ // Promise return is done as CPS callback, thus return type is void.
229
+ if (idl.IDLContainerUtils.isPromise(type))
230
+ return 'void';
231
+ return this.convertor.convert(type);
232
+ }
233
+ convertImport(type, importClause) {
234
+ return this.convertor.convert(type);
235
+ }
236
+ convertOptional(type) {
237
+ return this.convertor.convert(type);
238
+ }
239
+ convertPrimitiveType(type) {
240
+ if (type == idl.IDLUndefinedType)
241
+ return 'void';
242
+ if (type == idl.IDLStringType)
243
+ return 'void';
244
+ if (type == idl.IDLNumberType)
245
+ return generatorConfiguration().TypePrefix + 'Int32'; // :(
246
+ return this.convertor.convert(type);
247
+ }
248
+ convertTypeParameter(type) {
249
+ return this.convertor.convert(type);
63
250
  }
64
251
  convertTypeReference(type) {
65
- const resolved = this.resolver.resolveTypeReference(type);
66
- if (resolved && idl.isInterface(resolved) && isMaterialized(resolved, this.resolver))
67
- return generatorConfiguration().param("TypePrefix") + type.name;
68
- return super.convertTypeReference(type);
252
+ const decl = this.resolver.resolveTypeReference(type);
253
+ if (decl && idl.isInterface(decl) && isMaterialized(decl, this.resolver)) {
254
+ return generatorConfiguration().TypePrefix + decl.name;
255
+ }
256
+ return this.convertor.convert(type);
257
+ }
258
+ convertUnion(type) {
259
+ return this.convertor.convert(type);
69
260
  }
70
261
  }
71
262
  //# sourceMappingURL=CppConvertors.js.map
@@ -1,43 +1,12 @@
1
1
  import * as idl from '../../idl';
2
2
  import { PeerMethod } from '../../peer-generation/PeerMethod';
3
3
  import { ReferenceResolver } from '../../peer-generation/ReferenceResolver';
4
- import { IdlNameConvertor, NodeConvertor, TypeConvertor } from '../nameConvertor';
5
- export interface ConvertResult {
6
- text: string;
7
- noPrefix: boolean;
8
- }
9
- export declare class InteropConvertor implements NodeConvertor<ConvertResult> {
10
- protected resolver: ReferenceResolver;
11
- constructor(resolver: ReferenceResolver);
12
- private make;
13
- convertNode(node: idl.IDLNode): ConvertResult;
14
- convertNamespace(node: idl.IDLNamespace): ConvertResult;
15
- convertInterface(node: idl.IDLInterface): ConvertResult;
16
- convertEnum(node: idl.IDLEnum): ConvertResult;
17
- convertTypedef(node: idl.IDLTypedef): ConvertResult;
18
- convertCallback(node: idl.IDLCallback): ConvertResult;
19
- convertMethod(node: idl.IDLMethod): ConvertResult;
20
- convertConstant(node: idl.IDLConstant): ConvertResult;
21
- convertOptional(type: idl.IDLOptionalType): ConvertResult;
22
- convertUnion(type: idl.IDLUnionType): ConvertResult;
23
- convertContainer(type: idl.IDLContainerType): ConvertResult;
24
- convertImport(type: idl.IDLReferenceType, _: string): ConvertResult;
25
- convertTypeReference(type: idl.IDLReferenceType): ConvertResult;
26
- convertTypeParameter(type: idl.IDLTypeParameterType): ConvertResult;
27
- convertPrimitiveType(type: idl.IDLPrimitiveType): ConvertResult;
28
- private enumName;
29
- private computeTargetTypeLiteralName;
30
- }
31
- export declare class InteropNameConvertor implements IdlNameConvertor {
32
- protected resolver: ReferenceResolver;
33
- private readonly interopConvertor;
34
- constructor(resolver: ReferenceResolver);
35
- convert(node: idl.IDLNode): string;
36
- }
4
+ import { TypeConvertor } from '../nameConvertor';
37
5
  export declare class InteropReturnTypeConvertor implements TypeConvertor<string> {
38
- protected readonly resolver?: ReferenceResolver | undefined;
39
- constructor(resolver?: ReferenceResolver | undefined);
6
+ protected readonly resolver: ReferenceResolver;
7
+ constructor(resolver: ReferenceResolver);
40
8
  isVoid(method: PeerMethod): boolean;
9
+ isReturnInteropBuffer(type: idl.IDLType): boolean;
41
10
  convert(type: idl.IDLType): string;
42
11
  convertContainer(type: idl.IDLContainerType): string;
43
12
  convertImport(type: idl.IDLReferenceType, importClause: string): string;