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