Skip to content

Commit 0ca4256

Browse files
authored
Merge pull request #492 from swiftwasm/yt/fix-wrong-getImports
BridgeJS: Remove call to `getImports` when no JS interface is imported
2 parents 8d23cdb + c1dbce8 commit 0ca4256

29 files changed

+5
-29
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,12 @@ struct BridgeJSLink {
313313
printer.write(lines: [
314314
"bjs = {};",
315315
"importObject[\"bjs\"] = bjs;",
316-
"const imports = options.getImports(importsContext);",
317316
])
317+
if self.importedSkeletons.count > 0 {
318+
printer.write(lines: [
319+
"const imports = options.getImports(importsContext);"
320+
])
321+
}
318322
printer.write("bjs[\"swift_js_return_string\"] = function(ptr, len) {")
319323
printer.indent {
320324
printer.write(

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Async.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export async function createInstantiator(options, swift) {
3939
addImports: (importObject, importsContext) => {
4040
bjs = {};
4141
importObject["bjs"] = bjs;
42-
const imports = options.getImports(importsContext);
4342
bjs["swift_js_return_string"] = function(ptr, len) {
4443
const bytes = new Uint8Array(memory.buffer, ptr, len);
4544
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DefaultParameters.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export async function createInstantiator(options, swift) {
9393
addImports: (importObject, importsContext) => {
9494
bjs = {};
9595
importObject["bjs"] = bjs;
96-
const imports = options.getImports(importsContext);
9796
bjs["swift_js_return_string"] = function(ptr, len) {
9897
const bytes = new Uint8Array(memory.buffer, ptr, len);
9998
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumAssociatedValue.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ export async function createInstantiator(options, swift) {
515515
addImports: (importObject, importsContext) => {
516516
bjs = {};
517517
importObject["bjs"] = bjs;
518-
const imports = options.getImports(importsContext);
519518
bjs["swift_js_return_string"] = function(ptr, len) {
520519
const bytes = new Uint8Array(memory.buffer, ptr, len);
521520
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumCase.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export async function createInstantiator(options, swift) {
6363
addImports: (importObject, importsContext) => {
6464
bjs = {};
6565
importObject["bjs"] = bjs;
66-
const imports = options.getImports(importsContext);
6766
bjs["swift_js_return_string"] = function(ptr, len) {
6867
const bytes = new Uint8Array(memory.buffer, ptr, len);
6968
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export async function createInstantiator(options, swift) {
6464
addImports: (importObject, importsContext) => {
6565
bjs = {};
6666
importObject["bjs"] = bjs;
67-
const imports = options.getImports(importsContext);
6867
bjs["swift_js_return_string"] = function(ptr, len) {
6968
const bytes = new Uint8Array(memory.buffer, ptr, len);
7069
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export async function createInstantiator(options, swift) {
8383
addImports: (importObject, importsContext) => {
8484
bjs = {};
8585
importObject["bjs"] = bjs;
86-
const imports = options.getImports(importsContext);
8786
bjs["swift_js_return_string"] = function(ptr, len) {
8887
const bytes = new Uint8Array(memory.buffer, ptr, len);
8988
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumRawType.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export async function createInstantiator(options, swift) {
114114
addImports: (importObject, importsContext) => {
115115
bjs = {};
116116
importObject["bjs"] = bjs;
117-
const imports = options.getImports(importsContext);
118117
bjs["swift_js_return_string"] = function(ptr, len) {
119118
const bytes = new Uint8Array(memory.buffer, ptr, len);
120119
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedGlobal.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export async function createInstantiator(options, swift) {
3939
addImports: (importObject, importsContext) => {
4040
bjs = {};
4141
importObject["bjs"] = bjs;
42-
const imports = options.getImports(importsContext);
4342
bjs["swift_js_return_string"] = function(ptr, len) {
4443
const bytes = new Uint8Array(memory.buffer, ptr, len);
4544
tmpRetString = textDecoder.decode(bytes);

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.Export.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export async function createInstantiator(options, swift) {
3939
addImports: (importObject, importsContext) => {
4040
bjs = {};
4141
importObject["bjs"] = bjs;
42-
const imports = options.getImports(importsContext);
4342
bjs["swift_js_return_string"] = function(ptr, len) {
4443
const bytes = new Uint8Array(memory.buffer, ptr, len);
4544
tmpRetString = textDecoder.decode(bytes);

0 commit comments

Comments
 (0)