mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-28 04:22:38 +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]
|
[features]
|
||||||
spans = ["proc-macro2/nightly"]
|
spans = ["proc-macro2/nightly"]
|
||||||
|
extra-traits = ["syn/extra-traits"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = '0.6'
|
quote = '0.6'
|
||||||
proc-macro2 = "0.4"
|
proc-macro2 = "0.4"
|
||||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.11" }
|
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"
|
serde_json = "1.0"
|
||||||
|
@ -3,7 +3,8 @@ use quote::ToTokens;
|
|||||||
use shared;
|
use shared;
|
||||||
use syn;
|
use syn;
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Program {
|
pub struct Program {
|
||||||
pub exports: Vec<Export>,
|
pub exports: Vec<Export>,
|
||||||
pub imports: Vec<Import>,
|
pub imports: Vec<Import>,
|
||||||
@ -11,7 +12,7 @@ pub struct Program {
|
|||||||
pub structs: Vec<Struct>,
|
pub structs: Vec<Struct>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Export {
|
pub struct Export {
|
||||||
pub class: Option<Ident>,
|
pub class: Option<Ident>,
|
||||||
pub method: bool,
|
pub method: bool,
|
||||||
@ -20,7 +21,7 @@ pub struct Export {
|
|||||||
pub function: Function,
|
pub function: Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Import {
|
pub struct Import {
|
||||||
pub module: Option<String>,
|
pub module: Option<String>,
|
||||||
pub version: Option<String>,
|
pub version: Option<String>,
|
||||||
@ -28,14 +29,14 @@ pub struct Import {
|
|||||||
pub kind: ImportKind,
|
pub kind: ImportKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub enum ImportKind {
|
pub enum ImportKind {
|
||||||
Function(ImportFunction),
|
Function(ImportFunction),
|
||||||
Static(ImportStatic),
|
Static(ImportStatic),
|
||||||
Type(ImportType),
|
Type(ImportType),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct ImportFunction {
|
pub struct ImportFunction {
|
||||||
pub function: Function,
|
pub function: Function,
|
||||||
pub rust_name: Ident,
|
pub rust_name: Ident,
|
||||||
@ -43,14 +44,14 @@ pub struct ImportFunction {
|
|||||||
pub shim: Ident,
|
pub shim: Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub enum ImportFunctionKind {
|
pub enum ImportFunctionKind {
|
||||||
Method { class: String, ty: syn::Type },
|
Method { class: String, ty: syn::Type },
|
||||||
JsConstructor { class: String, ty: syn::Type },
|
JsConstructor { class: String, ty: syn::Type },
|
||||||
Normal,
|
Normal,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct ImportStatic {
|
pub struct ImportStatic {
|
||||||
pub vis: syn::Visibility,
|
pub vis: syn::Visibility,
|
||||||
pub ty: syn::Type,
|
pub ty: syn::Type,
|
||||||
@ -59,13 +60,13 @@ pub struct ImportStatic {
|
|||||||
pub js_name: Ident,
|
pub js_name: Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct ImportType {
|
pub struct ImportType {
|
||||||
pub vis: syn::Visibility,
|
pub vis: syn::Visibility,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub arguments: Vec<syn::Type>,
|
pub arguments: Vec<syn::Type>,
|
||||||
@ -76,13 +77,13 @@ pub struct Function {
|
|||||||
pub rust_vis: syn::Visibility,
|
pub rust_vis: syn::Visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub fields: Vec<StructField>,
|
pub fields: Vec<StructField>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct StructField {
|
pub struct StructField {
|
||||||
pub opts: BindgenAttrs,
|
pub opts: BindgenAttrs,
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
@ -92,13 +93,13 @@ pub struct StructField {
|
|||||||
pub setter: Ident,
|
pub setter: Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Enum {
|
pub struct Enum {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub variants: Vec<Variant>,
|
pub variants: Vec<Variant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
pub struct Variant {
|
pub struct Variant {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub value: u32,
|
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 {
|
pub struct BindgenAttrs {
|
||||||
attrs: Vec<BindgenAttr>,
|
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 {
|
enum BindgenAttr {
|
||||||
Catch,
|
Catch,
|
||||||
Constructor,
|
Constructor,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![deny(missing_debug_implementations)]
|
#![cfg_attr(feature = "extra-traits", deny(missing_debug_implementations))]
|
||||||
|
|
||||||
extern crate proc_macro2;
|
extern crate proc_macro2;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
Loading…
Reference in New Issue
Block a user