GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove remaining export_name + cdecl hacks · t089/JavaScriptKit@396899c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Examples/Embedded/Sources/EmbeddedApp
    • _thingsThatShouldNotBeNeeded.swift
  • Sources
    • JavaScriptKit/FundamentalObjects
      • JSClosure.swift
    • _CJavaScriptKit
      • _CJavaScriptKit.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Examples/Embedded/Sources/EmbeddedApp/_thingsThatShouldNotBeNeeded.swift‎

Copy file name to clipboardExpand all lines: Examples/Embedded/Sources/EmbeddedApp/_thingsThatShouldNotBeNeeded.swift
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import JavaScriptKit
22

3-
// NOTE: it seems the embedded tree shaker gets rid of these exports if they are not used somewhere
4-
func _i_need_to_be_here_for_wasm_exports_to_work() {
5-
_ = _swjs_library_features
6-
_ = _swjs_call_host_function
7-
_ = _swjs_free_host_function
8-
}
9-
103
// TODO: why do I need this? and surely this is not ideal... figure this out, or at least have this come from a C lib
114
@_cdecl("strlen")
125
func strlen(_ s: UnsafePointer<Int8>) -> Int {
Collapse file

‎Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift‎

Copy file name to clipboardExpand all lines: Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift
+12-24Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ private func makeAsyncClosure(
197197
// └─────────────────────┴──────────────────────────┘
198198

199199
/// Returns true if the host function has been already released, otherwise false.
200-
@_cdecl("_call_host_function_impl")
201-
func _call_host_function_impl(
200+
@_expose(wasm, "swjs_call_host_function")
201+
@_cdecl("_swjs_call_host_function")
202+
@available(*, unavailable)
203+
public func _swjs_call_host_function(
202204
_ hostFuncRef: JavaScriptHostFuncRef,
203205
_ argv: UnsafePointer<RawJSValue>, _ argc: Int32,
204206
_ callbackFuncRef: JavaScriptObjectRef
@@ -231,9 +233,10 @@ extension JSClosure {
231233
}
232234
}
233235

234-
235-
@_cdecl("_free_host_function_impl")
236-
func _free_host_function_impl(_ hostFuncRef: JavaScriptHostFuncRef) {}
236+
@_expose(wasm, "swjs_free_host_function")
237+
@_cdecl("_swjs_free_host_function")
238+
@available(*, unavailable)
239+
func _swjs_free_host_function(_ hostFuncRef: JavaScriptHostFuncRef) {}
237240

238241
#else
239242

@@ -244,25 +247,10 @@ extension JSClosure {
244247

245248
}
246249

247-
@_cdecl("_free_host_function_impl")
248-
func _free_host_function_impl(_ hostFuncRef: JavaScriptHostFuncRef) {
249-
JSClosure.sharedClosures.wrappedValue[hostFuncRef] = nil
250-
}
251-
#endif
252-
253-
#if compiler(>=6.0) && hasFeature(Embedded)
254-
// cdecls currently don't work in embedded, and expose for wasm only works >=6.0
255-
@_expose(wasm, "swjs_call_host_function")
256-
public func _swjs_call_host_function(
257-
_ hostFuncRef: JavaScriptHostFuncRef,
258-
_ argv: UnsafePointer<RawJSValue>, _ argc: Int32,
259-
_ callbackFuncRef: JavaScriptObjectRef) -> Bool {
260-
261-
_call_host_function_impl(hostFuncRef, argv, argc, callbackFuncRef)
262-
}
263-
264250
@_expose(wasm, "swjs_free_host_function")
265-
public func _swjs_free_host_function(_ hostFuncRef: JavaScriptHostFuncRef) {
266-
_free_host_function_impl(hostFuncRef)
251+
@_cdecl("_swjs_free_host_function")
252+
@available(*, unavailable)
253+
func _swjs_free_host_function(_ hostFuncRef: JavaScriptHostFuncRef) {
254+
JSClosure.sharedClosures.wrappedValue[hostFuncRef] = nil
267255
}
268256
#endif
Collapse file

‎Sources/_CJavaScriptKit/_CJavaScriptKit.c‎

Copy file name to clipboardExpand all lines: Sources/_CJavaScriptKit/_CJavaScriptKit.c
-18Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,6 @@ void swjs_cleanup_host_function_call(void *argv_buffer) {
2828
// cdecls don't work in Embedded, but @_expose(wasm) can be used with Swift >=6.0
2929
// the previously used `#if __Embedded` did not play well with SwiftPM (defines needed to be on every target up the chain)
3030
#ifdef __wasi__
31-
bool _call_host_function_impl(const JavaScriptHostFuncRef host_func_ref,
32-
const RawJSValue *argv, const int argc,
33-
const JavaScriptObjectRef callback_func);
34-
35-
__attribute__((export_name("swjs_call_host_function")))
36-
bool swjs_call_host_function(const JavaScriptHostFuncRef host_func_ref,
37-
const RawJSValue *argv, const int argc,
38-
const JavaScriptObjectRef callback_func) {
39-
return _call_host_function_impl(host_func_ref, argv, argc, callback_func);
40-
}
41-
42-
void _free_host_function_impl(const JavaScriptHostFuncRef host_func_ref);
43-
44-
__attribute__((export_name("swjs_free_host_function")))
45-
void swjs_free_host_function(const JavaScriptHostFuncRef host_func_ref) {
46-
_free_host_function_impl(host_func_ref);
47-
}
48-
4931
int swjs_get_worker_thread_id_cached(void) {
5032
_Thread_local static int tid = 0;
5133
if (tid == 0) {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.