-
-
Notifications
You must be signed in to change notification settings - Fork 63
Add import-side array handling and JSClass array tests #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kateinoigakukun
wants to merge
7
commits into
main
Choose a base branch
from
katei/18e3-bridgejs-import
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…SCore/ImportTS.swift` to allow array lowering/lifting (stack-based, no ABI params) and to handle stack-only parameters in `CallJSEmission`. `Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift` now lifts array parameters and lowers array returns for imported JS functions using existing array fragments. `Sources/JavaScriptKit/BridgeJSIntrinsics.swift` gives `Array` stack bridging conformance plus import helpers (`bridgeJSLowerParameter`, `bridgeJSLiftReturn`, `bridgeJSLowerStackReturn`), covering nested arrays. Added `Plugins/BridgeJS/Tests/BridgeJSToolTests/Inputs/MacroSwift/ImportArray.swift` with corresponding snapshots for JSFunction array imports. Tests: `UPDATE_SNAPSHOTS=1 swift test --package-path ./Plugins/BridgeJS --filter BridgeJSCodegenTests` followed by `swift test --package-path ./Plugins/BridgeJS --filter BridgeJSCodegenTests` (pass). Next steps: 1) Run the full BridgeJS test suite (`swift test --package-path ./Plugins/BridgeJS`) to ensure wider coverage. 2) Consider runtime-side coverage (e.g., `make unittest` with `JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1`) if you want to exercise the new import path end-to-end.
…IFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1` now passes end-to-end (BridgeJS experimental runtime), all 20 suites / 94 tests green. A consuming-use issue in `Sources/JavaScriptKit/BridgeJSIntrinsics.swift` was fixed by working on a local copy of the array before iteration. Notes: - Command output showed intermediate “Corrupted JSON” from SwiftPM’s diagnostics phase, but run completed successfully. - Relevant file touched: `Sources/JavaScriptKit/BridgeJSIntrinsics.swift`.
…arations (`Tests/BridgeJSRuntimeTests/ImportArrayAPIs.swift`) and tests in `Tests/BridgeJSRuntimeTests/ImportAPITests.swift` validating roundtrip and length for `[Int]`/`[String]`, with JS implementations wired into `Tests/prelude.mjs`. Updated BridgeJSLink to allow stack-lifted parameters (array import) without assertions, and regenerated BridgeJS runtime glue. Tests: `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` (all 20 suites / 96 tests pass).
- 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).
- **JSGlueGen.swift**: merged the import/export array return handling into a single `return try arrayLower(...)` branch; no behavioral change, just removes redundant switch. Tests (BridgeJS runtime, with new array coverage) still pass: - `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` (20 suites / 96 tests).
- `ImportTS.swift`: array handling now returns the same lowering/lifting info without redundant `switch context` blocks (lines ~965, ~1056). - `JSGlueGen.swift`: array parameter lifting uses a single `arrayLift` branch (around line 1555). Re-ran runtime tests: `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` — all 20 suites / 96 tests still pass.
… fixed the cleanup scoping bug: - New struct `ArrayMembers` with array properties and methods, plus helper exports `arrayMembersSum`/`arrayMembersFirst` and `roundTripArrayMembers` (`Tests/BridgeJSRuntimeTests/StructAPIs.swift`). - JS prelude exercises array fields/methods via those exports (`Tests/prelude.mjs`). - Fixed optional-field lowering to guard cleanup code and hoist cleanup arrays so optional arrays don’t throw ReferenceError (`Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift`). Tests: `SWIFT_SDK_ID=DEVELOPMENT-SNAPSHOT-2025-11-03-a-wasm32-unknown-wasip1 make unittest` now passes (20 suites / 96 tests).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
Overview: