6
6
7
7
@_spi ( BridgeJS) import JavaScriptKit
8
8
9
+ @_expose ( wasm, " bjs_PlayBridgeJS_init " )
10
+ @_cdecl ( " bjs_PlayBridgeJS_init " )
11
+ public func _bjs_PlayBridgeJS_init( ) -> UnsafeMutableRawPointer {
12
+ #if arch(wasm32)
13
+ let ret = PlayBridgeJS ( )
14
+ return Unmanaged . passRetained ( ret) . toOpaque ( )
15
+ #else
16
+ fatalError ( " Only available on WebAssembly " )
17
+ #endif
18
+ }
19
+
20
+ @_expose ( wasm, " bjs_PlayBridgeJS_update " )
21
+ @_cdecl ( " bjs_PlayBridgeJS_update " )
22
+ public func _bjs_PlayBridgeJS_update( _self: UnsafeMutableRawPointer , swiftSourceBytes: Int32 , swiftSourceLen: Int32 , dtsSourceBytes: Int32 , dtsSourceLen: Int32 ) -> UnsafeMutableRawPointer {
23
+ #if arch(wasm32)
24
+ do {
25
+ let swiftSource = String ( unsafeUninitializedCapacity: Int ( swiftSourceLen) ) { b in
26
+ _swift_js_init_memory ( swiftSourceBytes, b. baseAddress. unsafelyUnwrapped)
27
+ return Int ( swiftSourceLen)
28
+ }
29
+ let dtsSource = String ( unsafeUninitializedCapacity: Int ( dtsSourceLen) ) { b in
30
+ _swift_js_init_memory ( dtsSourceBytes, b. baseAddress. unsafelyUnwrapped)
31
+ return Int ( dtsSourceLen)
32
+ }
33
+ let ret = try Unmanaged < PlayBridgeJS > . fromOpaque ( _self) . takeUnretainedValue ( ) . update ( swiftSource: swiftSource, dtsSource: dtsSource)
34
+ return Unmanaged . passRetained ( ret) . toOpaque ( )
35
+ } catch let error {
36
+ if let error = error. thrownValue. object {
37
+ withExtendedLifetime ( error) {
38
+ _swift_js_throw ( Int32 ( bitPattern: $0. id) )
39
+ }
40
+ } else {
41
+ let jsError = JSError ( message: String ( describing: error) )
42
+ withExtendedLifetime ( jsError. jsObject) {
43
+ _swift_js_throw ( Int32 ( bitPattern: $0. id) )
44
+ }
45
+ }
46
+ return UnsafeMutableRawPointer ( bitPattern: - 1 ) . unsafelyUnwrapped
47
+ }
48
+ #else
49
+ fatalError ( " Only available on WebAssembly " )
50
+ #endif
51
+ }
52
+
53
+ @_expose ( wasm, " bjs_PlayBridgeJS_deinit " )
54
+ @_cdecl ( " bjs_PlayBridgeJS_deinit " )
55
+ public func _bjs_PlayBridgeJS_deinit( pointer: UnsafeMutableRawPointer ) {
56
+ Unmanaged < PlayBridgeJS > . fromOpaque ( pointer) . release ( )
57
+ }
58
+
9
59
@_expose ( wasm, " bjs_PlayBridgeJSOutput_outputJs " )
10
60
@_cdecl ( " bjs_PlayBridgeJSOutput_outputJs " )
11
61
public func _bjs_PlayBridgeJSOutput_outputJs( _self: UnsafeMutableRawPointer ) -> Void {
@@ -62,54 +112,4 @@ public func _bjs_PlayBridgeJSOutput_exportSwiftGlue(_self: UnsafeMutableRawPoint
62
112
@_cdecl ( " bjs_PlayBridgeJSOutput_deinit " )
63
113
public func _bjs_PlayBridgeJSOutput_deinit( pointer: UnsafeMutableRawPointer ) {
64
114
Unmanaged < PlayBridgeJSOutput > . fromOpaque ( pointer) . release ( )
65
- }
66
-
67
- @_expose ( wasm, " bjs_PlayBridgeJS_init " )
68
- @_cdecl ( " bjs_PlayBridgeJS_init " )
69
- public func _bjs_PlayBridgeJS_init( ) -> UnsafeMutableRawPointer {
70
- #if arch(wasm32)
71
- let ret = PlayBridgeJS ( )
72
- return Unmanaged . passRetained ( ret) . toOpaque ( )
73
- #else
74
- fatalError ( " Only available on WebAssembly " )
75
- #endif
76
- }
77
-
78
- @_expose ( wasm, " bjs_PlayBridgeJS_update " )
79
- @_cdecl ( " bjs_PlayBridgeJS_update " )
80
- public func _bjs_PlayBridgeJS_update( _self: UnsafeMutableRawPointer , swiftSourceBytes: Int32 , swiftSourceLen: Int32 , dtsSourceBytes: Int32 , dtsSourceLen: Int32 ) -> UnsafeMutableRawPointer {
81
- #if arch(wasm32)
82
- do {
83
- let swiftSource = String ( unsafeUninitializedCapacity: Int ( swiftSourceLen) ) { b in
84
- _swift_js_init_memory ( swiftSourceBytes, b. baseAddress. unsafelyUnwrapped)
85
- return Int ( swiftSourceLen)
86
- }
87
- let dtsSource = String ( unsafeUninitializedCapacity: Int ( dtsSourceLen) ) { b in
88
- _swift_js_init_memory ( dtsSourceBytes, b. baseAddress. unsafelyUnwrapped)
89
- return Int ( dtsSourceLen)
90
- }
91
- let ret = try Unmanaged < PlayBridgeJS > . fromOpaque ( _self) . takeUnretainedValue ( ) . update ( swiftSource: swiftSource, dtsSource: dtsSource)
92
- return Unmanaged . passRetained ( ret) . toOpaque ( )
93
- } catch let error {
94
- if let error = error. thrownValue. object {
95
- withExtendedLifetime ( error) {
96
- _swift_js_throw ( Int32 ( bitPattern: $0. id) )
97
- }
98
- } else {
99
- let jsError = JSError ( message: String ( describing: error) )
100
- withExtendedLifetime ( jsError. jsObject) {
101
- _swift_js_throw ( Int32 ( bitPattern: $0. id) )
102
- }
103
- }
104
- return UnsafeMutableRawPointer ( bitPattern: - 1 ) . unsafelyUnwrapped
105
- }
106
- #else
107
- fatalError ( " Only available on WebAssembly " )
108
- #endif
109
- }
110
-
111
- @_expose ( wasm, " bjs_PlayBridgeJS_deinit " )
112
- @_cdecl ( " bjs_PlayBridgeJS_deinit " )
113
- public func _bjs_PlayBridgeJS_deinit( pointer: UnsafeMutableRawPointer ) {
114
- Unmanaged < PlayBridgeJS > . fromOpaque ( pointer) . release ( )
115
115
}
0 commit comments