Commit 7f403b2
Add wrap-view annotation for in-place member modification
Adds a new `wrap-view` annotation that generates companion View classes
alongside regular wrapper classes. View classes provide direct access to
nested C++ objects without creating copies.
Key features:
- `obj.view()` returns a view for in-place member modification
- View properties return nested views (not copies) for wrapped classes
- Methods returning `T&` (mutable reference) return views on view class
- Views keep parent objects alive via Python reference chain
Implementation details:
- View classes use raw pointers + Python parent references (avoids
Cython issues with shared_ptr aliasing across types)
- Methods marked wrap-ignore that return T& are still available on
view classes (T& returns don't work on main classes due to Cython
limitations, but work on view classes via pointer access)
- Forward references handled by pre-computing classes_with_views
Includes unit tests for code generation and integration tests that
compile actual Cython code and verify runtime behavior.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 6236c3d commit 7f403b2
9 files changed
Lines changed: 1401 additions & 4 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| |||
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
| 201 | + | |
196 | 202 | | |
197 | 203 | | |
198 | 204 | | |
| |||
560 | 566 | | |
561 | 567 | | |
562 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
563 | 572 | | |
564 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
565 | 577 | | |
566 | 578 | | |
567 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
| |||
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
283 | 316 | | |
284 | 317 | | |
285 | 318 | | |
| |||
0 commit comments