aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2014-03-21 10:16:41 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2014-03-21 14:54:56 -0700
commit79ca9b6eb00e5a5945f03221227a43919f67caa4 (patch)
treefcdc17aae1a720f782ab703f7a2a603372579468 /src
parent831712206865e2c0516009b16e2ac60f754dd1a8 (diff)
downloadservo-79ca9b6eb00e5a5945f03221227a43919f67caa4.tar.gz
servo-79ca9b6eb00e5a5945f03221227a43919f67caa4.zip
Move common macros into a new crate (fixes #1882)
Diffstat (limited to 'src')
-rw-r--r--src/components/gfx/gfx.rs7
-rw-r--r--src/components/gfx/macros.rs24
-rw-r--r--src/components/macros/macros.rs (renamed from src/components/main/macros.rs)7
-rwxr-xr-xsrc/components/main/servo.rs6
-rw-r--r--src/components/script/macros.rs24
-rw-r--r--src/components/script/script.rs7
6 files changed, 15 insertions, 60 deletions
diff --git a/src/components/gfx/gfx.rs b/src/components/gfx/gfx.rs
index dffe06f5f1e..d2a50d8f46c 100644
--- a/src/components/gfx/gfx.rs
+++ b/src/components/gfx/gfx.rs
@@ -5,7 +5,7 @@
#[crate_id = "github.com/mozilla/servo#gfx:0.1"];
#[crate_type = "lib"];
-#[feature(globs, managed_boxes, macro_rules)];
+#[feature(globs, managed_boxes, macro_rules, phase)];
extern crate azure;
extern crate collections;
@@ -14,6 +14,8 @@ extern crate geom;
extern crate layers;
extern crate stb_image;
extern crate png;
+#[phase(syntax)]
+extern crate servo_macros = "macros";
extern crate servo_net = "net";
extern crate servo_util = "util";
extern crate servo_msg = "msg";
@@ -39,9 +41,6 @@ pub use gfx_font_list = font_list;
pub use servo_gfx_font = font;
pub use servo_gfx_font_list = font_list;
-// Macros
-mod macros;
-
// Private rendering modules
mod render_context;
diff --git a/src/components/gfx/macros.rs b/src/components/gfx/macros.rs
deleted file mode 100644
index 2edf8111732..00000000000
--- a/src/components/gfx/macros.rs
+++ /dev/null
@@ -1,24 +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/. */
-
-#[macro_escape];
-
-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/src/components/main/macros.rs b/src/components/macros/macros.rs
index 2d458d7511d..4ae1923d1f3 100644
--- a/src/components/main/macros.rs
+++ b/src/components/macros/macros.rs
@@ -1,12 +1,17 @@
/* 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/. */
-#[macro_escape];
+
+#[crate_id = "github.com/mozilla/servo#macros:0.1"];
+#[crate_type = "lib"];
+
+#[feature(macro_rules)];
// Spawn a task, capturing the listed variables in a way that avoids the
// move-from-closure error. This is sugar around the function spawn_with,
// taking care of building a tuple and a lambda.
+#[macro_export]
macro_rules! bitfield(
($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => (
impl $bitfieldname {
diff --git a/src/components/main/servo.rs b/src/components/main/servo.rs
index e5f919c5ccb..645c8794eab 100755
--- a/src/components/main/servo.rs
+++ b/src/components/main/servo.rs
@@ -6,7 +6,7 @@
#[comment = "The Servo Parallel Browser Project"];
#[license = "MPL"];
-#[feature(globs, macro_rules, managed_boxes, thread_local)];
+#[feature(globs, macro_rules, managed_boxes, phase, thread_local)];
extern crate alert;
extern crate azure;
@@ -23,6 +23,8 @@ extern crate png;
#[cfg(target_os="android")]
extern crate rustuv;
extern crate script;
+#[phase(syntax)]
+extern crate servo_macros = "macros";
extern crate servo_net = "net";
extern crate servo_msg = "msg";
extern crate servo_util = "util";
@@ -75,8 +77,6 @@ use std::task::TaskOpts;
#[path="compositing/compositor_task.rs"]
pub mod compositing;
-pub mod macros;
-
pub mod css {
mod node_util;
diff --git a/src/components/script/macros.rs b/src/components/script/macros.rs
deleted file mode 100644
index 0ebdd7c6b7e..00000000000
--- a/src/components/script/macros.rs
+++ /dev/null
@@ -1,24 +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/. */
-
-#[macro_escape];
-
-macro_rules! bitfield(
- ($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => (
- impl $bitfieldname {
- #[inline]
- pub fn $getter(self) -> bool {
- let $bitfieldname(s) = self;
- (s & $value) != 0
- }
-
- #[inline]
- pub fn $setter(&mut self, value: bool) {
- let $bitfieldname(s) = *self;
- *self = $bitfieldname((s & !$value) | (if value { $value } else { 0 }))
- }
- }
- )
-)
-
diff --git a/src/components/script/script.rs b/src/components/script/script.rs
index 4c5a53efbe6..c9160b56131 100644
--- a/src/components/script/script.rs
+++ b/src/components/script/script.rs
@@ -8,7 +8,7 @@
#[comment = "The Servo Parallel Browser Project"];
#[license = "MPL"];
-#[feature(globs, macro_rules, struct_variant, managed_boxes)];
+#[feature(globs, macro_rules, struct_variant, managed_boxes, phase)];
extern crate collections;
extern crate geom;
@@ -16,6 +16,8 @@ extern crate hubbub;
extern crate encoding;
extern crate js;
extern crate serialize;
+#[phase(syntax)]
+extern crate servo_macros = "macros";
extern crate servo_net = "net";
extern crate servo_util = "util";
extern crate style;
@@ -23,9 +25,6 @@ extern crate servo_msg = "msg";
extern crate extra;
extern crate native;
-// Macros
-mod macros;
-
pub mod dom {
pub mod bindings {
pub mod js;