BridgeJS: Macro-annotated import notations #499
Draft
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
Example
Given bridge-js.d.ts:
ts2swiftnow emits human-read/writable Swift declarations:Then the macro-annotated importing declarations are processed by
ImportSwiftMacros, then it producesImportedModuleSkeleton.ImportTStakes the generatedImportedModuleSkeletonand produce Swift glue code. Note that now ImportTS is not responsible to generate user-facing interface like class declarations, but just generate thunk implementations. (maybe the Swift macro might generate thunks directly in the future).graph LR subgraph ModuleA A.swift --> G1[bridge-js generate] B.swift --> G1 B1[bridge-js.d.ts] --> T1[[ts2swift]] T1 --> M1[BridgeJS.Macros.swift] M1 --> G1 G1 --> G3[BridgeJS.json] G1 --> G2[BridgeJS.swift] end subgraph ModuleB C.swift --> G4[bridge-js generate] D.swift --> G4 B2[bridge-js.d.ts] --> T2[[ts2swift]] T2 --> M2[BridgeJS.Macros.swift] M2 --> G4 G4 --> G5[BridgeJS.swift] G4 --> G6[BridgeJS.json] end G3 --> L1[[bridge-js link]] G6 --> L1 L1 --> F1[bridge-js.js] L1 --> F2[bridge-js.d.ts] ModuleA -----> App[App.wasm] ModuleB -----> App App --> PKG[[PackageToJS]] F1 --> PKG F2 --> PKG