Commit f483b91
authored
[BridgeJS] Synthesize typed-closure init access from declaration surface (swiftwasm#709) (swiftwasm#727)
* [BridgeJS] Synthesize typed-closure init access from declaration surface
Resolves swiftwasm#709: a public `@JSClass` exposing a
`JSTypedClosure<...>` parameter could not be consumed from another target
because the synthesized `extension JSTypedClosure { init(...) }` was always
internal, leaving downstream callers no way to construct the closure value
without hand-rolling a public wrapper.
Imported skeleton entries now record the source access level
(`public`/`package`/`internal`); the closure-signature collector takes the
maximum across every surface that references a given signature, and
`ClosureCodegen` prefixes the synthesized init with the resulting modifier
(internal stays bare). This matches the pattern `JSClassMacro` already uses
for `init(unsafelyWrapping:)`.
* [BridgeJS] Address PR feedback and refresh generated artifacts
- Make `accessLevel` decode-tolerant on imported skeleton structs
(`ImportedFunctionSkeleton`, `ImportedConstructorSkeleton`,
`ImportedGetterSkeleton`, `ImportedSetterSkeleton`,
`ImportedTypeSkeleton`) by writing explicit `init(from:)` decoders
that fall back to `.internal` when the key is missing. Without this,
any pre-existing skeleton JSON without the new field fails decoding —
the `build-examples` CI job hit `DecodingError.keyNotFound` for
`accessLevel` against externally consumed skeletons.
- Extract a private `recordSignature` helper so `visitClosure` and
`recordInjectedSignature` share a single merge implementation.
- Assert in `withAccessLevel(rawLevel:)` so unknown access strings
("open", "private", future schema additions) surface in debug
builds instead of silently inheriting the outer level.
- Document the `.internal` seeding assumption on
`ClosureSignatureCollectorVisitor.init(moduleName:signatures:)`.
- Regenerate the BridgeJS pre-generated artifacts under Benchmarks/,
Examples/PlayBridgeJS/, Tests/BridgeJSIdentityTests/, and
Tests/BridgeJSRuntimeTests/ via `./Utilities/bridge-js-generate.sh`,
per CONTRIBUTING.md. The runtime-tests Swift output now emits
`public init` on three `JSTypedClosure` extensions whose signatures
surface through public exported types.
* [BridgeJS] Refresh identity tests skeleton after merge with main
swiftwasm#731 added the GC lifecycle test (with new imported function entries)
to main while this branch was open. Re-running the BridgeJS regen
against the merged tree fills in the `accessLevel` field on the new
entries that were absent at merge time.
* ci: retry flaky JSPromiseTests.testPromiseAndTimer1 parent 09b3f4e commit f483b91
37 files changed
Lines changed: 1606 additions & 75 deletions
File tree
- Benchmarks/Sources/Generated/JavaScript
- Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript
- Plugins/BridgeJS
- Sources
- BridgeJSCore
- BridgeJSSkeleton
- Tests/BridgeJSToolTests
- Inputs/MacroSwift
- __Snapshots__
- BridgeJSCodegenTests
- BridgeJSLinkTests
- Tests
- BridgeJSIdentityTests/Generated/JavaScript
- BridgeJSRuntimeTests/Generated
- JavaScript
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3339 | 3339 | | |
3340 | 3340 | | |
3341 | 3341 | | |
| 3342 | + | |
3342 | 3343 | | |
3343 | 3344 | | |
3344 | 3345 | | |
| |||
3355 | 3356 | | |
3356 | 3357 | | |
3357 | 3358 | | |
| 3359 | + | |
3358 | 3360 | | |
3359 | 3361 | | |
3360 | 3362 | | |
| |||
3378 | 3380 | | |
3379 | 3381 | | |
3380 | 3382 | | |
| 3383 | + | |
3381 | 3384 | | |
3382 | 3385 | | |
3383 | 3386 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| 264 | + | |
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
267 | 269 | | |
| 270 | + | |
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
| |||
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | | - | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
195 | | - | |
196 | | - | |
| 199 | + | |
| 200 | + | |
197 | 201 | | |
198 | 202 | | |
199 | | - | |
200 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
201 | 206 | | |
202 | 207 | | |
203 | 208 | | |
| |||
Lines changed: 56 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2122 | 2122 | | |
2123 | 2123 | | |
2124 | 2124 | | |
| 2125 | + | |
2125 | 2126 | | |
2126 | 2127 | | |
2127 | 2128 | | |
| |||
2337 | 2338 | | |
2338 | 2339 | | |
2339 | 2340 | | |
| 2341 | + | |
2340 | 2342 | | |
2341 | 2343 | | |
2342 | 2344 | | |
| |||
2345 | 2347 | | |
2346 | 2348 | | |
2347 | 2349 | | |
2348 | | - | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
2349 | 2356 | | |
2350 | 2357 | | |
2351 | 2358 | | |
2352 | 2359 | | |
2353 | 2360 | | |
| 2361 | + | |
2354 | 2362 | | |
2355 | 2363 | | |
2356 | 2364 | | |
| |||
2371 | 2379 | | |
2372 | 2380 | | |
2373 | 2381 | | |
2374 | | - | |
| 2382 | + | |
| 2383 | + | |
2375 | 2384 | | |
2376 | 2385 | | |
2377 | 2386 | | |
| |||
2384 | 2393 | | |
2385 | 2394 | | |
2386 | 2395 | | |
2387 | | - | |
| 2396 | + | |
| 2397 | + | |
2388 | 2398 | | |
2389 | 2399 | | |
2390 | 2400 | | |
| |||
2400 | 2410 | | |
2401 | 2411 | | |
2402 | 2412 | | |
2403 | | - | |
| 2413 | + | |
| 2414 | + | |
2404 | 2415 | | |
2405 | 2416 | | |
2406 | 2417 | | |
| |||
2565 | 2576 | | |
2566 | 2577 | | |
2567 | 2578 | | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
2568 | 2584 | | |
2569 | | - | |
| 2585 | + | |
| 2586 | + | |
2570 | 2587 | | |
2571 | 2588 | | |
2572 | 2589 | | |
| |||
2599 | 2616 | | |
2600 | 2617 | | |
2601 | 2618 | | |
| 2619 | + | |
2602 | 2620 | | |
2603 | 2621 | | |
2604 | 2622 | | |
2605 | 2623 | | |
2606 | 2624 | | |
2607 | 2625 | | |
2608 | 2626 | | |
2609 | | - | |
| 2627 | + | |
| 2628 | + | |
2610 | 2629 | | |
2611 | 2630 | | |
2612 | 2631 | | |
| |||
2638 | 2657 | | |
2639 | 2658 | | |
2640 | 2659 | | |
| 2660 | + | |
2641 | 2661 | | |
2642 | 2662 | | |
2643 | 2663 | | |
2644 | 2664 | | |
2645 | 2665 | | |
2646 | 2666 | | |
2647 | | - | |
| 2667 | + | |
| 2668 | + | |
2648 | 2669 | | |
2649 | 2670 | | |
2650 | 2671 | | |
| |||
2667 | 2688 | | |
2668 | 2689 | | |
2669 | 2690 | | |
| 2691 | + | |
2670 | 2692 | | |
2671 | 2693 | | |
2672 | 2694 | | |
2673 | 2695 | | |
2674 | 2696 | | |
2675 | | - | |
| 2697 | + | |
| 2698 | + | |
2676 | 2699 | | |
2677 | 2700 | | |
2678 | 2701 | | |
| |||
2718 | 2741 | | |
2719 | 2742 | | |
2720 | 2743 | | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
2721 | 2769 | | |
2722 | 2770 | | |
2723 | 2771 | | |
| |||
0 commit comments