diff --git a/serde_codegen/Cargo.toml b/serde_codegen/Cargo.toml new file mode 100644 index 00000000..45a39bfc --- /dev/null +++ b/serde_codegen/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "serde_codegen" +version = "0.4.0" +authors = ["Erick Tryzelaar "] +license = "MIT/Apache-2.0" +description = "Macros to auto-generate implementations for the serde framework" +repository = "https://github.com/erickt/rust-serde" + +[dependencies] +aster = "*" +quasi = "*" +quasi_macros = "*" diff --git a/serde_macros/src/attr.rs b/serde_codegen/src/attr.rs similarity index 100% rename from serde_macros/src/attr.rs rename to serde_codegen/src/attr.rs diff --git a/serde_macros/src/de.rs b/serde_codegen/src/de.rs similarity index 100% rename from serde_macros/src/de.rs rename to serde_codegen/src/de.rs diff --git a/serde_macros/src/field.rs b/serde_codegen/src/field.rs similarity index 99% rename from serde_macros/src/field.rs rename to serde_codegen/src/field.rs index 30a8bf19..eb39d2f9 100644 --- a/serde_macros/src/field.rs +++ b/serde_codegen/src/field.rs @@ -7,7 +7,7 @@ use syntax::ptr::P; use aster; -use attr::FieldAttrs; +use super::attr::FieldAttrs; enum Rename<'a> { None, diff --git a/serde_codegen/src/lib.rs b/serde_codegen/src/lib.rs new file mode 100644 index 00000000..2e2d6018 --- /dev/null +++ b/serde_codegen/src/lib.rs @@ -0,0 +1,24 @@ +#![feature(custom_derive, plugin, rustc_private, unboxed_closures)] +#![plugin(quasi_macros)] + +extern crate aster; +extern crate quasi; +extern crate rustc; +extern crate syntax; + +mod attr; +mod de; +mod field; +mod ser; + +pub fn register(reg: &mut rustc::plugin::Registry) { + reg.register_syntax_extension( + syntax::parse::token::intern("derive_Serialize"), + syntax::ext::base::Decorator( + Box::new(ser::expand_derive_serialize))); + + reg.register_syntax_extension( + syntax::parse::token::intern("derive_Deserialize"), + syntax::ext::base::Decorator( + Box::new(de::expand_derive_deserialize))); +} diff --git a/serde_macros/src/ser.rs b/serde_codegen/src/ser.rs similarity index 100% rename from serde_macros/src/ser.rs rename to serde_codegen/src/ser.rs diff --git a/serde_macros/Cargo.toml b/serde_macros/Cargo.toml index 93d14dd6..bb8dc9f6 100644 --- a/serde_macros/Cargo.toml +++ b/serde_macros/Cargo.toml @@ -11,6 +11,4 @@ name = "serde_macros" plugin = true [dependencies] -aster = "*" -quasi = "*" -quasi_macros = "*" +serde_codegen = { version = "*", path = "../serde_codegen" } diff --git a/serde_macros/src/lib.rs b/serde_macros/src/lib.rs index afc37a34..a01d1341 100644 --- a/serde_macros/src/lib.rs +++ b/serde_macros/src/lib.rs @@ -1,28 +1,10 @@ -#![feature(custom_derive, plugin, plugin_registrar, rustc_private, unboxed_closures)] -#![plugin(quasi_macros)] +#![feature(plugin_registrar, rustc_private)] -extern crate aster; -extern crate quasi; +extern crate serde_codegen; extern crate rustc; -extern crate syntax; - -use syntax::ext::base::Decorator; -use syntax::parse::token; -use rustc::plugin::Registry; - -mod attr; -mod field; -mod de; -mod ser; #[plugin_registrar] #[doc(hidden)] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_syntax_extension( - token::intern("derive_Serialize"), - Decorator(Box::new(ser::expand_derive_serialize))); - - reg.register_syntax_extension( - token::intern("derive_Deserialize"), - Decorator(Box::new(de::expand_derive_deserialize))); +pub fn plugin_registrar(reg: &mut rustc::plugin::Registry) { + serde_codegen::register(reg); }