WIP: BridgeJS: Enum export support for multiple associated values of primitive types #434
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.
Introduction
This PR support for enums with associated values of primitive types to the BridgeJS plugin.
This is WIP just to discuss JS / Swift generated code side, I'm working on migrating this to new lifting / lowering approach and align with changes merged over last couple of days and will issue final PR soon.
In the meantime wanted to sync on
tmpRet = [];
parameters - I'd integrate any feedback along migrating to new changes_BJSBinaryReader
and new extern methods toBridgeJSInstrincics.swift
to align withmain
updates, I'd integrate any feedback on those along the way as wellOverview
I've decided to go with DataView buffer to encode short type information and then payload, to pass single value across the boundaries and unpack it on the other side.
I started with single value primitives using what is currently available, then migrated to serializing parameters into JSON string and with current solution
Other option I've considered but rejected was to generate a separate WASM export function for each enum case - this eliminates the need for case dispatching and parameter packing, but on the other hand it would lead to WASM export explosion given that each case in each enum would end up as separate function and multiple associated values within single case would lead to unreadable long parameters chains.
Examples
Case Enum with Both Styles
Generated TypeScript:
Testing
All tests are added, after merging fix for nested types nesting and method calls are also working
Docs
Will be added in final PR after updating to accommodate
main
changes