mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Fix deprecated plugin APIs
This commit is contained in:
parent
a0fccea670
commit
8394b82350
3 changed files with 53 additions and 47 deletions
|
@ -5,12 +5,13 @@
|
|||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ptr::P;
|
||||
use syntax::ast::{Item, MetaItem, Expr};
|
||||
use syntax::ast::{MetaItem, Expr};
|
||||
use syntax::ast;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldInfo, MethodDef, Struct, Substructure, TraitDef, ty};
|
||||
|
||||
pub fn expand_dom_struct(cx: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> {
|
||||
pub fn expand_dom_struct(cx: &mut ExtCtxt, sp: Span, _: &MetaItem, anno: Annotatable) -> Annotatable {
|
||||
if let Annotatable::Item(item) = anno {
|
||||
let mut item2 = (*item).clone();
|
||||
item2.attrs.push(quote_attr!(cx, #[must_root]));
|
||||
item2.attrs.push(quote_attr!(cx, #[privatize]));
|
||||
|
@ -21,7 +22,11 @@ pub fn expand_dom_struct(cx: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>)
|
|||
// #[dom_struct] gets consumed, so this lets us keep around a residue
|
||||
// Do NOT register a modifier/decorator on this attribute
|
||||
item2.attrs.push(quote_attr!(cx, #[_dom_struct_marker]));
|
||||
P(item2)
|
||||
Annotatable::Item(P(item2))
|
||||
} else {
|
||||
cx.span_err(sp, "#[dom_struct] applied to something other than a struct");
|
||||
anno
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides the hook to expand `#[jstraceable]` into an implementation of `JSTraceable`
|
||||
|
|
|
@ -39,9 +39,9 @@ pub mod casing;
|
|||
|
||||
#[plugin_registrar]
|
||||
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("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
|
||||
reg.register_syntax_extension(intern("jstraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
|
||||
reg.register_syntax_extension(intern("_generate_reflector"), Decorator(box reflector::expand_reflector));
|
||||
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
|
||||
reg.register_macro("to_lower", casing::expand_lower);
|
||||
reg.register_macro("to_upper", casing::expand_upper);
|
||||
reg.register_lint_pass(box lints::transmute_type::TransmutePass as LintPassObject);
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
* 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 syntax::ext::base::ExtCtxt;
|
||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ptr::P;
|
||||
use syntax::ast::{Item, MetaItem};
|
||||
use syntax::ast::MetaItem;
|
||||
use syntax::ast;
|
||||
use utils::match_ty_unwrap;
|
||||
|
||||
|
||||
pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item, push: &mut FnMut(P<Item>) -> ()) {
|
||||
pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, annotatable: Annotatable, push: &mut FnMut(Annotatable)) {
|
||||
if let Annotatable::Item(item) = annotatable {
|
||||
if let ast::ItemStruct(ref def, _) = item.node {
|
||||
let struct_name = item.ident;
|
||||
// This path has to be hardcoded, unfortunately, since we can't resolve paths at expansion time
|
||||
|
@ -25,7 +25,7 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
|
|||
}
|
||||
}
|
||||
);
|
||||
impl_item.map(|it| push(it))
|
||||
impl_item.map(|it| push(Annotatable::Item(it)))
|
||||
},
|
||||
// Or just call it on the first field (supertype).
|
||||
None => {
|
||||
|
@ -37,10 +37,11 @@ pub fn expand_reflector(cx: &mut ExtCtxt, span: Span, _: &MetaItem, item: &Item,
|
|||
}
|
||||
}
|
||||
);
|
||||
impl_item.map(|it| push(it))
|
||||
impl_item.map(|it| push(Annotatable::Item(it)))
|
||||
}
|
||||
};
|
||||
} else {
|
||||
cx.span_err(span, "#[dom_struct] seems to have been applied to a non-struct");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue