kajacx / wasm-bridge

Provides a single unified API to run WASM modules on the desktop using wasmtime, or on the web using js-sys.
MIT License
47 stars 7 forks source link

proc-macro derive produced unparsable tokens #5

Closed ten3roberts closed 1 year ago

ten3roberts commented 1 year ago

The from_js_value procedural macro, used within bindings! does not handle parameterized types

Occurs when a compound type (e.g; record) contains a parameterized type.

The from_js_value derive macro generating FromJsValue does not properly qualify the type, in this example, it uses

Vec<u32>::method which is not valid Rust syntax, rather than <Vec<u32>>::method

To reproduce (wasm32-unknown-unknown):

wasm_bridge::component::bindgen!({ path: "./wit", world: "bindings" });
package host:bindings

interface core {
    record build {
        a: list<u32>,
    }

    foo: func(q: build) -> u64
}

world bindings {
    import core
}

I'd love to help and open a PR to resolve this, are there any other areas I could tackle while I am at it?