stylo_derive/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5#![recursion_limit = "128"]
6
7#[macro_use]
8extern crate darling;
9extern crate proc_macro;
10extern crate proc_macro2;
11#[macro_use]
12extern crate quote;
13#[macro_use]
14extern crate syn;
15extern crate synstructure;
16
17use proc_macro::TokenStream;
18
19mod animate;
20mod cg;
21mod compute_squared_distance;
22mod parse;
23mod specified_value_info;
24mod to_animated_value;
25mod to_animated_zero;
26mod to_computed_value;
27mod to_css;
28mod to_resolved_value;
29mod to_typed;
30
31#[proc_macro_derive(Animate, attributes(animate, animation))]
32pub fn derive_animate(stream: TokenStream) -> TokenStream {
33    let input = syn::parse(stream).unwrap();
34    animate::derive(input).into()
35}
36
37#[proc_macro_derive(ComputeSquaredDistance, attributes(animation, distance))]
38pub fn derive_compute_squared_distance(stream: TokenStream) -> TokenStream {
39    let input = syn::parse(stream).unwrap();
40    compute_squared_distance::derive(input).into()
41}
42
43#[proc_macro_derive(ToAnimatedValue)]
44pub fn derive_to_animated_value(stream: TokenStream) -> TokenStream {
45    let input = syn::parse(stream).unwrap();
46    to_animated_value::derive(input).into()
47}
48
49#[proc_macro_derive(Parse, attributes(css, parse))]
50pub fn derive_parse(stream: TokenStream) -> TokenStream {
51    let input = syn::parse(stream).unwrap();
52    parse::derive(input).into()
53}
54
55#[proc_macro_derive(ToAnimatedZero, attributes(animation, zero))]
56pub fn derive_to_animated_zero(stream: TokenStream) -> TokenStream {
57    let input = syn::parse(stream).unwrap();
58    to_animated_zero::derive(input).into()
59}
60
61#[proc_macro_derive(ToComputedValue, attributes(compute))]
62pub fn derive_to_computed_value(stream: TokenStream) -> TokenStream {
63    let input = syn::parse(stream).unwrap();
64    to_computed_value::derive(input).into()
65}
66
67#[proc_macro_derive(ToResolvedValue, attributes(resolve))]
68pub fn derive_to_resolved_value(stream: TokenStream) -> TokenStream {
69    let input = syn::parse(stream).unwrap();
70    to_resolved_value::derive(input).into()
71}
72
73#[proc_macro_derive(ToCss, attributes(css))]
74pub fn derive_to_css(stream: TokenStream) -> TokenStream {
75    let input = syn::parse(stream).unwrap();
76    to_css::derive(input).into()
77}
78
79#[proc_macro_derive(SpecifiedValueInfo, attributes(css, parse, value_info))]
80pub fn derive_specified_value_info(stream: TokenStream) -> TokenStream {
81    let input = syn::parse(stream).unwrap();
82    specified_value_info::derive(input).into()
83}
84
85#[proc_macro_derive(ToTyped, attributes(css, typed_value))]
86pub fn derive_to_typed(stream: TokenStream) -> TokenStream {
87    let input = syn::parse(stream).unwrap();
88    to_typed::derive(input).into()
89}