1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-07-22 23:51:57 +00:00

webidl: add support for typedefs

This commit is contained in:
R. Andrew Ohana
2018-06-11 18:35:20 -07:00
parent 3710d87f3b
commit d065f4b05d
5 changed files with 58 additions and 2 deletions
crates
backend
webidl
src
tests
expected
fixtures

@@ -59,6 +59,9 @@ impl ToTokens for ast::Program {
for e in self.enums.iter() {
e.to_tokens(tokens);
}
for a in self.type_aliases.iter() {
a.to_tokens(tokens);
}
// Generate a static which will eventually be what lives in a custom section
// of the wasm executable. For now it's just a plain old static, but we'll
@@ -823,3 +826,15 @@ impl ToTokens for ast::ImportStatic {
}).to_tokens(into);
}
}
impl ToTokens for ast::TypeAlias {
fn to_tokens(&self, into: &mut TokenStream) {
let vis = &self.vis;
let dest = &self.dest;
let src = &self.src;
(quote! {
#[allow(non_camel_case_types)]
#vis type #dest = #src;
}).to_tokens(into);
}
}