Skip to content

Commit 1336270

Browse files
Expose swjs_library_features from Swift side
We now support only Swift 6.0 and above, so we can use `@_expose(wasm)` instead of `__attribute__((export_name))` and `@_cdecl` hack.
1 parent 653deb5 commit 1336270

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Diff for: Sources/JavaScriptKit/Features.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@ enum LibraryFeatures {
22
static let weakRefs: Int32 = 1 << 0
33
}
44

5-
@_cdecl("_library_features")
6-
func _library_features() -> Int32 {
5+
@_expose(wasm, "swjs_library_features")
6+
@_cdecl("_swjs_library_features")
7+
@available(*, unavailable)
8+
public func _swjs_library_features() -> Int32 {
79
var features: Int32 = 0
810
#if !JAVASCRIPTKIT_WITHOUT_WEAKREFS
911
features |= LibraryFeatures.weakRefs
1012
#endif
1113
return features
1214
}
13-
14-
#if compiler(>=6.0) && hasFeature(Embedded)
15-
// cdecls currently don't work in embedded, and expose for wasm only works >=6.0
16-
@_expose(wasm, "swjs_library_features")
17-
public func _swjs_library_features() -> Int32 { _library_features() }
18-
#endif

Diff for: Sources/_CJavaScriptKit/_CJavaScriptKit.c

-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ void swjs_free_host_function(const JavaScriptHostFuncRef host_func_ref) {
4646
_free_host_function_impl(host_func_ref);
4747
}
4848

49-
int _library_features(void);
50-
51-
__attribute__((export_name("swjs_library_features")))
52-
int swjs_library_features(void) {
53-
return _library_features();
54-
}
55-
5649
int swjs_get_worker_thread_id_cached(void) {
5750
_Thread_local static int tid = 0;
5851
if (tid == 0) {

0 commit comments

Comments
 (0)