mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 13:01:22 +00:00
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:
@ -524,11 +524,13 @@ impl ConvertToAst<()> for syn::ForeignItemType {
|
||||
type Target = ast::ImportKind;
|
||||
|
||||
fn convert(self, (): ()) -> Result<Self::Target, Diagnostic> {
|
||||
let shim = format!("__wbg_instanceof_{}_{}", self.ident, ShortHash(&self.ident));
|
||||
Ok(ast::ImportKind::Type(ast::ImportType {
|
||||
vis: self.vis,
|
||||
name: self.ident,
|
||||
attrs: self.attrs,
|
||||
doc_comment: None,
|
||||
instanceof_shim: shim,
|
||||
name: self.ident,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user