Skip to content

Commit

Permalink
Fixed compile errors from new macro syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeyerho committed Jul 2, 2012
1 parent 55d8fc3 commit 8861aba
Show file tree
Hide file tree
Showing 31 changed files with 223 additions and 270 deletions.
2 changes: 1 addition & 1 deletion src/rust-azure
Submodule rust-azure updated 1 files
+7 −12 test.rs
2 changes: 1 addition & 1 deletion src/rust-mozjs
Submodule rust-mozjs updated 3 files
+1 −1 global.rs
+2 −2 name_pool.rs
+15 −19 rust.rs
2 changes: 1 addition & 1 deletion src/rust-sdl
Submodule rust-sdl updated 3 files
+6 −6 sdl.rs
+11 −14 test.rs
+14 −17 video.rs
2 changes: 1 addition & 1 deletion src/rust-stb-image
Submodule rust-stb-image updated from c47816 to 455bb6
14 changes: 6 additions & 8 deletions src/servo/content.rs
Expand Up @@ -42,18 +42,17 @@ enum PingMsg {
fn join_layout(scope: NodeScope, layout: Layout) {

if scope.is_reader_forked() {
listen { |response_from_layout|
listen(|response_from_layout| {
layout.send(layout_task::PingMsg(response_from_layout));
response_from_layout.recv();
}
});
scope.reader_joined();
}
}

#[warn(no_non_implicitly_copyable_typarams)]
fn Content(layout: Layout) -> Content {
spawn_listener::<ControlMsg> {
|from_master|
spawn_listener::<ControlMsg>(|from_master| {
let scope = NodeScope();
let rt = jsrt();
loop {
Expand Down Expand Up @@ -95,11 +94,10 @@ fn Content(layout: Layout) -> Content {
let cx = rt.cx();
cx.set_default_options_and_version();
cx.set_logging_error_reporter();
cx.new_compartment(global_class).chain {
|compartment|
cx.new_compartment(global_class).chain(|compartment| {
compartment.define_functions(debug_fns);
cx.evaluate_script(compartment.global_obj, bytes, *filename, 1u)
};
});
}
}
}
Expand All @@ -110,5 +108,5 @@ fn Content(layout: Layout) -> Content {
}
}
}
}
})
}
4 changes: 2 additions & 2 deletions src/servo/dom/base.rs
Expand Up @@ -90,7 +90,7 @@ impl TreeReadMethods of tree::ReadMethods<Node> for NodeScope {
}

fn with_tree_fields<R>(node: Node, f: fn(tree::Tree<Node>) -> R) -> R {
self.read(node) { |n| f(n.tree) }
self.read(node, |n| f(n.tree))
}
}

Expand All @@ -101,7 +101,7 @@ impl TreeWriteMethods of tree::WriteMethods<Node> for NodeScope {
}

fn with_tree_fields<R>(node: Node, f: fn(tree::Tree<Node>) -> R) -> R {
self.write(node) { |n| f(n.tree) }
self.write(node, |n| f(n.tree))
}
}

12 changes: 6 additions & 6 deletions src/servo/dom/rcu.rs
Expand Up @@ -69,7 +69,7 @@ class ScopeResource<T:send,A> {
self.d = d;
}
drop unsafe {
for self.d.free_list.each { |h| free_handle(h); }
for self.d.free_list.each |h| { free_handle(h); }
}
}

Expand Down Expand Up @@ -277,23 +277,23 @@ mod test {
let read_chan = comm::chan(read_port);

// fire up a reader task
for uint::range(0u, iter1) { |i|
for uint::range(0u, iter1) |i| {
s.reader_forked();
let wait_chan = task::spawn_listener {|wait_port|
for uint::range(0u, iter2) { |_i|
let wait_chan = task::spawn_listener(|wait_port| {
for uint::range(0u, iter2) |_i| {
comm::send(read_chan, henrietta.read(read_characteristic));
comm::send(read_chan, ferdinand.read(read_characteristic));
comm::recv(wait_port);
}
};
});

let hrc = henrietta.read(read_characteristic);
assert hrc == (i * iter2);

let frc = ferdinand.read(read_characteristic);
assert frc == i * iter2;

for uint::range(0u, iter2) { |_i|
for uint::range(0u, iter2) |_i| {
assert hrc == comm::recv(read_port);
s.write(henrietta, mutate);
assert frc == comm::recv(read_port);
Expand Down
9 changes: 4 additions & 5 deletions src/servo/engine.rs
Expand Up @@ -13,7 +13,7 @@ enum Msg {
}

fn Engine<S: Sink send copy>(sink: S) -> Engine {
spawn_listener::<Msg> { |request|
spawn_listener::<Msg>(|request| {
// The renderer
let renderer = Renderer(sink);

Expand All @@ -37,15 +37,14 @@ fn Engine<S: Sink send copy>(sink: S) -> Engine {
ExitMsg(sender) {
content.send(content::ExitMsg);
layout.send(layout_task::ExitMsg);
listen {
|response_channel|
listen(|response_channel| {
renderer.send(renderer::ExitMsg(response_channel));
response_channel.recv();
}
});
sender.send(());
break;
}
}
}
}
})
}
19 changes: 8 additions & 11 deletions src/servo/gfx/pngsink.rs
Expand Up @@ -42,8 +42,7 @@ impl PngSink of Sink for chan<Msg> {
}

fn PngSink(output: chan<[u8]>) -> PngSink {
spawn_listener::<Msg> { |po|

spawn_listener::<Msg>(|po| {
let cairo_surf = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, 800 as c_int, 600 as c_int
);
Expand All @@ -68,15 +67,15 @@ fn PngSink(output: chan<[u8]>) -> PngSink {

AzReleaseDrawTarget(draw_target);
cairo_surface_destroy(cairo_surf);
}
})
}

fn do_draw(sender: chan<AzDrawTargetRef>,
dt: AzDrawTargetRef,
output: chan<[u8]>,
cairo_surf: *cairo_surface_t) {

listen {|data_ch: chan<[u8]>|
listen(|data_ch: chan<[u8]>| {

crust fn write_fn(closure: *c_void,
data: *c_uchar,
Expand Down Expand Up @@ -112,27 +111,25 @@ fn do_draw(sender: chan<AzDrawTargetRef>,

// Send the PNG image away
output.send(result);
}
});
// Send the next draw target to the renderer
sender.send(dt);
}

#[test]
fn sanity_check() {
listen {
|self_channel|
listen(|self_channel| {

let sink = PngSink(self_channel);
let renderer = Renderer(sink);

let dlist = [];
renderer.send(RenderMsg(dlist));
listen {
|from_renderer|
listen(|from_renderer| {
renderer.send(renderer::ExitMsg(from_renderer));
from_renderer.recv();
}
});

sink.send(Exit)
}
})
}
26 changes: 10 additions & 16 deletions src/servo/gfx/renderer.rs
Expand Up @@ -25,9 +25,8 @@ iface Sink {
}

fn Renderer<S: Sink send copy>(sink: S) -> chan<Msg> {
task::spawn_listener::<Msg> {|po|
listen {
|draw_target_ch|
task::spawn_listener::<Msg>(|po| {
listen(|draw_target_ch| {
#debug("renderer: beginning rendering loop");
sink.begin_drawing(draw_target_ch);

Expand All @@ -48,8 +47,8 @@ fn Renderer<S: Sink send copy>(sink: S) -> chan<Msg> {
}
}
}
}
}
})
})
}

impl to_float for u8 {
Expand All @@ -58,11 +57,8 @@ impl to_float for u8 {
}
}

fn draw_display_list(
draw_target: AzDrawTargetRef,
display_list: dl::display_list
) {
for display_list.each {|item|
fn draw_display_list(draw_target: AzDrawTargetRef, display_list: dl::display_list) {
for display_list.each |item| {
#debug["drawing %?", item];

alt item.item_type {
Expand Down Expand Up @@ -121,10 +117,8 @@ fn draw_image(draw_target: AzDrawTargetRef, item: dl::display_item,
}

let stride = image.width * image.depth;
for uint::range(0u, image.height) {
|y|
for uint::range(0u, image.width) {
|x|
for uint::range(0u, image.height) |y| {
for uint::range(0u, image.width) |x| {
let color = {
r: image.data[y * stride + x * image.depth].to_float()
as AzFloat,
Expand Down Expand Up @@ -195,7 +189,7 @@ fn draw_text(draw_target: AzDrawTargetRef, item: dl::display_item, text_run: Tex
};

let mut origin = Point2D(bounds.origin.x, bounds.origin.y.add(bounds.size.height));
let azglyphs = text_run.glyphs.map { |glyph|
let azglyphs = text_run.glyphs.map(|glyph| {
let azglyph: AzGlyph = {
mIndex: glyph.index as uint32_t,
mPosition: {
Expand All @@ -206,7 +200,7 @@ fn draw_text(draw_target: AzDrawTargetRef, item: dl::display_item, text_run: Tex
origin = Point2D(origin.x.add(glyph.pos.advance.x),
origin.y.add(glyph.pos.advance.y));
azglyph
};
});

let glyphbuf: AzGlyphBuffer = unsafe {{
mGlyphs: to_ptr(azglyphs),
Expand Down
20 changes: 11 additions & 9 deletions src/servo/layout/base.rs
Expand Up @@ -64,7 +64,7 @@ impl NodeTreeReadMethods of tree::ReadMethods<Node> for NTree {
}

fn with_tree_fields<R>(&&n: Node, f: fn(tree::Tree<Node>) -> R) -> R {
n.read { |n| f(n.tree) }
n.read(|n| f(n.tree))
}
}

Expand Down Expand Up @@ -93,15 +93,16 @@ impl layout_methods_priv for @Box {
#[doc="Dumps the box tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = "";
for uint::range(0u, indent) {
|_i|
for uint::range(0u, indent) |_i| {
s += " ";
}

s += #fmt("%?", self.kind);
#debug["%s", s];

for BTree.each_child(self) { |kid| kid.dump_indent(indent + 1u) }
for BTree.each_child(self) |kid| {
kid.dump_indent(indent + 1u)
}
}
}

Expand Down Expand Up @@ -135,15 +136,16 @@ impl PrivateNodeMethods for Node {
#[doc="Dumps the node tree, for debugging, with indentation."]
fn dump_indent(indent: uint) {
let mut s = "";
for uint::range(0u, indent) {
|_i|
for uint::range(0u, indent) |_i| {
s += " ";
}

s += #fmt("%?", self.read({ |n| copy n.kind }));
s += #fmt("%?", self.read(|n| copy n.kind ));
#debug["%s", s];

for NTree.each_child(self) { |kid| kid.dump_indent(indent + 1u) }
for NTree.each_child(self) |kid| {
kid.dump_indent(indent + 1u)
}
}
}

Expand Down Expand Up @@ -179,7 +181,7 @@ mod test {

fn flat_bounds(root: @Box) -> [Rect<au>] {
let mut r = [];
for tree::each_child(BTree, root) {|c|
for tree::each_child(BTree, root) |c| {
r += flat_bounds(c);
}
ret r + [copy root.bounds];
Expand Down
2 changes: 1 addition & 1 deletion src/servo/layout/block.rs
Expand Up @@ -23,7 +23,7 @@ impl block_layout_methods for @Box {
// - and recursively computes the bounds for each child

let mut current_height = 0;
for tree::each_child(BTree, self) {|c|
for tree::each_child(BTree, self) |c| {
let mut blk_available_width = available_width;
// FIXME subtract borders, margins, etc
c.bounds.origin = Point2D(au(0), au(current_height));
Expand Down
8 changes: 3 additions & 5 deletions src/servo/layout/box_builder.rs
Expand Up @@ -43,8 +43,7 @@ impl methods for ctxt {
attribute is 'block'.
"]
fn construct_boxes_for_block_children() {
for NTree.each_child(self.parent_node) {
|kid|
for NTree.each_child(self.parent_node) |kid| {

// Create boxes for the child. Get its primary box.
let kid_box = kid.construct_boxes();
Expand Down Expand Up @@ -91,8 +90,7 @@ impl methods for ctxt {
attribute is 'inline'.
"]
fn construct_boxes_for_inline_children() {
for NTree.each_child(self.parent_node) {
|kid|
for NTree.each_child(self.parent_node) |kid| {

// Construct boxes for the child. Get its primary box.
let kid_box = kid.construct_boxes();
Expand Down Expand Up @@ -154,7 +152,7 @@ impl box_builder_priv for Node {
size.
"]
fn determine_box_kind() -> BoxKind {
alt self.read({ |n| copy n.kind }) {
alt self.read(|n| copy n.kind) {
~Text(string) {
TextBox(@text_box(copy string))
}
Expand Down
2 changes: 1 addition & 1 deletion src/servo/layout/display_list_builder.rs
Expand Up @@ -43,7 +43,7 @@ fn build_display_list_from_origin(box: @Box, origin: Point2D<au>)

let mut list = box_to_display_items(box, box_origin);

for BTree.each_child(box) {|c|
for BTree.each_child(box) |c| {
#debug("Recursively building display list with origin %?", box_origin);
list += build_display_list_from_origin(c, box_origin);
}
Expand Down
3 changes: 1 addition & 2 deletions src/servo/layout/inline.rs
Expand Up @@ -21,8 +21,7 @@ impl inline_layout_methods for @Box {
let y = 0;
let mut x = 0, inline_available_width = *available_width;
let mut current_height = 0;
for tree::each_child(BTree, self) {
|kid|
for tree::each_child(BTree, self) |kid| {
kid.bounds.origin = Point2D(au(x), au(y));
kid.reflow(au(inline_available_width));
inline_available_width -= *kid.bounds.size.width;
Expand Down
4 changes: 2 additions & 2 deletions src/servo/layout/layout_task.rs
Expand Up @@ -27,7 +27,7 @@ enum Msg {
}

fn Layout(renderer: Renderer) -> Layout {
spawn_listener::<Msg> { |request|
spawn_listener::<Msg>(|request| {
loop {
alt request.recv() {
PingMsg(ping_channel) {
Expand All @@ -54,5 +54,5 @@ fn Layout(renderer: Renderer) -> Layout {
}
}
}
}
})
}

0 comments on commit 8861aba

Please sign in to comment.