witx-codegen
witx-codegen copied to clipboard
The way to dingtish which module I import?
I'm current implementation an cpp's backend and it work well. However, I wish split different module into different namespace (like rust's mod)
(module $wasi_ephemeral_crypto_symmetric
(use * from $wasi_ephemeral_crypto_common)
into
namespace WasiEphemeralCryptoSymmetric {
using namespace WitxCodegenHeader; // import header
using namespace handle; //generate from resource, but seem not corrrespond to import module
I found module_witx's resource
seem not correspond to the import module.
How to achieve it?
Hi!
Generator::generate()
is called for each module, so you can use this to create each namespace.
See how it's done for the Zig backend, which is probably the best starting point for a C++ backend: https://github.com/jedisct1/witx-codegen/blob/4ee1bb22f8f800ccb1c0ca17978db1be59b19edb/src/zig/mod.rs#L72-L82
This is how functions then get in namespaces: https://github.com/jedisct1/witx-codegen/blob/4ee1bb22f8f800ccb1c0ca17978db1be59b19edb/example-output/zig.zig#L315
This is how functions then get in namespaces:
https://github.com/jedisct1/witx-codegen/blob/4ee1bb22f8f800ccb1c0ca17978db1be59b19edb/example-output/zig.zig#L315
Oh I have just read zip example, so only function in module and expose type alias to other module? I through alias type also in module(sorry I'm not familiar with zig).