aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/casing.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-02-04 17:13:14 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2016-02-05 00:42:03 +0100
commitdcfb0915946aff54b01b6040427e56a66d82cb93 (patch)
treeb7daeb26ba4143aa40b24314b56a2c1d4a98d175 /components/plugins/casing.rs
parent2a6707ce58df27d93e865bffb6b44d396b810c99 (diff)
downloadservo-dcfb0915946aff54b01b6040427e56a66d82cb93.tar.gz
servo-dcfb0915946aff54b01b6040427e56a66d82cb93.zip
Remove the casing plugin
Diffstat (limited to 'components/plugins/casing.rs')
-rw-r--r--components/plugins/casing.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/components/plugins/casing.rs b/components/plugins/casing.rs
deleted file mode 100644
index 8a535cabf00..00000000000
--- a/components/plugins/casing.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-/* 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;
-use syntax::codemap::Span;
-use syntax::ext::base;
-use syntax::ext::base::ExtCtxt;
-use syntax::ext::build::AstBuilder;
-use syntax::parse::token;
-
-pub fn expand_lower<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
- -> Box<base::MacResult + 'cx> {
- expand_cased(cx, sp, tts, |s| { s.to_lowercase() })
-}
-
-pub fn expand_upper<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
- -> Box<base::MacResult + 'cx> {
- expand_cased(cx, sp, tts, |s| { s.to_uppercase() })
-}
-
-fn expand_cased<'cx, T>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree], transform: T)
- -> Box<base::MacResult + 'cx>
- where T: Fn(&str) -> String
-{
- let es = match base::get_exprs_from_tts(cx, sp, tts) {
- Some(e) => e,
- None => return base::DummyResult::expr(sp)
- };
-
- let mut it = es.iter();
- let res = if let Some(expr) = it.next() {
- if let ast::ExprLit(ref lit) = expr.node {
- if let ast::LitStr(ref s, _) = lit.node {
- Some((s, lit.span))
- } else {
- cx.span_err(expr.span, "expected a string literal");
- None
- }
- } else {
- cx.span_err(expr.span, "expected a string literal");
- None
- }
- } else {
- cx.span_err(sp, "expected 1 argument, found 0");
- None
- };
- match (res, it.count()) {
- (Some((s, span)), 0) => {
- base::MacEager::expr(cx.expr_str(span, token::intern_and_get_ident(&transform(&s))))
- }
- (_, rest) => {
- if rest > 0 {
- cx.span_err(sp, &format!("expected 1 argument, found {}", rest + 1));
- }
- base::DummyResult::expr(sp)
- }
- }
-}