@@ -186,8 +186,8 @@ private func makeAsyncClosure(_ body: @escaping ([JSValue]) async throws -> JSVa
186
186
// └─────────────────────┴──────────────────────────┘
187
187
188
188
/// Returns true if the host function has been already released, otherwise false.
189
- @_expose ( wasm , " swjs_call_host_function " )
190
- public func _call_host_function_impl(
189
+ @_cdecl ( " _call_host_function_impl " )
190
+ func _call_host_function_impl(
191
191
_ hostFuncRef: JavaScriptHostFuncRef ,
192
192
_ argv: UnsafePointer < RawJSValue > , _ argc: Int32 ,
193
193
_ callbackFuncRef: JavaScriptObjectRef
@@ -217,8 +217,9 @@ extension JSClosure {
217
217
}
218
218
}
219
219
220
- @_expose ( wasm, " swjs_free_host_function " )
221
- public func _free_host_function_impl( _ hostFuncRef: JavaScriptHostFuncRef ) { }
220
+
221
+ @_cdecl ( " _free_host_function_impl " )
222
+ func _free_host_function_impl( _ hostFuncRef: JavaScriptHostFuncRef ) { }
222
223
223
224
#else
224
225
@@ -229,8 +230,25 @@ extension JSClosure {
229
230
230
231
}
231
232
232
- @_expose ( wasm , " swjs_free_host_function " )
233
- public func _free_host_function_impl( _ hostFuncRef: JavaScriptHostFuncRef ) {
233
+ @_cdecl ( " _free_host_function_impl " )
234
+ func _free_host_function_impl( _ hostFuncRef: JavaScriptHostFuncRef ) {
234
235
JSClosure . sharedClosures [ hostFuncRef] = nil
235
236
}
236
237
#endif
238
+
239
+ #if hasFeature(Embedded)
240
+ // cdecls currently don't work in embedded, and expose for wasm only works >=6.0
241
+ @_expose ( wasm, " swjs_call_host_function " )
242
+ public func _swjs_call_host_function(
243
+ _ hostFuncRef: JavaScriptHostFuncRef ,
244
+ _ argv: UnsafePointer < RawJSValue > , _ argc: Int32 ,
245
+ _ callbackFuncRef: JavaScriptObjectRef ) -> Bool {
246
+
247
+ _call_host_function_impl ( hostFuncRef, argv, argc, callbackFuncRef)
248
+ }
249
+
250
+ @_expose ( wasm, " swjs_free_host_function " )
251
+ public func _swjs_free_host_function( _ hostFuncRef: JavaScriptHostFuncRef ) {
252
+ _free_host_function_impl ( hostFuncRef)
253
+ }
254
+ #endif
0 commit comments