various `wit-dylib` API tweaks by dicej · Pull Request #2362 · bytecodealliance/wasm-tools
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 <joel.dice@fermyon.com>
dicej
deleted the
wit-dylib-api-tweaks
branch
dicej
mentioned this pull request
github-merge-queue bot pushed a commit that referenced this pull request
Oct 23, 2025I forgot to do this as part of #2362 🤦 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters