mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Rename #[parse(aliases)] to #[css(aliases)]
This commit is contained in:
parent
3fba02a0d6
commit
579cef6a69
4 changed files with 12 additions and 18 deletions
|
@ -28,9 +28,9 @@ pub enum Display {
|
||||||
Table, InlineTable, TableRowGroup, TableHeaderGroup,
|
Table, InlineTable, TableRowGroup, TableHeaderGroup,
|
||||||
TableFooterGroup, TableRow, TableColumnGroup,
|
TableFooterGroup, TableRow, TableColumnGroup,
|
||||||
TableColumn, TableCell, TableCaption, ListItem, None,
|
TableColumn, TableCell, TableCaption, ListItem, None,
|
||||||
#[parse(aliases = "-webkit-flex")]
|
#[css(aliases = "-webkit-flex")]
|
||||||
Flex,
|
Flex,
|
||||||
#[parse(aliases = "-webkit-inline-flex")]
|
#[css(aliases = "-webkit-inline-flex")]
|
||||||
InlineFlex,
|
InlineFlex,
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
Grid,
|
Grid,
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub fn derive_to_animated_value(stream: TokenStream) -> TokenStream {
|
||||||
to_animated_value::derive(input).to_string().parse().unwrap()
|
to_animated_value::derive(input).to_string().parse().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_derive(Parse, attributes(parse))]
|
#[proc_macro_derive(Parse, attributes(css))]
|
||||||
pub fn derive_parse(stream: TokenStream) -> TokenStream {
|
pub fn derive_parse(stream: TokenStream) -> TokenStream {
|
||||||
let input = syn::parse_derive_input(&stream.to_string()).unwrap();
|
let input = syn::parse_derive_input(&stream.to_string()).unwrap();
|
||||||
parse::derive(input).to_string().parse().unwrap()
|
parse::derive(input).to_string().parse().unwrap()
|
||||||
|
|
|
@ -6,6 +6,7 @@ use cg;
|
||||||
use quote::Tokens;
|
use quote::Tokens;
|
||||||
use syn::DeriveInput;
|
use syn::DeriveInput;
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
use to_css::CssVariantAttrs;
|
||||||
|
|
||||||
pub fn derive(input: DeriveInput) -> Tokens {
|
pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
let name = &input.ident;
|
let name = &input.ident;
|
||||||
|
@ -19,7 +20,7 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
"Parse is only supported for single-variant enums for now"
|
"Parse is only supported for single-variant enums for now"
|
||||||
);
|
);
|
||||||
|
|
||||||
let variant_attrs = cg::parse_variant_attrs::<ParseVariantAttrs>(variant);
|
let variant_attrs = cg::parse_variant_attrs::<CssVariantAttrs>(variant);
|
||||||
let identifier = cg::to_css_identifier(variant.ident.as_ref());
|
let identifier = cg::to_css_identifier(variant.ident.as_ref());
|
||||||
let ident = &variant.ident;
|
let ident = &variant.ident;
|
||||||
|
|
||||||
|
@ -87,11 +88,3 @@ pub fn derive(input: DeriveInput) -> Tokens {
|
||||||
#methods_impl
|
#methods_impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[darling(attributes(parse), default)]
|
|
||||||
#[derive(Default, FromVariant)]
|
|
||||||
struct ParseVariantAttrs {
|
|
||||||
/// The comma-separated list of aliases this variant should be aliased to at
|
|
||||||
/// parse time.
|
|
||||||
aliases: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
|
@ -123,11 +123,12 @@ struct CssInputAttrs {
|
||||||
|
|
||||||
#[darling(attributes(css), default)]
|
#[darling(attributes(css), default)]
|
||||||
#[derive(Default, FromVariant)]
|
#[derive(Default, FromVariant)]
|
||||||
struct CssVariantAttrs {
|
pub struct CssVariantAttrs {
|
||||||
function: Option<Function>,
|
pub function: Option<Function>,
|
||||||
iterable: bool,
|
pub iterable: bool,
|
||||||
comma: bool,
|
pub comma: bool,
|
||||||
dimension: bool,
|
pub dimension: bool,
|
||||||
|
pub aliases: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[darling(attributes(css), default)]
|
#[darling(attributes(css), default)]
|
||||||
|
@ -136,7 +137,7 @@ struct CssFieldAttrs {
|
||||||
ignore_bound: bool,
|
ignore_bound: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Function {
|
pub struct Function {
|
||||||
name: Option<Ident>,
|
name: Option<Ident>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue