Repository navigation
BridgeJS: Replace the extraction logic with SwiftExtract - #808
kateinoigakukun wants to merge 2 commits into
Conversation
f379618 to
4fd5e0e
Compare
|
@kateinoigakukun I continued your draft here (rebased on main, moved to the released swift-binding-generator-core and ported what landed since). Could you review my commit on top of yours? GitHub doesn't let me request a review from the PR author. |
4fd5e0e to
53ead3f
Compare
kateinoigakukun
left a comment
There was a problem hiding this comment.
@krodak Thanks for following up! Looks good to me!
| .package(url: "https://github.com/swiftlang/swift-syntax", from: "603.0.0"), | ||
| .package( | ||
| url: "https://github.com/swiftlang/swift-binding-generator-core", | ||
| .upToNextMinor(from: "0.1.0") |
There was a problem hiding this comment.
Because of swift-subprocess dependency, I prefer we don't tag new JavaScriptKit before new SBGC is tagged that includes swiftlang/swift-binding-generator-core#21 and relaxes swift-subprocess package graph constraint.
There was a problem hiding this comment.
Hmm, can we even remove the swift-subprocess dependency from SBGC? The usage seems pretty trivial and not worth spending time fetching the dependency. It slows down the example projects build
There was a problem hiding this comment.
Agreed, swift-subprocess seems to be only used by the static build config plugin to run swift frontend -print-static-build-config once, so Foundation.Process would do. @MaxDesiatov would you be up for folding that into swiftlang/swift-binding-generator-core#21 instead of bumping the version?
I could also send a separate PR if you'd rather keep #21 as is
There was a problem hiding this comment.
I don't mind either way, it's up to @ktoso as the codeowner to consider removing it.
Overview
This replaces BridgeJS's hand-written declaration extractor (
SwiftToSkeletonplusTypeDeclResolver) withSwiftExtractfrom swift-binding-generator-core, the extraction layer shared with swift-java.SwiftToSkeletonnow runsSwiftAnalyzerand lowers its result into the skeleton inExportLoweringandImportLowering. All JavaScript-specific rules (BridgeTypemapping,@JSarguments, namespaces, diagnostics) stay in BridgeJS.The first commit is Yuta's original proof of concept. The second commit finishes it:
1. Released dependency. The symlinks into a local swift-java checkout are replaced by
swift-binding-generator-core0.1.0(.upToNextMinor). Two gaps found along the way were fixed upstream before the release: a caller-provided build configuration for#if(swiftlang/swift-binding-generator-core#14) and declarations likevar a: Int, b: String(swiftlang/swift-binding-generator-core#15).2. Parity with current main. The upstream changes made since the proof of concept are ported: custom exported type names, protocol refinement and constrained generic imports,
any Tand(T), escaped parameter names, the async/throwing struct initializer diagnostic, and the diagnostic for non-class conformers of@JSprotocols. Types and members are emitted in source order, so the snapshots and the committedGenerated/bindings are unchanged. Diagnostic messages are unchanged. As before, declarations in every#ifbranch are extracted: BridgeJS removes the directives before analysis.3. Behavior changes.
@JS actornow gets a clear diagnostic.@JStype now work.BridgeJS tests,
bridge-js-generate.sh(no diff),check:bridgejs-dts,make unittestand the PlayBridgeJS example (also run in WebAssembly) pass.