mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-26 06:22:14 +00:00
Merge pull request #400 from alexcrichton/derive-import
Forward attributes on `type` declaration to definition
This commit is contained in:
commit
142d7377e2
@ -84,6 +84,7 @@ pub struct ImportStatic {
|
|||||||
pub struct ImportType {
|
pub struct ImportType {
|
||||||
pub vis: syn::Visibility,
|
pub vis: syn::Visibility,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
|
pub attrs: Vec<syn::Attribute>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
@ -469,6 +470,7 @@ impl Program {
|
|||||||
ImportKind::Type(ImportType {
|
ImportKind::Type(ImportType {
|
||||||
vis: f.vis,
|
vis: f.vis,
|
||||||
name: f.ident,
|
name: f.ident,
|
||||||
|
attrs: f.attrs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,8 +505,10 @@ impl ToTokens for ast::ImportType {
|
|||||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
let vis = &self.vis;
|
let vis = &self.vis;
|
||||||
let name = &self.name;
|
let name = &self.name;
|
||||||
|
let attrs = &self.attrs;
|
||||||
(quote! {
|
(quote! {
|
||||||
#[allow(bad_style)]
|
#[allow(bad_style)]
|
||||||
|
#(#attrs)*
|
||||||
#vis struct #name {
|
#vis struct #name {
|
||||||
obj: ::wasm_bindgen::JsValue,
|
obj: ::wasm_bindgen::JsValue,
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,7 @@ impl WebidlParse<()> for webidl::ast::NonPartialInterface {
|
|||||||
pub_token: Default::default(),
|
pub_token: Default::default(),
|
||||||
}),
|
}),
|
||||||
name: rust_ident(&self.name),
|
name: rust_ident(&self.name),
|
||||||
|
attrs: Vec::new(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ fn construct() {
|
|||||||
|
|
||||||
#[wasm_bindgen(module = "./another")]
|
#[wasm_bindgen(module = "./another")]
|
||||||
extern {
|
extern {
|
||||||
|
#[derive(Clone)]
|
||||||
type Foo;
|
type Foo;
|
||||||
#[wasm_bindgen(js_namespace = Foo)]
|
#[wasm_bindgen(js_namespace = Foo)]
|
||||||
fn create() -> Foo;
|
fn create() -> Foo;
|
||||||
@ -127,6 +128,7 @@ fn construct() {
|
|||||||
pub fn run() {
|
pub fn run() {
|
||||||
let f = Foo::create();
|
let f = Foo::create();
|
||||||
assert_eq!(f.get_internal_string(), "this");
|
assert_eq!(f.get_internal_string(), "this");
|
||||||
|
assert_eq!(f.clone().get_internal_string(), "this");
|
||||||
f.append_to_internal_string(" foo");
|
f.append_to_internal_string(" foo");
|
||||||
f.assert_internal_string("this foo");
|
f.assert_internal_string("this foo");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user