Commit 2941cd2
committed
BridgeJS: Support optional @js struct in imported function signatures
Optional @js structs could not be used as parameters or return values of
imported (@JSFunction) signatures: the generator lowered Optional<Struct>
using the non-optional object-id ABI ([isSome, objectId] / a single Int32
return), for which no Optional lowering exists, so the generated thunk did
not compile.
Bridge optional @js structs through the stack ABI instead - an isSome
discriminator plus the struct fields - exactly like optional arrays and
dictionaries. Structs already conform to the stack-based bridging protocols,
so the existing _BridgedAsOptional/stack runtime extensions and the JS link's
stack handling already support this; only the import-side lowering/lifting in
the code generator needed to change.
Adds a jsRoundTripOptionalPoint runtime round-trip (some + none) and a
SwiftStructImports codegen snapshot.1 parent d1e0f95 commit 2941cd2
11 files changed
Lines changed: 151 additions & 1 deletion
File tree
- Plugins/BridgeJS
- Sources/BridgeJSCore
- Tests/BridgeJSToolTests
- Inputs/MacroSwift
- __Snapshots__
- BridgeJSCodegenTests
- BridgeJSLinkTests
- Tests
- BridgeJSRuntimeTests
- Generated
- JavaScript
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
957 | 957 | | |
958 | 958 | | |
959 | 959 | | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
960 | 964 | | |
961 | 965 | | |
962 | 966 | | |
| |||
1034 | 1038 | | |
1035 | 1039 | | |
1036 | 1040 | | |
1037 | | - | |
| 1041 | + | |
| 1042 | + | |
1038 | 1043 | | |
1039 | 1044 | | |
1040 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1041 | 1049 | | |
1042 | 1050 | | |
1043 | 1051 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
103 | 137 | | |
104 | 138 | | |
105 | 139 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
70 | 91 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
229 | 248 | | |
230 | 249 | | |
231 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13279 | 13279 | | |
13280 | 13280 | | |
13281 | 13281 | | |
| 13282 | + | |
| 13283 | + | |
| 13284 | + | |
| 13285 | + | |
| 13286 | + | |
| 13287 | + | |
| 13288 | + | |
| 13289 | + | |
| 13290 | + | |
| 13291 | + | |
| 13292 | + | |
| 13293 | + | |
| 13294 | + | |
| 13295 | + | |
| 13296 | + | |
| 13297 | + | |
| 13298 | + | |
| 13299 | + | |
| 13300 | + | |
| 13301 | + | |
| 13302 | + | |
13282 | 13303 | | |
13283 | 13304 | | |
13284 | 13305 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19745 | 19745 | | |
19746 | 19746 | | |
19747 | 19747 | | |
| 19748 | + | |
| 19749 | + | |
| 19750 | + | |
| 19751 | + | |
| 19752 | + | |
| 19753 | + | |
| 19754 | + | |
| 19755 | + | |
| 19756 | + | |
| 19757 | + | |
| 19758 | + | |
| 19759 | + | |
| 19760 | + | |
| 19761 | + | |
| 19762 | + | |
| 19763 | + | |
| 19764 | + | |
| 19765 | + | |
| 19766 | + | |
| 19767 | + | |
| 19768 | + | |
| 19769 | + | |
| 19770 | + | |
| 19771 | + | |
| 19772 | + | |
| 19773 | + | |
| 19774 | + | |
| 19775 | + | |
| 19776 | + | |
| 19777 | + | |
| 19778 | + | |
| 19779 | + | |
| 19780 | + | |
| 19781 | + | |
19748 | 19782 | | |
19749 | 19783 | | |
19750 | 19784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
0 commit comments