jsii-pacmak 1.64.0 → 1.65.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.
- package/bin/jsii-pacmak.js +10 -0
- package/lib/builder.d.ts +12 -7
- package/lib/builder.js +4 -3
- package/lib/generator.d.ts +7 -1
- package/lib/generator.js +4 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.js +7 -5
- package/lib/target.d.ts +3 -0
- package/lib/target.js +4 -3
- package/lib/targets/dotnet/dotnetgenerator.d.ts +5 -2
- package/lib/targets/dotnet/dotnetgenerator.js +24 -6
- package/lib/targets/dotnet.js +5 -4
- package/lib/targets/java.d.ts +5 -2
- package/lib/targets/java.js +8 -7
- package/lib/targets/js.d.ts +1 -0
- package/lib/targets/js.js +4 -0
- package/lib/targets/python/type-name.js +1 -1
- package/lib/targets/python.d.ts +3 -1
- package/lib/targets/python.js +10 -6
- package/lib/targets/version-utils.js +1 -1
- package/lib/version.d.ts +2 -2
- package/lib/version.js +3 -3
- package/package.json +14 -12
package/bin/jsii-pacmak.js
CHANGED
|
@@ -36,6 +36,15 @@ const version_1 = require("../lib/version");
|
|
|
36
36
|
type: 'boolean',
|
|
37
37
|
desc: 'generate code only (instead of building and packaging)',
|
|
38
38
|
default: false,
|
|
39
|
+
})
|
|
40
|
+
.option('runtime-type-checking', {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
desc: [
|
|
43
|
+
'generate runtime type checking code where compile-time type checking is not possible.',
|
|
44
|
+
'Disabling this will generate less code, but will produce less helpful error messages when',
|
|
45
|
+
'developers pass invalid values to the generated bindings.',
|
|
46
|
+
].join(' '),
|
|
47
|
+
default: true,
|
|
39
48
|
})
|
|
40
49
|
.option('fingerprint', {
|
|
41
50
|
type: 'boolean',
|
|
@@ -154,6 +163,7 @@ const version_1 = require("../lib/version");
|
|
|
154
163
|
recurse: argv.recurse,
|
|
155
164
|
rosettaUnknownSnippets,
|
|
156
165
|
rosettaTablet: argv['rosetta-tablet'],
|
|
166
|
+
runtimeTypeChecking: argv['runtime-type-checking'],
|
|
157
167
|
targets: argv.targets?.map((target) => target),
|
|
158
168
|
updateNpmIgnoreFiles: argv.npmignore,
|
|
159
169
|
validateAssemblies: argv['validate-assemblies'],
|
package/lib/builder.d.ts
CHANGED
|
@@ -8,34 +8,39 @@ export interface BuildOptions {
|
|
|
8
8
|
* Whether to fingerprint the produced artifacts.
|
|
9
9
|
* @default true
|
|
10
10
|
*/
|
|
11
|
-
fingerprint?: boolean;
|
|
11
|
+
readonly fingerprint?: boolean;
|
|
12
12
|
/**
|
|
13
13
|
* Whether artifacts should be re-build even if their fingerprints look up-to-date.
|
|
14
14
|
* @default false
|
|
15
15
|
*/
|
|
16
|
-
force?: boolean;
|
|
16
|
+
readonly force?: boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Arguments provided by the user (how they are used is target-dependent)
|
|
19
19
|
*/
|
|
20
|
-
arguments: {
|
|
20
|
+
readonly arguments: {
|
|
21
21
|
readonly [name: string]: any;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Only generate code, don't build
|
|
25
25
|
*/
|
|
26
|
-
codeOnly?: boolean;
|
|
26
|
+
readonly codeOnly?: boolean;
|
|
27
27
|
/**
|
|
28
28
|
* Whether or not to clean
|
|
29
29
|
*/
|
|
30
|
-
clean?: boolean;
|
|
30
|
+
readonly clean?: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Whether to add an additional subdirectory for the target language
|
|
33
33
|
*/
|
|
34
|
-
languageSubdirectory?: boolean;
|
|
34
|
+
readonly languageSubdirectory?: boolean;
|
|
35
35
|
/**
|
|
36
36
|
* The Rosetta instance to load examples from
|
|
37
37
|
*/
|
|
38
|
-
rosetta: Rosetta;
|
|
38
|
+
readonly rosetta: Rosetta;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to generate runtime type checking code in places where compile-time
|
|
41
|
+
* type checking is not possible.
|
|
42
|
+
*/
|
|
43
|
+
readonly runtimeTypeChecking: boolean;
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
46
|
* Interface for classes that can build language targets
|
package/lib/builder.js
CHANGED
|
@@ -63,13 +63,14 @@ class IndependentPackageBuilder {
|
|
|
63
63
|
}
|
|
64
64
|
makeTarget(module, options) {
|
|
65
65
|
return new this.targetConstructor({
|
|
66
|
-
|
|
67
|
-
packageDir: module.moduleDirectory,
|
|
66
|
+
arguments: options.arguments,
|
|
68
67
|
assembly: module.assembly,
|
|
69
68
|
fingerprint: options.fingerprint,
|
|
70
69
|
force: options.force,
|
|
71
|
-
|
|
70
|
+
packageDir: module.moduleDirectory,
|
|
72
71
|
rosetta: options.rosetta,
|
|
72
|
+
runtimeTypeChecking: options.runtimeTypeChecking,
|
|
73
|
+
targetName: this.targetName,
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
finalOutputDir(module, options) {
|
package/lib/generator.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface GeneratorOptions {
|
|
|
20
20
|
* If this property is set, the generator will add "Base" to abstract class names
|
|
21
21
|
*/
|
|
22
22
|
addBasePostfixToAbstractClassNames?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If this property is set, the generator will add runtime type checking code in places
|
|
25
|
+
* where compile-time type checking is not possible.
|
|
26
|
+
*/
|
|
27
|
+
runtimeTypeChecking: boolean;
|
|
23
28
|
}
|
|
24
29
|
export interface IGenerator {
|
|
25
30
|
/**
|
|
@@ -72,7 +77,8 @@ export declare abstract class Generator implements IGenerator {
|
|
|
72
77
|
private _assembly?;
|
|
73
78
|
protected _reflectAssembly?: reflect.Assembly;
|
|
74
79
|
private fingerprint?;
|
|
75
|
-
constructor(options
|
|
80
|
+
constructor(options: GeneratorOptions);
|
|
81
|
+
protected get runtimeTypeChecking(): boolean;
|
|
76
82
|
protected get assembly(): spec.Assembly;
|
|
77
83
|
get reflectAssembly(): reflect.Assembly;
|
|
78
84
|
get metadata(): {
|
package/lib/generator.js
CHANGED
|
@@ -13,11 +13,14 @@ const version_1 = require("./version");
|
|
|
13
13
|
* Given a jsii module, it will invoke "events" to emit various elements.
|
|
14
14
|
*/
|
|
15
15
|
class Generator {
|
|
16
|
-
constructor(options
|
|
16
|
+
constructor(options) {
|
|
17
17
|
this.options = options;
|
|
18
18
|
this.excludeTypes = new Array();
|
|
19
19
|
this.code = new codemaker_1.CodeMaker();
|
|
20
20
|
}
|
|
21
|
+
get runtimeTypeChecking() {
|
|
22
|
+
return this.options.runtimeTypeChecking;
|
|
23
|
+
}
|
|
21
24
|
get assembly() {
|
|
22
25
|
if (!this._assembly) {
|
|
23
26
|
throw new Error('No assembly has been loaded! The #load() method must be called first!');
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { configure as configureLogging } from './logging';
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates code in the desired targets.
|
|
8
8
|
*/
|
|
9
|
-
export declare function pacmak({ argv, clean, codeOnly, fingerprint, force, forceSubdirectory, forceTarget, inputDirectories, outputDirectory, parallel, recurse, rosettaTablet, targets, timers,
|
|
9
|
+
export declare function pacmak({ argv, clean, codeOnly, fingerprint, force, forceSubdirectory, forceTarget, inputDirectories, outputDirectory, parallel, recurse, rosettaTablet, rosettaUnknownSnippets, runtimeTypeChecking, targets, timers, updateNpmIgnoreFiles, validateAssemblies, }: PacmakOptions): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Options provided to the `pacmak` function.
|
|
12
12
|
*/
|
|
@@ -93,6 +93,12 @@ export interface PacmakOptions {
|
|
|
93
93
|
* @default undefined
|
|
94
94
|
*/
|
|
95
95
|
readonly rosettaTablet?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Whether to inject runtime type checks in places where compile-time type checking is not performed.
|
|
98
|
+
*
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
readonly runtimeTypeChecking?: boolean;
|
|
96
102
|
/**
|
|
97
103
|
* The list of targets for which code should be generated. Unless `forceTarget` is `true`, a given target will only
|
|
98
104
|
* be generated for assemblies that have configured it.
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "configureLogging", { enumerable: true, get: func
|
|
|
16
16
|
/**
|
|
17
17
|
* Generates code in the desired targets.
|
|
18
18
|
*/
|
|
19
|
-
async function pacmak({ argv = {}, clean = true, codeOnly = false, fingerprint = true, force = false, forceSubdirectory = true, forceTarget = false, inputDirectories, outputDirectory, parallel = true, recurse = false, rosettaTablet, targets = Object.values(targets_1.TargetName), timers = new timer_1.Timers(),
|
|
19
|
+
async function pacmak({ argv = {}, clean = true, codeOnly = false, fingerprint = true, force = false, forceSubdirectory = true, forceTarget = false, inputDirectories, outputDirectory, parallel = true, recurse = false, rosettaTablet, rosettaUnknownSnippets = undefined, runtimeTypeChecking = true, targets = Object.values(targets_1.TargetName), timers = new timer_1.Timers(), updateNpmIgnoreFiles = false, validateAssemblies = false, }) {
|
|
20
20
|
const rosetta = new jsii_rosetta_1.Rosetta({
|
|
21
21
|
unknownSnippets: rosettaUnknownSnippets,
|
|
22
22
|
prefixDisclaimer: true,
|
|
@@ -74,6 +74,7 @@ async function pacmak({ argv = {}, clean = true, codeOnly = false, fingerprint =
|
|
|
74
74
|
force,
|
|
75
75
|
perLanguageDirectory,
|
|
76
76
|
rosetta,
|
|
77
|
+
runtimeTypeChecking,
|
|
77
78
|
}))
|
|
78
79
|
.then(() => logging.info(`${targetSet.targetType} finished`), (err) => {
|
|
79
80
|
logging.warn(`${targetSet.targetType} failed`);
|
|
@@ -95,20 +96,21 @@ async function pacmak({ argv = {}, clean = true, codeOnly = false, fingerprint =
|
|
|
95
96
|
exports.pacmak = pacmak;
|
|
96
97
|
//#endregion
|
|
97
98
|
//#region Building
|
|
98
|
-
async function buildTargetsForLanguage(targetLanguage, modules, { argv, clean, codeOnly, fingerprint, force, perLanguageDirectory, rosetta, }) {
|
|
99
|
+
async function buildTargetsForLanguage(targetLanguage, modules, { argv, clean, codeOnly, fingerprint, force, perLanguageDirectory, rosetta, runtimeTypeChecking, }) {
|
|
99
100
|
// ``argv.target`` is guaranteed valid by ``yargs`` through the ``choices`` directive.
|
|
100
101
|
const factory = targets_1.ALL_BUILDERS[targetLanguage];
|
|
101
102
|
if (!factory) {
|
|
102
103
|
throw new Error(`Unsupported target: '${targetLanguage}'`);
|
|
103
104
|
}
|
|
104
105
|
return factory(modules, {
|
|
106
|
+
arguments: argv,
|
|
105
107
|
clean: clean,
|
|
106
108
|
codeOnly: codeOnly,
|
|
107
|
-
rosetta,
|
|
108
|
-
force: force,
|
|
109
109
|
fingerprint: fingerprint,
|
|
110
|
-
|
|
110
|
+
force: force,
|
|
111
111
|
languageSubdirectory: perLanguageDirectory,
|
|
112
|
+
rosetta,
|
|
113
|
+
runtimeTypeChecking,
|
|
112
114
|
}).buildModules();
|
|
113
115
|
}
|
|
114
116
|
function sliceTargets(modulesSorted, requestedTargets, force) {
|
package/lib/target.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare abstract class Target {
|
|
|
12
12
|
protected readonly targetName: string;
|
|
13
13
|
protected readonly assembly: reflect.Assembly;
|
|
14
14
|
protected readonly rosetta: Rosetta;
|
|
15
|
+
protected readonly runtimeTypeChecking: boolean;
|
|
15
16
|
protected abstract readonly generator: IGenerator;
|
|
16
17
|
constructor(options: TargetOptions);
|
|
17
18
|
/**
|
|
@@ -125,6 +126,8 @@ export interface TargetOptions {
|
|
|
125
126
|
assembly: reflect.Assembly;
|
|
126
127
|
/** The Rosetta instance */
|
|
127
128
|
rosetta: Rosetta;
|
|
129
|
+
/** Whether to generate runtime type-checking code */
|
|
130
|
+
runtimeTypeChecking: boolean;
|
|
128
131
|
/**
|
|
129
132
|
* Whether to fingerprint the produced artifacts.
|
|
130
133
|
* @default true
|
package/lib/target.js
CHANGED
|
@@ -8,12 +8,13 @@ const dependency_graph_1 = require("./dependency-graph");
|
|
|
8
8
|
const logging = require("./logging");
|
|
9
9
|
class Target {
|
|
10
10
|
constructor(options) {
|
|
11
|
-
this.
|
|
11
|
+
this.arguments = options.arguments;
|
|
12
12
|
this.assembly = options.assembly;
|
|
13
|
-
this.rosetta = options.rosetta;
|
|
14
13
|
this.fingerprint = options.fingerprint ?? true;
|
|
15
14
|
this.force = options.force ?? false;
|
|
16
|
-
this.
|
|
15
|
+
this.packageDir = options.packageDir;
|
|
16
|
+
this.rosetta = options.rosetta;
|
|
17
|
+
this.runtimeTypeChecking = options.runtimeTypeChecking;
|
|
17
18
|
this.targetName = options.targetName;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
@@ -7,13 +7,16 @@ import { Generator, Legalese } from '../../generator';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class DotNetGenerator extends Generator {
|
|
9
9
|
private readonly assembliesCurrentlyBeingCompiled;
|
|
10
|
+
private readonly nameutils;
|
|
10
11
|
private readonly rosetta;
|
|
11
12
|
private firstMemberWritten;
|
|
12
13
|
private typeresolver;
|
|
13
|
-
private readonly nameutils;
|
|
14
14
|
private dotnetRuntimeGenerator;
|
|
15
15
|
private dotnetDocGenerator;
|
|
16
|
-
constructor(assembliesCurrentlyBeingCompiled: string[],
|
|
16
|
+
constructor(assembliesCurrentlyBeingCompiled: string[], options: {
|
|
17
|
+
readonly rosetta: Rosetta;
|
|
18
|
+
readonly runtimeTypeChecking: boolean;
|
|
19
|
+
});
|
|
17
20
|
load(packageRoot: string, assembly: reflect.Assembly): Promise<void>;
|
|
18
21
|
/**
|
|
19
22
|
* Runs the generator (in-memory).
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DotNetGenerator = void 0;
|
|
4
4
|
const spec = require("@jsii/spec");
|
|
5
5
|
const clone = require("clone");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
6
7
|
const fs = require("fs-extra");
|
|
7
8
|
const http = require("http");
|
|
8
9
|
const https = require("https");
|
|
@@ -18,18 +19,18 @@ const nameutils_1 = require("./nameutils");
|
|
|
18
19
|
* CODE GENERATOR V2
|
|
19
20
|
*/
|
|
20
21
|
class DotNetGenerator extends generator_1.Generator {
|
|
21
|
-
constructor(assembliesCurrentlyBeingCompiled,
|
|
22
|
-
super();
|
|
22
|
+
constructor(assembliesCurrentlyBeingCompiled, options) {
|
|
23
|
+
super(options);
|
|
23
24
|
this.assembliesCurrentlyBeingCompiled = assembliesCurrentlyBeingCompiled;
|
|
24
|
-
this.
|
|
25
|
+
this.nameutils = new nameutils_1.DotNetNameUtils();
|
|
25
26
|
// Flags that tracks if we have already wrote the first member of the class
|
|
26
27
|
this.firstMemberWritten = false;
|
|
27
|
-
this.nameutils = new nameutils_1.DotNetNameUtils();
|
|
28
28
|
// Override the openBlock to get a correct C# looking code block with the curly brace after the line
|
|
29
29
|
this.code.openBlock = function (text) {
|
|
30
30
|
this.line(text);
|
|
31
31
|
this.open('{');
|
|
32
32
|
};
|
|
33
|
+
this.rosetta = options.rosetta;
|
|
33
34
|
}
|
|
34
35
|
async load(packageRoot, assembly) {
|
|
35
36
|
await super.load(packageRoot, assembly);
|
|
@@ -443,6 +444,10 @@ class DotNetGenerator extends generator_1.Generator {
|
|
|
443
444
|
* @param noMangle use parameter names as-is (useful for setters, for example) instead of mangling them.
|
|
444
445
|
*/
|
|
445
446
|
emitUnionParameterValdation(parameters, { noMangle = false } = {}) {
|
|
447
|
+
if (!this.runtimeTypeChecking) {
|
|
448
|
+
// We were configured not to emit those, so bail out now.
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
446
451
|
const unionParameters = parameters?.filter(({ type }) => containsUnionType(type));
|
|
447
452
|
if (unionParameters == null || unionParameters.length === 0) {
|
|
448
453
|
return;
|
|
@@ -479,13 +484,19 @@ class DotNetGenerator extends generator_1.Generator {
|
|
|
479
484
|
}
|
|
480
485
|
}
|
|
481
486
|
function validateArray(value, descr, elementType, parameterName) {
|
|
482
|
-
const varName = `__idx_${
|
|
487
|
+
const varName = `__idx_${(0, crypto_1.createHash)('sha256')
|
|
488
|
+
.update(descr)
|
|
489
|
+
.digest('hex')
|
|
490
|
+
.slice(0, 6)}`;
|
|
483
491
|
this.code.openBlock(`for (int ${varName} = 0 ; ${varName} < ${value}.Length ; ${varName}++)`);
|
|
484
492
|
validate.call(this, `${value}[${varName}]`, `${descr}[{${varName}}]`, elementType, parameterName);
|
|
485
493
|
this.code.closeBlock();
|
|
486
494
|
}
|
|
487
495
|
function validateMap(value, descr, elementType, parameterName) {
|
|
488
|
-
const varName = `__item_${
|
|
496
|
+
const varName = `__item_${(0, crypto_1.createHash)('sha256')
|
|
497
|
+
.update(descr)
|
|
498
|
+
.digest('hex')
|
|
499
|
+
.slice(0, 6)}`;
|
|
489
500
|
this.code.openBlock(`foreach (var ${varName} in ${value})`);
|
|
490
501
|
validate.call(this, `${varName}.Value`, `${descr}[\\"{${varName}.Key}\\"]`, elementType, parameterName);
|
|
491
502
|
this.code.closeBlock();
|
|
@@ -518,6 +529,13 @@ class DotNetGenerator extends generator_1.Generator {
|
|
|
518
529
|
this.code.line(`${prefix}!(${test})`);
|
|
519
530
|
emitAnd = true;
|
|
520
531
|
}
|
|
532
|
+
if (typeRefs.some((ref) => spec.isNamedTypeReference(ref) &&
|
|
533
|
+
spec.isInterfaceType(this.findType(ref.fqn)))) {
|
|
534
|
+
// AnonymousObject will convert to any interface type, even if unsafely. It is the opaque
|
|
535
|
+
// type returned when a non-intrinsically typed value is passed through an any or union
|
|
536
|
+
// return point. We basically cannot type-check that at runtime in a complete way.
|
|
537
|
+
this.code.line(`&& !(${value} is Amazon.JSII.Runtime.Deputy.AnonymousObject)`);
|
|
538
|
+
}
|
|
521
539
|
this.code.unindent(')');
|
|
522
540
|
this.code.openBlock('');
|
|
523
541
|
const placeholders = typeRefs
|
package/lib/targets/dotnet.js
CHANGED
|
@@ -164,13 +164,14 @@ class DotnetBuilder {
|
|
|
164
164
|
}
|
|
165
165
|
makeTarget(module) {
|
|
166
166
|
return new Dotnet({
|
|
167
|
-
|
|
168
|
-
packageDir: module.moduleDirectory,
|
|
167
|
+
arguments: this.options.arguments,
|
|
169
168
|
assembly: module.assembly,
|
|
170
169
|
fingerprint: this.options.fingerprint,
|
|
171
170
|
force: this.options.force,
|
|
172
|
-
|
|
171
|
+
packageDir: module.moduleDirectory,
|
|
173
172
|
rosetta: this.options.rosetta,
|
|
173
|
+
runtimeTypeChecking: this.options.runtimeTypeChecking,
|
|
174
|
+
targetName: this.targetName,
|
|
174
175
|
}, this.modules.map((m) => m.name));
|
|
175
176
|
}
|
|
176
177
|
}
|
|
@@ -185,7 +186,7 @@ function projectLocation(module) {
|
|
|
185
186
|
class Dotnet extends target_1.Target {
|
|
186
187
|
constructor(options, assembliesCurrentlyBeingCompiled) {
|
|
187
188
|
super(options);
|
|
188
|
-
this.generator = new dotnetgenerator_1.DotNetGenerator(assembliesCurrentlyBeingCompiled, options
|
|
189
|
+
this.generator = new dotnetgenerator_1.DotNetGenerator(assembliesCurrentlyBeingCompiled, options);
|
|
189
190
|
}
|
|
190
191
|
static toPackageInfos(assm) {
|
|
191
192
|
const packageId = assm.targets.dotnet.packageId;
|
package/lib/targets/java.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/lib/targets/java.js
CHANGED
|
@@ -225,13 +225,14 @@ class JavaBuilder {
|
|
|
225
225
|
}
|
|
226
226
|
makeTarget(module, options) {
|
|
227
227
|
return new Java({
|
|
228
|
-
|
|
229
|
-
packageDir: module.moduleDirectory,
|
|
228
|
+
arguments: options.arguments,
|
|
230
229
|
assembly: module.assembly,
|
|
231
230
|
fingerprint: options.fingerprint,
|
|
232
231
|
force: options.force,
|
|
233
|
-
|
|
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
|
|
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(
|
|
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').
|
package/lib/targets/js.d.ts
CHANGED
|
@@ -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,7 +214,7 @@ 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
|
-
//
|
|
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
220
|
// be used instead of it's locally qualified name.
|
package/lib/targets/python.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/lib/targets/python.js
CHANGED
|
@@ -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);
|
|
@@ -440,7 +440,7 @@ class BaseMethod {
|
|
|
440
440
|
});
|
|
441
441
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
442
442
|
(!renderAbstract || !this.abstract)) {
|
|
443
|
-
emitParameterTypeChecks(code, pythonParams.slice(1), `${(0, type_name_1.toPythonFullName)(this.parent.fqn, context.assembly)}.${this.pythonName}`);
|
|
443
|
+
emitParameterTypeChecks(code, context, pythonParams.slice(1), `${(0, type_name_1.toPythonFullName)(this.parent.fqn, context.assembly)}.${this.pythonName}`);
|
|
444
444
|
}
|
|
445
445
|
this.emitBody(code, context, renderAbstract, forceEmitBody, liftedPropNames, pythonParams[0], returnType);
|
|
446
446
|
code.closeBlock();
|
|
@@ -597,7 +597,7 @@ class BaseProperty {
|
|
|
597
597
|
openSignature(code, 'def', this.pythonName, [this.implicitParameter, `value: ${pythonType}`], 'None');
|
|
598
598
|
if ((this.shouldEmitBody || forceEmitBody) &&
|
|
599
599
|
(!renderAbstract || !this.abstract)) {
|
|
600
|
-
emitParameterTypeChecks(code, [`value: ${pythonType}`],
|
|
600
|
+
emitParameterTypeChecks(code, context, [`value: ${pythonType}`],
|
|
601
601
|
// In order to get a property accessor, we must resort to getting the
|
|
602
602
|
// attribute on the type, instead of the value (where the getter would
|
|
603
603
|
// be implicitly invoked for us...)
|
|
@@ -744,7 +744,7 @@ class Struct extends BasePythonClassType {
|
|
|
744
744
|
code.line(`${member.pythonName} = ${typeName}(**${member.pythonName})`);
|
|
745
745
|
code.closeBlock();
|
|
746
746
|
}
|
|
747
|
-
emitParameterTypeChecks(code, kwargs, `${(0, type_name_1.toPythonFullName)(this.spec.fqn, context.assembly)}.__init__`);
|
|
747
|
+
emitParameterTypeChecks(code, context, kwargs, `${(0, type_name_1.toPythonFullName)(this.spec.fqn, context.assembly)}.__init__`);
|
|
748
748
|
// Required properties, those will always be put into the dict
|
|
749
749
|
assignDictionary(code, `${implicitParameter}._values: typing.Dict[str, typing.Any]`, members
|
|
750
750
|
.filter((m) => !m.optional)
|
|
@@ -1580,7 +1580,7 @@ class TypeResolver {
|
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
1582
1582
|
class PythonGenerator extends generator_1.Generator {
|
|
1583
|
-
constructor(rosetta, options
|
|
1583
|
+
constructor(rosetta, options) {
|
|
1584
1584
|
super(options);
|
|
1585
1585
|
this.rosetta = rosetta;
|
|
1586
1586
|
this.code.openBlockFormatter = (s) => `${s}:`;
|
|
@@ -1728,6 +1728,7 @@ class PythonGenerator extends generator_1.Generator {
|
|
|
1728
1728
|
assembly: assm,
|
|
1729
1729
|
emittedTypes: new Set(),
|
|
1730
1730
|
resolver,
|
|
1731
|
+
runtimeTypeChecking: this.runtimeTypeChecking,
|
|
1731
1732
|
submodule: assm.name,
|
|
1732
1733
|
typeResolver: (fqn) => resolver.dereference(fqn),
|
|
1733
1734
|
});
|
|
@@ -2012,7 +2013,10 @@ function openSignature(code, keyword, name, params, returnType, lineComment) {
|
|
|
2012
2013
|
* @param params the parameter signatures to be type-checked.
|
|
2013
2014
|
* @param typedEntity the type-annotated entity.
|
|
2014
2015
|
*/
|
|
2015
|
-
function emitParameterTypeChecks(code, params, typedEntity) {
|
|
2016
|
+
function emitParameterTypeChecks(code, context, params, typedEntity) {
|
|
2017
|
+
if (!context.runtimeTypeChecking) {
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2016
2020
|
const paramInfo = params.map((param) => {
|
|
2017
2021
|
const [name] = param.split(/\s*[:=#]\s*/, 1);
|
|
2018
2022
|
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
|
|
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.
|
|
2
|
+
export declare const VERSION = "1.65.0";
|
|
3
3
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
4
|
-
export declare const VERSION_DESC = "1.
|
|
4
|
+
export declare const VERSION_DESC = "1.65.0 (build 7a02b7f)";
|
|
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-
|
|
2
|
+
// Generated at 2022-08-18T14:34:45Z 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.
|
|
6
|
+
exports.VERSION = '1.65.0';
|
|
7
7
|
/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
|
|
8
|
-
exports.VERSION_DESC = '1.
|
|
8
|
+
exports.VERSION_DESC = '1.65.0 (build 7a02b7f)';
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsii-pacmak",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.65.0",
|
|
4
4
|
"description": "A code generation framework for jsii backend languages",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,31 +37,33 @@
|
|
|
37
37
|
"package": "package-js"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jsii/check-node": "1.
|
|
41
|
-
"@jsii/spec": "^1.
|
|
40
|
+
"@jsii/check-node": "1.65.0",
|
|
41
|
+
"@jsii/spec": "^1.65.0",
|
|
42
42
|
"clone": "^2.1.2",
|
|
43
|
-
"codemaker": "^1.
|
|
43
|
+
"codemaker": "^1.65.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.
|
|
48
|
-
"jsii-rosetta": "^1.
|
|
47
|
+
"jsii-reflect": "^1.65.0",
|
|
48
|
+
"jsii-rosetta": "^1.65.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.
|
|
56
|
-
"@jsii/java-runtime": "^1.
|
|
57
|
-
"@jsii/go-runtime": "^1.
|
|
58
|
-
"@scope/jsii-calc-lib": "^1.
|
|
55
|
+
"@jsii/dotnet-runtime": "^1.65.0",
|
|
56
|
+
"@jsii/java-runtime": "^1.65.0",
|
|
57
|
+
"@jsii/go-runtime": "^1.65.0",
|
|
58
|
+
"@scope/jsii-calc-lib": "^1.65.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
63
|
"@types/semver": "^7.3.10",
|
|
63
|
-
"
|
|
64
|
-
"jsii
|
|
64
|
+
"diff": "^5.1.0",
|
|
65
|
+
"jsii": "^1.65.0",
|
|
66
|
+
"jsii-build-tools": "^1.65.0",
|
|
65
67
|
"jsii-calc": "^3.20.120",
|
|
66
68
|
"pyright": "^1.1.266"
|
|
67
69
|
},
|