Commit 34a4bc7
authored
Reimplement the host Python generator with worlds (#386)
* Reimplement the host Python generator with worlds
This commit is the equivalent of #381 but for Wasmtime Python host
bindings. This is a large-scale refactor of the internals of the Python
host generator in which I took quite a few liberties in internal
restructuring as well as output restructuring. The tests are probably
the best to review and better reflect what changed, but there are some
aspects of worlds that the tests are not currently exercising which
we'll want to add with the introduction of worlds in the future.
This means that all host generators are now working with worlds as input
rather than individual `*.wit` files, and the only two remaining
generators are the C and Java generators for guests (which I hope are
easier).
The high level summary of the new output is:
out_dir/
__init__.py # top-level component exports/definitions
types.py # shared type information, currently just `Result`
imports/
__init__.py # only here if something is imported
foo.py # type and protocol definition per interface
exports/
__init__.py # only here if an instance is exported
bar.py # one per exported instance
"Default exports" will show up on the generated structure in
`out_dir/__init__.py` so all runtime tests, for example, do not generate
`exports` at this time. Lots of fiddly stuff went into structuring this
all right to get past `mypy` and additionally try to avoid name
conflicts. It's still somewhat easy to have name conflicts but ideally
they're of the more esoteric category rather than "really easy to run
into".
* Try to fix windows1 parent 5be459e commit 34a4bc7
27 files changed
Lines changed: 1962 additions & 1943 deletions
File tree
- crates
- gen-host-js/tests
- gen-host-wasmtime-py
- src
- tests
- gen-host-wasmtime-rust/tests
- test-helpers
- macros/src
- src
- wasi_snapshot_preview1
- src
- wit-bindgen-demo/src
- src/bin
- tests
- codegen
- runtime
- flavorful
- invalid
- lists
- many_arguments
- numbers
- records
- smoke
- unions
- variants
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
0 commit comments