Skip to content

Commit d822fec

Browse files
Merge pull request #44 from swiftwasm/resolve-small-issues
Resolve small issues
2 parents 002a72f + af97471 commit d822fec

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Diff for: Runtime/src/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ export class SwiftRuntime {
398398
writeUint32(result_obj, this.heap.retain(result));
399399
},
400400
swjs_instanceof: (
401-
obj_ref: ref, constructor_ref: ref,
402-
result_ptr: pointer
401+
obj_ref: ref, constructor_ref: ref
403402
) => {
404403
const obj = this.heap.referenceHeap(obj_ref)
405404
const constructor = this.heap.referenceHeap(constructor_ref)
@@ -415,9 +414,6 @@ export class SwiftRuntime {
415414
// Call `.slice()` to copy the memory
416415
writeUint32(result_obj, this.heap.retain(array.slice()));
417416
},
418-
swjs_retain: (ref: ref) => {
419-
this.heap.retain(this.heap.referenceHeap(ref))
420-
},
421417
swjs_release: (ref: ref) => {
422418
this.heap.release(ref)
423419
}

Diff for: Sources/JavaScriptKit/BasicObjects/JSTypedArray.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import _CJavaScriptKit
66

77
public protocol TypedArrayElement: JSValueConvertible, JSValueConstructible {
88
static var typedArrayKind: JavaScriptTypedArrayKind { get }
9-
static var typedArrayClass: JSFunctionRef { get }
9+
static var typedArrayClass: JSFunction { get }
1010
}
1111

1212
public class JSTypedArray<Element>: JSValueConvertible, ExpressibleByArrayLiteral where Element: TypedArrayElement {
@@ -23,7 +23,7 @@ public class JSTypedArray<Element>: JSValueConvertible, ExpressibleByArrayLitera
2323
setJSValue(this: ref, index: Int32(index), value: newValue.jsValue())
2424
}
2525
}
26-
26+
2727
// This private initializer assumes that the passed object is TypedArray
2828
private init(unsafe object: JSObject) {
2929
self.ref = object
@@ -70,16 +70,16 @@ func valueForBitWidth<T>(typeName: String, bitWidth: Int, when32: T) -> T {
7070
}
7171

7272
extension Int: TypedArrayElement {
73-
public static var typedArrayClass: JSFunctionRef {
74-
valueForBitWidth(typeName: "Int", bitWidth: Int.bitWidth, when32: JSObjectRef.global.Int32Array).function!
73+
public static var typedArrayClass: JSFunction {
74+
valueForBitWidth(typeName: "Int", bitWidth: Int.bitWidth, when32: JSObject.global.Int32Array).function!
7575
}
7676
public static var typedArrayKind: JavaScriptTypedArrayKind {
7777
valueForBitWidth(typeName: "Int", bitWidth: Int.bitWidth, when32: .int32)
7878
}
7979
}
8080
extension UInt: TypedArrayElement {
81-
public static var typedArrayClass: JSFunctionRef {
82-
valueForBitWidth(typeName: "UInt", bitWidth: Int.bitWidth, when32: JSObjectRef.global.Uint32Array).function!
81+
public static var typedArrayClass: JSFunction {
82+
valueForBitWidth(typeName: "UInt", bitWidth: Int.bitWidth, when32: JSObject.global.Uint32Array).function!
8383
}
8484
public static var typedArrayKind: JavaScriptTypedArrayKind {
8585
valueForBitWidth(typeName: "UInt", bitWidth: UInt.bitWidth, when32: .uint32)
@@ -89,30 +89,30 @@ extension UInt: TypedArrayElement {
8989
// MARK: - Concrete TypedArray classes
9090

9191
extension Int8: TypedArrayElement {
92-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Int8Array.function! }
92+
public static var typedArrayClass: JSFunction { JSObject.global.Int8Array.function! }
9393
public static var typedArrayKind: JavaScriptTypedArrayKind { .int8 }
9494
}
9595
extension UInt8: TypedArrayElement {
96-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Uint8Array.function! }
96+
public static var typedArrayClass: JSFunction { JSObject.global.Uint8Array.function! }
9797
public static var typedArrayKind: JavaScriptTypedArrayKind { .uint8 }
9898
}
9999
// TODO: Support Uint8ClampedArray?
100100

101101
extension Int16: TypedArrayElement {
102-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Int16Array.function! }
102+
public static var typedArrayClass: JSFunction { JSObject.global.Int16Array.function! }
103103
public static var typedArrayKind: JavaScriptTypedArrayKind { .int16 }
104104
}
105105
extension UInt16: TypedArrayElement {
106-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Uint16Array.function! }
106+
public static var typedArrayClass: JSFunction { JSObject.global.Uint16Array.function! }
107107
public static var typedArrayKind: JavaScriptTypedArrayKind { .uint16 }
108108
}
109109

110110
extension Int32: TypedArrayElement {
111-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Int32Array.function! }
111+
public static var typedArrayClass: JSFunction { JSObject.global.Int32Array.function! }
112112
public static var typedArrayKind: JavaScriptTypedArrayKind { .int32 }
113113
}
114114
extension UInt32: TypedArrayElement {
115-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Uint32Array.function! }
115+
public static var typedArrayClass: JSFunction { JSObject.global.Uint32Array.function! }
116116
public static var typedArrayKind: JavaScriptTypedArrayKind { .uint32 }
117117
}
118118

@@ -127,10 +127,10 @@ extension UInt32: TypedArrayElement {
127127
//}
128128

129129
extension Float32: TypedArrayElement {
130-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Float32Array.function! }
130+
public static var typedArrayClass: JSFunction { JSObject.global.Float32Array.function! }
131131
public static var typedArrayKind: JavaScriptTypedArrayKind { .float32 }
132132
}
133133
extension Float64: TypedArrayElement {
134-
public static var typedArrayClass: JSFunctionRef { JSObjectRef.global.Float64Array.function! }
134+
public static var typedArrayClass: JSFunction { JSObject.global.Float64Array.function! }
135135
public static var typedArrayKind: JavaScriptTypedArrayKind { .float64 }
136136
}

Diff for: Sources/_CJavaScriptKit/include/module.modulemap

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module _CJavaScriptKit {
2+
header "_CJavaScriptKit.h"
3+
export *
4+
}

0 commit comments

Comments
 (0)