From 52f9ecfc4dac65d305fd920e8c7f748889a0804f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 12 Aug 2019 23:24:48 +0200 Subject: Move api into its own crate --- dhall_proc_macros/src/derive.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dhall_proc_macros/src') diff --git a/dhall_proc_macros/src/derive.rs b/dhall_proc_macros/src/derive.rs index 725cdfb..0ebfe7d 100644 --- a/dhall_proc_macros/src/derive.rs +++ b/dhall_proc_macros/src/derive.rs @@ -18,7 +18,7 @@ where T: quote::ToTokens, { quote!( - <#ty as ::dhall::de::StaticType>::static_type() + <#ty as ::serde_dhall::de::StaticType>::static_type() ) } @@ -53,7 +53,7 @@ fn derive_for_struct( let ty = static_type(ty); quote!( (#name.to_owned(), #ty) ) }); - Ok(quote! { ::dhall::de::Type::make_record_type( + Ok(quote! { ::serde_dhall::de::Type::make_record_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -90,7 +90,7 @@ fn derive_for_enum( }) .collect::>()?; - Ok(quote! { ::dhall::de::Type::make_union_type( + Ok(quote! { ::serde_dhall::de::Type::make_union_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -134,7 +134,7 @@ pub fn derive_static_type_inner( let mut local_where_clause = orig_where_clause.clone(); local_where_clause .predicates - .push(parse_quote!(#ty: ::dhall::de::StaticType)); + .push(parse_quote!(#ty: ::serde_dhall::de::StaticType)); let phantoms = generics.params.iter().map(|param| match param { syn::GenericParam::Type(syn::TypeParam { ident, .. }) => { quote!(#ident) @@ -156,16 +156,16 @@ pub fn derive_static_type_inner( for ty in constraints.iter() { where_clause .predicates - .push(parse_quote!(#ty: ::dhall::de::StaticType)); + .push(parse_quote!(#ty: ::serde_dhall::de::StaticType)); } let ident = &input.ident; let tokens = quote! { - impl #impl_generics ::dhall::de::StaticType + impl #impl_generics ::serde_dhall::de::StaticType for #ident #ty_generics #where_clause { fn static_type() -> - ::dhall::de::Type { + ::serde_dhall::de::Type { #(#assertions)* #get_type } -- cgit v1.2.3 From 1ea8b10051d29c634399304273d6ee565d039bc2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 13 Aug 2019 15:25:53 +0200 Subject: Merge `Type` and `Value` in serde_dhall There was no point in separating them --- dhall_proc_macros/src/derive.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dhall_proc_macros/src') diff --git a/dhall_proc_macros/src/derive.rs b/dhall_proc_macros/src/derive.rs index 0ebfe7d..ea78766 100644 --- a/dhall_proc_macros/src/derive.rs +++ b/dhall_proc_macros/src/derive.rs @@ -53,7 +53,7 @@ fn derive_for_struct( let ty = static_type(ty); quote!( (#name.to_owned(), #ty) ) }); - Ok(quote! { ::serde_dhall::de::Type::make_record_type( + Ok(quote! { ::serde_dhall::de::Value::make_record_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -90,7 +90,7 @@ fn derive_for_enum( }) .collect::>()?; - Ok(quote! { ::serde_dhall::de::Type::make_union_type( + Ok(quote! { ::serde_dhall::de::Value::make_union_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -165,7 +165,7 @@ pub fn derive_static_type_inner( for #ident #ty_generics #where_clause { fn static_type() -> - ::serde_dhall::de::Type { + ::serde_dhall::de::Value { #(#assertions)* #get_type } -- cgit v1.2.3 From bf5d33f3ba991afe398d58fb4fed38ec72d6f4c7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 13 Aug 2019 16:31:41 +0200 Subject: Rework API to resemble that of serde_json --- dhall_proc_macros/src/derive.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dhall_proc_macros/src') diff --git a/dhall_proc_macros/src/derive.rs b/dhall_proc_macros/src/derive.rs index ea78766..79b553b 100644 --- a/dhall_proc_macros/src/derive.rs +++ b/dhall_proc_macros/src/derive.rs @@ -18,7 +18,7 @@ where T: quote::ToTokens, { quote!( - <#ty as ::serde_dhall::de::StaticType>::static_type() + <#ty as ::serde_dhall::StaticType>::static_type() ) } @@ -53,7 +53,7 @@ fn derive_for_struct( let ty = static_type(ty); quote!( (#name.to_owned(), #ty) ) }); - Ok(quote! { ::serde_dhall::de::Value::make_record_type( + Ok(quote! { ::serde_dhall::value::Value::make_record_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -90,7 +90,7 @@ fn derive_for_enum( }) .collect::>()?; - Ok(quote! { ::serde_dhall::de::Value::make_union_type( + Ok(quote! { ::serde_dhall::value::Value::make_union_type( vec![ #(#entries),* ].into_iter() ) }) } @@ -134,7 +134,7 @@ pub fn derive_static_type_inner( let mut local_where_clause = orig_where_clause.clone(); local_where_clause .predicates - .push(parse_quote!(#ty: ::serde_dhall::de::StaticType)); + .push(parse_quote!(#ty: ::serde_dhall::StaticType)); let phantoms = generics.params.iter().map(|param| match param { syn::GenericParam::Type(syn::TypeParam { ident, .. }) => { quote!(#ident) @@ -156,16 +156,16 @@ pub fn derive_static_type_inner( for ty in constraints.iter() { where_clause .predicates - .push(parse_quote!(#ty: ::serde_dhall::de::StaticType)); + .push(parse_quote!(#ty: ::serde_dhall::StaticType)); } let ident = &input.ident; let tokens = quote! { - impl #impl_generics ::serde_dhall::de::StaticType + impl #impl_generics ::serde_dhall::StaticType for #ident #ty_generics #where_clause { fn static_type() -> - ::serde_dhall::de::Value { + ::serde_dhall::value::Value { #(#assertions)* #get_type } -- cgit v1.2.3 From e8bf879471708ac2cc03df904d14a618daaf2132 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 16 Aug 2019 11:16:33 +0200 Subject: dhall_proc_macros actually does not depend on dhall_syntax anymore --- dhall_proc_macros/src/derive.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'dhall_proc_macros/src') diff --git a/dhall_proc_macros/src/derive.rs b/dhall_proc_macros/src/derive.rs index 79b553b..140ff20 100644 --- a/dhall_proc_macros/src/derive.rs +++ b/dhall_proc_macros/src/derive.rs @@ -1,5 +1,4 @@ extern crate proc_macro; -// use dhall_syntax::*; use proc_macro::TokenStream; use quote::{quote, quote_spanned}; use syn::spanned::Spanned; -- cgit v1.2.3