Skip to content

Commit 6d36763

Browse files
committed
Regenerate fetchWeatherData bridging code
1 parent a250ab3 commit 6d36763

File tree

3 files changed

+311
-0
lines changed

3 files changed

+311
-0
lines changed

Tests/BridgeJSRuntimeTests/Generated/BridgeJS.Macros.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ extension FeatureFlag: _BridgedSwiftEnumNoPayload, _BridgedSwiftRawValueEnum {}
4343

4444
@JSFunction func runAsyncWorks() async throws(JSException) -> Void
4545

46+
@JSFunction func fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData
47+
48+
@JSClass struct WeatherData {
49+
@JSGetter var temperature: Double
50+
@JSSetter func setTemperature(_ value: Double) throws(JSException)
51+
@JSGetter var description: String
52+
@JSSetter func setDescription(_ value: String) throws(JSException)
53+
@JSGetter var humidity: Double
54+
@JSSetter func setHumidity(_ value: Double) throws(JSException)
55+
}
56+
4657
@JSFunction(jsName: "$jsWeirdFunction") func _jsWeirdFunction() throws(JSException) -> Double
4758
4859
@JSClass(jsName: "$WeirdClass") struct _WeirdClass {

Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,67 @@ public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11
17361736
#endif
17371737
}
17381738

1739+
#if arch(wasm32)
1740+
@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y")
1741+
fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void
1742+
#else
1743+
fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ callback: Int32, _ param0: Int32) -> Void {
1744+
fatalError("Only available on WebAssembly")
1745+
}
1746+
#endif
1747+
@inline(never) fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ callback: Int32, _ param0: Int32) -> Void {
1748+
return invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(callback, param0)
1749+
}
1750+
1751+
#if arch(wasm32)
1752+
@_extern(wasm, module: "bjs", name: "make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y")
1753+
fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer<UInt8>, _ line: UInt32) -> Int32
1754+
#else
1755+
fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer<UInt8>, _ line: UInt32) -> Int32 {
1756+
fatalError("Only available on WebAssembly")
1757+
}
1758+
#endif
1759+
@inline(never) fileprivate func make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ file: UnsafePointer<UInt8>, _ line: UInt32) -> Int32 {
1760+
return make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y_extern(boxPtr, file, line)
1761+
}
1762+
1763+
private enum _BJS_Closure_20BridgeJSRuntimeTestss11WeatherDataC_y {
1764+
static func bridgeJSLift(_ callbackId: Int32) -> (sending WeatherData) -> Void {
1765+
let callback = JSObject.bridgeJSLiftParameter(callbackId)
1766+
return { [callback] param0 in
1767+
#if arch(wasm32)
1768+
let callbackValue = callback.bridgeJSLowerParameter()
1769+
let param0Value = param0.bridgeJSLowerParameter()
1770+
invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(callbackValue, param0Value)
1771+
#else
1772+
fatalError("Only available on WebAssembly")
1773+
#endif
1774+
}
1775+
}
1776+
}
1777+
1778+
extension JSTypedClosure where Signature == (sending WeatherData) -> Void {
1779+
init(fileID: StaticString = #fileID, line: UInt32 = #line, _ body: @escaping (sending WeatherData) -> Void) {
1780+
self.init(
1781+
makeClosure: make_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y,
1782+
body: body,
1783+
fileID: fileID,
1784+
line: line
1785+
)
1786+
}
1787+
}
1788+
1789+
@_expose(wasm, "invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y")
1790+
@_cdecl("invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y")
1791+
public func _invoke_swift_closure_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss11WeatherDataC_y(_ boxPtr: UnsafeMutableRawPointer, _ param0: Int32) -> Void {
1792+
#if arch(wasm32)
1793+
let closure = Unmanaged<_BridgeJSTypedClosureBox<(sending WeatherData) -> Void>>.fromOpaque(boxPtr).takeUnretainedValue().closure
1794+
closure(WeatherData.bridgeJSLiftParameter(param0))
1795+
#else
1796+
fatalError("Only available on WebAssembly")
1797+
#endif
1798+
}
1799+
17391800
#if arch(wasm32)
17401801
@_extern(wasm, module: "bjs", name: "invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y")
17411802
fileprivate func invoke_js_callback_BridgeJSRuntimeTests_20BridgeJSRuntimeTestss7JSValueV_y_extern(_ callback: Int32, _ param0Kind: Int32, _ param0Payload1: Int32, _ param0Payload2: Float64) -> Void
@@ -12170,6 +12231,31 @@ func _$runAsyncWorks() async throws(JSException) -> Void {
1217012231
}
1217112232
}
1217212233

12234+
#if arch(wasm32)
12235+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_fetchWeatherData")
12236+
fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void
12237+
#else
12238+
fileprivate func bjs_fetchWeatherData_extern(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void {
12239+
fatalError("Only available on WebAssembly")
12240+
}
12241+
#endif
12242+
@inline(never) fileprivate func bjs_fetchWeatherData(_ resolveRef: Int32, _ rejectRef: Int32, _ cityBytes: Int32, _ cityLength: Int32) -> Void {
12243+
return bjs_fetchWeatherData_extern(resolveRef, rejectRef, cityBytes, cityLength)
12244+
}
12245+
12246+
func _$fetchWeatherData(_ city: String) async throws(JSException) -> WeatherData {
12247+
let resolved = try await _bjs_awaitPromise(makeResolveClosure: {
12248+
JSTypedClosure<(sending WeatherData) -> Void>($0)
12249+
}, makeRejectClosure: {
12250+
JSTypedClosure<(sending JSValue) -> Void>($0)
12251+
}) { resolveRef, rejectRef in
12252+
city.bridgeJSWithLoweredParameter { (cityBytes, cityLength) in
12253+
bjs_fetchWeatherData(resolveRef, rejectRef, cityBytes, cityLength)
12254+
}
12255+
}
12256+
return resolved
12257+
}
12258+
1217312259
#if arch(wasm32)
1217412260
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__jsWeirdFunction")
1217512261
fileprivate func bjs__jsWeirdFunction_extern() -> Float64
@@ -12348,6 +12434,133 @@ func _$JsGreeter_changeName(_ self: JSObject, _ name: String) throws(JSException
1234812434
}
1234912435
}
1235012436

12437+
#if arch(wasm32)
12438+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_get")
12439+
fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64
12440+
#else
12441+
fileprivate func bjs_WeatherData_temperature_get_extern(_ self: Int32) -> Float64 {
12442+
fatalError("Only available on WebAssembly")
12443+
}
12444+
#endif
12445+
@inline(never) fileprivate func bjs_WeatherData_temperature_get(_ self: Int32) -> Float64 {
12446+
return bjs_WeatherData_temperature_get_extern(self)
12447+
}
12448+
12449+
#if arch(wasm32)
12450+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_get")
12451+
fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32
12452+
#else
12453+
fileprivate func bjs_WeatherData_description_get_extern(_ self: Int32) -> Int32 {
12454+
fatalError("Only available on WebAssembly")
12455+
}
12456+
#endif
12457+
@inline(never) fileprivate func bjs_WeatherData_description_get(_ self: Int32) -> Int32 {
12458+
return bjs_WeatherData_description_get_extern(self)
12459+
}
12460+
12461+
#if arch(wasm32)
12462+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_get")
12463+
fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64
12464+
#else
12465+
fileprivate func bjs_WeatherData_humidity_get_extern(_ self: Int32) -> Float64 {
12466+
fatalError("Only available on WebAssembly")
12467+
}
12468+
#endif
12469+
@inline(never) fileprivate func bjs_WeatherData_humidity_get(_ self: Int32) -> Float64 {
12470+
return bjs_WeatherData_humidity_get_extern(self)
12471+
}
12472+
12473+
#if arch(wasm32)
12474+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_temperature_set")
12475+
fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void
12476+
#else
12477+
fileprivate func bjs_WeatherData_temperature_set_extern(_ self: Int32, _ newValue: Float64) -> Void {
12478+
fatalError("Only available on WebAssembly")
12479+
}
12480+
#endif
12481+
@inline(never) fileprivate func bjs_WeatherData_temperature_set(_ self: Int32, _ newValue: Float64) -> Void {
12482+
return bjs_WeatherData_temperature_set_extern(self, newValue)
12483+
}
12484+
12485+
#if arch(wasm32)
12486+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_description_set")
12487+
fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void
12488+
#else
12489+
fileprivate func bjs_WeatherData_description_set_extern(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void {
12490+
fatalError("Only available on WebAssembly")
12491+
}
12492+
#endif
12493+
@inline(never) fileprivate func bjs_WeatherData_description_set(_ self: Int32, _ newValueBytes: Int32, _ newValueLength: Int32) -> Void {
12494+
return bjs_WeatherData_description_set_extern(self, newValueBytes, newValueLength)
12495+
}
12496+
12497+
#if arch(wasm32)
12498+
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs_WeatherData_humidity_set")
12499+
fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void
12500+
#else
12501+
fileprivate func bjs_WeatherData_humidity_set_extern(_ self: Int32, _ newValue: Float64) -> Void {
12502+
fatalError("Only available on WebAssembly")
12503+
}
12504+
#endif
12505+
@inline(never) fileprivate func bjs_WeatherData_humidity_set(_ self: Int32, _ newValue: Float64) -> Void {
12506+
return bjs_WeatherData_humidity_set_extern(self, newValue)
12507+
}
12508+
12509+
func _$WeatherData_temperature_get(_ self: JSObject) throws(JSException) -> Double {
12510+
let selfValue = self.bridgeJSLowerParameter()
12511+
let ret = bjs_WeatherData_temperature_get(selfValue)
12512+
if let error = _swift_js_take_exception() {
12513+
throw error
12514+
}
12515+
return Double.bridgeJSLiftReturn(ret)
12516+
}
12517+
12518+
func _$WeatherData_description_get(_ self: JSObject) throws(JSException) -> String {
12519+
let selfValue = self.bridgeJSLowerParameter()
12520+
let ret = bjs_WeatherData_description_get(selfValue)
12521+
if let error = _swift_js_take_exception() {
12522+
throw error
12523+
}
12524+
return String.bridgeJSLiftReturn(ret)
12525+
}
12526+
12527+
func _$WeatherData_humidity_get(_ self: JSObject) throws(JSException) -> Double {
12528+
let selfValue = self.bridgeJSLowerParameter()
12529+
let ret = bjs_WeatherData_humidity_get(selfValue)
12530+
if let error = _swift_js_take_exception() {
12531+
throw error
12532+
}
12533+
return Double.bridgeJSLiftReturn(ret)
12534+
}
12535+
12536+
func _$WeatherData_temperature_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void {
12537+
let selfValue = self.bridgeJSLowerParameter()
12538+
let newValueValue = newValue.bridgeJSLowerParameter()
12539+
bjs_WeatherData_temperature_set(selfValue, newValueValue)
12540+
if let error = _swift_js_take_exception() {
12541+
throw error
12542+
}
12543+
}
12544+
12545+
func _$WeatherData_description_set(_ self: JSObject, _ newValue: String) throws(JSException) -> Void {
12546+
let selfValue = self.bridgeJSLowerParameter()
12547+
newValue.bridgeJSWithLoweredParameter { (newValueBytes, newValueLength) in
12548+
bjs_WeatherData_description_set(selfValue, newValueBytes, newValueLength)
12549+
}
12550+
if let error = _swift_js_take_exception() {
12551+
throw error
12552+
}
12553+
}
12554+
12555+
func _$WeatherData_humidity_set(_ self: JSObject, _ newValue: Double) throws(JSException) -> Void {
12556+
let selfValue = self.bridgeJSLowerParameter()
12557+
let newValueValue = newValue.bridgeJSLowerParameter()
12558+
bjs_WeatherData_humidity_set(selfValue, newValueValue)
12559+
if let error = _swift_js_take_exception() {
12560+
throw error
12561+
}
12562+
}
12563+
1235112564
#if arch(wasm32)
1235212565
@_extern(wasm, module: "BridgeJSRuntimeTests", name: "bjs__WeirdClass_init")
1235312566
fileprivate func bjs__WeirdClass_init_extern() -> Int32

Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18616,6 +18616,29 @@
1861618616
}
1861718617
}
1861818618
},
18619+
{
18620+
"effects" : {
18621+
"isAsync" : true,
18622+
"isStatic" : false,
18623+
"isThrows" : true
18624+
},
18625+
"name" : "fetchWeatherData",
18626+
"parameters" : [
18627+
{
18628+
"name" : "city",
18629+
"type" : {
18630+
"string" : {
18631+
18632+
}
18633+
}
18634+
}
18635+
],
18636+
"returnType" : {
18637+
"jsObject" : {
18638+
"_0" : "WeatherData"
18639+
}
18640+
}
18641+
},
1861918642
{
1862018643
"effects" : {
1862118644
"isAsync" : false,
@@ -18766,6 +18789,70 @@
1876618789

1876718790
]
1876818791
},
18792+
{
18793+
"getters" : [
18794+
{
18795+
"name" : "temperature",
18796+
"type" : {
18797+
"double" : {
18798+
18799+
}
18800+
}
18801+
},
18802+
{
18803+
"name" : "description",
18804+
"type" : {
18805+
"string" : {
18806+
18807+
}
18808+
}
18809+
},
18810+
{
18811+
"name" : "humidity",
18812+
"type" : {
18813+
"double" : {
18814+
18815+
}
18816+
}
18817+
}
18818+
],
18819+
"methods" : [
18820+
18821+
],
18822+
"name" : "WeatherData",
18823+
"setters" : [
18824+
{
18825+
"functionName" : "temperature_set",
18826+
"name" : "temperature",
18827+
"type" : {
18828+
"double" : {
18829+
18830+
}
18831+
}
18832+
},
18833+
{
18834+
"functionName" : "description_set",
18835+
"name" : "description",
18836+
"type" : {
18837+
"string" : {
18838+
18839+
}
18840+
}
18841+
},
18842+
{
18843+
"functionName" : "humidity_set",
18844+
"name" : "humidity",
18845+
"type" : {
18846+
"double" : {
18847+
18848+
}
18849+
}
18850+
}
18851+
],
18852+
"staticMethods" : [
18853+
18854+
]
18855+
},
1876918856
{
1877018857
"constructor" : {
1877118858
"parameters" : [

0 commit comments

Comments
 (0)