11
11
public func _bjs_PlayBridgeJS_init( ) -> UnsafeMutableRawPointer {
12
12
#if arch(wasm32)
13
13
let ret = PlayBridgeJS ( )
14
- return Unmanaged . passRetained ( ret) . toOpaque ( )
14
+ return ret. bridgeJSLowerReturn ( )
15
15
#else
16
16
fatalError ( " Only available on WebAssembly " )
17
17
#endif
18
18
}
19
19
20
20
@_expose ( wasm, " bjs_PlayBridgeJS_update " )
21
21
@_cdecl ( " bjs_PlayBridgeJS_update " )
22
- public func _bjs_PlayBridgeJS_update( _self: UnsafeMutableRawPointer , swiftSourceBytes: Int32 , swiftSourceLen : Int32 , dtsSourceBytes: Int32 , dtsSourceLen : Int32 ) -> UnsafeMutableRawPointer {
22
+ public func _bjs_PlayBridgeJS_update( _self: UnsafeMutableRawPointer , swiftSourceBytes: Int32 , swiftSourceLength : Int32 , dtsSourceBytes: Int32 , dtsSourceLength : Int32 ) -> UnsafeMutableRawPointer {
23
23
#if arch(wasm32)
24
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 ( )
25
+ let ret = try PlayBridgeJS . bridgeJSLiftParameter ( _self) . update ( swiftSource: String . bridgeJSLiftParameter ( swiftSourceBytes, swiftSourceLength) , dtsSource: String . bridgeJSLiftParameter ( dtsSourceBytes, dtsSourceLength) )
26
+ return ret. bridgeJSLowerReturn ( )
35
27
} catch let error {
36
28
if let error = error. thrownValue. object {
37
29
withExtendedLifetime ( error) {
@@ -56,10 +48,16 @@ public func _bjs_PlayBridgeJS_deinit(pointer: UnsafeMutableRawPointer) {
56
48
Unmanaged < PlayBridgeJS > . fromOpaque ( pointer) . release ( )
57
49
}
58
50
59
- extension PlayBridgeJS : ConvertibleToJSValue {
51
+ extension PlayBridgeJS : ConvertibleToJSValue , _BridgedSwiftHeapObject {
60
52
var jsValue : JSValue {
53
+ #if arch(wasm32)
61
54
@_extern ( wasm, module: " PlayBridgeJS " , name: " bjs_PlayBridgeJS_wrap " )
62
55
func _bjs_PlayBridgeJS_wrap( _: UnsafeMutableRawPointer ) -> Int32
56
+ #else
57
+ func _bjs_PlayBridgeJS_wrap( _: UnsafeMutableRawPointer ) -> Int32 {
58
+ fatalError ( " Only available on WebAssembly " )
59
+ }
60
+ #endif
63
61
return . object( JSObject ( id: UInt32 ( bitPattern: _bjs_PlayBridgeJS_wrap ( Unmanaged . passRetained ( self ) . toOpaque ( ) ) ) ) )
64
62
}
65
63
}
@@ -68,10 +66,8 @@ extension PlayBridgeJS: ConvertibleToJSValue {
68
66
@_cdecl ( " bjs_PlayBridgeJSOutput_outputJs " )
69
67
public func _bjs_PlayBridgeJSOutput_outputJs( _self: UnsafeMutableRawPointer ) -> Void {
70
68
#if arch(wasm32)
71
- var ret = Unmanaged < PlayBridgeJSOutput > . fromOpaque ( _self) . takeUnretainedValue ( ) . outputJs ( )
72
- return ret. withUTF8 { ptr in
73
- _swift_js_return_string ( ptr. baseAddress, Int32 ( ptr. count) )
74
- }
69
+ let ret = PlayBridgeJSOutput . bridgeJSLiftParameter ( _self) . outputJs ( )
70
+ return ret. bridgeJSLowerReturn ( )
75
71
#else
76
72
fatalError ( " Only available on WebAssembly " )
77
73
#endif
@@ -81,10 +77,8 @@ public func _bjs_PlayBridgeJSOutput_outputJs(_self: UnsafeMutableRawPointer) ->
81
77
@_cdecl ( " bjs_PlayBridgeJSOutput_outputDts " )
82
78
public func _bjs_PlayBridgeJSOutput_outputDts( _self: UnsafeMutableRawPointer ) -> Void {
83
79
#if arch(wasm32)
84
- var ret = Unmanaged < PlayBridgeJSOutput > . fromOpaque ( _self) . takeUnretainedValue ( ) . outputDts ( )
85
- return ret. withUTF8 { ptr in
86
- _swift_js_return_string ( ptr. baseAddress, Int32 ( ptr. count) )
87
- }
80
+ let ret = PlayBridgeJSOutput . bridgeJSLiftParameter ( _self) . outputDts ( )
81
+ return ret. bridgeJSLowerReturn ( )
88
82
#else
89
83
fatalError ( " Only available on WebAssembly " )
90
84
#endif
@@ -94,10 +88,8 @@ public func _bjs_PlayBridgeJSOutput_outputDts(_self: UnsafeMutableRawPointer) ->
94
88
@_cdecl ( " bjs_PlayBridgeJSOutput_importSwiftGlue " )
95
89
public func _bjs_PlayBridgeJSOutput_importSwiftGlue( _self: UnsafeMutableRawPointer ) -> Void {
96
90
#if arch(wasm32)
97
- var ret = Unmanaged < PlayBridgeJSOutput > . fromOpaque ( _self) . takeUnretainedValue ( ) . importSwiftGlue ( )
98
- return ret. withUTF8 { ptr in
99
- _swift_js_return_string ( ptr. baseAddress, Int32 ( ptr. count) )
100
- }
91
+ let ret = PlayBridgeJSOutput . bridgeJSLiftParameter ( _self) . importSwiftGlue ( )
92
+ return ret. bridgeJSLowerReturn ( )
101
93
#else
102
94
fatalError ( " Only available on WebAssembly " )
103
95
#endif
@@ -107,10 +99,8 @@ public func _bjs_PlayBridgeJSOutput_importSwiftGlue(_self: UnsafeMutableRawPoint
107
99
@_cdecl ( " bjs_PlayBridgeJSOutput_exportSwiftGlue " )
108
100
public func _bjs_PlayBridgeJSOutput_exportSwiftGlue( _self: UnsafeMutableRawPointer ) -> Void {
109
101
#if arch(wasm32)
110
- var ret = Unmanaged < PlayBridgeJSOutput > . fromOpaque ( _self) . takeUnretainedValue ( ) . exportSwiftGlue ( )
111
- return ret. withUTF8 { ptr in
112
- _swift_js_return_string ( ptr. baseAddress, Int32 ( ptr. count) )
113
- }
102
+ let ret = PlayBridgeJSOutput . bridgeJSLiftParameter ( _self) . exportSwiftGlue ( )
103
+ return ret. bridgeJSLowerReturn ( )
114
104
#else
115
105
fatalError ( " Only available on WebAssembly " )
116
106
#endif
@@ -122,10 +112,16 @@ public func _bjs_PlayBridgeJSOutput_deinit(pointer: UnsafeMutableRawPointer) {
122
112
Unmanaged < PlayBridgeJSOutput > . fromOpaque ( pointer) . release ( )
123
113
}
124
114
125
- extension PlayBridgeJSOutput : ConvertibleToJSValue {
115
+ extension PlayBridgeJSOutput : ConvertibleToJSValue , _BridgedSwiftHeapObject {
126
116
var jsValue : JSValue {
117
+ #if arch(wasm32)
127
118
@_extern ( wasm, module: " PlayBridgeJS " , name: " bjs_PlayBridgeJSOutput_wrap " )
128
119
func _bjs_PlayBridgeJSOutput_wrap( _: UnsafeMutableRawPointer ) -> Int32
120
+ #else
121
+ func _bjs_PlayBridgeJSOutput_wrap( _: UnsafeMutableRawPointer ) -> Int32 {
122
+ fatalError ( " Only available on WebAssembly " )
123
+ }
124
+ #endif
129
125
return . object( JSObject ( id: UInt32 ( bitPattern: _bjs_PlayBridgeJSOutput_wrap ( Unmanaged . passRetained ( self ) . toOpaque ( ) ) ) ) )
130
126
}
131
127
}
0 commit comments