jsii-pacmak 1.64.0 → 1.66.0

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 (55) hide show
  1. package/bin/jsii-pacmak.js +10 -0
  2. package/lib/builder.d.ts +12 -7
  3. package/lib/builder.js +4 -3
  4. package/lib/generator.d.ts +7 -1
  5. package/lib/generator.js +4 -1
  6. package/lib/index.d.ts +7 -1
  7. package/lib/index.js +7 -5
  8. package/lib/target.d.ts +3 -0
  9. package/lib/target.js +4 -3
  10. package/lib/targets/dotnet/dotnetgenerator.d.ts +5 -2
  11. package/lib/targets/dotnet/dotnetgenerator.js +27 -100
  12. package/lib/targets/dotnet/dotnettyperesolver.js +5 -4
  13. package/lib/targets/dotnet/runtime-type-checking.d.ts +13 -0
  14. package/lib/targets/dotnet/runtime-type-checking.js +146 -0
  15. package/lib/targets/dotnet.js +5 -4
  16. package/lib/targets/go/dependencies.d.ts +16 -0
  17. package/lib/targets/go/dependencies.js +59 -0
  18. package/lib/targets/go/emit-context.d.ts +2 -0
  19. package/lib/targets/go/package.d.ts +1 -0
  20. package/lib/targets/go/package.js +54 -33
  21. package/lib/targets/go/runtime/class-constructor.d.ts +2 -1
  22. package/lib/targets/go/runtime/class-constructor.js +4 -1
  23. package/lib/targets/go/runtime/method-call.d.ts +2 -2
  24. package/lib/targets/go/runtime/method-call.js +11 -5
  25. package/lib/targets/go/runtime/property-access.d.ts +3 -2
  26. package/lib/targets/go/runtime/property-access.js +7 -2
  27. package/lib/targets/go/runtime/runtime-type-checking.d.ts +29 -0
  28. package/lib/targets/go/runtime/runtime-type-checking.js +408 -0
  29. package/lib/targets/go/types/class.d.ts +10 -5
  30. package/lib/targets/go/types/class.js +60 -30
  31. package/lib/targets/go/types/enum.d.ts +2 -2
  32. package/lib/targets/go/types/enum.js +6 -2
  33. package/lib/targets/go/types/go-type-reference.d.ts +6 -1
  34. package/lib/targets/go/types/go-type-reference.js +37 -21
  35. package/lib/targets/go/types/go-type.d.ts +4 -1
  36. package/lib/targets/go/types/go-type.js +3 -0
  37. package/lib/targets/go/types/interface.d.ts +5 -3
  38. package/lib/targets/go/types/interface.js +40 -17
  39. package/lib/targets/go/types/struct.d.ts +7 -3
  40. package/lib/targets/go/types/struct.js +41 -2
  41. package/lib/targets/go/types/type-member.d.ts +8 -1
  42. package/lib/targets/go/types/type-member.js +63 -18
  43. package/lib/targets/go.d.ts +6 -2
  44. package/lib/targets/go.js +6 -4
  45. package/lib/targets/java.d.ts +5 -2
  46. package/lib/targets/java.js +8 -7
  47. package/lib/targets/js.d.ts +1 -0
  48. package/lib/targets/js.js +4 -0
  49. package/lib/targets/python/type-name.js +4 -4
  50. package/lib/targets/python.d.ts +3 -1
  51. package/lib/targets/python.js +15 -7
  52. package/lib/targets/version-utils.js +1 -1
  53. package/lib/version.d.ts +2 -2
  54. package/lib/version.js +3 -3
  55. package/package.json +16 -14
@@ -1,9 +1,22 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _GoProperty_validator, _GoMethod_validator;
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.GoParameter = exports.GoMethod = exports.GoProperty = void 0;
4
16
  const jsii_reflect_1 = require("jsii-reflect");
5
17
  const naming_util_1 = require("../../../naming-util");
6
18
  const runtime_1 = require("../runtime");
19
+ const runtime_type_checking_1 = require("../runtime/runtime-type-checking");
7
20
  const util_1 = require("../util");
8
21
  const index_1 = require("./index");
9
22
  /*
@@ -14,7 +27,14 @@ class GoProperty {
14
27
  constructor(parent, property) {
15
28
  this.parent = parent;
16
29
  this.property = property;
17
- this.name = (0, naming_util_1.jsiiToPascalCase)(this.property.name);
30
+ _GoProperty_validator.set(this, null);
31
+ const localName = (0, naming_util_1.jsiiToPascalCase)(this.property.name);
32
+ this.name = property.spec.static
33
+ ? `${parent.name}_${localName}`
34
+ : localName;
35
+ this.setterName = property.spec.static
36
+ ? `${parent.name}_Set${localName}`
37
+ : `Set${this.name}`;
18
38
  this.immutable = property.immutable;
19
39
  this.apiLocation = {
20
40
  api: 'member',
@@ -22,14 +42,21 @@ class GoProperty {
22
42
  memberName: this.property.name,
23
43
  };
24
44
  }
45
+ get validator() {
46
+ if (__classPrivateFieldGet(this, _GoProperty_validator, "f") === null) {
47
+ __classPrivateFieldSet(this, _GoProperty_validator, runtime_type_checking_1.ParameterValidator.forProperty(this), "f");
48
+ }
49
+ return __classPrivateFieldGet(this, _GoProperty_validator, "f");
50
+ }
25
51
  get reference() {
26
52
  return new index_1.GoTypeRef(this.parent.pkg.root, this.property.type);
27
53
  }
28
54
  get specialDependencies() {
29
55
  return {
30
- runtime: true,
56
+ fmt: false,
31
57
  init: this.static,
32
58
  internal: false,
59
+ runtime: true,
33
60
  time: !!this.reference?.specialDependencies.time,
34
61
  };
35
62
  }
@@ -60,49 +87,56 @@ class GoProperty {
60
87
  documenter.emit(this.property.docs, this.apiLocation);
61
88
  code.line(`${this.name}() ${this.returnType}`);
62
89
  }
63
- emitGetter({ code }) {
64
- const receiver = this.parent.name;
65
- const instanceArg = receiver.substring(0, 1).toLowerCase();
66
- code.openBlock(`func (${instanceArg} *${receiver}) Get${this.name}() ${this.returnType}`);
67
- code.line(`return ${instanceArg}.${this.name}`);
68
- code.closeBlock();
69
- }
70
90
  emitSetterDecl({ code, documenter }) {
71
91
  if (!this.immutable) {
72
92
  // For setters, only emit the stability. Copying the documentation from
73
93
  // the getter might result in confusing documentation. This is an "okay"
74
94
  // middle-ground.
75
95
  documenter.emitStability(this.property.docs);
76
- code.line(`Set${this.name}(val ${this.returnType})`);
96
+ code.line(`${this.setterName}(val ${this.returnType})`);
77
97
  }
78
98
  }
79
99
  // Emits getter methods on the struct for each property
80
100
  emitGetterProxy(context) {
81
101
  const { code } = context;
82
- const receiver = this.parent.proxyName;
83
- const instanceArg = receiver.substring(0, 1).toLowerCase();
84
- code.openBlock(`func (${instanceArg} *${receiver}) ${this.name}() ${this.returnType}`);
85
- new runtime_1.GetProperty(this).emit(code);
102
+ if (!this.static) {
103
+ const receiver = this.parent.proxyName;
104
+ const instanceArg = receiver.substring(0, 1).toLowerCase();
105
+ code.openBlock(`func (${instanceArg} *${receiver}) ${this.name}() ${this.returnType}`);
106
+ new runtime_1.GetProperty(this).emit(code);
107
+ }
108
+ else {
109
+ code.openBlock(`func ${this.name}() ${this.returnType}`);
110
+ new runtime_1.StaticGetProperty(this).emit(code);
111
+ }
86
112
  code.closeBlock();
87
113
  code.line();
88
114
  }
89
115
  emitSetterProxy(context) {
90
116
  if (!this.immutable) {
91
117
  const { code } = context;
92
- const receiver = this.parent.proxyName;
93
- const instanceArg = receiver.substring(0, 1).toLowerCase();
94
- code.openBlock(`func (${instanceArg} *${receiver}) Set${this.name}(val ${this.returnType})`);
95
- new runtime_1.SetProperty(this).emit(code);
118
+ if (!this.static) {
119
+ const receiver = this.parent.proxyName;
120
+ const instanceArg = receiver.substring(0, 1).toLowerCase();
121
+ code.openBlock(`func (${instanceArg} *${receiver})${this.setterName}(val ${this.returnType})`);
122
+ new runtime_1.SetProperty(this).emit(context);
123
+ }
124
+ else {
125
+ code.openBlock(`func ${this.setterName}(val ${this.returnType})`);
126
+ new runtime_1.StaticSetProperty(this).emit(context);
127
+ }
96
128
  code.closeBlock();
97
129
  code.line();
98
130
  }
99
131
  }
100
132
  }
101
133
  exports.GoProperty = GoProperty;
134
+ _GoProperty_validator = new WeakMap();
102
135
  class GoMethod {
103
136
  constructor(parent, method) {
104
137
  this.parent = parent;
105
138
  this.method = method;
139
+ _GoMethod_validator.set(this, null);
106
140
  this.name = (0, naming_util_1.jsiiToPascalCase)(method.name);
107
141
  this.parameters = this.method.parameters.map((param) => new GoParameter(parent, param));
108
142
  this.apiLocation =
@@ -110,6 +144,12 @@ class GoMethod {
110
144
  ? { api: 'initializer', fqn: parent.fqn }
111
145
  : { api: 'member', fqn: parent.fqn, memberName: method.name };
112
146
  }
147
+ get validator() {
148
+ if (__classPrivateFieldGet(this, _GoMethod_validator, "f") === null) {
149
+ __classPrivateFieldSet(this, _GoMethod_validator, runtime_type_checking_1.ParameterValidator.forMethod(this), "f");
150
+ }
151
+ return __classPrivateFieldGet(this, _GoMethod_validator, "f");
152
+ }
113
153
  get reference() {
114
154
  if (jsii_reflect_1.Method.isMethod(this.method) && this.method.returns.type) {
115
155
  return new index_1.GoTypeRef(this.parent.pkg.root, this.method.returns.type);
@@ -132,6 +172,9 @@ class GoMethod {
132
172
  get override() {
133
173
  return `${runtime_1.JSII_RT_ALIAS}.MemberMethod{JsiiMethod: "${this.method.name}", GoMethod: "${this.name}"}`;
134
174
  }
175
+ get static() {
176
+ return false;
177
+ }
135
178
  paramString() {
136
179
  return this.parameters.length === 0
137
180
  ? ''
@@ -139,9 +182,11 @@ class GoMethod {
139
182
  }
140
183
  }
141
184
  exports.GoMethod = GoMethod;
185
+ _GoMethod_validator = new WeakMap();
142
186
  class GoParameter {
143
187
  constructor(parent, parameter) {
144
188
  this.name = (0, util_1.substituteReservedWords)(parameter.name);
189
+ this.isOptional = parameter.optional;
145
190
  this.isVariadic = parameter.variadic;
146
191
  this.type = parameter.type;
147
192
  this.pkg = parent.pkg;
@@ -24,12 +24,16 @@ export declare class Golang extends Target {
24
24
  private writeLocalGoMod;
25
25
  }
26
26
  declare class GoGenerator implements IGenerator {
27
- private readonly rosetta;
28
27
  private assembly;
29
28
  rootPackage: RootPackage;
30
29
  private readonly code;
31
30
  private readonly documenter;
32
- constructor(rosetta: Rosetta);
31
+ private readonly rosetta;
32
+ private readonly runtimeTypeChecking;
33
+ constructor(options: {
34
+ readonly rosetta: Rosetta;
35
+ readonly runtimeTypeChecking: boolean;
36
+ });
33
37
  load(_: string, assembly: Assembly): Promise<void>;
34
38
  upToDate(_outDir: string): Promise<boolean>;
35
39
  generate(): void;
package/lib/targets/go.js CHANGED
@@ -14,7 +14,7 @@ const util_2 = require("./go/util");
14
14
  class Golang extends target_1.Target {
15
15
  constructor(options) {
16
16
  super(options);
17
- this.goGenerator = new GoGenerator(options.rosetta);
17
+ this.goGenerator = new GoGenerator(options);
18
18
  }
19
19
  get generator() {
20
20
  return this.goGenerator;
@@ -32,7 +32,7 @@ class Golang extends target_1.Target {
32
32
  // write `local.go.mod` with "replace" directives for local modules
33
33
  const localGoMod = await this.writeLocalGoMod(pkgDir);
34
34
  try {
35
- // run `go build` with local.go.mod, go 1.16 requires that we download
35
+ // run `go build` with local.go.mod, go 1.16+ requires that we download
36
36
  // modules explicit so go.sum is updated. We'd normally want to use
37
37
  // `go mod download`, but because of a bug in go 1.16, we have to use
38
38
  // `go mod tidy` instead.
@@ -114,13 +114,14 @@ class Golang extends target_1.Target {
114
114
  }
115
115
  exports.Golang = Golang;
116
116
  class GoGenerator {
117
- constructor(rosetta) {
118
- this.rosetta = rosetta;
117
+ constructor(options) {
119
118
  this.code = new codemaker_1.CodeMaker({
120
119
  indentCharacter: '\t',
121
120
  indentationLevel: 1,
122
121
  });
122
+ this.rosetta = options.rosetta;
123
123
  this.documenter = new documentation_1.Documentation(this.code, this.rosetta);
124
+ this.runtimeTypeChecking = options.runtimeTypeChecking;
124
125
  }
125
126
  async load(_, assembly) {
126
127
  this.assembly = assembly;
@@ -134,6 +135,7 @@ class GoGenerator {
134
135
  return this.rootPackage.emit({
135
136
  code: this.code,
136
137
  documenter: this.documenter,
138
+ runtimeTypeChecking: this.runtimeTypeChecking,
137
139
  });
138
140
  }
139
141
  async save(outDir, tarball, { license, notice }) {
@@ -47,7 +47,6 @@ export default class Java extends Target {
47
47
  build(sourceDir: string, outDir: string): Promise<void>;
48
48
  }
49
49
  declare class JavaGenerator extends Generator {
50
- private readonly rosetta;
51
50
  private static readonly RESERVED_KEYWORDS;
52
51
  /**
53
52
  * Turns a raw javascript property name (eg: 'default') into a safe Java property name (eg: 'defaultValue').
@@ -69,7 +68,11 @@ declare class JavaGenerator extends Generator {
69
68
  * interface proxies.
70
69
  */
71
70
  private readonly referencedModules;
72
- constructor(rosetta: Rosetta);
71
+ private readonly rosetta;
72
+ constructor(options: {
73
+ readonly rosetta: Rosetta;
74
+ readonly runtimeTypeChecking: boolean;
75
+ });
73
76
  protected onBeginAssembly(assm: spec.Assembly, fingerprint: boolean): void;
74
77
  protected onEndAssembly(assm: spec.Assembly, fingerprint: boolean): void;
75
78
  protected getAssemblyOutputDir(mod: spec.Assembly): string;
@@ -225,13 +225,14 @@ class JavaBuilder {
225
225
  }
226
226
  makeTarget(module, options) {
227
227
  return new Java({
228
- targetName: this.targetName,
229
- packageDir: module.moduleDirectory,
228
+ arguments: options.arguments,
230
229
  assembly: module.assembly,
231
230
  fingerprint: options.fingerprint,
232
231
  force: options.force,
233
- arguments: options.arguments,
232
+ packageDir: module.moduleDirectory,
234
233
  rosetta: options.rosetta,
234
+ runtimeTypeChecking: options.runtimeTypeChecking,
235
+ targetName: this.targetName,
235
236
  });
236
237
  }
237
238
  }
@@ -247,7 +248,7 @@ function moduleArtifactsSubdir(module) {
247
248
  class Java extends target_1.Target {
248
249
  constructor(options) {
249
250
  super(options);
250
- this.generator = new JavaGenerator(options.rosetta);
251
+ this.generator = new JavaGenerator(options);
251
252
  }
252
253
  static toPackageInfos(assm) {
253
254
  const groupId = assm.targets.java.maven.groupId;
@@ -329,9 +330,8 @@ const MODULE_CLASS_NAME = '$Module';
329
330
  const INTERFACE_PROXY_CLASS_NAME = 'Jsii$Proxy';
330
331
  const INTERFACE_DEFAULT_CLASS_NAME = 'Jsii$Default';
331
332
  class JavaGenerator extends generator_1.Generator {
332
- constructor(rosetta) {
333
- super({ generateOverloadsForMethodWithOptionals: true });
334
- this.rosetta = rosetta;
333
+ constructor(options) {
334
+ super({ ...options, generateOverloadsForMethodWithOptionals: true });
335
335
  /**
336
336
  * A map of all the modules ever referenced during code generation. These include
337
337
  * direct dependencies but can potentially also include transitive dependencies, when,
@@ -339,6 +339,7 @@ class JavaGenerator extends generator_1.Generator {
339
339
  * interface proxies.
340
340
  */
341
341
  this.referencedModules = {};
342
+ this.rosetta = options.rosetta;
342
343
  }
343
344
  /**
344
345
  * Turns a raw javascript property name (eg: 'default') into a safe Java property name (eg: 'defaultValue').
@@ -13,6 +13,7 @@ export default class JavaScript extends Target {
13
13
  build(sourceDir: string, outDir: string): Promise<void>;
14
14
  }
15
15
  declare class PackOnly extends Generator {
16
+ constructor();
16
17
  save(outdir: string, tarball: string, _: Legalese): Promise<string[]>;
17
18
  protected getAssemblyOutputDir(_mod: spec.Assembly): string;
18
19
  protected onBeginInterface(_ifc: spec.InterfaceType): void;
package/lib/targets/js.js CHANGED
@@ -55,6 +55,10 @@ exports.default = JavaScript;
55
55
  // # CODE GENERATOR #
56
56
  // ##################
57
57
  class PackOnly extends generator_1.Generator {
58
+ constructor() {
59
+ // NB: This does not generate code, so runtime type checking is irrelevant
60
+ super({ runtimeTypeChecking: false });
61
+ }
58
62
  async save(outdir, tarball, _) {
59
63
  // Intentionally ignore the Legalese field here... it's not useful here.
60
64
  return super.save(outdir, tarball, {});
@@ -214,10 +214,10 @@ class UserType {
214
214
  const submodulePythonName = toPythonFqn(submodule, assembly).pythonFqn;
215
215
  const typeSubmodulePythonName = toPythonFqn(findParentSubmodule(assembly.types[__classPrivateFieldGet(this, _UserType_fqn, "f")], assembly), assembly).pythonFqn;
216
216
  if (typeSubmodulePythonName === submodulePythonName) {
217
- // Identifiy declarations that are not yet initialized and hence cannot be
217
+ // Identify declarations that are not yet initialized and hence cannot be
218
218
  // used as part of a type qualification. Since this is not a forward
219
219
  // reference, the type was already emitted and its un-qualified name must
220
- // be used instead of it's locally qualified name.
220
+ // be used instead of its locally qualified name.
221
221
  const nestingParent = surroundingTypeFqns
222
222
  ?.map((fqn) => toPythonFqn(fqn, assembly).pythonFqn)
223
223
  ?.reverse()
@@ -233,7 +233,7 @@ class UserType {
233
233
  // This is not for a type annotation, so we should be at a point in time
234
234
  // where the surrounding symbol has been defined entirely, so we can
235
235
  // refer to it "normally" now.
236
- return { pythonType: pythonFqn.substring(nestingParent.length + 1) };
236
+ return { pythonType: pythonFqn.slice(packageName.length + 1) };
237
237
  }
238
238
  // We'll just make a module-qualified reference at this point.
239
239
  return {
@@ -251,7 +251,7 @@ class UserType {
251
251
  .substring(0, 8);
252
252
  const alias = `_${toImport}_${aliasSuffix}`;
253
253
  return {
254
- pythonType: [alias, ...nested].join('.'),
254
+ pythonType: wrapType([alias, ...nested].join('.')),
255
255
  requiredImport: {
256
256
  sourcePackage: relativeImportPath(submodulePythonName, typeSubmodulePythonName),
257
257
  item: `${toImport} as ${alias}`,
@@ -13,6 +13,8 @@ export default class Python extends Target {
13
13
  interface EmitContext extends NamingContext {
14
14
  /** @deprecated The TypeResolver */
15
15
  readonly resolver: TypeResolver;
16
+ /** Whether to emit runtime type checking code */
17
+ readonly runtimeTypeChecking: boolean;
16
18
  }
17
19
  interface PythonBase {
18
20
  readonly pythonName: string;
@@ -49,7 +51,7 @@ declare class PythonGenerator extends Generator {
49
51
  private package;
50
52
  private rootModule?;
51
53
  private readonly types;
52
- constructor(rosetta: Rosetta, options?: GeneratorOptions);
54
+ constructor(rosetta: Rosetta, options: GeneratorOptions);
53
55
  emitDocString(code: CodeMaker, apiLocation: ApiLocation, docs: spec.Docs | undefined, options?: {
54
56
  arguments?: DocumentableArgument[];
55
57
  documentableItem?: string;
@@ -26,7 +26,7 @@ const DOCSTRING_QUOTES = "'''";
26
26
  class Python extends target_1.Target {
27
27
  constructor(options) {
28
28
  super(options);
29
- this.generator = new PythonGenerator(options.rosetta);
29
+ this.generator = new PythonGenerator(options.rosetta, options);
30
30
  }
31
31
  async generateCode(outDir, tarball) {
32
32
  await super.generateCode(outDir, tarball);
@@ -394,6 +394,7 @@ class BaseMethod {
394
394
  const paramType = (0, type_name_1.toTypeName)(prop.prop).pythonType({
395
395
  ...context,
396
396
  parameterType: true,
397
+ typeAnnotation: true,
397
398
  });
398
399
  const paramDefault = prop.prop.optional ? ' = None' : '';
399
400
  pythonParams.push(`${paramName}: ${paramType}${paramDefault}`);
@@ -440,7 +441,7 @@ class BaseMethod {
440
441
  });
441
442
  if ((this.shouldEmitBody || forceEmitBody) &&
442
443
  (!renderAbstract || !this.abstract)) {
443
- emitParameterTypeChecks(code, pythonParams.slice(1), `${(0, type_name_1.toPythonFullName)(this.parent.fqn, context.assembly)}.${this.pythonName}`);
444
+ emitParameterTypeChecks(code, context, pythonParams.slice(1), `${(0, type_name_1.toPythonFullName)(this.parent.fqn, context.assembly)}.${this.pythonName}`);
444
445
  }
445
446
  this.emitBody(code, context, renderAbstract, forceEmitBody, liftedPropNames, pythonParams[0], returnType);
446
447
  code.closeBlock();
@@ -597,7 +598,7 @@ class BaseProperty {
597
598
  openSignature(code, 'def', this.pythonName, [this.implicitParameter, `value: ${pythonType}`], 'None');
598
599
  if ((this.shouldEmitBody || forceEmitBody) &&
599
600
  (!renderAbstract || !this.abstract)) {
600
- emitParameterTypeChecks(code, [`value: ${pythonType}`],
601
+ emitParameterTypeChecks(code, context, [`value: ${pythonType}`],
601
602
  // In order to get a property accessor, we must resort to getting the
602
603
  // attribute on the type, instead of the value (where the getter would
603
604
  // be implicitly invoked for us...)
@@ -739,12 +740,15 @@ class Struct extends BasePythonClassType {
739
740
  // Re-type struct arguments that were passed as "dict". Do this before validating argument types...
740
741
  for (const member of members.filter((m) => m.isStruct(this.generator))) {
741
742
  // Note that "None" is NOT an instance of dict (that's convenient!)
742
- const typeName = (0, type_name_1.toPythonFullName)(member.type.type.fqn, context.assembly);
743
+ const typeName = (0, type_name_1.toTypeName)(member.type.type).pythonType({
744
+ ...context,
745
+ typeAnnotation: false,
746
+ });
743
747
  code.openBlock(`if isinstance(${member.pythonName}, dict)`);
744
748
  code.line(`${member.pythonName} = ${typeName}(**${member.pythonName})`);
745
749
  code.closeBlock();
746
750
  }
747
- emitParameterTypeChecks(code, kwargs, `${(0, type_name_1.toPythonFullName)(this.spec.fqn, context.assembly)}.__init__`);
751
+ emitParameterTypeChecks(code, context, kwargs, `${(0, type_name_1.toPythonFullName)(this.spec.fqn, context.assembly)}.__init__`);
748
752
  // Required properties, those will always be put into the dict
749
753
  assignDictionary(code, `${implicitParameter}._values: typing.Dict[str, typing.Any]`, members
750
754
  .filter((m) => !m.optional)
@@ -1580,7 +1584,7 @@ class TypeResolver {
1580
1584
  }
1581
1585
  }
1582
1586
  class PythonGenerator extends generator_1.Generator {
1583
- constructor(rosetta, options = {}) {
1587
+ constructor(rosetta, options) {
1584
1588
  super(options);
1585
1589
  this.rosetta = rosetta;
1586
1590
  this.code.openBlockFormatter = (s) => `${s}:`;
@@ -1728,6 +1732,7 @@ class PythonGenerator extends generator_1.Generator {
1728
1732
  assembly: assm,
1729
1733
  emittedTypes: new Set(),
1730
1734
  resolver,
1735
+ runtimeTypeChecking: this.runtimeTypeChecking,
1731
1736
  submodule: assm.name,
1732
1737
  typeResolver: (fqn) => resolver.dereference(fqn),
1733
1738
  });
@@ -2012,7 +2017,10 @@ function openSignature(code, keyword, name, params, returnType, lineComment) {
2012
2017
  * @param params the parameter signatures to be type-checked.
2013
2018
  * @param typedEntity the type-annotated entity.
2014
2019
  */
2015
- function emitParameterTypeChecks(code, params, typedEntity) {
2020
+ function emitParameterTypeChecks(code, context, params, typedEntity) {
2021
+ if (!context.runtimeTypeChecking) {
2022
+ return;
2023
+ }
2016
2024
  const paramInfo = params.map((param) => {
2017
2025
  const [name] = param.split(/\s*[:=#]\s*/, 1);
2018
2026
  if (name === '*') {
@@ -72,7 +72,7 @@ exports.toPythonVersionRange = toPythonVersionRange;
72
72
  * @returns the version that should be serialized
73
73
  */
74
74
  function toReleaseVersion(assemblyVersion, target) {
75
- const version = (0, semver_1.parse)(assemblyVersion, { includePrerelease: true });
75
+ const version = (0, semver_1.parse)(assemblyVersion);
76
76
  if (version == null) {
77
77
  throw new Error(`Unable to parse the provided assembly version: "${assemblyVersion}"`);
78
78
  }
package/lib/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
2
- export declare const VERSION = "1.64.0";
2
+ export declare const VERSION = "1.66.0";
3
3
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
4
- export declare const VERSION_DESC = "1.64.0 (build 4c1eae8)";
4
+ export declare const VERSION_DESC = "1.66.0 (build 3c9512b)";
5
5
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- // Generated at 2022-08-12T17:08:11Z by generate.sh
2
+ // Generated at 2022-08-29T23:52:00Z by generate.sh
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.VERSION_DESC = exports.VERSION = void 0;
5
5
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
6
- exports.VERSION = '1.64.0';
6
+ exports.VERSION = '1.66.0';
7
7
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
8
- exports.VERSION_DESC = '1.64.0 (build 4c1eae8)';
8
+ exports.VERSION_DESC = '1.66.0 (build 3c9512b)';
9
9
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsii-pacmak",
3
- "version": "1.64.0",
3
+ "version": "1.66.0",
4
4
  "description": "A code generation framework for jsii backend languages",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,33 +37,35 @@
37
37
  "package": "package-js"
38
38
  },
39
39
  "dependencies": {
40
- "@jsii/check-node": "1.64.0",
41
- "@jsii/spec": "^1.64.0",
40
+ "@jsii/check-node": "1.66.0",
41
+ "@jsii/spec": "^1.66.0",
42
42
  "clone": "^2.1.2",
43
- "codemaker": "^1.64.0",
43
+ "codemaker": "^1.66.0",
44
44
  "commonmark": "^0.30.0",
45
45
  "escape-string-regexp": "^4.0.0",
46
46
  "fs-extra": "^10.1.0",
47
- "jsii-reflect": "^1.64.0",
48
- "jsii-rosetta": "^1.64.0",
47
+ "jsii-reflect": "^1.66.0",
48
+ "jsii-rosetta": "^1.66.0",
49
49
  "semver": "^7.3.7",
50
50
  "spdx-license-list": "^6.6.0",
51
51
  "xmlbuilder": "^15.1.1",
52
52
  "yargs": "^16.2.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@jsii/dotnet-runtime": "^1.64.0",
56
- "@jsii/java-runtime": "^1.64.0",
57
- "@jsii/go-runtime": "^1.64.0",
58
- "@scope/jsii-calc-lib": "^1.64.0",
55
+ "@jsii/dotnet-runtime": "^1.66.0",
56
+ "@jsii/java-runtime": "^1.66.0",
57
+ "@jsii/go-runtime": "^1.66.0",
58
+ "@scope/jsii-calc-lib": "^1.66.0",
59
59
  "@types/clone": "^2.1.1",
60
+ "@types/diff": "^5.0.2",
60
61
  "@types/commonmark": "^0.27.5",
61
62
  "@types/fs-extra": "^9.0.13",
62
- "@types/semver": "^7.3.10",
63
- "jsii": "^1.64.0",
64
- "jsii-build-tools": "^1.64.0",
63
+ "@types/semver": "^7.3.12",
64
+ "diff": "^5.1.0",
65
+ "jsii": "^1.66.0",
66
+ "jsii-build-tools": "^1.66.0",
65
67
  "jsii-calc": "^3.20.120",
66
- "pyright": "^1.1.266"
68
+ "pyright": "^1.1.267"
67
69
  },
68
70
  "keywords": [
69
71
  "jsii",