mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add unifying #[dom_struct] attribute (fixes #3667)
This commit is contained in:
parent
a6001329b8
commit
c45550de73
2 changed files with 15 additions and 3 deletions
|
@ -7,10 +7,21 @@ 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_jstraceable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Item, push: |P<Item>|) {
|
pub fn expand_dom_struct(_: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> {
|
||||||
|
let mut item2 = (*item).clone();
|
||||||
|
item2.attrs.push(attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(InternedString::new("must_root"))));
|
||||||
|
item2.attrs.push(attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(InternedString::new("privatize"))));
|
||||||
|
item2.attrs.push(attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(InternedString::new("jstraceable"))));
|
||||||
|
//expand_jstraceable_inner(cx, span, mitem, &*item, |_| ());
|
||||||
|
P(item2)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn expand_jstraceable(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem, item: &Item, push: |P<Item>|) {
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span: span,
|
span: span,
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern crate sync;
|
||||||
|
|
||||||
use rustc::lint::LintPassObject;
|
use rustc::lint::LintPassObject;
|
||||||
use rustc::plugin::Registry;
|
use rustc::plugin::Registry;
|
||||||
use syntax::ext::base::Decorator;
|
use syntax::ext::base::{Decorator, Modifier};
|
||||||
|
|
||||||
use syntax::parse::token::intern;
|
use syntax::parse::token::intern;
|
||||||
|
|
||||||
|
@ -25,9 +25,10 @@ mod jstraceable;
|
||||||
|
|
||||||
#[plugin_registrar]
|
#[plugin_registrar]
|
||||||
pub fn plugin_registrar(reg: &mut Registry) {
|
pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
|
reg.register_syntax_extension(intern("dom_struct"), Modifier(box jstraceable::expand_dom_struct));
|
||||||
|
reg.register_syntax_extension(intern("jstraceable"), Decorator(box jstraceable::expand_jstraceable));
|
||||||
reg.register_lint_pass(box lints::TransmutePass as LintPassObject);
|
reg.register_lint_pass(box lints::TransmutePass as LintPassObject);
|
||||||
reg.register_lint_pass(box lints::UnrootedPass as LintPassObject);
|
reg.register_lint_pass(box lints::UnrootedPass as LintPassObject);
|
||||||
reg.register_lint_pass(box lints::PrivatizePass as LintPassObject);
|
reg.register_lint_pass(box lints::PrivatizePass as LintPassObject);
|
||||||
reg.register_syntax_extension(intern("jstraceable"), Decorator(box jstraceable::expand_jstraceable))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue