diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-14 21:57:50 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-19 12:59:40 -0700 |
| commit | fb169d5543c84e11038ba2d07b538ec88fb49ca6 (patch) | |
| tree | 252d6fd6dffe26a06e39f735275979b247f40302 /src/libfourcc/lib.rs | |
| parent | c121cbab35c9ff9ba133c578976a4ec35c011bcf (diff) | |
| download | rust-fb169d5543c84e11038ba2d07b538ec88fb49ca6.tar.gz rust-fb169d5543c84e11038ba2d07b538ec88fb49ca6.zip | |
Remove a number of deprecated crates
All of these crates have been deprecated for some time and properly live in the rust-lang organization as cargo-based crates. To update your code, depend on the rust-lang/foo repository via cargo. [breaking-change]
Diffstat (limited to 'src/libfourcc/lib.rs')
| -rw-r--r-- | src/libfourcc/lib.rs | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs deleted file mode 100644 index ffa72e6d795..00000000000 --- a/src/libfourcc/lib.rs +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! -Syntax extension to generate FourCCs. - -Once loaded, fourcc!() is called with a single 4-character string, -and an optional ident that is either `big`, `little`, or `target`. -The ident represents endianness, and specifies in which direction -the characters should be read. If the ident is omitted, it is assumed -to be `big`, i.e. left-to-right order. It returns a u32. - -# Examples - -To load the extension and use it: - -```rust,ignore -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let val = fourcc!("\xC0\xFF\xEE!"); - assert_eq!(val, 0xC0FFEE21u32); - let little_val = fourcc!("foo ", little); - assert_eq!(little_val, 0x21EEFFC0u32); -} -``` - -# References - -* [Wikipedia: FourCC](http://en.wikipedia.org/wiki/FourCC) - -*/ - -#![crate_name = "fourcc"] -#![deprecated = "This is now a cargo package located at: \ - https://github.com/rust-lang/fourcc"] -#![allow(deprecated)] -#![crate_type = "rlib"] -#![crate_type = "dylib"] -#![license = "MIT/ASL2"] -#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/nightly/")] - -#![feature(plugin_registrar)] - -extern crate syntax; -extern crate rustc; - -use syntax::ast; -use syntax::attr::contains; -use syntax::codemap::{Span, mk_sp}; -use syntax::ext::base; -use syntax::ext::base::{ExtCtxt, MacExpr}; -use syntax::ext::build::AstBuilder; -use syntax::parse::token; -use syntax::parse::token::InternedString; -use syntax::ptr::P; -use rustc::plugin::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_macro("fourcc", expand_syntax_ext); -} - -pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box<base::MacResult+'cx> { - let (expr, endian) = parse_tts(cx, tts); - - let little = match endian { - None => false, - Some(Ident{ident, span}) => match token::get_ident(ident).get() { - "little" => true, - "big" => false, - "target" => target_endian_little(cx, sp), - _ => { - cx.span_err(span, "invalid endian directive in fourcc!"); - target_endian_little(cx, sp) - } - } - }; - - let s = match expr.node { - // expression is a literal - ast::ExprLit(ref lit) => match lit.node { - // string literal - ast::LitStr(ref s, _) => { - if s.get().char_len() != 4 { - cx.span_err(expr.span, "string literal with len != 4 in fourcc!"); - } - s - } - _ => { - cx.span_err(expr.span, "unsupported literal in fourcc!"); - return base::DummyResult::expr(sp) - } - }, - _ => { - cx.span_err(expr.span, "non-literal in fourcc!"); - return base::DummyResult::expr(sp) - } - }; - - let mut val = 0u32; - for codepoint in s.get().chars().take(4) { - let byte = if codepoint as u32 > 0xFF { - cx.span_err(expr.span, "fourcc! literal character out of range 0-255"); - 0u8 - } else { - codepoint as u8 - }; - - val = if little { - (val >> 8) | ((byte as u32) << 24) - } else { - (val << 8) | (byte as u32) - }; - } - let e = cx.expr_lit(sp, ast::LitInt(val as u64, ast::UnsignedIntLit(ast::TyU32))); - MacExpr::new(e) -} - -struct Ident { - ident: ast::Ident, - span: Span -} - -fn parse_tts(cx: &ExtCtxt, - tts: &[ast::TokenTree]) -> (P<ast::Expr>, Option<Ident>) { - let p = &mut cx.new_parser_from_tts(tts); - let ex = p.parse_expr(); - let id = if p.token == token::EOF { - None - } else { - p.expect(&token::COMMA); - let lo = p.span.lo; - let ident = p.parse_ident(); - let hi = p.last_span.hi; - Some(Ident{ident: ident, span: mk_sp(lo, hi)}) - }; - if p.token != token::EOF { - p.unexpected(); - } - (ex, id) -} - -fn target_endian_little(cx: &ExtCtxt, sp: Span) -> bool { - let meta = cx.meta_name_value(sp, InternedString::new("target_endian"), - ast::LitStr(InternedString::new("little"), ast::CookedStr)); - contains(cx.cfg().as_slice(), &*meta) -} - -// FIXME (10872): This is required to prevent an LLVM assert on Windows -#[test] -fn dummy_test() { } |
