Commit 2dc6558
authored
# Summary
Currently the `GetTypeDependencies` trait struggles with deeply nested
container types.
For example `HashMap<Result<T,E>,V>` would place bounds of
`GetTypeRegistration` on `Result` which quickly falls apart with
non-`'static` types like `Ref` and `Mut` which don't have
`GetTypeRegistration` implementations.
This overhaul introduces the concept of an `Underlying` type allowing us
to have two type trees, the `Real` types which we want to end up being
registered in the registry, and the `Facade` types which exist purely as
trait carriers:
```mermaid
graph TD;
subgraph facade
A1[HashMap<.Val<.T>>] --> A2["`Val<.T>`"]
A2 --> T
end
subgraph underlying
B1[HashMap<.T>] --> B2["`T`"]
end
```
Thanks to that we can make the two assertions confidently:
- I want your REAL types in the script function signature, to be `Typed`
and possible to add to the type registry
- I don't care if your FACADE types are
Also previously, `HashMap<T, Val<T>>` would not register `HashMap<T, T>`
correctly at all, meaning we now get better dependency coverage!
# Migration Guide
- Any types which you implemented `GetTypeDependencies` for manually,
will need to specify an underlying type, for non-generic types this will
just be `Self`, for types which have recursive registrations, this will
be `Self<T1::Underlying, T2::Underlying...>` etc
- You can use the derive macro to make this easier instead
1 parent b34d5d4 commit 2dc6558
File tree
9 files changed
+374
-104
lines changed- crates
- bevy_mod_scripting_core/src
- bindings/function
- private
- bevy_mod_scripting_derive/src
- derive
9 files changed
+374
-104
lines changedLines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
472 | 483 | | |
473 | 484 | | |
474 | 485 | | |
| |||
484 | 495 | | |
485 | 496 | | |
486 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
487 | 506 | | |
488 | 507 | | |
489 | 508 | | |
| |||
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | 54 | | |
57 | | - | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
| |||
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 71 | + | |
77 | 72 | | |
78 | 73 | | |
79 | 74 | | |
| |||
99 | 94 | | |
100 | 95 | | |
101 | 96 | | |
102 | | - | |
103 | 97 | | |
104 | 98 | | |
105 | 99 | | |
106 | 100 | | |
107 | 101 | | |
108 | 102 | | |
109 | 103 | | |
110 | | - | |
| 104 | + | |
111 | 105 | | |
112 | 106 | | |
113 | 107 | | |
| |||
156 | 150 | | |
157 | 151 | | |
158 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
| |||
Lines changed: 23 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 25 | + | |
| 26 | + | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
137 | 133 | | |
138 | 134 | | |
139 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | | - | |
143 | | - | |
| 148 | + | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
151 | | - | |
152 | | - | |
| 157 | + | |
| 158 | + | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
| |||
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
163 | | - | |
164 | | - | |
| 169 | + | |
| 170 | + | |
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
172 | | - | |
173 | | - | |
| 178 | + | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
181 | | - | |
182 | | - | |
| 187 | + | |
| 188 | + | |
183 | 189 | | |
184 | 190 | | |
185 | 191 | | |
| |||
0 commit comments