-
-
Notifications
You must be signed in to change notification settings - Fork 55
BridgeJS: Standardize lift/lower pattern across Swift and JavaScript #423
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
Conversation
Replace global intrinsic functions with consistent extension-based system. Each bridged type now defines standardized lift/lower operations: Swift side (type extensions): - bridgeJSLowerParameter/Return: Swift -> Wasm core types - bridgeJSLiftParameter/Return: Wasm core types -> Swift JavaScript side (JSGlueGen): - Corresponding lift/lower functions for JS <-> Wasm interop Adds CodeFragmentPrinter for improved code organization. Reduces generated code complexity across both Swift and JS.
Clean up variable declaration in VariableDeclSyntax visitor.
Introduce _BridgedSwiftTypeLoweredIntoSingleWasmCoreType protocol to formalize lift/lower operations. All basic types (Bool, Int, Float, Double) now conform to this protocol with standardized bridgeJS* methods. Add _BridgedSwiftHeapObject and _BridgedSwiftEnumNoPayload protocols for heap objects and enums respectively. Update generated code and test snapshots to use new protocol-based intrinsic functions.
…gedClass Add _JSBridgedClass protocol with lift/lower operations for JavaScript objects imported into Swift. Update ImportTS code generation to use new protocol-based bridgeJS* methods. Update all generated ImportTS Swift files and test snapshots to use the new bridgeJS* method calls instead of legacy functions.
9811899
to
177be43
Compare
This is a workaround for the issue that reference to imported bjs wasm functions can't be eliminated in debug builds, even if they are not reachable at runtime without explicit BridgeJS usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR standardizes the lift/lower pattern across Swift and JavaScript by replacing global intrinsic functions with a consistent extension-based system. The change implements standardized bridge operations for each type, improving code organization and reducing complexity.
- Introduces a standardized lift/lower protocol system for all bridged types
- Replaces manual type conversion code with consistent
bridgeJSLowerParameter/Return
andbridgeJSLiftParameter/Return
methods - Adds
CodeFragmentPrinter
for improved JavaScript code generation
Reviewed Changes
Copilot reviewed 51 out of 56 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
Sources/JavaScriptKit/BridgeJSInstrincics.swift | Implements standardized lift/lower extensions for all basic types (Bool, Int, Float, Double, String, JSObject) and bridged types |
Sources/JavaScriptKit/JSBridgedType.swift | Adds _JSBridgedClass protocol and updates JSBridgedClass to inherit from it |
Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift | New file implementing JavaScript-side lift/lower operations with IntrinsicJSFragment |
Plugins/BridgeJS/Sources/BridgeJSLink/CodeFragmentPrinter.swift | New utility class for organized code fragment printing |
Multiple test snapshots | Updates generated code to use new standardized bridge methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
Remove unused _BridgedSwiftTypeLoweredIntoWasmCoreType protocol and fix incomplete documentation comment for the remaining protocol.
Replace global intrinsic functions with consistent extension-based system.
Each bridged type now defines standardized lift/lower operations:
Swift side (type extensions):
JavaScript side (JSGlueGen):
Adds CodeFragmentPrinter for improved code organization.
Reduces generated code complexity across both Swift and JS.