aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_plugins/jstraceable.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-02-16 09:18:02 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-02-16 18:37:14 +0100
commit3eed8a91a1183e22b69b1be48ad97a253bc1dc0a (patch)
treeba6b0b4740560d40445e2a817397a674ec1f8637 /components/script_plugins/jstraceable.rs
parent84a44a401424852bc44ef5e751e84544ed892e70 (diff)
downloadservo-3eed8a91a1183e22b69b1be48ad97a253bc1dc0a.tar.gz
servo-3eed8a91a1183e22b69b1be48ad97a253bc1dc0a.zip
Move script lints to script_plugins
The plugins crate now just allows to hook into clippy from a single crate.
Diffstat (limited to 'components/script_plugins/jstraceable.rs')
-rw-r--r--components/script_plugins/jstraceable.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/components/script_plugins/jstraceable.rs b/components/script_plugins/jstraceable.rs
new file mode 100644
index 00000000000..071a0b54fdc
--- /dev/null
+++ b/components/script_plugins/jstraceable.rs
@@ -0,0 +1,24 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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::ast::MetaItem;
+use syntax::codemap::Span;
+use syntax::ext::base::{Annotatable, ExtCtxt};
+use syntax::ptr::P;
+
+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, #[repr(C)]));
+ item2.attrs.push(quote_attr!(cx, #[derive(JSTraceable)]));
+ item2.attrs.push(quote_attr!(cx, #[derive(HeapSizeOf)]));
+ item2.attrs.push(quote_attr!(cx, #[derive(DenyPublicFields)]));
+ item2.attrs.push(quote_attr!(cx, #[derive(DomObject)]));
+ Annotatable::Item(P(item2))
+ } else {
+ cx.span_err(sp, "#[dom_struct] applied to something other than a struct");
+ anno
+ }
+}