Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork57
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 -> SwiftJavaScript side (JSGlueGen):- Corresponding lift/lower functions for JS <-> Wasm interopAdds CodeFragmentPrinter for improved code organization.Reduces generated code complexity across both Swift and JS.
Clean up variable declaration in VariableDeclSyntax visitor.
Introduce _BridgedSwiftTypeLoweredIntoSingleWasmCoreType protocolto formalize lift/lower operations. All basic types (Bool, Int,Float, Double) now conform to this protocol with standardizedbridgeJS* methods.Add _BridgedSwiftHeapObject and _BridgedSwiftEnumNoPayload protocolsfor heap objects and enums respectively.Update generated code and test snapshots to use new protocol-basedintrinsic functions.
…gedClassAdd _JSBridgedClass protocol with lift/lower operations for JavaScriptobjects imported into Swift. Update ImportTS code generation to usenew protocol-based bridgeJS* methods.Update all generated ImportTS Swift files and test snapshots to usethe new bridgeJS* method calls instead of legacy functions.
9811899 to177be43CompareThis is a workaround for the issue that reference to imported bjswasm functions can't be eliminated in debug builds, even if theyare 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/ReturnandbridgeJSLiftParameter/Returnmethods - Adds
CodeFragmentPrinterfor 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 updatesJSBridgedClass to inherit from it |
| Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift | New file implementing JavaScript-side lift/lower operations withIntrinsicJSFragment |
| 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 orlearn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 protocoland fix incomplete documentation comment for the remaining protocol.
cb3ea6c intomainUh oh!
There was an error while loading.Please reload this page.
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.