style: Remove HasViewportPercentage.

It's not needed since #18268
This commit is contained in:
Emilio Cobos Álvarez 2017-08-29 23:45:45 +02:00
parent 473934c989
commit 36ff89bd28
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
61 changed files with 73 additions and 437 deletions

View file

@ -1,42 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cg;
use quote;
use syn;
use synstructure;
pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
let name = &input.ident;
let trait_path = &["style_traits", "HasViewportPercentage"];
let (impl_generics, ty_generics, mut where_clause) =
cg::trait_parts(&input, trait_path);
let style = synstructure::BindStyle::Ref.into();
let match_body = synstructure::each_variant(&input, &style, |bindings, _| {
let (first, rest) = match bindings.split_first() {
None => return Some(quote!(false)),
Some(pair) => pair,
};
where_clause.add_trait_bound(&first.field.ty);
let mut expr = quote!(::style_traits::HasViewportPercentage::has_viewport_percentage(#first));
for binding in rest {
where_clause.add_trait_bound(&binding.field.ty);
expr = quote!(#expr || ::style_traits::HasViewportPercentage::has_viewport_percentage(#binding));
}
Some(expr)
});
quote! {
impl #impl_generics ::style_traits::HasViewportPercentage for #name #ty_generics #where_clause {
#[allow(unused_variables, unused_imports)]
#[inline]
fn has_viewport_percentage(&self) -> bool {
match *self {
#match_body
}
}
}
}
}

View file

@ -13,7 +13,6 @@ use proc_macro::TokenStream;
mod animate;
mod cg;
mod compute_squared_distance;
mod has_viewport_percentage;
mod to_animated_value;
mod to_animated_zero;
mod to_computed_value;
@ -31,12 +30,6 @@ pub fn derive_compute_squared_distance(stream: TokenStream) -> TokenStream {
compute_squared_distance::derive(input).to_string().parse().unwrap()
}
#[proc_macro_derive(HasViewportPercentage)]
pub fn derive_has_viewport_percentage(stream: TokenStream) -> TokenStream {
let input = syn::parse_derive_input(&stream.to_string()).unwrap();
has_viewport_percentage::derive(input).to_string().parse().unwrap()
}
#[proc_macro_derive(ToAnimatedValue)]
pub fn derive_to_animated_value(stream: TokenStream) -> TokenStream {
let input = syn::parse_derive_input(&stream.to_string()).unwrap();