Permalink
Browse files

Fixed syntax by changing alt to match

  • Loading branch information...
1 parent 0b796c4 commit 7e8d0949d092bb6c5fe162861261efae2e5fdc28 @mmeyerho mmeyerho committed Aug 8, 2012
Submodule rust-geom updated 0 files
Submodule rust-glut updated 2 files
+1 −1 glut.rs
+1 −1 test.rs
Submodule rust-layers updated 4 files
+1 −1 layers.rs
+3 −3 rendergl.rs
+3 −3 test.rs
+1 −1 util.rs
View
@@ -43,8 +43,6 @@ import std::net::url::url;
import url_to_str = std::net::url::to_str;
import util::url::make_url;
-type Content = chan<ControlMsg>;
-
enum ControlMsg {
ParseMsg(url),
ExecuteMsg(url),
@@ -114,14 +112,14 @@ class Content<S:Sink send copy> {
}
fn handle_msg(msg: either<ControlMsg,Event>) -> bool {
- alt msg {
+ match msg {
left(control_msg) => self.handle_control_msg(control_msg),
right(event) => self.handle_event(event)
}
}
fn handle_control_msg(control_msg: ControlMsg) -> bool {
- alt control_msg {
+ match control_msg {
ParseMsg(url) => {
#debug["content: Received url `%s` to parse", url_to_str(url)];
@@ -161,7 +159,7 @@ class Content<S:Sink send copy> {
ExecuteMsg(url) => {
#debug["content: Received url `%s` to execute", url_to_str(url)];
- alt read_whole_file(url.path) {
+ match read_whole_file(url.path) {
err(msg) => {
println(#fmt["Error opening %s: %s", url_to_str(url), msg]);
}
@@ -202,10 +200,10 @@ class Content<S:Sink send copy> {
}
fn handle_event(event: Event) -> bool {
- alt event {
+ match event {
ResizeEvent(new_width, new_height) => {
#debug("content got resize event: %d, %d", new_width, new_height);
- alt copy self.document {
+ match copy self.document {
none => {
// Nothing to do.
}
@@ -93,7 +93,7 @@ unsafe fn unwrap(obj: *JSObject) -> *rust_box<Node> {
extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool {
unsafe {
(*unwrap(obj)).payload.read(|nd| {
- alt nd.tree.first_child {
+ match nd.tree.first_child {
some(n) => {
let obj = create(cx, n).ptr;
*rval = RUST_OBJECT_TO_JSVAL(obj);
@@ -110,7 +110,7 @@ extern fn getFirstChild(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut js
extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool {
unsafe {
(*unwrap(obj)).payload.read(|nd| {
- alt nd.tree.next_sibling {
+ match nd.tree.next_sibling {
some(n) => {
let obj = create(cx, n).ptr;
*rval = RUST_OBJECT_TO_JSVAL(obj);
@@ -127,7 +127,7 @@ extern fn getNextSibling(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut j
extern fn getTagName(cx: *JSContext, obj: *JSObject, _id: jsid, rval: *mut jsval) -> JSBool {
unsafe {
(*unwrap(obj)).payload.read(|nd| {
- alt nd.kind {
+ match nd.kind {
~Element(ed) => {
let s = str(copy ed.tag_name);
*rval = domstring_to_jsval(cx, s);
@@ -54,7 +54,7 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> result<~str, ()> {
}
unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval {
- alt str {
+ match str {
null_string => {
JSVAL_NULL
}
View
@@ -249,14 +249,14 @@ mod test {
}
fn mutate(a: animal) {
- alt a.species {
+ match a.species {
chicken(c) => c.eggs_per_day += 1u,
bull(c) => c.horns += 1u
}
}
fn read_characteristic(a: animal) -> uint {
- alt a.species {
+ match a.species {
chicken(c) => c.eggs_per_day,
bull(c) => c.horns
}
View
@@ -41,9 +41,9 @@ class Engine<S:Sink send copy> {
}
fn handle_request(request: Msg) -> bool {
- alt request {
+ match request {
LoadURLMsg(url) => {
- // TODO: change copy to move once we have alt move
+ // TODO: change copy to move once we have match move
let url = copy url;
if url.path.ends_with(".js") {
self.content.send(ExecuteMsg(url))
View
@@ -58,7 +58,7 @@ fn PngSink(output: chan<~[u8]>) -> PngSink {
assert draw_target.is_not_null();
loop {
- alt po.recv() {
+ match po.recv() {
BeginDrawing(sender) => {
#debug("pngsink: begin_drawing");
sender.send(draw_target);
@@ -46,7 +46,7 @@ fn Renderer<S: Sink send copy>(sink: S) -> comm::chan<Msg> {
sink.begin_drawing(draw_target_ch);
loop {
- alt po.recv() {
+ match po.recv() {
RenderMsg(display_list) => {
#debug("renderer: got render request");
let draw_target = draw_target_po.recv();
@@ -87,7 +87,7 @@ fn draw_display_list(draw_target: AzDrawTargetRef, display_list: dl::display_lis
for display_list.each |item| {
#debug["drawing %?", item];
- alt item.item_type {
+ match item.item_type {
dl::display_item_solid_color(r, g, b) => draw_solid_color(draw_target, item, r, g, b),
dl::display_item_image(image) => draw_image(draw_target, item, *image),
dl::display_item_text(text_run) => draw_text(draw_target, item, text_run),
@@ -132,7 +132,7 @@ fn draw_image(draw_target: AzDrawTargetRef, item: dl::display_item, image: arc<~
let data = do vec::from_fn(image.width * image.height * 4) |i| {
let color = i % 4;
let pixel = i / 4;
- alt color {
+ match color {
0 => image.data[pixel * 3 + 2],
1 => image.data[pixel * 3 + 1],
2 => image.data[pixel * 3 + 0],
View
@@ -14,7 +14,7 @@ type image_surface = {
impl format for format {
fn bpp() -> uint {
- alt self {
+ match self {
fo_rgba_8888 => 32u
}
}
View
@@ -48,7 +48,7 @@ class Appearance {
let mut image = none;
// Do a dance where we swap the ImageHolder out before we can
- // get the image out of it because we can't alt over it
+ // get the image out of it because we can't match against it
// because holder.get_image() is not pure.
if (self.background_image).is_some() {
let mut temp = none;
@@ -179,7 +179,7 @@ impl layout_methods_priv for @Box {
impl layout_methods for @Box {
#[doc="The main reflow routine."]
fn reflow(available_width: au) {
- alt self.kind {
+ match self.kind {
BlockBox => self.reflow_block(available_width),
InlineBox => self.reflow_inline(available_width),
IntrinsicBox(size) => self.reflow_intrinsic(*size),
@@ -54,10 +54,10 @@ impl methods for ctxt {
}
// Add the child's box to the current enclosing box or the current anonymous box.
- alt kid.get_specified_style().display_type {
+ match kid.get_specified_style().display_type {
some(DisBlock) => BTree.add_child(self.parent_box, kid_box),
some(DisInline) => {
- let anon_box = alt self.anon_box {
+ let anon_box = match self.anon_box {
none => {
//
// The anonymous box inherits the attributes of its parents for now, so
@@ -101,7 +101,7 @@ impl methods for ctxt {
}
// Add the child's box to the current enclosing box.
- alt kid.get_specified_style().display_type {
+ match kid.get_specified_style().display_type {
some(DisBlock) => {
// TODO
#warn("TODO: non-inline display found inside inline box");
@@ -124,7 +124,7 @@ impl methods for ctxt {
#debug("parent node:");
self.parent_node.dump();
- alt self.parent_node.get_specified_style().display_type {
+ match self.parent_node.get_specified_style().display_type {
some(DisBlock) => self.construct_boxes_for_block_children(),
some(DisInline) => self.construct_boxes_for_inline_children(),
some(DisNone) => { /* Nothing to do. */ }
@@ -141,7 +141,7 @@ impl methods for ctxt {
anonymous box to the block.
"]
fn finish_anonymous_box_if_necessary() {
- alt copy self.anon_box {
+ match copy self.anon_box {
none => { /* Nothing to do. */ }
some(b) => BTree.add_child(self.parent_box, b)
}
@@ -159,10 +159,10 @@ impl box_builder_priv of box_builder_priv for Node {
size.
"]
fn determine_box_kind() -> BoxKind {
- alt self.read(|n| copy n.kind) {
+ match self.read(|n| copy n.kind) {
~Text(string) => TextBox(@text_box(copy string)),
~Element(element) => {
- alt *element.kind {
+ match *element.kind {
HTMLDivElement => BlockBox,
HTMLImageElement({size}) => IntrinsicBox(@size),
UnknownElement => InlineBox
@@ -181,7 +181,7 @@ impl box_builder_methods of box_builder_methods for Node {
fn construct_boxes() -> @Box {
let box_kind = self.determine_box_kind();
let my_box = @Box(self, box_kind);
- alt box_kind {
+ match box_kind {
BlockBox | InlineBox => {
let cx = create_context(self, my_box);
cx.construct_boxes_for_children();
@@ -72,7 +72,7 @@ fn box_to_display_items(list: dl::display_list, box: @Box, origin: Point2D<au>)
let bounds = Rect(origin, copy box.bounds.size);
let col = box.appearance.background_color;
- alt box.kind {
+ match box.kind {
TextBox(subbox) => {
let run = copy subbox.run;
assert run.is_some();
@@ -119,13 +119,13 @@ fn should_convert_text_boxes_to_solid_color_background_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
- let subbox = alt check b.kind { TextBox(subbox) => subbox };
+ let subbox = match check b.kind { TextBox(subbox) => subbox };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
- alt list[0].item_type {
+ match list[0].item_type {
dl::display_item_solid_color(*) => { }
_ => { fail }
}
@@ -140,13 +140,13 @@ fn should_convert_text_boxes_to_text_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
- let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
+ let subbox = match check b.kind { TextBox(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
box_to_display_items(list, b, Point2D(px_to_au(0), px_to_au(0)));
- alt list[1].item_type {
+ match list[1].item_type {
dl::display_item_text(_) => { }
_ => { fail }
}
@@ -160,7 +160,7 @@ fn should_calculate_the_bounds_of_the_text_box_background_color() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
- let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
+ let subbox = match check b.kind { TextBox(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
@@ -182,7 +182,7 @@ fn should_calculate_the_bounds_of_the_text_items() {
let n = s.new_node(Text(~"firecracker"));
let b = n.construct_boxes();
- let subbox = alt check b.kind { TextBox(subbox) => { subbox } };
+ let subbox = match check b.kind { TextBox(subbox) => { subbox } };
b.reflow_text(px_to_au(800), subbox);
let list = dvec();
@@ -29,7 +29,7 @@ enum Msg {
fn Layout(renderer: Renderer) -> Layout {
do spawn_listener::<Msg>|request| {
loop {
- alt request.recv() {
+ match request.recv() {
PingMsg(ping_channel) => ping_channel.send(content::PongMsg),
ExitMsg => {
#debug("layout: ExitMsg received");
@@ -33,16 +33,16 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
fn apply_style() {
// Right now, we only handle images.
do self.node.read |node| {
- alt node.kind {
+ match node.kind {
~Element(element) => {
let style = self.node.get_specified_style();
- self.appearance.background_color = alt style.background_color {
+ self.appearance.background_color = match style.background_color {
some(col) => col,
none => node.kind.default_color()
};
- alt element.kind {
+ match element.kind {
~HTMLImageElement(*) => {
let url = element.get_attr(~"src");
Oops, something went wrong.

0 comments on commit 7e8d094

Please sign in to comment.