Pull codegen into it's own crate

This commit is contained in:
Erick Tryzelaar 2015-05-17 23:11:08 -07:00
parent 426394cd7b
commit 24ac61f9f2
8 changed files with 42 additions and 26 deletions

12
serde_codegen/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "serde_codegen"
version = "0.4.0"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
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 = "*"

View File

@ -7,7 +7,7 @@ use syntax::ptr::P;
use aster; use aster;
use attr::FieldAttrs; use super::attr::FieldAttrs;
enum Rename<'a> { enum Rename<'a> {
None, None,

24
serde_codegen/src/lib.rs Normal file
View File

@ -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)));
}

View File

@ -11,6 +11,4 @@ name = "serde_macros"
plugin = true plugin = true
[dependencies] [dependencies]
aster = "*" serde_codegen = { version = "*", path = "../serde_codegen" }
quasi = "*"
quasi_macros = "*"

View File

@ -1,28 +1,10 @@
#![feature(custom_derive, plugin, plugin_registrar, rustc_private, unboxed_closures)] #![feature(plugin_registrar, rustc_private)]
#![plugin(quasi_macros)]
extern crate aster; extern crate serde_codegen;
extern crate quasi;
extern crate rustc; 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] #[plugin_registrar]
#[doc(hidden)] #[doc(hidden)]
pub fn plugin_registrar(reg: &mut Registry) { pub fn plugin_registrar(reg: &mut rustc::plugin::Registry) {
reg.register_syntax_extension( serde_codegen::register(reg);
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)));
} }