diff options
-rw-r--r-- | Cargo.lock | 16 | ||||
-rw-r--r-- | ORGANIZATION.md | 2 | ||||
-rw-r--r-- | components/gfx/Cargo.toml | 4 | ||||
-rw-r--r-- | components/gfx/lib.rs | 2 | ||||
-rw-r--r-- | components/layout/Cargo.toml | 4 | ||||
-rw-r--r-- | components/layout/lib.rs | 2 | ||||
-rw-r--r-- | components/plugins/Cargo.toml (renamed from components/macros/Cargo.toml) | 4 | ||||
-rw-r--r-- | components/plugins/lib.rs | 30 | ||||
-rw-r--r-- | components/plugins/lints.rs (renamed from components/macros/lib.rs) | 61 | ||||
-rw-r--r-- | components/plugins/macros.rs | 24 | ||||
-rw-r--r-- | components/script/Cargo.toml | 4 | ||||
-rw-r--r-- | components/script/lib.rs | 2 | ||||
-rw-r--r-- | components/style/Cargo.toml | 4 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 12 | ||||
-rw-r--r-- | ports/cef/Cargo.toml | 4 | ||||
-rw-r--r-- | ports/cef/lib.rs | 2 |
16 files changed, 94 insertions, 83 deletions
diff --git a/Cargo.lock b/Cargo.lock index 6751b20a60b..cd402b9397a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,9 +182,9 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "harfbuzz 0.1.0 (git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6)", "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", - "macros 0.0.1", "msg 0.0.1", "net 0.0.1", + "plugins 0.0.1", "png 0.1.0 (git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79)", "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image#f5022de4ad6bb474a03493d1f274dde9b0f1af0c)", "style 0.0.1", @@ -283,8 +283,8 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "gfx 0.0.1", "layout_traits 0.0.1", - "macros 0.0.1", "net 0.0.1", + "plugins 0.0.1", "script 0.0.1", "script_traits 0.0.1", "style 0.0.1", @@ -309,10 +309,6 @@ version = "0.1.0" source = "git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360" [[package]] -name = "macros" -version = "0.0.1" - -[[package]] name = "mozjs-sys" version = "0.0.0" source = "git+https://github.com/servo/mozjs#47cd6a4e60c75642ba182f0df9a42b71ec7c2c88" @@ -368,6 +364,10 @@ version = "0.0.0" source = "git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0" [[package]] +name = "plugins" +version = "0.0.1" + +[[package]] name = "png" version = "0.1.0" source = "git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79" @@ -393,9 +393,9 @@ dependencies = [ "http 0.1.0-pre (git+https://github.com/servo/rust-http?ref=servo#4fdedeea8fc77149adf51bb24a37372af21c25b7)", "hubbub 0.1.0 (git+https://github.com/servo/rust-hubbub#c7f868e688de6e9cbdc26aa09292ed072bc2648b)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)", - "macros 0.0.1", "msg 0.0.1", "net 0.0.1", + "plugins 0.0.1", "script_traits 0.0.1", "style 0.0.1", "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", @@ -458,7 +458,7 @@ dependencies = [ "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360)", - "macros 0.0.1", + "plugins 0.0.1", "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", "util 0.0.1", ] diff --git a/ORGANIZATION.md b/ORGANIZATION.md index 9e237010d5c..661aa9d9f02 100644 --- a/ORGANIZATION.md +++ b/ORGANIZATION.md @@ -12,7 +12,7 @@ * `components/net`: Networking, caching, image decoding. * `components/msg`: Message structure definitions for inter-task communication. * `components/*_traits`: Trait definitions to break crate dependencies. -* `components/macros`: Macros used by the rest of Servo. +* `components/plugins`: Various compiler plugins and macros used by the rest of Servo. * `components/util`: Various utility functions used by other Servo components. ## Supporting libraries diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index b1b6faaa7a8..ad62df8fd92 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -8,8 +8,8 @@ authors = ["The Servo Project Developers"] name = "gfx" path = "lib.rs" -[dependencies.macros] -path = "../macros" +[dependencies.plugins] +path = "../plugins" [dependencies.net] path = "../net" diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 2895750c1a2..975ad1bd3a5 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -22,7 +22,7 @@ extern crate stb_image; extern crate png; extern crate serialize; #[phase(plugin)] -extern crate "macros" as servo_macros; +extern crate "plugins" as servo_plugins; extern crate "net" as servo_net; #[phase(plugin, link)] extern crate "util" as servo_util; diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index ed1ba4a5740..b6e7da758c5 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -22,8 +22,8 @@ path = "../script_traits" [dependencies.style] path = "../style" -[dependencies.macros] -path = "../macros" +[dependencies.plugins] +path = "../plugins" [dependencies.net] path = "../net" diff --git a/components/layout/lib.rs b/components/layout/lib.rs index a613a5dec1e..5ef17f65359 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -23,7 +23,7 @@ extern crate script_traits; extern crate serialize; extern crate style; #[phase(plugin)] -extern crate "macros" as servo_macros; +extern crate "plugins" as servo_plugins; extern crate "net" as servo_net; extern crate "msg" as servo_msg; #[phase(plugin, link)] diff --git a/components/macros/Cargo.toml b/components/plugins/Cargo.toml index c187d554829..38099fc5677 100644 --- a/components/macros/Cargo.toml +++ b/components/plugins/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "macros" +name = "plugins" version = "0.0.1" authors = ["The Servo Project Developers"] [lib] -name = "macros" +name = "plugins" path = "lib.rs" plugin = true diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs new file mode 100644 index 00000000000..3247ad383ed --- /dev/null +++ b/components/plugins/lib.rs @@ -0,0 +1,30 @@ +/* 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/. */ + +#![feature(macro_rules, plugin_registrar, quote, phase)] + +#![deny(unused_imports, unused_variable)] + + + +#[phase(plugin,link)] +extern crate syntax; +#[phase(plugin, link)] +extern crate rustc; +#[cfg(test)] +extern crate sync; + +use rustc::lint::LintPassObject; +use rustc::plugin::Registry; + +mod lints; +mod macros; + + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_lint_pass(box lints::TransmutePass as LintPassObject); + reg.register_lint_pass(box lints::UnrootedPass as LintPassObject); +} + diff --git a/components/macros/lib.rs b/components/plugins/lints.rs index b8db24baea1..4a1bbb85f09 100644 --- a/components/macros/lib.rs +++ b/components/plugins/lints.rs @@ -1,24 +1,6 @@ -/* 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/. */ - -#![feature(macro_rules, plugin_registrar, quote, phase)] - -#![deny(unused_imports, unused_variable)] - -//! Exports macros for use in other Servo crates. - -extern crate syntax; - -#[phase(plugin, link)] -extern crate rustc; -#[cfg(test)] -extern crate sync; - -use syntax::ast; +use syntax::{ast, codemap, visit}; use syntax::attr::AttrMetaMethods; -use rustc::lint::{Context, LintPass, LintPassObject, LintArray}; -use rustc::plugin::Registry; +use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty::expr_ty; use rustc::middle::{ty, def}; use rustc::middle::typeck::astconv::AstConv; @@ -29,8 +11,8 @@ declare_lint!(TRANSMUTE_TYPE_LINT, Allow, declare_lint!(UNROOTED_MUST_ROOT, Deny, "Warn and report usage of unrooted jsmanaged objects") -struct TransmutePass; -struct UnrootedPass; +pub struct TransmutePass; +pub struct UnrootedPass; impl LintPass for TransmutePass { fn get_lints(&self) -> LintArray { @@ -109,11 +91,11 @@ impl LintPass for UnrootedPass { } } - fn check_fn(&mut self, cx: &Context, kind: syntax::visit::FnKind, decl: &ast::FnDecl, - block: &ast::Block, _span: syntax::codemap::Span, _id: ast::NodeId) { + fn check_fn(&mut self, cx: &Context, kind: visit::FnKind, decl: &ast::FnDecl, + block: &ast::Block, _span: codemap::Span, _id: ast::NodeId) { match kind { - syntax::visit::FkItemFn(i, _, _, _) | - syntax::visit::FkMethod(i, _, _) if i.as_str() == "new" || i.as_str() == "new_inherited" => { + visit::FkItemFn(i, _, _, _) | + visit::FkMethod(i, _, _) if i.as_str() == "new" || i.as_str() == "new_inherited" => { return; } _ => () @@ -158,29 +140,4 @@ impl LintPass for UnrootedPass { _ => {} } } -} - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_lint_pass(box TransmutePass as LintPassObject); - reg.register_lint_pass(box UnrootedPass as LintPassObject); -} - -#[macro_export] -macro_rules! bitfield( - ($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => ( - impl $bitfieldname { - #[inline] - pub fn $getter(self) -> bool { - let $bitfieldname(this) = self; - (this & $value) != 0 - } - - #[inline] - pub fn $setter(&mut self, value: bool) { - let $bitfieldname(this) = *self; - *self = $bitfieldname((this & !$value) | (if value { $value } else { 0 })) - } - } - ) -) +}
\ No newline at end of file diff --git a/components/plugins/macros.rs b/components/plugins/macros.rs new file mode 100644 index 00000000000..12a1953c43c --- /dev/null +++ b/components/plugins/macros.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/. */ + +//! Exports macros for use in other Servo crates. + +#[macro_export] +macro_rules! bitfield( + ($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => ( + impl $bitfieldname { + #[inline] + pub fn $getter(self) -> bool { + let $bitfieldname(this) = self; + (this & $value) != 0 + } + + #[inline] + pub fn $setter(&mut self, value: bool) { + let $bitfieldname(this) = *self; + *self = $bitfieldname((this & !$value) | (if value { $value } else { 0 })) + } + } + ) +) diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 8bf75b57b20..cfd3c3d8e44 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -9,8 +9,8 @@ build = "make -f makefile.cargo" name = "script" path = "lib.rs" -[dependencies.macros] -path = "../macros" +[dependencies.plugins] +path = "../plugins" [dependencies.util] path = "../util" diff --git a/components/script/lib.rs b/components/script/lib.rs index c4b6b675d42..667bfb0e413 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -33,7 +33,7 @@ extern crate time; extern crate canvas; extern crate script_traits; #[phase(plugin)] -extern crate "macros" as servo_macros; +extern crate "plugins" as servo_plugins; extern crate "net" as servo_net; extern crate "util" as servo_util; extern crate style; diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 38964c0e4da..a272eeb01f3 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -11,8 +11,8 @@ path = "lib.rs" doc = false -[dependencies.macros] -path = "../macros" +[dependencies.plugins] +path = "../plugins" [dependencies.util] path = "../util" diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 435c545ae92..c4d77206c38 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -12,7 +12,7 @@ dependencies = [ "glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)", "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", - "macros 0.0.1", +"plugins 0.0.1", "msg 0.0.1", "net 0.0.1", "opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)", @@ -194,7 +194,7 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "harfbuzz 0.1.0 (git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6)", "layers 0.1.0 (git+https://github.com/servo/rust-layers#ef89918471815dfced7aaf2f1594d5469f03eab7)", - "macros 0.0.1", + "plugins 0.0.1", "msg 0.0.1", "net 0.0.1", "png 0.1.0 (git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79)", @@ -295,7 +295,7 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "gfx 0.0.1", "layout_traits 0.0.1", - "macros 0.0.1", + "plugins 0.0.1", "net 0.0.1", "script 0.0.1", "script_traits 0.0.1", @@ -321,7 +321,7 @@ version = "0.1.0" source = "git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360" [[package]] -name = "macros" +name = "plugins" version = "0.0.1" [[package]] @@ -405,7 +405,7 @@ dependencies = [ "http 0.1.0-pre (git+https://github.com/servo/rust-http?ref=servo#4fdedeea8fc77149adf51bb24a37372af21c25b7)", "hubbub 0.1.0 (git+https://github.com/servo/rust-hubbub#c7f868e688de6e9cbdc26aa09292ed072bc2648b)", "js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)", - "macros 0.0.1", + "plugins 0.0.1", "msg 0.0.1", "net 0.0.1", "script_traits 0.0.1", @@ -484,7 +484,7 @@ dependencies = [ "encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#35f0d70f65f73ba16f296f9ec675eddee661ba79)", "geom 0.1.0 (git+https://github.com/servo/rust-geom#50a294fd997f0c6eb43e9a58ad6e227fdc2a4692)", "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360)", - "macros 0.0.1", + "plugins 0.0.1", "url 0.1.0 (git+https://github.com/servo/rust-url#bfdf809365600a7941a77524f9bb065886de3379)", "util 0.0.1", ] diff --git a/ports/cef/Cargo.toml b/ports/cef/Cargo.toml index c53fbfbfec1..95ffcf73cef 100644 --- a/ports/cef/Cargo.toml +++ b/ports/cef/Cargo.toml @@ -11,8 +11,8 @@ crate-type = ["dylib"] [dependencies.servo] path = "../.." -[dependencies.macros] -path = "../../components/macros" +[dependencies.plugins] +path = "../../components/plugins" [dependencies.gfx] path = "../../components/gfx" diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 69425526f44..e486644aa89 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -12,7 +12,7 @@ extern crate log; extern crate rustuv; -extern crate "macros" as servo_macros; +extern crate "plugins" as servo_plugins; extern crate servo; extern crate azure; |