Skip to content

Commit 6c8d3ee

Browse files
Prefer UInt(bitPattern:) for object id to guarantee uniqueness
Close #218
1 parent 99c9965 commit 6c8d3ee

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Runtime/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class SwiftRuntime {
1414
private _instance: WebAssembly.Instance | null;
1515
private _memory: Memory | null;
1616
private _closureDeallocator: SwiftClosureDeallocator | null;
17-
private version: number = 708;
17+
private version: number = 709;
1818

1919
private textDecoder = new TextDecoder("utf-8");
2020
private textEncoder = new TextEncoder(); // Only support utf-8

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class JSOneshotClosure: JSObject, JSClosureProtocol {
2020
super.init(id: 0)
2121

2222
// 2. Create a new JavaScript function which calls the given Swift function.
23-
hostFuncRef = JavaScriptHostFuncRef(bitPattern: Int32(ObjectIdentifier(self).hashValue))
23+
hostFuncRef = JavaScriptHostFuncRef(bitPattern: ObjectIdentifier(self))
2424
id = withExtendedLifetime(JSString(file)) { file in
2525
_create_function(hostFuncRef, line, file.asInternalJSRef())
2626
}
@@ -86,7 +86,7 @@ public class JSClosure: JSObject, JSClosureProtocol {
8686
super.init(id: 0)
8787

8888
// 2. Create a new JavaScript function which calls the given Swift function.
89-
hostFuncRef = JavaScriptHostFuncRef(bitPattern: Int32(ObjectIdentifier(self).hashValue))
89+
hostFuncRef = JavaScriptHostFuncRef(bitPattern: ObjectIdentifier(self))
9090
id = withExtendedLifetime(JSString(file)) { file in
9191
_create_function(hostFuncRef, line, file.asInternalJSRef())
9292
}

Sources/_CJavaScriptKit/_CJavaScriptKit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void swjs_cleanup_host_function_call(void *argv_buffer) {
3737
/// this and `SwiftRuntime.version` in `./Runtime/src/index.ts`.
3838
__attribute__((export_name("swjs_library_version")))
3939
int swjs_library_version(void) {
40-
return 708;
40+
return 709;
4141
}
4242

4343
int _library_features(void);

Sources/_CJavaScriptKit/include/_CJavaScriptKit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
typedef unsigned int JavaScriptObjectRef;
1111
/// `JavaScriptHostFuncRef` represents Swift closure that is referenced by JavaScript side.
1212
/// This value is produced by `JSClosure`.
13-
typedef unsigned int JavaScriptHostFuncRef;
13+
typedef uintptr_t JavaScriptHostFuncRef;
1414

1515
/// `JavaScriptValueKind` represents the kind of JavaScript primitive value.
1616
typedef enum __attribute__((enum_extensibility(closed))) {

0 commit comments

Comments
 (0)