Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ public struct BridgeJSLink {
printer.write("return pointer || 0;")
}
printer.write("}")
// Always provide swift_js_closure_unregister as a no-op by default.
// The @_extern(wasm) declaration in BridgeJSIntrinsics.swift is unconditional,
// so the WASM binary always imports this symbol. When closures ARE used,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// so the WASM binary always imports this symbol. When closures ARE used,
// so the Wasm binary always imports this symbol. When closures ARE used,

// the real implementation below will override this no-op.
printer.write("bjs[\"swift_js_closure_unregister\"] = function(funcRef) {}")

for unified in skeletons {
let moduleName = unified.moduleName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
},
setInstance: (i) => {
instance = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
},
setInstance: (i) => {
instance = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_takesFeatureFlag"] = function bjs_takesFeatureFlag(flag) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_console_get"] = function bjs_console_get() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_console_get"] = function bjs_console_get() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_roundtrip"] = function bjs_roundtrip() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_Foo_init"] = function bjs_Foo_init() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_createWeirdObject"] = function bjs_createWeirdObject() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_returnAnimatable"] = function bjs_returnAnimatable() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_StaticBox_create_static"] = function bjs_StaticBox_create_static(value) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: GlobalModule
if (!importObject["GlobalModule"]) {
importObject["GlobalModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_check"] = function bjs_check(a, b) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_checkNumber"] = function bjs_checkNumber() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_checkString"] = function bjs_checkString(a) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_checkString"] = function bjs_checkString() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
bjs["swift_js_closure_unregister"] = function(funcRef) {
const func = swift.memory.getObject(funcRef);
func.__unregister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
bjs["swift_js_closure_unregister"] = function(funcRef) {
const func = swift.memory.getObject(funcRef);
func.__unregister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
// Wrapper functions for module: TestModule
if (!importObject["TestModule"]) {
importObject["TestModule"] = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_translate"] = function bjs_translate(point, dx, dy) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
},
setInstance: (i) => {
instance = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
},
setInstance: (i) => {
instance = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function createInstantiator(options, swift) {
tmpRetOptionalHeapObject = undefined;
return pointer || 0;
}
bjs["swift_js_closure_unregister"] = function(funcRef) {}
const TestModule = importObject["TestModule"] = importObject["TestModule"] || {};
TestModule["bjs_check"] = function bjs_check() {
try {
Expand Down