mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Merge pull request #3435 from Manishearth/macro_reorg
Reorganize macros crate; r=jdm
This commit is contained in:
commit
27f3bcd718
16 changed files with 94 additions and 83 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -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",
|
||||
|
@ -308,10 +308,6 @@ name = "lazy_static"
|
|||
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"
|
||||
|
@ -367,6 +363,10 @@ name = "phf_mac"
|
|||
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"
|
||||
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,8 +22,8 @@ path = "../script_traits"
|
|||
[dependencies.style]
|
||||
path = "../style"
|
||||
|
||||
[dependencies.macros]
|
||||
path = "../macros"
|
||||
[dependencies.plugins]
|
||||
path = "../plugins"
|
||||
|
||||
[dependencies.net]
|
||||
path = "../net"
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
30
components/plugins/lib.rs
Normal file
30
components/plugins/lib.rs
Normal file
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 }))
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
24
components/plugins/macros.rs
Normal file
24
components/plugins/macros.rs
Normal file
|
@ -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 }))
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -11,8 +11,8 @@ path = "lib.rs"
|
|||
|
||||
doc = false
|
||||
|
||||
[dependencies.macros]
|
||||
path = "../macros"
|
||||
[dependencies.plugins]
|
||||
path = "../plugins"
|
||||
|
||||
[dependencies.util]
|
||||
path = "../util"
|
||||
|
|
12
ports/cef/Cargo.lock
generated
12
ports/cef/Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue