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.
This commit is contained in:
bors-servo 2014-03-25 12:37:49 -04:00
commit 11639c34e6
8 changed files with 30 additions and 67 deletions

View file

@ -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

1
configure vendored
View file

@ -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

View file

@ -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;

View file

@ -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 }))
}
}
)
)

View file

@ -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 {

View file

@ -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;

View file

@ -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 }))
}
}
)
)

View file

@ -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;