forked from swiftwasm/WebAPIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayBufferView.swift
More file actions
92 lines (87 loc) · 3.34 KB
/
ArrayBufferView.swift
File metadata and controls
92 lines (87 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// This file was auto-generated by WebIDLToSwift. DO NOT EDIT!
import JavaScriptKit
// TODO: expand this to BigInt arrays
public protocol AnyArrayBufferView: ConvertibleToJSValue {}
extension DataView: AnyArrayBufferView {}
extension JSTypedArray: AnyArrayBufferView {}
public enum ArrayBufferView: JSValueCompatible, AnyArrayBufferView {
case dataView(DataView)
// case bigInt64Array(BigInt64Array)
// case bigUint64Array(BigUint64Array)
case float32Array(Float32Array)
case float64Array(Float64Array)
case int16Array(Int16Array)
case int32Array(Int32Array)
case int8Array(Int8Array)
case uint16Array(Uint16Array)
case uint32Array(Uint32Array)
case uint8Array(Uint8Array)
case uint8ClampedArray(JSUInt8ClampedArray)
public static func construct(from value: JSValue) -> Self? {
// if let bigInt64Array: BigInt64Array = value.fromJSValue() {
// return .bigInt64Array(bigInt64Array)
// }
// if let bigUint64Array: BigUint64Array = value.fromJSValue() {
// return .bigUint64Array(bigUint64Array)
// }
if let dataView: DataView = value.fromJSValue() {
return .dataView(dataView)
}
if let float32Array: Float32Array = value.fromJSValue() {
return .float32Array(float32Array)
}
if let float64Array: Float64Array = value.fromJSValue() {
return .float64Array(float64Array)
}
if let int16Array: Int16Array = value.fromJSValue() {
return .int16Array(int16Array)
}
if let int32Array: Int32Array = value.fromJSValue() {
return .int32Array(int32Array)
}
if let int8Array: Int8Array = value.fromJSValue() {
return .int8Array(int8Array)
}
if let uint16Array: Uint16Array = value.fromJSValue() {
return .uint16Array(uint16Array)
}
if let uint32Array: Uint32Array = value.fromJSValue() {
return .uint32Array(uint32Array)
}
if let uint8Array: Uint8Array = value.fromJSValue() {
return .uint8Array(uint8Array)
}
if let uint8ClampedArray: JSUInt8ClampedArray = value.fromJSValue() {
return .uint8ClampedArray(uint8ClampedArray)
}
return nil
}
public var jsValue: JSValue {
switch self {
// case let .bigInt64Array(bigInt64Array):
// return bigInt64Array.jsValue
// case let .bigUint64Array(bigUint64Array):
// return bigUint64Array.jsValue
case let .dataView(dataView):
return dataView.jsValue
case let .float32Array(float32Array):
return float32Array.jsValue
case let .float64Array(float64Array):
return float64Array.jsValue
case let .int16Array(int16Array):
return int16Array.jsValue
case let .int32Array(int32Array):
return int32Array.jsValue
case let .int8Array(int8Array):
return int8Array.jsValue
case let .uint16Array(uint16Array):
return uint16Array.jsValue
case let .uint32Array(uint32Array):
return uint32Array.jsValue
case let .uint8Array(uint8Array):
return uint8Array.jsValue
case let .uint8ClampedArray(uint8ClampedArray):
return uint8ClampedArray.jsValue
}
}
}