forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwiftStructImports.swift
More file actions
91 lines (82 loc) · 3.09 KB
/
SwiftStructImports.swift
File metadata and controls
91 lines (82 loc) · 3.09 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
extension Point: _BridgedSwiftStruct {
@_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point {
let y = Int.bridgeJSStackPop()
let x = Int.bridgeJSStackPop()
return Point(x: x, y: y)
}
@_spi(BridgeJS) @_transparent public consuming func bridgeJSStackPush() {
self.x.bridgeJSStackPush()
self.y.bridgeJSStackPush()
}
init(unsafelyCopying jsObject: JSObject) {
_bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}
func toJSObject() -> JSObject {
let __bjs_self = self
__bjs_self.bridgeJSStackPush()
return JSObject(id: UInt32(bitPattern: _bjs_struct_lift_Point()))
}
}
#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point")
fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_Point_extern(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void {
return _bjs_struct_lower_Point_extern(objectId)
}
#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lift_Point")
fileprivate func _bjs_struct_lift_Point_extern() -> Int32
#else
fileprivate func _bjs_struct_lift_Point_extern() -> Int32 {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func _bjs_struct_lift_Point() -> Int32 {
return _bjs_struct_lift_Point_extern()
}
#if arch(wasm32)
@_extern(wasm, module: "TestModule", name: "bjs_translate")
fileprivate func bjs_translate_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32
#else
fileprivate func bjs_translate_extern(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func bjs_translate(_ point: Int32, _ dx: Int32, _ dy: Int32) -> Int32 {
return bjs_translate_extern(point, dx, dy)
}
func _$translate(_ point: Point, _ dx: Int, _ dy: Int) throws(JSException) -> Point {
let pointObjectId = point.bridgeJSLowerParameter()
let dxValue = dx.bridgeJSLowerParameter()
let dyValue = dy.bridgeJSLowerParameter()
let ret = bjs_translate(pointObjectId, dxValue, dyValue)
if let error = _swift_js_take_exception() {
throw error
}
return Point.bridgeJSLiftReturn(ret)
}
#if arch(wasm32)
@_extern(wasm, module: "TestModule", name: "bjs_roundTripOptional")
fileprivate func bjs_roundTripOptional_extern(_ point: Int32) -> Void
#else
fileprivate func bjs_roundTripOptional_extern(_ point: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
@inline(never) fileprivate func bjs_roundTripOptional(_ point: Int32) -> Void {
return bjs_roundTripOptional_extern(point)
}
func _$roundTripOptional(_ point: Optional<Point>) throws(JSException) -> Optional<Point> {
let pointIsSome = point.bridgeJSLowerParameter()
bjs_roundTripOptional(pointIsSome)
if let error = _swift_js_take_exception() {
throw error
}
return Optional<Point>.bridgeJSLiftReturn()
}