Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7861,6 +7861,17 @@ public func _bjs_Vector2D_scaled(_ factor: Float64) -> Void {
#endif
}

@_expose(wasm, "bjs_Vector2D_describe")
@_cdecl("bjs_Vector2D_describe")
public func _bjs_Vector2D_describe() -> Void {
#if arch(wasm32)
let ret = Vector2D.bridgeJSLiftParameter().describe()
return ret.bridgeJSLowerReturn()
#else
fatalError("Only available on WebAssembly")
#endif
}

extension JSObjectContainer: _BridgedSwiftStruct {
@_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> JSObjectContainer {
let optionalObject = Optional<JSObject>.bridgeJSStackPop()
Expand Down
17 changes: 17 additions & 0 deletions Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json
Original file line number Diff line number Diff line change
Expand Up @@ -19680,6 +19680,23 @@
"_0" : "Vector2D"
}
}
},
{
"abiName" : "bjs_Vector2D_describe",
"effects" : {
"isAsync" : false,
"isStatic" : false,
"isThrows" : false
},
"name" : "describe",
"parameters" : [

],
"returnType" : {
"string" : {

}
}
}
],
"name" : "Vector2D",
Expand Down
4 changes: 4 additions & 0 deletions Tests/BridgeJSRuntimeTests/StructAPIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ extension Vector2D {
@JS func scaled(by factor: Double) -> Vector2D {
return Vector2D(dx: dx * factor, dy: dy * factor)
}

@JS func describe() -> String {
return "Vector2D(\(dx), \(dy))"
}
}

@JS func roundTripDataPoint(_ data: DataPoint) -> DataPoint {
Expand Down
1 change: 1 addition & 0 deletions Tests/prelude.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ function testStructSupport(exports) {
const scaled = vec.scaled(2.0);
assert.equal(scaled.dx, 6.0);
assert.equal(scaled.dy, 8.0);
assert.equal(vec.describe(), "Vector2D(3.0, 4.0)");

const publicPoint = { x: 9, y: -3 };
assert.deepEqual(exports.roundTripPublicPoint(publicPoint), publicPoint);
Expand Down
Loading