aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2014-03-25 12:37:49 -0400
committerbors-servo <release+servo@mozilla.com>2014-03-25 12:37:49 -0400
commit11639c34e65bedfcc34b8734e691b5b720f085e6 (patch)
treeb5e2d57d6d1ba8db1da5d03963b38e44463f70a9
parent3401a568f276c55f90ec050df605492b900f79ac (diff)
parent79ca9b6eb00e5a5945f03221227a43919f67caa4 (diff)
downloadservo-11639c34e65bedfcc34b8734e691b5b720f085e6.tar.gz
servo-11639c34e65bedfcc34b8734e691b5b720f085e6.zip
auto merge of #1958 : mbrubeck/servo/macro-crate, r=kmcallister
This moves the bitfield! macro into a new shared `macros` crate as suggested in #1882.
-rw-r--r--Makefile.in21
-rwxr-xr-xconfigure1
-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
8 files changed, 30 insertions, 67 deletions
diff --git a/Makefile.in b/Makefile.in
index b3b191ecfb1..4758e39349f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -203,6 +203,13 @@ $(eval $(call DEF_SUBMODULE_RULES,$(submodule))))
DONE_SUBMODULES = $(foreach submodule,$(SUBMODULES),$(DONE_$(submodule)))
+RFLAGS_macros = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES))
+SRC_macros = $(call rwildcard,$(S)src/components/macros/,*.rs)
+CRATE_macros = $(S)src/components/macros/macros.rs
+DONE_macros = $(B)src/components/macros/libmacros.dummy
+
+DEPS_macros = $(CRATE_macros) $(SRC_macros) $(DONE_SUBMODULES)
+
RFLAGS_util = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES))
SRC_util = $(call rwildcard,$(S)src/components/util/,*.rs)
CRATE_util = $(S)src/components/util/util.rs
@@ -224,14 +231,14 @@ DONE_msg = $(B)src/components/msg/libmsg.dummy
DEPS_msg = $(CRATE_msg) $(SRC_msg) $(DONE_SUBMODULES)
-RFLAGS_gfx = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util -L $(B)src/components/style -L $(B)src/components/net -L $(B)src/components/msg
+RFLAGS_gfx = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util -L $(B)src/components/style -L $(B)src/components/net -L $(B)src/components/msg -L$(B)src/components/macros
SRC_gfx = $(call rwildcard,$(S)src/components/gfx/,*.rs)
CRATE_gfx = $(S)src/components/gfx/gfx.rs
DONE_gfx = $(B)src/components/gfx/libgfx.dummy
-DEPS_gfx = $(CRATE_gfx) $(SRC_gfx) $(DONE_SUBMODULES) $(DONE_util) $(DONE_style) $(DONE_net) $(DONE_msg)
+DEPS_gfx = $(CRATE_gfx) $(SRC_gfx) $(DONE_SUBMODULES) $(DONE_util) $(DONE_style) $(DONE_net) $(DONE_msg) $(DONE_macros)
-RFLAGS_script = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util -L $(B)src/components/style -L $(B)src/components/net -L $(B)src/components/msg
+RFLAGS_script = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util -L $(B)src/components/style -L $(B)src/components/net -L $(B)src/components/msg -L$(B)src/components/macros
BINDINGS_SRC = $(S)src/components/script/dom/bindings/codegen
WEBIDLS_SRC = $(S)src/components/script/dom/webidls
@@ -244,7 +251,7 @@ SRC_script = $(call rwildcard,$(S)src/components/script/,*.rs) $(AUTOGEN_SRC_scr
CRATE_script = $(S)src/components/script/script.rs
DONE_script = $(B)src/components/script/libscript.dummy
-DEPS_script = $(CRATE_script) $(SRC_script) $(DONE_SUBMODULES) $(DONE_util) $(DONE_style) $(DONE_net) $(DONE_msg)
+DEPS_script = $(CRATE_script) $(SRC_script) $(DONE_SUBMODULES) $(DONE_util) $(DONE_style) $(DONE_net) $(DONE_msg) $(DONE_macros)
RFLAGS_style = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/util
MAKO_ZIP = $(S)src/components/style/Mako-0.8.1.zip
@@ -256,14 +263,14 @@ DONE_style = $(B)src/components/style/libstyle.dummy
DEPS_style = $(CRATE_style) $(SRC_style) $(DONE_SUBMODULES) $(DONE_util)
-RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/style -L $(B)src/components/msg
+RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/style -L $(B)src/components/msg -L$(B)src/components/macros
SRC_servo = $(call rwildcard,$(S)src/components/main/,*.rs)
CRATE_servo = $(S)src/components/main/servo.rs
-DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_script) $(DONE_net) $(DONE_msg) $(DONE_style)
+DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_util) $(DONE_gfx) $(DONE_script) $(DONE_net) $(DONE_msg) $(DONE_style) $(DONE_macros)
-SERVO_LIB_CRATES = util net msg gfx script style
+SERVO_LIB_CRATES = macros util net msg gfx script style
# rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc)
# and SERVO_LIB_CRATES
diff --git a/configure b/configure
index 6973835cdad..ad101f6201f 100755
--- a/configure
+++ b/configure
@@ -583,6 +583,7 @@ do
make_dir ${CFG_BUILD_DIR}src/${i}
done
+make_dir ${CFG_BUILD_DIR}src/components/macros
make_dir ${CFG_BUILD_DIR}src/components/util
make_dir ${CFG_BUILD_DIR}src/components/msg
make_dir ${CFG_BUILD_DIR}src/components/net
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;