Commit 65e5924
authored
various
* various `wit-dylib` API tweaks
I've recently ported `componentize-py` to use `wit-dylib` instead of its own
Wasm code generator and found it useful to tweak the `wit-dylib` APIs a bit.
The main idea here is to give `componentize-py` (and any similar build tool)
access to the metadata generated by `wit-dylib` _before_ the guest runs, as well
as match the types in that metadata up with the `wit_parser::TypeId`s from the
input world. That allows the build tool to generate high-level binding code
ahead of time and later match it up with the metadata at runtime.
Specifically, this commit does the following:
- Add a `wit_dylib::create_with_metadata` function which returns both the generated module and the `Metadata` object produced for it.
- Add `id: TypeId` fields to all the "WIT type types" so that they can be matched up with the corresponding `wit-parser` types
- Add `index` methods to the `wit-dylib-ffi` wrapper types, allowing the interpreter to determine where the instance appears in its respective array
- Split the metadata `Function` type into separate `ImportFunction` and `ExportFunction` types, each with its own array in the `Wit` structure. Imported and exported functions are used very differently by interpreters; separating them makes them easier to deal with.
Signed-off-by: Joel Dice <[email protected]>
* update tests to match `wit-dylib` changes
Signed-off-by: Joel Dice <[email protected]>
* address review feedback
Signed-off-by: Joel Dice <[email protected]>
* add `index` methods to remaining `wit-dylib-ffi` types
Signed-off-by: Joel Dice <[email protected]>
---------
Signed-off-by: Joel Dice <[email protected]>wit-dylib API tweaks (#2362)1 parent 5300663 commit 65e5924
File tree
38 files changed
+396
-148
lines changed- crates/wit-dylib
- ffi
- src
- src
- test-programs/src
- bin
- tests/cli
38 files changed
+396
-148
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
194 | 204 | | |
195 | 205 | | |
196 | 206 | | |
197 | | - | |
198 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
199 | 211 | | |
200 | 212 | | |
201 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | | - | |
| 515 | + | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
553 | | - | |
| 553 | + | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| |||
0 commit comments