diff options
author | Margaret Meyerhofer <mmeyerhofer@mozilla.com> | 2012-07-12 10:13:06 -0700 |
---|---|---|
committer | Margaret Meyerhofer <mmeyerhofer@mozilla.com> | 2012-07-12 17:48:53 -0700 |
commit | 1212f3df65db6ca7d7948805d285100dfc8f8336 (patch) | |
tree | 46ba33a57a9ce55b6fa0818965737a8ba92b2ed3 | |
parent | 12a05daa5da455b5888d5b393a924fc1384e7c24 (diff) | |
download | servo-1212f3df65db6ca7d7948805d285100dfc8f8336.tar.gz servo-1212f3df65db6ca7d7948805d285100dfc8f8336.zip |
Fixed deprecated vector syntax
28 files changed, 124 insertions, 123 deletions
diff --git a/Makefile.in b/Makefile.in index b021598308c..45ad64206cd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -186,11 +186,11 @@ check-rust-opengles: $(MAKE) check -C src/rust-opengles .PHONY: check-rust-glut -check-rust-glut: +check-rust-glut: $(GLUT_DEPS) RUSTFLAGS="-L ../rust-opengles" $(MAKE) check -C src/rust-glut .PHONY: check-rust-layers -check-rust-layers: +check-rust-layers: $(LAYERS_DEPS) RUSTFLAGS="-L ../rust-geom -L ../rust-opengles -L ../rust-glut -L ../rust-azure -L ../rust-cocoa" \ $(MAKE) check -C src/rust-layers diff --git a/src/rust-layers b/src/rust-layers -Subproject e9f7c1a5944608dd55d5dfb517c86c408e23a0f +Subproject 50c5e964d91316ce19d7be8de68903eedca8770 diff --git a/src/rust-mozjs b/src/rust-mozjs -Subproject 9a133eb6edcc576b006fdb446a80072f7da3e22 +Subproject fc51299da10833faa6fe322ced5e998139015c7 diff --git a/src/rust-sdl b/src/rust-sdl -Subproject a878f4fa59f7f95e527e342eeb1a7041e735582 +Subproject ce58ddadbc61b3c79033db13b3e63ac2946c758 diff --git a/src/rust-stb-image b/src/rust-stb-image -Subproject 2d87ae88486ee1a438fa71d1199dd7bc987b17f +Subproject 30f1c06c32979da20f6dc82119b4037deba0822 diff --git a/src/servo/dom/rcu.rs b/src/servo/dom/rcu.rs index a1cb270ccc3..74edc0f7076 100644 --- a/src/servo/dom/rcu.rs +++ b/src/servo/dom/rcu.rs @@ -51,6 +51,7 @@ of the RCU nodes themselves. import ptr::extensions; import core::libc::types::os::arch::c95::size_t; +import vec::push; export Handle; export ReaderMethods; @@ -59,7 +60,7 @@ export Scope; type ScopeData<T:send,A> = { mut layout_active: bool, - mut free_list: [Handle<T,A>], + mut free_list: ~[Handle<T,A>], mut first_dirty: Handle<T,A> }; @@ -159,7 +160,7 @@ fn null_handle<T:send,A>() -> Handle<T,A> { fn Scope<T:send,A>() -> Scope<T,A> { @ScopeResource({mut layout_active: false, - mut free_list: [], + mut free_list: ~[], mut first_dirty: null_handle()}) } @@ -219,7 +220,7 @@ impl WriterMethods<T:copy send,A> for Scope<T,A> { (*d).read_aux = ptr::null(); (*d).next_dirty = null_handle(); let h = _Handle(d); - self.d.free_list += [h]; + push(self.d.free_list, h); ret h; } } diff --git a/src/servo/dom/style.rs b/src/servo/dom/style.rs index a1ae7af3659..3dff0a0fa82 100644 --- a/src/servo/dom/style.rs +++ b/src/servo/dom/style.rs @@ -21,12 +21,12 @@ enum Attr{ } enum Selector{ - Element(str, [Attr]), + Element(str, ~[Attr]), Child(~Selector, ~Selector), Descendant(~Selector, ~Selector), Sibling(~Selector, ~Selector) } -type Rule = ([~Selector], [StyleDeclaration]); +type Rule = (~[~Selector], ~[StyleDeclaration]); -type Stylesheet = [~Rule]; +type Stylesheet = ~[~Rule]; diff --git a/src/servo/gfx/pngsink.rs b/src/servo/gfx/pngsink.rs index ec1e18d351c..4dc602e01c1 100644 --- a/src/servo/gfx/pngsink.rs +++ b/src/servo/gfx/pngsink.rs @@ -2,7 +2,7 @@ A graphics sink that renders to PNG format buffers Each time the renderer renders a frame the bufsink will output a -`[u8]` containing the frame in PNG format. +`~[u8]` containing the frame in PNG format. "]; export PngSink, Msg, Exit; @@ -45,7 +45,7 @@ impl PngSink of Sink for chan<Msg> { } } -fn PngSink(output: chan<[u8]>) -> PngSink { +fn PngSink(output: chan<~[u8]>) -> PngSink { spawn_listener::<Msg>(|po| { let cairo_surf = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, 800 as c_int, 600 as c_int @@ -76,10 +76,10 @@ fn PngSink(output: chan<[u8]>) -> PngSink { fn do_draw(sender: chan<AzDrawTargetRef>, dt: AzDrawTargetRef, - output: chan<[u8]>, + output: chan<~[u8]>, cairo_surf: *cairo_surface_t) { - listen(|data_ch: chan<[u8]>| { + listen(|data_ch: chan<~[u8]>| { extern fn write_fn(closure: *c_void, data: *c_uchar, @@ -87,7 +87,7 @@ fn do_draw(sender: chan<AzDrawTargetRef>, -> cairo_status_t unsafe { - let p: *chan<[u8]> = reinterpret_cast(closure); + let p: *chan<~[u8]> = reinterpret_cast(closure); let data_ch = *p; // Convert from *c_uchar to *u8 @@ -108,7 +108,7 @@ fn do_draw(sender: chan<AzDrawTargetRef>, } // Collect the entire image into a single vector - let mut result = []; + let mut result = ~[]; while data_ch.peek() { result += data_ch.recv(); } @@ -127,7 +127,7 @@ fn sanity_check() { let sink = PngSink(self_channel); let renderer = Renderer(sink); - let dlist = []; + let dlist = ~[]; renderer.send(RenderMsg(dlist)); listen(|from_renderer| { renderer.send(renderer::ExitMsg(from_renderer)); diff --git a/src/servo/gfx/surface.rs b/src/servo/gfx/surface.rs index 55f5f73e128..c190a5c1d8f 100644 --- a/src/servo/gfx/surface.rs +++ b/src/servo/gfx/surface.rs @@ -9,7 +9,7 @@ enum format { type image_surface = { size: Size2D<int>, format: format, - buffer: [u8] + buffer: ~[u8] }; impl format for format { diff --git a/src/servo/layout/base.rs b/src/servo/layout/base.rs index d11951e157c..14ddedd16df 100644 --- a/src/servo/layout/base.rs +++ b/src/servo/layout/base.rs @@ -17,6 +17,7 @@ import util::color::Color; import text::text_box; import style::style::computed_style; import text::text_layout_methods; +import vec::{push, push_all}; enum BoxKind { BlockBox, @@ -171,7 +172,7 @@ mod test { fn with_screen(f: fn(*sdl::surface)) { let screen = video::set_video_mode( 320, 200, 32, - [video::hwsurface], [video::doublebuf]); + ~[video::hwsurface], ~[video::doublebuf]); assert screen != ptr::null(); f(screen); @@ -180,12 +181,15 @@ mod test { } */ - fn flat_bounds(root: @Box) -> [Rect<au>] { - let mut r = []; + fn flat_bounds(root: @Box) -> ~[Rect<au>] { + let mut r = ~[]; for tree::each_child(BTree, root) |c| { - r += flat_bounds(c); + push_all(r, flat_bounds(c)); } - ret r + [copy root.bounds]; + + push(r, copy root.bounds); + + ret r; } #[test] @@ -218,10 +222,10 @@ mod test { b3.reflow_block(au(100)); let fb = flat_bounds(b3); #debug["fb=%?", fb]; - assert fb == [geometry::box(au(0), au(0), au(10), au(10)), // n0 - geometry::box(au(0), au(10), au(10), au(15)), // n1 - geometry::box(au(0), au(25), au(10), au(20)), // n2 - geometry::box(au(0), au(0), au(100), au(45))]; // n3 + assert fb == ~[geometry::box(au(0), au(0), au(10), au(10)), // n0 + geometry::box(au(0), au(10), au(10), au(15)), // n1 + geometry::box(au(0), au(25), au(10), au(20)), // n2 + geometry::box(au(0), au(0), au(100), au(45))]; // n3 } } diff --git a/src/servo/layout/display_list.rs b/src/servo/layout/display_list.rs index c2e37dfafb6..9ff753f50c5 100644 --- a/src/servo/layout/display_list.rs +++ b/src/servo/layout/display_list.rs @@ -16,4 +16,4 @@ enum display_item = { bounds: Rect<au> }; -type display_list = [display_item]; +type display_list = ~[display_item]; diff --git a/src/servo/layout/display_list_builder.rs b/src/servo/layout/display_list_builder.rs index db677de54bc..6e28525be34 100644 --- a/src/servo/layout/display_list_builder.rs +++ b/src/servo/layout/display_list_builder.rs @@ -13,6 +13,7 @@ import geom::size::Size2D; import geom::point::Point2D; import geom::rect::Rect; import base::{Box, TextBox, BTree, BoxTreeReadMethods}; +import vec::push; #[doc = " @@ -63,8 +64,8 @@ Creates a display list item for a single block. "] #[warn(no_non_implicitly_copyable_typarams)] -fn box_to_display_items(box: @Box, origin: Point2D<au>) -> [dl::display_item] { - let mut items = []; +fn box_to_display_items(box: @Box, origin: Point2D<au>) -> ~[dl::display_item] { + let mut items = ~[]; #debug("request to display a box from origin %?", origin); @@ -74,38 +75,36 @@ fn box_to_display_items(box: @Box, origin: Point2D<au>) -> [dl::display_item] { (TextBox(subbox), _, _) { let run = copy subbox.run; assert run.is_some(); - items += [ - dl::display_item({ - item_type: dl::display_item_solid_color(255u8, 255u8, 255u8), - bounds: bounds - }), - dl::display_item({ - item_type: dl::display_item_text(run.get()), - bounds: bounds - }) - ]; + push(items, dl::display_item({ + item_type: dl::display_item_solid_color(255u8, 255u8, 255u8), + bounds: bounds + })); + push(items, dl::display_item({ + item_type: dl::display_item_text(run.get()), + bounds: bounds + })); } (_, some(image), some(*)) | (_, some(image), none) { - items += [dl::display_item({ + push(items, dl::display_item({ item_type: dl::display_item_image(~copy *image), bounds: bounds - })]; + })); } (_, none, some(col)) { #debug("Assigning color %? to box with bounds %?", col, bounds); - items += [dl::display_item({ + push(items, dl::display_item({ item_type: dl::display_item_solid_color(col.red, col.green, col.blue), bounds: bounds - })]; + })); } (_, none, none) { let r = rand::rng(); - items += [dl::display_item({ + push(items, dl::display_item({ item_type: dl::display_item_solid_color(r.next() as u8, r.next() as u8, r.next() as u8), bounds: bounds - })]; + })); } } diff --git a/src/servo/layout/style/matching.rs b/src/servo/layout/style/matching.rs index 7acde4932e6..bc02a41c632 100644 --- a/src/servo/layout/style/matching.rs +++ b/src/servo/layout/style/matching.rs @@ -219,7 +219,7 @@ mod test { let scope = NodeScope(); let node = new_node_from_attr(scope, "lang", "en-us"); - let sel = Element("*", [StartsWith("lang", "en")]); + let sel = Element("*", ~[StartsWith("lang", "en")]); assert node.matches_selector(~sel); } @@ -229,7 +229,7 @@ mod test { let scope = NodeScope(); let node = new_node_from_attr(scope, "lang", "en"); - let sel = Element("*", [StartsWith("lang", "en")]); + let sel = Element("*", ~[StartsWith("lang", "en")]); assert node.matches_selector(~sel); } @@ -239,7 +239,7 @@ mod test { let scope = NodeScope(); let node = new_node_from_attr(scope, "lang", "english"); - let sel = Element("*", [StartsWith("lang", "en")]); + let sel = Element("*", ~[StartsWith("lang", "en")]); assert !node.matches_selector(~sel); } @@ -249,7 +249,7 @@ mod test { let scope = NodeScope(); let node = new_node_from_attr(scope, "mad", "hatter cobler cooper"); - let sel = Element("div", [Includes("mad", "hatter")]); + let sel = Element("div", ~[Includes("mad", "hatter")]); assert node.matches_selector(~sel); } @@ -259,8 +259,8 @@ mod test { let scope = NodeScope(); let node = new_node_from_attr(scope, "mad", "hatter cobler cooper"); - let sel1 = Element("div", [Exists("mad")]); - let sel2 = Element("div", [Exists("hatter")]); + let sel1 = Element("div", ~[Exists("mad")]); + let sel2 = Element("div", ~[Exists("hatter")]); assert node.matches_selector(~sel1); assert !node.matches_selector(~sel2); @@ -272,7 +272,7 @@ mod test { let node1 = new_node_from_attr(scope, "mad", "hatter cobler cooper"); let node2 = new_node_from_attr(scope, "mad", "hatter"); - let sel = Element("div", [Exact("mad", "hatter")]); + let sel = Element("div", ~[Exact("mad", "hatter")]); assert !node1.matches_selector(~copy sel); assert node2.matches_selector(~sel); @@ -295,8 +295,8 @@ mod test { scope.add_child(gchild, ggchild); scope.add_child(ggchild, gggchild); - let sel1 = Descendant(~Element("*", [Exact("class", "blue")]), - ~Element("*", [])); + let sel1 = Descendant(~Element("*", ~[Exact("class", "blue")]), + ~Element("*", ~[])); assert !root.matches_selector(~copy sel1); assert child1.matches_selector(~copy sel1); @@ -305,9 +305,9 @@ mod test { assert ggchild.matches_selector(~copy sel1); assert gggchild.matches_selector(~sel1); - let sel2 = Descendant(~Child(~Element("*", [Exact("class", "blue")]), - ~Element("*", [])), - ~Element("div", [Exists("flag")])); + let sel2 = Descendant(~Child(~Element("*", ~[Exact("class", "blue")]), + ~Element("*", ~[])), + ~Element("div", ~[Exists("flag")])); assert !root.matches_selector(~copy sel2); assert !child1.matches_selector(~copy sel2); @@ -316,7 +316,7 @@ mod test { assert ggchild.matches_selector(~copy sel2); assert gggchild.matches_selector(~sel2); - let sel3 = Sibling(~Element("*", []), ~Element("*", [])); + let sel3 = Sibling(~Element("*", ~[]), ~Element("*", ~[])); assert !root.matches_selector(~copy sel3); assert child1.matches_selector(~copy sel3); @@ -325,9 +325,9 @@ mod test { assert !ggchild.matches_selector(~copy sel3); assert !gggchild.matches_selector(~sel3); - let sel4 = Descendant(~Child(~Element("*", [Exists("class")]), - ~Element("*", [])), - ~Element("*", [])); + let sel4 = Descendant(~Child(~Element("*", ~[Exists("class")]), + ~Element("*", ~[])), + ~Element("*", ~[])); assert !root.matches_selector(~copy sel4); assert !child1.matches_selector(~copy sel4); diff --git a/src/servo/net.rs b/src/servo/net.rs index 37d62e62c93..289f6522e45 100644 --- a/src/servo/net.rs +++ b/src/servo/net.rs @@ -4,7 +4,7 @@ import uri::uri; iface input_stream { fn close(); - fn read() -> [u8]; + fn read() -> ~[u8]; } iface channel { diff --git a/src/servo/opts.rs b/src/servo/opts.rs index 304674e6c69..4785ba55491 100644 --- a/src/servo/opts.rs +++ b/src/servo/opts.rs @@ -6,7 +6,7 @@ from command line arguments. "]; type Opts = { - urls: [str], + urls: ~[str], render_mode: RenderMode }; @@ -16,12 +16,12 @@ enum RenderMode { } #[warn(no_non_implicitly_copyable_typarams)] -fn from_cmdline_args(args: [str]) -> Opts { +fn from_cmdline_args(args: ~[str]) -> Opts { import std::getopts; let args = args.tail(); - let opts = [ + let opts = ~[ getopts::optopt("o") ]; diff --git a/src/servo/parser/css_builder.rs b/src/servo/parser/css_builder.rs index ffead37313e..f96c34b5f8d 100644 --- a/src/servo/parser/css_builder.rs +++ b/src/servo/parser/css_builder.rs @@ -12,6 +12,7 @@ import parser::css_lexer::{Token, StartDescription, EndDescription, import comm::recv; import option::is_none; import util::color::parsing::parse_color; +import vec::push; type TokenReader = {stream : port<Token>, mut lookahead : option<Token>}; @@ -37,13 +38,13 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> { _ { fail "Expected an element" } }; - let mut attr_list = []; + let mut attr_list = ~[]; // Get the attributes associated with that element loop { let tok = reader.get(); alt tok { - Attr(attr) { attr_list += [copy attr]; } + Attr(attr) { push(attr_list, copy attr); } StartDescription | Descendant | Child | Sibling | Comma { reader.unget(tok); break; @@ -60,8 +61,8 @@ fn parse_element(reader : TokenReader) -> option<~style::Selector> { } fn parse_rule(reader : TokenReader) -> option<~style::Rule> { - let mut sel_list = []; - let mut desc_list = []; + let mut sel_list = ~[]; + let mut desc_list = ~[]; // Collect all the selectors that this rule applies to loop { @@ -107,13 +108,13 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> { } StartDescription { let built_sel <- cur_sel; - sel_list += [built_sel]; + push(sel_list, built_sel); reader.unget(StartDescription); break; } Comma { let built_sel <- cur_sel; - sel_list += [built_sel]; + push(sel_list, built_sel); reader.unget(Comma); break; } @@ -146,27 +147,25 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> { let num = val.substr(0u, val.len() - 2u); alt uint::from_str(num) { - some(n) { desc_list += [FontSize(n)]; } + some(n) { push(desc_list, FontSize(n)); } none { fail "Nonnumber provided as font size"; } } } "display" { alt val { - "inline" { desc_list += [Display(DisInline)]; } - "block" { desc_list += [Display(DisBlock)]; } - "none" { desc_list += [Display(DisNone)]; } - _ { #debug["Recieved unknown display value '%s'", - val]; } + "inline" { push(desc_list, Display(DisInline)); } + "block" { push(desc_list, Display(DisBlock)); } + "none" { push(desc_list, Display(DisNone)); } + _ { #debug["Recieved unknown display value '%s'", val]; } } } "color" { - desc_list += [TextColor(parse_color(val))]; + push(desc_list, TextColor(parse_color(val))); } "background-color" { - desc_list += [BackgroundColor(parse_color(val))]; + push(desc_list, BackgroundColor(parse_color(val))); } - _ { #debug["Recieved unknown style property '%s'", - val]; } + _ { #debug["Recieved unknown style property '%s'", val]; } } } Eof { ret none; } @@ -180,13 +179,13 @@ fn parse_rule(reader : TokenReader) -> option<~style::Rule> { ret some(~(sel_list, desc_list)); } -fn build_stylesheet(stream : port<Token>) -> [~style::Rule] { - let mut rule_list = []; +fn build_stylesheet(stream : port<Token>) -> ~[~style::Rule] { + let mut rule_list = ~[]; let reader = {stream : stream, mut lookahead : none}; loop { alt parse_rule(reader) { - some(rule) { rule_list += [copy rule]; } + some(rule) { push(rule_list, copy rule); } none { break; } } } diff --git a/src/servo/parser/css_lexer.rs b/src/servo/parser/css_lexer.rs index 00516f4142c..04cb1dcd56f 100644 --- a/src/servo/parser/css_lexer.rs +++ b/src/servo/parser/css_lexer.rs @@ -2,6 +2,7 @@ import comm::{port, chan}; import dom::style; import option::is_none; import str::from_bytes; +import vec::push; import lexer_util::*; @@ -155,7 +156,7 @@ impl css_methods for CssLexer { } } - let mut desc_name = []; + let mut desc_name = ~[]; // Get the name of the descriptor loop { @@ -168,7 +169,7 @@ impl css_methods for CssLexer { break; } } else { - desc_name += [ch]; + push(desc_name, ch); } alt self.input_state.get() { @@ -178,7 +179,7 @@ impl css_methods for CssLexer { } self.input_state.eat_whitespace(); - let mut desc_val = []; + let mut desc_val = ~[]; // Get the value of the descriptor loop { @@ -203,7 +204,7 @@ impl css_methods for CssLexer { break; } } else { - desc_val += [ch]; + push(desc_val, ch); } } diff --git a/src/servo/parser/html_builder.rs b/src/servo/parser/html_builder.rs index 669c3cdb6bd..79f006e53fa 100644 --- a/src/servo/parser/html_builder.rs +++ b/src/servo/parser/html_builder.rs @@ -10,7 +10,7 @@ import gfx::geometry::au; import parser = parser::html_lexer; import parser::Token; import dom::style::Stylesheet; - +import vec::{push, push_all_move, flat_map}; import dvec::extensions; enum css_message { @@ -86,7 +86,7 @@ spawned, collates them, and sends them to the given result channel. "] fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_message>) { - let mut result_vec = []; + let mut result_vec = ~[]; loop { alt from_parent.recv() { @@ -101,7 +101,7 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag let mut css_rules = css_builder::build_stylesheet(css_stream); result_chan.send(css_rules); }); - result_vec += [result_port]; + push(result_vec, result_port); } exit { break; @@ -109,13 +109,8 @@ fn css_link_listener(to_parent : chan<Stylesheet>, from_parent : port<css_messag } } - let css_rules = []; + let css_rules = flat_map(result_vec, |result_port| { result_port.recv() }); - let css_rules = result_vec.foldl(css_rules, |rules, result_port| { - let new_rules = result_port.recv(); - rules + new_rules - }); - to_parent.send(css_rules); } diff --git a/src/servo/parser/html_lexer.rs b/src/servo/parser/html_lexer.rs index ae521b5e0cb..6e7ebb7d744 100644 --- a/src/servo/parser/html_lexer.rs +++ b/src/servo/parser/html_lexer.rs @@ -2,6 +2,7 @@ import comm::{port, chan}; import dom::style; import option::is_none; import str::from_bytes; +import vec::push; import lexer_util::*; enum Token { @@ -76,7 +77,7 @@ impl html_methods for HtmlLexer { } // Make a text node. - let mut s: [u8] = [ch]; + let mut s: ~[u8] = ~[ch]; loop { alt self.input_state.get() { CoeChar(c) { @@ -84,7 +85,7 @@ impl html_methods for HtmlLexer { self.input_state.unget(c); ret Text(from_bytes(s)); } - s += [c]; + push(s, c); } CoeEof { ret Text(from_bytes(s)); } } @@ -120,12 +121,12 @@ impl html_methods for HtmlLexer { } // Parse an attribute. - let mut attribute_name = [ch]; + let mut attribute_name = ~[ch]; loop { alt self.input_state.get() { CoeChar(c) { if c == ('=' as u8) { break; } - attribute_name += [c]; + push(attribute_name, c); } CoeEof { let name = from_bytes(attribute_name); @@ -136,12 +137,12 @@ impl html_methods for HtmlLexer { // Parse the attribute value. self.input_state.expect('"' as u8); - let mut attribute_value = []; + let mut attribute_value = ~[]; loop { alt self.input_state.get() { CoeChar(c) { if c == ('"' as u8) { break; } - attribute_value += [c]; + push(attribute_value, c); } CoeEof { ret Attr(from_bytes(attribute_name), from_bytes(attribute_value)); diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs index f925c82e858..6cd395f82a8 100644 --- a/src/servo/parser/lexer_util.rs +++ b/src/servo/parser/lexer_util.rs @@ -1,6 +1,6 @@ import option::is_none; import str::from_bytes; - +import vec::push; enum CharOrEof { CoeChar(u8), @@ -63,12 +63,12 @@ impl util_methods for InputState { } fn parse_ident() -> str { - let mut result: [u8] = []; + let mut result: ~[u8] = ~[]; loop { alt self.get() { CoeChar(c) { if (c.is_alpha()) { - result += [c]; + push(result, c); } else if result.len() == 0u { self.parse_err("expected ident"); } else { diff --git a/src/servo/platform/osmain.rs b/src/servo/platform/osmain.rs index c6607f6506a..cea40517414 100644 --- a/src/servo/platform/osmain.rs +++ b/src/servo/platform/osmain.rs @@ -13,6 +13,7 @@ import dom::event::{Event, ResizeEvent}; import layers::ImageLayer; import geom::size::Size2D; import std::cmp::fuzzy_eq; +import vec::push; type OSMain = chan<Msg>; @@ -200,6 +201,7 @@ type surface = { fn mk_surface() -> surface { let cairo_surf = cairo_image_surface_create(cairo::CAIRO_FORMAT_RGB24, 800, 600); + assert !ptr::is_null(cairo_surf); let azure_target = AzCreateDrawTargetForCairoSurface(cairo_surf); diff --git a/src/servo/servo.rc b/src/servo/servo.rc index e2be7c2b17d..835c87acd21 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -7,8 +7,6 @@ #[license = "MPL"]; #[crate_type = "lib"]; -#[warn(no_old_vecs)]; - use std; use sdl; use azure; @@ -96,6 +94,7 @@ mod util { mod unsafe; } +#[warn(no_non_implicitly_copyable_typarams)] mod content { } diff --git a/src/servo/servo.rs b/src/servo/servo.rs index fce2e92251d..a90da258c2d 100644 --- a/src/servo/servo.rs +++ b/src/servo/servo.rs @@ -5,7 +5,7 @@ import osmain::{OSMain, AddKeyHandler}; import opts::{Opts, Screen, Png}; import engine::{Engine, LoadURLMsg}; -fn main(args: [str]) { +fn main(args: ~[str]) { run(opts::from_cmdline_args(args)) } @@ -25,7 +25,7 @@ fn run(opts: Opts) { } } -fn run_pipeline_screen(urls: [str]) { +fn run_pipeline_screen(urls: ~[str]) { // The platform event handler thread let osmain = OSMain(); diff --git a/src/servo/text/font.rs b/src/servo/text/font.rs index 542c57e496e..fb26ec48635 100644 --- a/src/servo/text/font.rs +++ b/src/servo/text/font.rs @@ -32,7 +32,7 @@ class Font { let cairo_font: *cairo_scaled_font_t; let font_dtor: fn@(); - new(-fontbuf: [u8]) { + new(-fontbuf: ~[u8]) { let (cairo_font, font_dtor) = get_cairo_font(© fontbuf); assert cairo_font.is_not_null(); @@ -81,7 +81,7 @@ class Font { #debug("getting h advance for glyph %?", glyph); - let glyphs: [cairo_glyph_t] = [{ + let glyphs: ~[cairo_glyph_t] = ~[{ index: glyph as c_ulong, x: 0 as c_double, y: 0 as c_double, @@ -264,7 +264,7 @@ fn create_test_font() -> @Font { ret flib.get_test_font(); } -fn test_font_bin() -> [u8] { #include_bin("JosefinSans-SemiBold.ttf") } +fn test_font_bin() -> ~[u8] { #include_bin("JosefinSans-SemiBold.ttf") } fn should_destruct_on_fail_without_leaking() { #[test]; diff --git a/src/servo/text/native_font/quartz_native_font.rs b/src/servo/text/native_font/quartz_native_font.rs index ec3bb335209..4f80e413151 100644 --- a/src/servo/text/native_font/quartz_native_font.rs +++ b/src/servo/text/native_font/quartz_native_font.rs @@ -48,7 +48,7 @@ class QuartzNativeFont/& { } } -fn create(buf: [u8]) -> result<QuartzNativeFont, ()> { +fn create(buf: ~[u8]) -> result<QuartzNativeFont, ()> { let fontprov = vec::as_buf(buf, |cbuf| { CGDataProviderCreateWithData( null(), diff --git a/src/servo/text/shaper.rs b/src/servo/text/shaper.rs index c602171a413..c0b62fc5b8e 100644 --- a/src/servo/text/shaper.rs +++ b/src/servo/text/shaper.rs @@ -35,7 +35,7 @@ import harfbuzz::bindgen::{hb_blob_create, hb_blob_destroy, Calculate the layout metrics associated with a some given text when rendered in a specific font. "] -fn shape_text(font: &Font, text: str) -> [Glyph] unsafe { +fn shape_text(font: &Font, text: str) -> ~[Glyph] unsafe { #debug("shaping text '%s'", text); let face_blob = vec::as_buf(*(*font).buf(), |buf| { @@ -79,7 +79,7 @@ fn shape_text(font: &Font, text: str) -> [Glyph] unsafe { assert info_len == pos_len; - let mut glyphs = []; + let mut glyphs = ~[]; for uint::range(0u, info_len as uint) |i| { let info_ = offset(info_, i); @@ -89,7 +89,7 @@ fn shape_text(font: &Font, text: str) -> [Glyph] unsafe { #debug("glyph %?: codep %?, x_adv %?, y_adv %?, x_off %?, y_of %?", i, codepoint, pos.advance.x, pos.advance.y, pos.offset.x, pos.offset.y); - glyphs += [Glyph(codepoint, pos)]; + glyphs += ~[Glyph(codepoint, pos)]; } hb_buffer_destroy(buffer); @@ -148,7 +148,7 @@ fn should_get_glyph_indexes() { let font = font::create_test_font(); let glyphs = shape_text(font, "firecracker"); let idxs = glyphs.map(|glyph| glyph.index); - assert idxs == [32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u]; + assert idxs == ~[32u, 8u, 13u, 14u, 10u, 13u, 201u, 10u, 37u, 14u, 13u]; } fn should_get_glyph_h_advance() { @@ -158,6 +158,6 @@ fn should_get_glyph_h_advance() { let font = font::create_test_font(); let glyphs = shape_text(font, "firecracker"); let actual = glyphs.map(|g| g.pos.advance.x); - let expected = [6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7].map(|a| px_to_au(a)); + let expected = (~[6, 4, 7, 9, 8, 7, 10, 8, 9, 9, 7]).map(|a| px_to_au(a)); assert expected == actual; } diff --git a/src/servo/text/text_run.rs b/src/servo/text/text_run.rs index 81f1bf7bcb5..f170637f3ea 100644 --- a/src/servo/text/text_run.rs +++ b/src/servo/text/text_run.rs @@ -9,7 +9,7 @@ import shaper::shape_text; #[doc="A single, unbroken line of text."] class TextRun { - let glyphs: [Glyph]; + let glyphs: ~[Glyph]; new(font: Font, text: str) { self.glyphs = shape_text(&font, text); diff --git a/src/servo/util/tree.rs b/src/servo/util/tree.rs index 1fce0175620..daefa821673 100644 --- a/src/servo/util/tree.rs +++ b/src/servo/util/tree.rs @@ -99,10 +99,10 @@ mod test { dummy(@{fields: empty(), value: v}) } - fn parent_with_3_children() -> {p: dummy, children: [dummy]} { - let children = [new_dummy(0u), - new_dummy(1u), - new_dummy(2u)]; + fn parent_with_3_children() -> {p: dummy, children: ~[dummy]} { + let children = ~[new_dummy(0u), + new_dummy(1u), + new_dummy(2u)]; let p = new_dummy(3u); for vec::each(children) |c| { |