Auto merge of #5523 - servo:use-quasiquote-for-attributes, r=jdm

Fixes #5157.
This commit is contained in:
bors-servo 2015-04-07 01:57:08 -05:00
commit d38fca6ed6

View file

@ -7,27 +7,20 @@ use syntax::codemap::Span;
use syntax::ptr::P; use syntax::ptr::P;
use syntax::ast::{Item, MetaItem, Expr}; use syntax::ast::{Item, MetaItem, Expr};
use syntax::ast; use syntax::ast;
use syntax::attr;
use syntax::ext::build::AstBuilder; use syntax::ext::build::AstBuilder;
use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldInfo, MethodDef, Struct, Substructure, TraitDef, ty}; use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldInfo, MethodDef, Struct, Substructure, TraitDef, ty};
use syntax::parse::token::InternedString;
pub fn expand_dom_struct(_: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> { pub fn expand_dom_struct(cx: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> {
let mut item2 = (*item).clone(); let mut item2 = (*item).clone();
{ item2.attrs.push(quote_attr!(cx, #[must_root]));
let mut add_attr = |s| { item2.attrs.push(quote_attr!(cx, #[privatize]));
item2.attrs.push(attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(InternedString::new(s)))); item2.attrs.push(quote_attr!(cx, #[jstraceable]));
};
add_attr("must_root");
add_attr("privatize");
add_attr("jstraceable");
// The following attributes are only for internal usage // The following attributes are only for internal usage
add_attr("_generate_reflector"); item2.attrs.push(quote_attr!(cx, #[_generate_reflector]));
// #[dom_struct] gets consumed, so this lets us keep around a residue // #[dom_struct] gets consumed, so this lets us keep around a residue
// Do NOT register a modifier/decorator on this attribute // Do NOT register a modifier/decorator on this attribute
add_attr("_dom_struct_marker"); item2.attrs.push(quote_attr!(cx, #[_dom_struct_marker]));
}
P(item2) P(item2)
} }
@ -48,9 +41,7 @@ pub fn expand_jstraceable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item:
explicit_self: ty::borrowed_explicit_self(), explicit_self: ty::borrowed_explicit_self(),
args: vec!(ty::Ptr(box ty::Literal(ty::Path::new(vec!("js","jsapi","JSTracer"))), ty::Raw(ast::MutMutable))), args: vec!(ty::Ptr(box ty::Literal(ty::Path::new(vec!("js","jsapi","JSTracer"))), ty::Raw(ast::MutMutable))),
ret_ty: ty::nil_ty(), ret_ty: ty::nil_ty(),
attributes: vec!(attr::mk_attr_outer(attr::mk_attr_id(), attributes: vec![quote_attr!(cx, #[inline(always)])],
attr::mk_name_value_item_str(InternedString::new("inline"),
InternedString::new("always")))),
combine_substructure: combine_substructure(box jstraceable_substructure) combine_substructure: combine_substructure(box jstraceable_substructure)
} }
], ],