Skip to content

Commit 18339d3

Browse files
committed
BridgeJS: Always provide swift_js_closure_unregister intrinsic in generated bridge-js.js
1 parent 8217d06 commit 18339d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+46
-0
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ public struct BridgeJSLink {
602602
printer.write("return pointer || 0;")
603603
}
604604
printer.write("}")
605+
// Always provide swift_js_closure_unregister as a no-op by default.
606+
// The @_extern(wasm) declaration in BridgeJSIntrinsics.swift is unconditional,
607+
// so the WASM binary always imports this symbol. When closures ARE used,
608+
// the real implementation below will override this no-op.
609+
printer.write("bjs[\"swift_js_closure_unregister\"] = function(funcRef) {}")
605610

606611
for unified in skeletons {
607612
let moduleName = unified.moduleName

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export async function createInstantiator(options, swift) {
236236
tmpRetOptionalHeapObject = undefined;
237237
return pointer || 0;
238238
}
239+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
239240
// Wrapper functions for module: TestModule
240241
if (!importObject["TestModule"]) {
241242
importObject["TestModule"] = {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
197197
tmpRetOptionalHeapObject = undefined;
198198
return pointer || 0;
199199
}
200+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
200201
},
201202
setInstance: (i) => {
202203
instance = i;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ export async function createInstantiator(options, swift) {
272272
tmpRetOptionalHeapObject = undefined;
273273
return pointer || 0;
274274
}
275+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
275276
// Wrapper functions for module: TestModule
276277
if (!importObject["TestModule"]) {
277278
importObject["TestModule"] = {};

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/DictionaryTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
198198
tmpRetOptionalHeapObject = undefined;
199199
return pointer || 0;
200200
}
201+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
201202
// Wrapper functions for module: TestModule
202203
if (!importObject["TestModule"]) {
203204
importObject["TestModule"] = {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ export async function createInstantiator(options, swift) {
10541054
tmpRetOptionalHeapObject = undefined;
10551055
return pointer || 0;
10561056
}
1057+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
10571058
// Wrapper functions for module: TestModule
10581059
if (!importObject["TestModule"]) {
10591060
importObject["TestModule"] = {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export async function createInstantiator(options, swift) {
221221
tmpRetOptionalHeapObject = undefined;
222222
return pointer || 0;
223223
}
224+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
224225
},
225226
setInstance: (i) => {
226227
instance = i;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export async function createInstantiator(options, swift) {
241241
tmpRetOptionalHeapObject = undefined;
242242
return pointer || 0;
243243
}
244+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
244245
// Wrapper functions for module: TestModule
245246
if (!importObject["TestModule"]) {
246247
importObject["TestModule"] = {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export async function createInstantiator(options, swift) {
222222
tmpRetOptionalHeapObject = undefined;
223223
return pointer || 0;
224224
}
225+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
225226
// Wrapper functions for module: TestModule
226227
if (!importObject["TestModule"]) {
227228
importObject["TestModule"] = {};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export async function createInstantiator(options, swift) {
273273
tmpRetOptionalHeapObject = undefined;
274274
return pointer || 0;
275275
}
276+
bjs["swift_js_closure_unregister"] = function(funcRef) {}
276277
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
277278
TestModule["bjs_takesFeatureFlag"] = function bjs_takesFeatureFlag(flag) {
278279
try {

0 commit comments

Comments
 (0)