forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumCase.swift
More file actions
230 lines (212 loc) · 6.76 KB
/
Copy pathEnumCase.swift
File metadata and controls
230 lines (212 loc) · 6.76 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
extension Direction: _BridgedSwiftCaseEnum {
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 {
return bridgeJSRawValue
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Direction {
return bridgeJSLiftParameter(value)
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Direction {
return Direction(bridgeJSRawValue: value)!
}
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 {
return bridgeJSLowerParameter()
}
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
switch bridgeJSRawValue {
case 0:
self = .north
case 1:
self = .south
case 2:
self = .east
case 3:
self = .west
default:
return nil
}
}
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
switch self {
case .north:
return 0
case .south:
return 1
case .east:
return 2
case .west:
return 3
}
}
}
extension Status: _BridgedSwiftCaseEnum {
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 {
return bridgeJSRawValue
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> Status {
return bridgeJSLiftParameter(value)
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> Status {
return Status(bridgeJSRawValue: value)!
}
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 {
return bridgeJSLowerParameter()
}
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
switch bridgeJSRawValue {
case 0:
self = .loading
case 1:
self = .success
case 2:
self = .error
default:
return nil
}
}
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
switch self {
case .loading:
return 0
case .success:
return 1
case .error:
return 2
}
}
}
extension TSDirection: _BridgedSwiftCaseEnum {
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 {
return bridgeJSRawValue
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> TSDirection {
return bridgeJSLiftParameter(value)
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> TSDirection {
return TSDirection(bridgeJSRawValue: value)!
}
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 {
return bridgeJSLowerParameter()
}
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
switch bridgeJSRawValue {
case 0:
self = .north
case 1:
self = .south
case 2:
self = .east
case 3:
self = .west
default:
return nil
}
}
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
switch self {
case .north:
return 0
case .south:
return 1
case .east:
return 2
case .west:
return 3
}
}
}
extension PublicStatus: _BridgedSwiftCaseEnum {
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerParameter() -> Int32 {
return bridgeJSRawValue
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftReturn(_ value: Int32) -> PublicStatus {
return bridgeJSLiftParameter(value)
}
@_spi(BridgeJS) @_transparent public static func bridgeJSLiftParameter(_ value: Int32) -> PublicStatus {
return PublicStatus(bridgeJSRawValue: value)!
}
@_spi(BridgeJS) @_transparent public consuming func bridgeJSLowerReturn() -> Int32 {
return bridgeJSLowerParameter()
}
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
switch bridgeJSRawValue {
case 0:
self = .success
default:
return nil
}
}
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
switch self {
case .success:
return 0
}
}
}
@_expose(wasm, "bjs_setDirection")
@_cdecl("bjs_setDirection")
public func _bjs_setDirection(_ direction: Int32) -> Void {
#if arch(wasm32)
setDirection(_: Direction.bridgeJSLiftParameter(direction))
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_getDirection")
@_cdecl("bjs_getDirection")
public func _bjs_getDirection() -> Int32 {
#if arch(wasm32)
let ret = getDirection()
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_processDirection")
@_cdecl("bjs_processDirection")
public func _bjs_processDirection(_ input: Int32) -> Int32 {
#if arch(wasm32)
let ret = processDirection(_: Direction.bridgeJSLiftParameter(input))
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_roundTripOptionalDirection")
@_cdecl("bjs_roundTripOptionalDirection")
public func _bjs_roundTripOptionalDirection(_ inputIsSome: Int32, _ inputValue: Int32) -> Void {
#if arch(wasm32)
let ret = roundTripOptionalDirection(_: Optional<Direction>.bridgeJSLiftParameter(inputIsSome, inputValue))
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_setTSDirection")
@_cdecl("bjs_setTSDirection")
public func _bjs_setTSDirection(_ direction: Int32) -> Void {
#if arch(wasm32)
setTSDirection(_: TSDirection.bridgeJSLiftParameter(direction))
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_getTSDirection")
@_cdecl("bjs_getTSDirection")
public func _bjs_getTSDirection() -> Int32 {
#if arch(wasm32)
let ret = getTSDirection()
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}
@_expose(wasm, "bjs_roundTripOptionalTSDirection")
@_cdecl("bjs_roundTripOptionalTSDirection")
public func _bjs_roundTripOptionalTSDirection(_ inputIsSome: Int32, _ inputValue: Int32) -> Void {
#if arch(wasm32)
let ret = roundTripOptionalTSDirection(_: Optional<TSDirection>.bridgeJSLiftParameter(inputIsSome, inputValue))
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}