Implement JsCast for all imported types

This commit implements the `JsCast` trait automatically for all imported types
in `#[wasm_bindgen] extern { ... }` blocks. The main change here was to generate
an `instanceof` shim for all imported types in case it's needed.

All imported types now also implement `AsRef<JsValue>` and `AsMut<JsValue>`
This commit is contained in:
Alex Crichton
2018-08-04 09:41:59 -07:00
parent f3f11ed8eb
commit 11553a1af2
9 changed files with 178 additions and 6 deletions

View File

@ -246,6 +246,7 @@ impl<'src> WebidlParse<'src, ()> for weedle::InterfaceDefinition<'src> {
name: rust_ident(camel_case_ident(self.identifier.0).as_str()),
attrs: Vec::new(),
doc_comment,
instanceof_shim: format!("__widl_instanceof_{}", self.name),
}),
});