mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-15 16:41:01 +00:00
Merge serde_codegen into serde_derive crate
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "serde_codegen"
|
|
||||||
version = "0.9.0"
|
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
|
||||||
license = "MIT/Apache-2.0"
|
|
||||||
description = "Macros to auto-generate implementations for the serde framework"
|
|
||||||
homepage = "https://serde.rs"
|
|
||||||
repository = "https://github.com/serde-rs/serde"
|
|
||||||
documentation = "https://serde.rs/codegen.html"
|
|
||||||
keywords = ["serde", "serialization"]
|
|
||||||
include = ["Cargo.toml", "src/**/*.rs"]
|
|
||||||
|
|
||||||
[features]
|
|
||||||
unstable = []
|
|
||||||
unstable-testing = ["clippy"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
clippy = { version = "0.*", optional = true }
|
|
||||||
quote = "0.3.8"
|
|
||||||
serde_codegen_internals = { version = "=0.11.3", default-features = false, path = "../serde_codegen_internals" }
|
|
||||||
syn = { version = "0.10", features = ["aster", "visit"] }
|
|
||||||
|
|
||||||
[badges]
|
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
|
||||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
|
||||||
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
|
|
||||||
#![cfg_attr(feature = "clippy", allow(used_underscore_binding))]
|
|
||||||
|
|
||||||
// The `quote!` macro requires deep recursion.
|
|
||||||
#![recursion_limit = "192"]
|
|
||||||
|
|
||||||
extern crate serde_codegen_internals as internals;
|
|
||||||
|
|
||||||
extern crate syn;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate quote;
|
|
||||||
|
|
||||||
mod bound;
|
|
||||||
mod de;
|
|
||||||
mod ser;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
/// Not public API. Use the serde_derive crate.
|
|
||||||
pub fn expand_derive_serialize(item: &str) -> Result<quote::Tokens, String> {
|
|
||||||
let syn_item = syn::parse_macro_input(item).unwrap();
|
|
||||||
ser::expand_derive_serialize(&syn_item)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
/// Not public API. Use the serde_derive crate.
|
|
||||||
pub fn expand_derive_deserialize(item: &str) -> Result<quote::Tokens, String> {
|
|
||||||
let syn_item = syn::parse_macro_input(item).unwrap();
|
|
||||||
de::expand_derive_deserialize(&syn_item)
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,10 @@ documentation = "https://serde.rs/codegen.html"
|
|||||||
keywords = ["serde", "serialization"]
|
keywords = ["serde", "serialization"]
|
||||||
include = ["Cargo.toml", "src/**/*.rs"]
|
include = ["Cargo.toml", "src/**/*.rs"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
unstable = []
|
||||||
|
unstable-testing = ["clippy"]
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "serde-rs/serde" }
|
travis-ci = { repository = "serde-rs/serde" }
|
||||||
|
|
||||||
@@ -18,7 +22,10 @@ name = "serde_derive"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_codegen = { version = "=0.9.0", path = "../serde_codegen" }
|
clippy = { version = "0.*", optional = true }
|
||||||
|
quote = "0.3.8"
|
||||||
|
serde_codegen_internals = { version = "=0.11.3", default-features = false, path = "../serde_codegen_internals" }
|
||||||
|
syn = { version = "0.10", features = ["aster", "visit"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
compiletest_rs = "0.2"
|
compiletest_rs = "0.2"
|
||||||
|
|||||||
+22
-4
@@ -1,11 +1,28 @@
|
|||||||
extern crate proc_macro;
|
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||||
extern crate serde_codegen;
|
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||||
|
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
|
||||||
|
#![cfg_attr(feature = "clippy", allow(used_underscore_binding))]
|
||||||
|
|
||||||
|
// The `quote!` macro requires deep recursion.
|
||||||
|
#![recursion_limit = "192"]
|
||||||
|
|
||||||
|
extern crate syn;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate quote;
|
||||||
|
|
||||||
|
extern crate serde_codegen_internals as internals;
|
||||||
|
|
||||||
|
extern crate proc_macro;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
mod bound;
|
||||||
|
mod de;
|
||||||
|
mod ser;
|
||||||
|
|
||||||
#[proc_macro_derive(Serialize, attributes(serde))]
|
#[proc_macro_derive(Serialize, attributes(serde))]
|
||||||
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
||||||
match serde_codegen::expand_derive_serialize(&input.to_string()) {
|
let input = syn::parse_macro_input(&input.to_string()).unwrap();
|
||||||
|
match ser::expand_derive_serialize(&input) {
|
||||||
Ok(expanded) => expanded.parse().unwrap(),
|
Ok(expanded) => expanded.parse().unwrap(),
|
||||||
Err(msg) => panic!(msg),
|
Err(msg) => panic!(msg),
|
||||||
}
|
}
|
||||||
@@ -13,7 +30,8 @@ pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
#[proc_macro_derive(Deserialize, attributes(serde))]
|
#[proc_macro_derive(Deserialize, attributes(serde))]
|
||||||
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
||||||
match serde_codegen::expand_derive_deserialize(&input.to_string()) {
|
let input = syn::parse_macro_input(&input.to_string()).unwrap();
|
||||||
|
match de::expand_derive_deserialize(&input) {
|
||||||
Ok(expanded) => expanded.parse().unwrap(),
|
Ok(expanded) => expanded.parse().unwrap(),
|
||||||
Err(msg) => panic!(msg),
|
Err(msg) => panic!(msg),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user