@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
@@ -12,167 +12,11 @@
12
12
  * See the License for the specific language governing permissions and
13
13
  * limitations under the License.
14
14
  */
15
- import { generatorConfiguration } from '../../config';
16
15
  import * as idl from '../../idl';
17
- import { qualifiedName } from '../../peer-generation/idl/common';
16
+ import { isMaterialized } from '../../peer-generation/isMaterialized';
18
17
  import { PrimitiveTypesInstance } from '../../peer-generation/PrimitiveType';
19
- import { capitalize } from '../../util';
20
- import { maybeTransformManagedCallback } from '../ArgConvertors';
21
- import { convertNode, convertType } from '../nameConvertor';
22
- export class InteropConvertor {
23
- constructor(resolver) {
24
- this.resolver = resolver;
25
- }
26
- make(text, noPrefix = false) {
27
- return { text, noPrefix };
28
- }
29
- convertNode(node) {
30
- return convertNode(this, node);
31
- }
32
- convertNamespace(node) {
33
- throw new Error("Internal error: namespaces are not allowed on the interop layer");
34
- }
35
- convertInterface(node) {
36
- switch (node.subkind) {
37
- case idl.IDLInterfaceSubkind.AnonymousInterface:
38
- return node.name
39
- ? this.make(node.name)
40
- : this.make(this.computeTargetTypeLiteralName(node), true);
41
- case idl.IDLInterfaceSubkind.Interface:
42
- case idl.IDLInterfaceSubkind.Class:
43
- if (idl.hasExtAttribute(node, idl.IDLExtendedAttributes.Predefined)) {
44
- return this.make(node.name, true);
45
- }
46
- return this.make(node.name);
47
- case idl.IDLInterfaceSubkind.Tuple:
48
- return node.name
49
- ? this.make(node.name)
50
- : this.make(`Tuple_${node.properties.map(it => this.convertNode(idl.maybeOptional(it.type, it.isOptional)).text).join("_")}`, true);
51
- }
52
- }
53
- convertEnum(node) {
54
- return this.make(this.enumName(node));
55
- }
56
- convertTypedef(node) {
57
- return this.make(node.name);
58
- }
59
- convertCallback(node) {
60
- return this.make(generatorConfiguration().LibraryPrefix + node.name, true);
61
- }
62
- convertMethod(node) {
63
- return this.make(node.name);
64
- }
65
- convertConstant(node) {
66
- return this.make(node.name);
67
- }
68
- /////////////////////////////////////////////////////////////////////////////////////////
69
- convertOptional(type) {
70
- return this.convertNode(type.type);
71
- }
72
- convertUnion(type) {
73
- return this.make(type.name, false);
74
- }
75
- convertContainer(type) {
76
- if (idl.IDLContainerUtils.isPromise(type)) {
77
- return this.make(`Promise_${this.convertNode(type.elementType[0]).text}`);
78
- }
79
- if (idl.IDLContainerUtils.isSequence(type)) {
80
- if (type.elementType[0] === idl.IDLU8Type) {
81
- return this.make(`uint8_t*`, true);
82
- }
83
- return this.make(`Array_${this.convertNode(type.elementType[0]).text}`, true);
84
- }
85
- if (idl.IDLContainerUtils.isRecord(type)) {
86
- return this.make(`Map_${this.convertNode(type.elementType[0]).text}_${this.convertNode(type.elementType[1]).text}`, true);
87
- }
88
- throw new Error(`Unmapped container type ${idl.DebugUtils.debugPrintType(type)}`);
89
- }
90
- convertImport(type, _) {
91
- return this.make(idl.IDLCustomObjectType.name);
92
- }
93
- convertTypeReference(type) {
94
- var _a;
95
- const refName = type.name;
96
- switch (refName) {
97
- case "object":
98
- case "Object":
99
- return this.make('CustomObject');
100
- }
101
- if (generatorConfiguration().param("parameterized").includes(refName)) {
102
- return this.make('CustomObject');
103
- }
104
- let decl = this.resolver.toDeclaration(type);
105
- if (idl.isCallback(decl)) {
106
- decl = (_a = maybeTransformManagedCallback(decl)) !== null && _a !== void 0 ? _a : decl;
107
- }
108
- if (idl.isType(decl)) {
109
- if (idl.isReferenceType(decl)) {
110
- return this.make(`${capitalize(decl.name)}`);
111
- }
112
- return this.convertNode(decl);
113
- }
114
- let res = this.convertNode(decl);
115
- if (type.name === "Optional")
116
- res = this.make("Opt_" + res.text, true);
117
- return res;
118
- }
119
- convertTypeParameter(type) {
120
- return this.make('CustomObject');
121
- }
122
- convertPrimitiveType(type) {
123
- switch (type) {
124
- case idl.IDLVoidType: return this.make('void', true);
125
- case idl.IDLI8Type: return this.make(`Int8`);
126
- case idl.IDLU8Type: return this.make(`UInt8`);
127
- case idl.IDLI16Type: return this.make(`Int16`);
128
- case idl.IDLU16Type: return this.make(`UInt16`);
129
- case idl.IDLI32Type: return this.make(`Int32`);
130
- case idl.IDLU32Type: return this.make(`UInt32`);
131
- case idl.IDLI64Type: return this.make(`Int64`);
132
- case idl.IDLU64Type: return this.make(`UInt64`);
133
- case idl.IDLF32Type: return this.make(`Float32`);
134
- case idl.IDLF64Type: return this.make(`Float64`);
135
- case idl.IDLNumberType: return this.make(`Number`);
136
- case idl.IDLStringType: return this.make(`String`);
137
- case idl.IDLBooleanType: return this.make(`Boolean`);
138
- case idl.IDLBigintType: return this.make(`UInt64`); // TODO add arbitrary precision numeric type
139
- case idl.IDLPointerType: return this.make('NativePointer');
140
- case idl.IDLUnknownType:
141
- case idl.IDLCustomObjectType:
142
- case idl.IDLAnyType: return this.make(`CustomObject`);
143
- case idl.IDLUndefinedType: return this.make(`Undefined`);
144
- case idl.IDLLengthType: return this.make(`Length`);
145
- case idl.IDLFunctionType: return this.make(`Function`);
146
- case idl.IDLDate: return this.make(`Date`);
147
- case idl.IDLBufferType: return this.make('Buffer');
148
- case idl.IDLPointerType: return this.make('Pointer');
149
- }
150
- throw new Error(`Unmapped primitive type ${idl.DebugUtils.debugPrintType(type)}`);
151
- }
152
- enumName(target) {
153
- return qualifiedName(target, "_");
154
- }
155
- computeTargetTypeLiteralName(decl) {
156
- const map = new Map();
157
- for (const prop of decl.properties) {
158
- const type = this.convertNode(prop.type);
159
- const values = map.has(type.text) ? map.get(type.text) : [];
160
- values.push(prop.name);
161
- map.set(type.text, values);
162
- }
163
- const names = Array.from(map.keys()).map(key => `${key}_${map.get(key).join('_')}`);
164
- return `Literal_${names.join('_')}`;
165
- }
166
- }
167
- export class InteropNameConvertor {
168
- constructor(resolver) {
169
- this.resolver = resolver;
170
- this.interopConvertor = new InteropConvertor(resolver);
171
- }
172
- convert(node) {
173
- return this.interopConvertor.convertNode(node).text;
174
- }
175
- }
18
+ import { convertType } from '../nameConvertor';
19
+ const KInteropReturnBuffer = 'KInteropReturnBuffer';
176
20
  export class InteropReturnTypeConvertor {
177
21
  constructor(resolver) {
178
22
  this.resolver = resolver;
@@ -180,22 +24,24 @@ export class InteropReturnTypeConvertor {
180
24
  isVoid(method) {
181
25
  return this.convert(method.returnType) === idl.IDLVoidType.name;
182
26
  }
27
+ isReturnInteropBuffer(type) {
28
+ return this.convert(type) === KInteropReturnBuffer;
29
+ }
183
30
  convert(type) {
184
31
  return convertType(this, type);
185
32
  }
186
33
  convertContainer(type) {
187
- if (idl.IDLContainerUtils.isSequence(type) || idl.IDLContainerUtils.isPromise(type)) {
34
+ if (idl.IDLContainerUtils.isPromise(type)) {
188
35
  // TODO return array by some way
189
36
  return "void";
190
37
  }
191
- else
192
- return PrimitiveTypesInstance.NativePointer.getText();
38
+ return "void";
193
39
  }
194
40
  convertImport(type, importClause) {
195
41
  throw new Error(`Cannot pass import type ${type.name} through interop`);
196
42
  }
197
43
  convertOptional(type) {
198
- return this.convert(type.type);
44
+ return 'void';
199
45
  }
200
46
  convertPrimitiveType(type) {
201
47
  switch (type) {
@@ -215,10 +61,10 @@ export class InteropReturnTypeConvertor {
215
61
  case idl.IDLBigintType: return PrimitiveTypesInstance.Int64.getText();
216
62
  case idl.IDLAnyType:
217
63
  case idl.IDLBufferType:
218
- case idl.IDLStringType:
219
64
  case idl.IDLThisType:
220
65
  case idl.IDLUndefinedType:
221
66
  case idl.IDLUnknownType:
67
+ case idl.IDLStringType:
222
68
  case idl.IDLVoidType: return idl.IDLVoidType.name;
223
69
  case idl.IDLPointerType: return PrimitiveTypesInstance.NativePointer.getText();
224
70
  }
@@ -230,14 +76,23 @@ export class InteropReturnTypeConvertor {
230
76
  convertTypeReference(type) {
231
77
  if (type.name.endsWith("Attribute"))
232
78
  return idl.IDLVoidType.name;
233
- // Callbacks and array types return by value
234
- if (this.resolver && idl.isCallback(this.resolver.toDeclaration(type))) {
235
- return type.name;
79
+ const decl = this.resolver.resolveTypeReference(type);
80
+ if (decl) {
81
+ // Callbacks and array types return by value
82
+ if (idl.isCallback(this.resolver.toDeclaration(type))) {
83
+ return type.name;
84
+ }
85
+ if (idl.isInterface(decl)) {
86
+ if (isMaterialized(decl, this.resolver)) {
87
+ return PrimitiveTypesInstance.NativePointer.getText();
88
+ }
89
+ return KInteropReturnBuffer;
90
+ }
236
91
  }
237
- return PrimitiveTypesInstance.NativePointer.getText();
92
+ return "void";
238
93
  }
239
94
  convertUnion(type) {
240
- return PrimitiveTypesInstance.NativePointer.getText();
95
+ return KInteropReturnBuffer;
241
96
  }
242
97
  }
243
98
  export class InteropArgConvertor {
@@ -126,6 +126,7 @@ export class JavaTypeNameConvertor {
126
126
  case idl.IDLVoidType: return 'void';
127
127
  case idl.IDLDate: return 'Date';
128
128
  case idl.IDLBufferType: return 'byte[]';
129
+ case idl.IDLInteropReturnBufferType: return 'byte[]';
129
130
  }
130
131
  throw new Error(`Unsupported IDL primitive ${idl.DebugUtils.debugPrintType(type)}`);
131
132
  }
@@ -146,6 +146,8 @@ export class TSTypeNameConvertor {
146
146
  return 'Date';
147
147
  case idl.IDLBufferType:
148
148
  return `ArrayBuffer`;
149
+ case idl.IDLInteropReturnBufferType:
150
+ return `KInteropReturnBuffer`;
149
151
  }
150
152
  throw new Error(`Unmapped primitive type ${idl.DebugUtils.debugPrintType(type)}`);
151
153
  }
@@ -3,7 +3,7 @@ import { Language } from "../Language";
3
3
  import { PrimitiveTypesInstance } from "../peer-generation/PrimitiveType";
4
4
  import { createEmptyReferenceResolver } from "../peer-generation/ReferenceResolver";
5
5
  import { CJIDLTypeToForeignStringConvertor, CJInteropArgConvertor, CJTypeNameConvertor } from "./convertors/CJConvertors";
6
- import { CppInteropArgConvertor, CppInteropConvertor } from "./convertors/CppConvertors";
6
+ import { CppInteropArgConvertor, CppConvertor } from "./convertors/CppConvertors";
7
7
  import { ETSTypeNameConvertor } from "./convertors/ETSConvertors";
8
8
  import { InteropArgConvertor } from "./convertors/InteropConvertors";
9
9
  import { JavaInteropArgConvertor, JavaTypeNameConvertor } from "./convertors/JavaConvertors";
@@ -19,9 +19,9 @@ export function createLanguageWriter(language, resolver) {
19
19
  const printer = new IndentedPrinter();
20
20
  switch (language) {
21
21
  case Language.TS: return new TSLanguageWriter(printer, resolver, new TSTypeNameConvertor(resolver));
22
- case Language.ARKTS: return new ETSLanguageWriter(printer, resolver, new ETSTypeNameConvertor(resolver), new CppInteropConvertor(resolver));
22
+ case Language.ARKTS: return new ETSLanguageWriter(printer, resolver, new ETSTypeNameConvertor(resolver), new CppConvertor(resolver));
23
23
  case Language.JAVA: return new JavaLanguageWriter(printer, resolver, new JavaTypeNameConvertor(resolver));
24
- case Language.CPP: return new CppLanguageWriter(printer, resolver, new CppInteropConvertor(resolver), PrimitiveTypesInstance);
24
+ case Language.CPP: return new CppLanguageWriter(printer, resolver, new CppConvertor(resolver), PrimitiveTypesInstance);
25
25
  case Language.CJ: return new CJLanguageWriter(printer, resolver, new CJTypeNameConvertor(resolver), new CJIDLTypeToForeignStringConvertor(resolver));
26
26
  default: throw new Error(`Language ${language.toString()} is not supported`);
27
27
  }
@@ -29,7 +29,8 @@ export declare class CJMatchExpression implements LanguageExpression {
29
29
  matchValue: LanguageExpression;
30
30
  matchCases: LanguageExpression[];
31
31
  caseBlocks: LanguageExpression[];
32
- constructor(matchValue: LanguageExpression, matchCases: LanguageExpression[], caseBlocks: LanguageExpression[]);
32
+ indentDepth?: number | undefined;
33
+ constructor(matchValue: LanguageExpression, matchCases: LanguageExpression[], caseBlocks: LanguageExpression[], indentDepth?: number | undefined);
33
34
  asString(): string;
34
35
  }
35
36
  export declare class CJTernaryExpression implements LanguageExpression {
@@ -139,6 +140,8 @@ export declare class CJLanguageWriter extends LanguageWriter {
139
140
  makeEquals(args: LanguageExpression[]): LanguageExpression;
140
141
  runtimeType(param: ArgConvertor, valueType: string, value: string): void;
141
142
  escapeKeyword(word: string): string;
143
+ pushNamespace(namespace: string, ident?: boolean): void;
144
+ popNamespace(ident?: boolean): void;
142
145
  castToInt(value: string, bitness: 8 | 32): string;
143
146
  castToBoolean(value: string): string;
144
147
  makeLengthSerializer(serializer: string, value: string): LanguageStatement | undefined;
@@ -18,7 +18,7 @@ import { CJKeywords } from "../../languageSpecificKeywords";
18
18
  import { RuntimeType } from "../common";
19
19
  import { AssignStatement, ExpressionStatement, FieldModifier, LambdaExpression, LanguageWriter, MethodModifier, MethodSignature, ReturnStatement, StringExpression } from "../LanguageWriter";
20
20
  import { Language } from "../../Language";
21
- import { isDefined } from "../../util";
21
+ import { indentedBy, isDefined } from "../../util";
22
22
  ////////////////////////////////////////////////////////////////
23
23
  // EXPRESSIONS //
24
24
  ////////////////////////////////////////////////////////////////
@@ -64,19 +64,21 @@ export class CJUnionCastExpression {
64
64
  }
65
65
  }
66
66
  export class CJMatchExpression {
67
- constructor(matchValue, matchCases, caseBlocks) {
67
+ constructor(matchValue, matchCases, caseBlocks, indentDepth) {
68
68
  this.matchValue = matchValue;
69
69
  this.matchCases = matchCases;
70
70
  this.caseBlocks = caseBlocks;
71
+ this.indentDepth = indentDepth;
71
72
  }
72
73
  asString() {
74
+ var _a, _b, _c;
73
75
  let output = [];
74
76
  output.push(`match (${this.matchValue.asString()}) {`);
75
77
  for (let index in this.matchCases) {
76
- output.push(`case ${this.matchCases[index].asString()} => ${this.caseBlocks[index].asString()} `);
78
+ output.push(indentedBy(`case ${this.matchCases[index].asString()} => ${this.caseBlocks[index].asString()}`, ((_a = this.indentDepth) !== null && _a !== void 0 ? _a : 0) + 1));
77
79
  }
78
- output.push(`case _ => throw Exception(\"Unmatched pattern ${this.matchValue.asString()}\")`);
79
- output.push(`}`);
80
+ output.push(indentedBy(`case _ => throw Exception(\"Unmatched pattern ${this.matchValue.asString()}\")`, ((_b = this.indentDepth) !== null && _b !== void 0 ? _b : 1) + 1));
81
+ output.push(indentedBy(`}`, ((_c = this.indentDepth) !== null && _c !== void 0 ? _c : 1)));
80
82
  return output.join('\n');
81
83
  }
82
84
  }
@@ -308,7 +310,7 @@ export class CJLanguageWriter extends LanguageWriter {
308
310
  this.printer.print('}');
309
311
  }
310
312
  generateFunctionDeclaration(name, signature) {
311
- const args = signature.args.map((it, index) => `${signature.argName(index)}: ${this.getNodeName(it)}`);
313
+ const args = signature.args.map((it, index) => `${this.escapeKeyword(signature.argName(index))}: ${this.getNodeName(it)}`);
312
314
  return `public func ${name}(${args.join(", ")}): ${this.getNodeName(signature.returnType)}`;
313
315
  }
314
316
  writeMethodCall(receiver, method, params, nullable = false) {
@@ -388,7 +390,7 @@ export class CJLanguageWriter extends LanguageWriter {
388
390
  writeDeclaration(name, signature, modifiers, postfix) {
389
391
  let prefix = modifiers === null || modifiers === void 0 ? void 0 : modifiers.filter(it => this.supportedModifiers.includes(it)).map(it => this.mapMethodModifier(it)).join(" ");
390
392
  prefix = prefix ? prefix + " " : "";
391
- this.print(`${prefix}func ${name}(${signature.args.map((it, index) => `${signature.argName(index)}: ${this.getNodeName(it)}`).join(", ")}): ${this.getNodeName(signature.returnType)}${postfix !== null && postfix !== void 0 ? postfix : ""}`);
393
+ this.print(`${prefix}func ${name}(${signature.args.map((it, index) => `${this.escapeKeyword(signature.argName(index))}: ${this.getNodeName(it)}`).join(", ")}): ${this.getNodeName(signature.returnType)}${postfix !== null && postfix !== void 0 ? postfix : ""}`);
392
394
  }
393
395
  writeNativeFunctionCall(printer, name, signature) {
394
396
  printer.print(`return unsafe { ${name}(${signature.args.map((it, index) => `${signature.argName(index)}`).join(", ")}) }`);
@@ -482,7 +484,7 @@ export class CJLanguageWriter extends LanguageWriter {
482
484
  return this.makeString("Option.None");
483
485
  }
484
486
  makeUnwrapOptional(expression) {
485
- return new CJMatchExpression(expression, [this.makeString('Some(serializer)')], [this.makeString('serializer')]);
487
+ return new CJMatchExpression(expression, [this.makeString('Some(serializer)')], [this.makeString('serializer')], this.indentDepth());
486
488
  }
487
489
  makeValueFromOption(value, destinationConvertor) {
488
490
  return this.makeString(`${value}`);
@@ -498,7 +500,7 @@ export class CJLanguageWriter extends LanguageWriter {
498
500
  return this.makeStatement(this.makeMethodCall(keyAccessor, "set", [this.makeString(key), this.makeString(value)]));
499
501
  }
500
502
  makeNull(value) {
501
- return new StringExpression(`None<${value}>`);
503
+ return new StringExpression(`Option.None`);
502
504
  }
503
505
  getTagType() {
504
506
  return idl.createReferenceType("Tags");
@@ -545,6 +547,8 @@ export class CJLanguageWriter extends LanguageWriter {
545
547
  escapeKeyword(word) {
546
548
  return CJKeywords.has(word) ? word + "_" : word;
547
549
  }
550
+ pushNamespace(namespace, ident = true) { }
551
+ popNamespace(ident = true) { }
548
552
  castToInt(value, bitness) {
549
553
  return `Int${bitness}(${value})`;
550
554
  }
@@ -109,7 +109,7 @@ export declare class CppLanguageWriter extends CLikeLanguageWriter {
109
109
  stringifyMethodReturnType(type: IDLType, hint?: PrintHint): string;
110
110
  stringifyMethodArgType(type: IDLType, hint?: PrintHint): string;
111
111
  stringifyTypeWithReceiver(type: IDLType, receiver?: string): string;
112
- makeSerializerConstructorSignature(): NamedMethodSignature | undefined;
112
+ makeSerializerConstructorSignatures(): NamedMethodSignature[] | undefined;
113
113
  makeLengthSerializer(serializer: string, value: string): LanguageStatement | undefined;
114
114
  makeLengthDeserializer(deserializer: string): LanguageStatement | undefined;
115
115
  }
@@ -455,12 +455,16 @@ export class CppLanguageWriter extends CLikeLanguageWriter {
455
455
  }
456
456
  return this.getNodeName(type);
457
457
  }
458
- makeSerializerConstructorSignature() {
459
- return new NamedMethodSignature(IDLVoidType, [
458
+ makeSerializerConstructorSignatures() {
459
+ const fromBufferCtor = new NamedMethodSignature(IDLVoidType, [
460
460
  IDLUint8ArrayType,
461
461
  IDLU32Type,
462
- createReferenceType("CallbackResourceHolder" /* ast */)
462
+ createReferenceType("CallbackResourceHolder")
463
463
  ], ["data", "dataLength", "resourceHolder"], [undefined, `0`, `nullptr`], [undefined, undefined, undefined, PrintHint.AsPointer]);
464
+ const ownedDataCtor = new NamedMethodSignature(IDLVoidType, [
465
+ createReferenceType("CallbackResourceHolder")
466
+ ], ["resourceHolder"], [`nullptr`], [undefined, PrintHint.AsPointer]);
467
+ return [ownedDataCtor, fromBufferCtor];
464
468
  }
465
469
  makeLengthSerializer(serializer, value) {
466
470
  return undefined;
@@ -88,6 +88,6 @@ export declare class TSLanguageWriter extends LanguageWriter {
88
88
  makeCallIsObject(value: string): LanguageExpression;
89
89
  escapeKeyword(keyword: string): string;
90
90
  makeDiscriminatorConvertor(convertor: ArgConvertor, value: string, index: number): LanguageExpression | undefined;
91
- makeSerializerConstructorSignature(): NamedMethodSignature | undefined;
91
+ makeSerializerConstructorSignatures(): NamedMethodSignature[] | undefined;
92
92
  }
93
93
  //# sourceMappingURL=TsLanguageWriter.d.ts.map
@@ -390,8 +390,8 @@ export class TSLanguageWriter extends LanguageWriter {
390
390
  this.makeNaryOp("<=", [ordinal, this.makeString(high.toString())])
391
391
  ]);
392
392
  }
393
- makeSerializerConstructorSignature() {
394
- return new NamedMethodSignature(idl.IDLVoidType, [], []);
393
+ makeSerializerConstructorSignatures() {
394
+ return [new NamedMethodSignature(idl.IDLVoidType, [], [])];
395
395
  }
396
396
  }
397
397
  //# sourceMappingURL=TsLanguageWriter.js.map
@@ -9,6 +9,7 @@ export interface LibraryFileInterface {
9
9
  export interface LibraryInterface extends ReferenceResolver {
10
10
  language: Language;
11
11
  get files(): LibraryFileInterface[];
12
+ get libraryPackages(): string[] | undefined;
12
13
  typeConvertor(param: string, type: idl.IDLType, isOptionalParam?: boolean): ArgConvertor;
13
14
  declarationConvertor(param: string, type: idl.IDLReferenceType, declaration: idl.IDLEntry | undefined): ArgConvertor;
14
15
  getInteropName(node: idl.IDLNode): string;
@@ -1,19 +1,16 @@
1
- export interface GeneratorConfiguration {
2
- param<T>(name: string): T;
3
- readonly params: Record<string, any>;
4
- TypePrefix: string;
5
- LibraryPrefix: string;
6
- OptionalPrefix: string;
1
+ export interface CoreConfiguration {
2
+ readonly TypePrefix: string;
3
+ readonly LibraryPrefix: string;
4
+ readonly OptionalPrefix: string;
5
+ readonly rootComponents: string[];
6
+ readonly standaloneComponents: string[];
7
+ readonly parameterized: string[];
8
+ readonly ignoreMaterialized: string[];
9
+ readonly builderClasses: string[];
10
+ readonly forceMaterialized: string[];
7
11
  }
8
- export declare class BaseGeneratorConfiguration implements GeneratorConfiguration {
9
- readonly params: Record<string, any>;
10
- constructor(params?: Record<string, any>);
11
- param<T>(name: string): T;
12
- get TypePrefix(): string;
13
- get LibraryPrefix(): string;
14
- get OptionalPrefix(): string;
15
- }
16
- export declare function setDefaultConfiguration(config: GeneratorConfiguration): void;
17
- export declare function generatorConfiguration(): GeneratorConfiguration;
12
+ export declare const defaultCoreConfuguration: CoreConfiguration;
13
+ export declare function setDefaultConfiguration<T extends CoreConfiguration>(config: T): void;
14
+ export declare function generatorConfiguration<T extends CoreConfiguration>(): T;
18
15
  export declare function generatorTypePrefix(): string;
19
16
  //# sourceMappingURL=config.d.ts.map
@@ -12,22 +12,18 @@
12
12
  * See the License for the specific language governing permissions and
13
13
  * limitations under the License.
14
14
  */
15
- export class BaseGeneratorConfiguration {
16
- constructor(params = {}) {
17
- this.params = {};
18
- Object.assign(this.params, Object.assign({ TypePrefix: "", LibraryPrefix: "", OptionalPrefix: "" }, params));
19
- }
20
- param(name) {
21
- if (name in this.params) {
22
- return this.params[name];
23
- }
24
- throw new Error(`${name} is unknown`);
25
- }
26
- get TypePrefix() { return this.param("TypePrefix"); }
27
- get LibraryPrefix() { return this.param("LibraryPrefix"); }
28
- get OptionalPrefix() { return this.param("OptionalPrefix"); }
29
- }
30
- let currentConfig = new BaseGeneratorConfiguration();
15
+ export const defaultCoreConfuguration = {
16
+ TypePrefix: "",
17
+ LibraryPrefix: "",
18
+ OptionalPrefix: "",
19
+ rootComponents: [],
20
+ standaloneComponents: [],
21
+ parameterized: [],
22
+ ignoreMaterialized: [],
23
+ builderClasses: [],
24
+ forceMaterialized: [],
25
+ };
26
+ let currentConfig = defaultCoreConfuguration;
31
27
  export function setDefaultConfiguration(config) {
32
28
  currentConfig = config;
33
29
  }
@@ -36,6 +32,6 @@ export function generatorConfiguration() {
36
32
  }
37
33
  export function generatorTypePrefix() {
38
34
  const conf = generatorConfiguration();
39
- return `${conf.param("TypePrefix")}${conf.param("LibraryPrefix")}`;
35
+ return `${conf.TypePrefix}${conf.LibraryPrefix}`;
40
36
  }
41
37
  //# sourceMappingURL=config.js.map
@@ -86,7 +86,6 @@ export interface IDLNamedNode extends IDLNode {
86
86
  export interface IDLEntry extends IDLNode, IDLNamedNode {
87
87
  _idlEntryBrand: any;
88
88
  comment?: string;
89
- scope?: IDLEntry[];
90
89
  namespace?: IDLNamespace;
91
90
  }
92
91
  export interface IDLType extends IDLNode {
@@ -288,6 +287,7 @@ export declare const IDLUint8ArrayType: IDLContainerType;
288
287
  export declare const IDLFunctionType: IDLPrimitiveType;
289
288
  export declare const IDLLengthType: IDLPrimitiveType;
290
289
  export declare const IDLCustomObjectType: IDLPrimitiveType;
290
+ export declare const IDLInteropReturnBufferType: IDLPrimitiveType;
291
291
  export type IDLNodeInitializer = {
292
292
  extendedAttributes?: IDLExtendedAttribute[];
293
293
  fileName?: string;
@@ -98,7 +98,7 @@ export var IDLInterfaceSubkind;
98
98
  IDLInterfaceSubkind[IDLInterfaceSubkind["Tuple"] = 3] = "Tuple";
99
99
  })(IDLInterfaceSubkind || (IDLInterfaceSubkind = {}));
100
100
  export function forEachChild(node, cbEnter, cbLeave) {
101
- var _a, _b, _c;
101
+ var _a, _b;
102
102
  cbEnter(node);
103
103
  switch (node.kind) {
104
104
  case IDLKind.Namespace:
@@ -111,7 +111,6 @@ export function forEachChild(node, cbEnter, cbLeave) {
111
111
  concrete.properties.forEach((value) => forEachChild(value, cbEnter, cbLeave));
112
112
  concrete.methods.forEach((value) => forEachChild(value, cbEnter, cbLeave));
113
113
  concrete.callables.forEach((value) => forEachChild(value, cbEnter, cbLeave));
114
- (_a = concrete.scope) === null || _a === void 0 ? void 0 : _a.forEach((value) => forEachChild(value, cbEnter, cbLeave));
115
114
  break;
116
115
  }
117
116
  case IDLKind.Method:
@@ -119,14 +118,14 @@ export function forEachChild(node, cbEnter, cbLeave) {
119
118
  case IDLKind.Callback:
120
119
  case IDLKind.Constructor: {
121
120
  let concrete = node;
122
- (_b = concrete.parameters) === null || _b === void 0 ? void 0 : _b.forEach((value) => forEachChild(value, cbEnter, cbLeave));
121
+ (_a = concrete.parameters) === null || _a === void 0 ? void 0 : _a.forEach((value) => forEachChild(value, cbEnter, cbLeave));
123
122
  if (concrete.returnType)
124
123
  forEachChild(concrete.returnType, cbEnter, cbLeave);
125
124
  break;
126
125
  }
127
126
  case IDLKind.UnionType: {
128
127
  let concrete = node;
129
- (_c = concrete.types) === null || _c === void 0 ? void 0 : _c.forEach((value) => forEachChild(value, cbEnter, cbLeave));
128
+ (_b = concrete.types) === null || _b === void 0 ? void 0 : _b.forEach((value) => forEachChild(value, cbEnter, cbLeave));
130
129
  break;
131
130
  }
132
131
  case IDLKind.OptionalType: {
@@ -334,6 +333,7 @@ export const IDLUint8ArrayType = createContainerType('sequence', [IDLU8Type]);
334
333
  export const IDLFunctionType = createPrimitiveType('Function');
335
334
  export const IDLLengthType = createPrimitiveType('Length');
336
335
  export const IDLCustomObjectType = createPrimitiveType('CustomObject');
336
+ export const IDLInteropReturnBufferType = createPrimitiveType('InteropReturnBuffer');
337
337
  export function createNamespace(name, extendedAttributes, fileName) {
338
338
  return {
339
339
  kind: IDLKind.Namespace,
@@ -746,14 +746,6 @@ export function printScoped(idl) {
746
746
  throw new Error(`Unexpected scoped: ${idl.kind} ${idl.name}`);
747
747
  }
748
748
  export function printInterface(idl) {
749
- idl.methods
750
- .map(it => {
751
- let result = it.scope;
752
- it.scope = undefined;
753
- return result;
754
- })
755
- .filter(isDefined)
756
- .forEach(scope => idl.scope ? idl.scope.push(...scope) : idl.scope = scope);
757
749
  return [
758
750
  ...printExtendedAttributes(idl, 0),
759
751
  `interface ${idl.name}${hasSuperType(idl) ? ": " + printType(idl.inheritance[0]) : ""} {`,
@@ -852,7 +844,6 @@ export function toIDLString(entries, options) {
852
844
  let indent = 0;
853
845
  const generatedIdl = entries
854
846
  .map(it => printIDL(it, options))
855
- .concat(printScopes(entries))
856
847
  .flat()
857
848
  .filter(isDefined)
858
849
  .filter(it => it.length > 0)
@@ -872,12 +863,6 @@ export function verifyIDLString(source) {
872
863
  webidl2.validate(webidl2.parse(source));
873
864
  return true;
874
865
  }
875
- function printScopes(entries) {
876
- return entries
877
- .map((it) => it.scope)
878
- .filter(isDefined)
879
- .flatMap((it) => it.map(printScoped));
880
- }
881
866
  export function hasExtAttribute(node, attribute) {
882
867
  var _a;
883
868
  return ((_a = node.extendedAttributes) === null || _a === void 0 ? void 0 : _a.find((it) => it.name == attribute)) != undefined;
@@ -37,6 +37,8 @@ export * from "./peer-generation/PeerClass";
37
37
  export * from "./peer-generation/PeerMethod";
38
38
  export * from "./peer-generation/BuilderClass";
39
39
  export * from "./peer-generation/Materialized";
40
+ export * from "./peer-generation/isMaterialized";
41
+ export * from "./peer-generation/isStructureType";
40
42
  export * from "./peer-generation/unions";
41
43
  export * from "./LanguageWriters";
42
44
  export * from "./peer-generation/ReferenceResolver";
@@ -51,6 +51,8 @@ export * from "./peer-generation/PeerClass";
51
51
  export * from "./peer-generation/PeerMethod";
52
52
  export * from "./peer-generation/BuilderClass";
53
53
  export * from "./peer-generation/Materialized";
54
+ export * from "./peer-generation/isMaterialized";
55
+ export * from "./peer-generation/isStructureType";
54
56
  export * from "./peer-generation/unions";
55
57
  export * from "./LanguageWriters";
56
58
  export * from "./peer-generation/ReferenceResolver";
@@ -39,9 +39,9 @@ export function isCommonMethodOrSubclass(typeChecker, decl) {
39
39
  return isSubclass;
40
40
  }
41
41
  export function determineInheritanceRole(name) {
42
- if (generatorConfiguration().param("rootComponents").includes(name))
42
+ if (generatorConfiguration().rootComponents.includes(name))
43
43
  return InheritanceRole.Root;
44
- if (generatorConfiguration().param("standaloneComponents").includes(name))
44
+ if (generatorConfiguration().standaloneComponents.includes(name))
45
45
  return InheritanceRole.Standalone;
46
46
  return InheritanceRole.Heir;
47
47
  }