@@ -140,33 +140,28 @@ public final class JSTypedArray<Traits>: JSBridgedClass, ExpressibleByArrayLiter
140
140
}
141
141
}
142
142
143
- // MARK: - Int and UInt support
144
-
145
- // FIXME: Should be updated to support wasm64 when that becomes available.
146
- func valueForBitWidth< T> ( typeName: String , bitWidth: Int , when32: T ) -> T {
147
- if bitWidth == 32 {
148
- return when32
149
- } else if bitWidth == 64 {
150
- fatalError ( " 64-bit \( typeName) s are not yet supported in JSTypedArray " )
151
- } else {
152
- fatalError (
153
- " Unsupported bit width for type \( typeName) : \( bitWidth) (hint: stick to fixed-size \( typeName) s to avoid this issue) "
154
- )
155
- }
156
- }
157
-
158
143
extension Int : TypedArrayElement {
159
- public static var typedArrayClass : JSFunction { _typedArrayClass. wrappedValue }
160
- private static let _typedArrayClass = LazyThreadLocal ( initialize: {
161
- valueForBitWidth ( typeName: " Int " , bitWidth: Int . bitWidth, when32: JSObject . global. Int32Array) . function!
162
- } )
144
+ public static var typedArrayClass : JSFunction {
145
+ #if _pointerBitWidth(_32)
146
+ return JSObject . global. Int32Array. function!
147
+ #elseif _pointerBitWidth(_64)
148
+ return JSObject . global. Int64Array. function!
149
+ #else
150
+ #error("Unsupported pointer width")
151
+ #endif
152
+ }
163
153
}
164
154
165
155
extension UInt : TypedArrayElement {
166
- public static var typedArrayClass : JSFunction { _typedArrayClass. wrappedValue }
167
- private static let _typedArrayClass = LazyThreadLocal ( initialize: {
168
- valueForBitWidth ( typeName: " UInt " , bitWidth: Int . bitWidth, when32: JSObject . global. Uint32Array) . function!
169
- } )
156
+ public static var typedArrayClass : JSFunction {
157
+ #if _pointerBitWidth(_32)
158
+ return JSObject . global. Uint32Array. function!
159
+ #elseif _pointerBitWidth(_64)
160
+ return JSObject . global. Uint64Array. function!
161
+ #else
162
+ #error("Unsupported pointer width")
163
+ #endif
164
+ }
170
165
}
171
166
172
167
extension Int8 : TypedArrayElement {
0 commit comments