mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-27 03:55:20 +03:00
Only derive extra traits when the extra-traits
feature is enabled
This commit is contained in:
parent
07d5afa268
commit
6885ea073e
@ -12,10 +12,11 @@ Backend code generation of the wasm-bindgen tool
|
||||
|
||||
[features]
|
||||
spans = ["proc-macro2/nightly"]
|
||||
extra-traits = ["syn/extra-traits"]
|
||||
|
||||
[dependencies]
|
||||
quote = '0.6'
|
||||
proc-macro2 = "0.4"
|
||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.11" }
|
||||
syn = { version = '0.14', features = ['extra-traits', 'full', 'visit-mut'] }
|
||||
syn = { version = '0.14', features = ['full', 'visit-mut'] }
|
||||
serde_json = "1.0"
|
||||
|
@ -3,7 +3,8 @@ use quote::ToTokens;
|
||||
use shared;
|
||||
use syn;
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
#[derive(Default)]
|
||||
pub struct Program {
|
||||
pub exports: Vec<Export>,
|
||||
pub imports: Vec<Import>,
|
||||
@ -11,7 +12,7 @@ pub struct Program {
|
||||
pub structs: Vec<Struct>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Export {
|
||||
pub class: Option<Ident>,
|
||||
pub method: bool,
|
||||
@ -20,7 +21,7 @@ pub struct Export {
|
||||
pub function: Function,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Import {
|
||||
pub module: Option<String>,
|
||||
pub version: Option<String>,
|
||||
@ -28,14 +29,14 @@ pub struct Import {
|
||||
pub kind: ImportKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub enum ImportKind {
|
||||
Function(ImportFunction),
|
||||
Static(ImportStatic),
|
||||
Type(ImportType),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct ImportFunction {
|
||||
pub function: Function,
|
||||
pub rust_name: Ident,
|
||||
@ -43,14 +44,14 @@ pub struct ImportFunction {
|
||||
pub shim: Ident,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub enum ImportFunctionKind {
|
||||
Method { class: String, ty: syn::Type },
|
||||
JsConstructor { class: String, ty: syn::Type },
|
||||
Normal,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct ImportStatic {
|
||||
pub vis: syn::Visibility,
|
||||
pub ty: syn::Type,
|
||||
@ -59,13 +60,13 @@ pub struct ImportStatic {
|
||||
pub js_name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct ImportType {
|
||||
pub vis: syn::Visibility,
|
||||
pub name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Function {
|
||||
pub name: Ident,
|
||||
pub arguments: Vec<syn::Type>,
|
||||
@ -76,13 +77,13 @@ pub struct Function {
|
||||
pub rust_vis: syn::Visibility,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Struct {
|
||||
pub name: Ident,
|
||||
pub fields: Vec<StructField>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct StructField {
|
||||
pub opts: BindgenAttrs,
|
||||
pub name: Ident,
|
||||
@ -92,13 +93,13 @@ pub struct StructField {
|
||||
pub setter: Ident,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Enum {
|
||||
pub name: Ident,
|
||||
pub variants: Vec<Variant>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Variant {
|
||||
pub name: Ident,
|
||||
pub value: u32,
|
||||
@ -769,7 +770,8 @@ impl StructField {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
#[derive(Default)]
|
||||
pub struct BindgenAttrs {
|
||||
attrs: Vec<BindgenAttr>,
|
||||
}
|
||||
@ -930,7 +932,7 @@ impl syn::synom::Synom for BindgenAttrs {
|
||||
));
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
enum BindgenAttr {
|
||||
Catch,
|
||||
Constructor,
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![recursion_limit = "256"]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![cfg_attr(feature = "extra-traits", deny(missing_debug_implementations))]
|
||||
|
||||
extern crate proc_macro2;
|
||||
#[macro_use]
|
||||
|
Loading…
Reference in New Issue
Block a user