|
1 | 1 | // @ts-check |
2 | | -import { SwiftRuntime } from "./runtime.js" |
| 2 | +import { SwiftRuntime, createBridgeJSStubs } from "./runtime.js" |
3 | 3 |
|
4 | 4 | export const MODULE_PATH = "@PACKAGE_TO_JS_MODULE_PATH@"; |
5 | 5 | /* #if USE_SHARED_MEMORY */ |
@@ -30,39 +30,8 @@ async function createInstantiator(options, swift) { |
30 | 30 | addImports: (importObject, importsContext) => { |
31 | 31 | // Provide a default implementation for BridgeJS functions that are not |
32 | 32 | // used at runtime without BridgeJS but required to instantiate the module. |
33 | | - const unexpectedBjsCall = () => { throw new Error("Unexpected call to BridgeJS function") } |
34 | | - importObject["bjs"] = { |
35 | | - swift_js_return_string: unexpectedBjsCall, |
36 | | - swift_js_init_memory: unexpectedBjsCall, |
37 | | - swift_js_make_js_string: unexpectedBjsCall, |
38 | | - swift_js_init_memory_with_result: unexpectedBjsCall, |
39 | | - swift_js_throw: unexpectedBjsCall, |
40 | | - swift_js_retain: unexpectedBjsCall, |
41 | | - swift_js_release: unexpectedBjsCall, |
42 | | - swift_js_push_tag: unexpectedBjsCall, |
43 | | - swift_js_push_int: unexpectedBjsCall, |
44 | | - swift_js_push_f32: unexpectedBjsCall, |
45 | | - swift_js_push_f64: unexpectedBjsCall, |
46 | | - swift_js_push_string: unexpectedBjsCall, |
47 | | - swift_js_pop_param_int32: unexpectedBjsCall, |
48 | | - swift_js_pop_param_f32: unexpectedBjsCall, |
49 | | - swift_js_pop_param_f64: unexpectedBjsCall, |
50 | | - swift_js_return_optional_bool: unexpectedBjsCall, |
51 | | - swift_js_return_optional_int: unexpectedBjsCall, |
52 | | - swift_js_return_optional_string: unexpectedBjsCall, |
53 | | - swift_js_return_optional_double: unexpectedBjsCall, |
54 | | - swift_js_return_optional_float: unexpectedBjsCall, |
55 | | - swift_js_return_optional_heap_object: unexpectedBjsCall, |
56 | | - swift_js_return_optional_object: unexpectedBjsCall, |
57 | | - swift_js_get_optional_int_presence: unexpectedBjsCall, |
58 | | - swift_js_get_optional_int_value: unexpectedBjsCall, |
59 | | - swift_js_get_optional_string: unexpectedBjsCall, |
60 | | - swift_js_get_optional_float_presence: unexpectedBjsCall, |
61 | | - swift_js_get_optional_float_value: unexpectedBjsCall, |
62 | | - swift_js_get_optional_double_presence: unexpectedBjsCall, |
63 | | - swift_js_get_optional_double_value: unexpectedBjsCall, |
64 | | - swift_js_get_optional_heap_object_pointer: unexpectedBjsCall, |
65 | | - } |
| 33 | + |
| 34 | + importObject["bjs"] = createBridgeJSStubs(); |
66 | 35 | }, |
67 | 36 | /** @param {WebAssembly.Instance} instance */ |
68 | 37 | setInstance: (instance) => {}, |
|
0 commit comments