Skip to content

Commit 389fe9e

Browse files
Added import-side array coverage and cleaned up the generator/runtime:
- New JS imports and runtime tests for arrays: `Tests/BridgeJSRuntimeTests/ImportArrayAPIs.swift` and added roundtrip/length checks in `Tests/BridgeJSRuntimeTests/ImportAPITests.swift` with JS implementations in `Tests/prelude.mjs`. - Fixed import codegen to avoid unused return warnings and support stack-only returns: `Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift` now skips `ret` binding when ABI return is absent. - Allowed zero-parameter lifting fragments in JS glue to handle stack-returning arrays: `Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift`. - Regenerated BridgeJS artifacts for runtime tests. Tests: `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` (all 20 suites / 96 tests passing).
1 parent 3774db4 commit 389fe9e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public struct ImportTS {
189189
}
190190

191191
func call(returnType: BridgeType) throws {
192+
let liftingInfo = try returnType.liftingReturnInfo(context: context)
192193
// Build function call expression
193194
let callExpr = FunctionCallExprSyntax(
194195
calledExpression: ExprSyntax("\(raw: abiName)"),
@@ -206,6 +207,9 @@ public struct ImportTS {
206207
} else if returnType.usesSideChannelForOptionalReturn() {
207208
// Side channel returns don't need "let ret ="
208209
body.append(CodeBlockItemSyntax(item: .stmt(StmtSyntax(ExpressionStmtSyntax(expression: callExpr)))))
210+
} else if liftingInfo.valueToLift == nil {
211+
// Value is returned via stacks, no direct ABI return
212+
body.append(CodeBlockItemSyntax(item: .stmt(StmtSyntax(ExpressionStmtSyntax(expression: callExpr)))))
209213
} else {
210214
body.append("let ret = \(raw: callExpr)")
211215
}

0 commit comments

Comments
 (0)