Skip to content

Commit 2e7d52e

Browse files
committed
Merge pull request #45 from mozilla-servo/rustup_20140410
Update to current rust
2 parents 5ecc433 + 7aef3d8 commit 2e7d52e

File tree

6 files changed

+50
-48
lines changed

6 files changed

+50
-48
lines changed

ast.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use std::slice;
88

99
#[deriving(Eq)]
1010
pub struct NumericValue {
11-
representation: ~str,
12-
value: f64,
13-
int_value: Option<i64>,
11+
pub representation: ~str,
12+
pub value: f64,
13+
pub int_value: Option<i64>,
1414
}
1515

1616

1717
#[deriving(Eq)]
1818
pub struct SourceLocation {
19-
line: uint, // First line is 1
20-
column: uint, // First character of a line is at column 1
19+
pub line: uint, // First line is 1
20+
pub column: uint, // First character of a line is at column 1
2121
}
2222

2323

@@ -70,25 +70,25 @@ pub enum ComponentValue {
7070

7171
#[deriving(Eq)]
7272
pub struct Declaration {
73-
location: SourceLocation,
74-
name: ~str,
75-
value: ~[ComponentValue],
76-
important: bool,
73+
pub location: SourceLocation,
74+
pub name: ~str,
75+
pub value: ~[ComponentValue],
76+
pub important: bool,
7777
}
7878

7979
#[deriving(Eq)]
8080
pub struct QualifiedRule {
81-
location: SourceLocation,
82-
prelude: ~[ComponentValue],
83-
block: ~[Node],
81+
pub location: SourceLocation,
82+
pub prelude: ~[ComponentValue],
83+
pub block: ~[Node],
8484
}
8585

8686
#[deriving(Eq)]
8787
pub struct AtRule {
88-
location: SourceLocation,
89-
name: ~str,
90-
prelude: ~[ComponentValue],
91-
block: Option<~[Node]>,
88+
pub location: SourceLocation,
89+
pub name: ~str,
90+
pub prelude: ~[ComponentValue],
91+
pub block: Option<~[Node]>,
9292
}
9393

9494
#[deriving(Eq)]
@@ -106,8 +106,8 @@ pub enum Rule {
106106

107107
#[deriving(Eq)]
108108
pub struct SyntaxError {
109-
location: SourceLocation,
110-
reason: ErrorReason,
109+
pub location: SourceLocation,
110+
pub reason: ErrorReason,
111111
}
112112

113113
#[deriving(Eq)]
@@ -139,7 +139,7 @@ impl<'a> SkipWhitespaceIterable<'a> for &'a [ComponentValue] {
139139

140140
#[deriving(Clone)]
141141
pub struct SkipWhitespaceIterator<'a> {
142-
iter_with_whitespace: slice::Items<'a, ComponentValue>,
142+
pub iter_with_whitespace: slice::Items<'a, ComponentValue>,
143143
}
144144

145145
impl<'a> Iterator<&'a ComponentValue> for SkipWhitespaceIterator<'a> {

color.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use ast::*;
1111
pub struct RGBA {
1212
// All in 0..1
1313
// Use f32 to try and match rust-azure’s AzFloat
14-
red: f32,
15-
green: f32,
16-
blue: f32,
17-
alpha: f32,
14+
pub red: f32,
15+
pub green: f32,
16+
pub blue: f32,
17+
pub alpha: f32,
1818
}
1919

2020
#[deriving(Clone, Eq)]

from_bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
5050
Some(label_length)
5151
=> if css.slice_from(10 + label_length).starts_with("\";".as_bytes()) {
5252
let label = css.slice(10, 10 + label_length);
53-
let label = str::from_chars(label.iter().map(|&b| b as char).to_owned_vec());
53+
let label = str::from_chars(label.iter().map(|&b| b as char).collect::<~[char]>());
5454
match encoding_from_whatwg_label(label) {
5555
None => (),
5656
Some(fallback) => match fallback.name() {

lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
#[crate_id = "github.com/mozilla-servo/rust-cssparser#cssparser:0.1"];
6-
#[feature(globs, macro_rules)];
7-
#[crate_type = "lib"];
8-
#[crate_type = "dylib"];
9-
#[crate_type = "rlib"];
5+
#![crate_id = "github.com/mozilla-servo/rust-cssparser#cssparser:0.1"]
6+
#![crate_type = "lib"]
7+
#![crate_type = "dylib"]
8+
#![crate_type = "rlib"]
9+
10+
#![feature(globs, macro_rules)]
1011

1112
extern crate encoding; // https://github.com/lifthrasiir/rust-encoding
1213

tests.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn run_json_tests<T: ToJson>(json_data: &str, parse: |input: ~str| -> T) {
9292
#[test]
9393
fn component_value_list() {
9494
run_json_tests(include_str!("css-parsing-tests/component_value_list.json"), |input| {
95-
tokenize(input).map(|(c, _)| c).to_owned_vec()
95+
tokenize(input).map(|(c, _)| c).collect::<~[ComponentValue]>()
9696
});
9797
}
9898
@@ -108,7 +108,7 @@ fn one_component_value() {
108108
#[test]
109109
fn declaration_list() {
110110
run_json_tests(include_str!("css-parsing-tests/declaration_list.json"), |input| {
111-
parse_declaration_list(tokenize(input)).to_owned_vec()
111+
parse_declaration_list(tokenize(input)).collect::<~[Result<DeclarationListItem, SyntaxError>]>()
112112
});
113113
}
114114
@@ -124,15 +124,15 @@ fn one_declaration() {
124124
#[test]
125125
fn rule_list() {
126126
run_json_tests(include_str!("css-parsing-tests/rule_list.json"), |input| {
127-
parse_rule_list(tokenize(input)).to_owned_vec()
127+
parse_rule_list(tokenize(input)).collect::<~[Result<Rule, SyntaxError>]>()
128128
});
129129
}
130130
131131
132132
#[test]
133133
fn stylesheet() {
134134
run_json_tests(include_str!("css-parsing-tests/stylesheet.json"), |input| {
135-
parse_stylesheet_rules(tokenize(input)).to_owned_vec()
135+
parse_stylesheet_rules(tokenize(input)).collect::<~[Result<Rule, SyntaxError>]>()
136136
});
137137
}
138138
@@ -158,15 +158,15 @@ fn stylesheet_from_bytes() {
158158
let css = get_string(map, &~"css_bytes").unwrap().chars().map(|c| {
159159
assert!(c as u32 <= 0xFF);
160160
c as u8
161-
}).to_owned_vec();
161+
}).collect::<~[u8]>();
162162
let protocol_encoding_label = get_string(map, &~"protocol_encoding");
163163
let environment_encoding = get_string(map, &~"environment_encoding")
164164
.and_then(encoding_from_whatwg_label);
165165
166166
let (mut rules, used_encoding) = parse_stylesheet_rules_from_bytes(
167167
css, protocol_encoding_label, environment_encoding);
168168
169-
(rules.to_owned_vec(), used_encoding.name().to_owned()).to_json()
169+
(rules.collect::<~[Result<Rule, SyntaxError>]>(), used_encoding.name().to_owned()).to_json()
170170
};
171171
assert_json_eq(result, expected, json::Object(map).to_str());
172172
});
@@ -242,17 +242,17 @@ fn bench_color_lookup_fail(b: &mut test::BenchHarness) {
242242
#[test]
243243
fn nth() {
244244
run_json_tests(include_str!("css-parsing-tests/An+B.json"), |input| {
245-
parse_nth(tokenize(input).map(|(c, _)| c).to_owned_vec())
245+
parse_nth(tokenize(input).map(|(c, _)| c).collect::<~[ComponentValue]>())
246246
});
247247
}
248248
249249
250250
#[test]
251251
fn serializer() {
252252
run_json_tests(include_str!("css-parsing-tests/component_value_list.json"), |input| {
253-
let component_values = tokenize(input).map(|(c, _)| c).to_owned_vec();
253+
let component_values = tokenize(input).map(|(c, _)| c).collect::<~[ComponentValue]>();
254254
let serialized = component_values.iter().to_css();
255-
tokenize(serialized).map(|(c, _)| c).to_owned_vec()
255+
tokenize(serialized).map(|(c, _)| c).collect::<~[ComponentValue]>()
256256
});
257257
}
258258
@@ -339,11 +339,11 @@ impl ToJson for DeclarationListItem {
339339
340340
341341
fn list_to_json(list: &~[(ComponentValue, SourceLocation)]) -> ~[json::Json] {
342-
list.map(|tuple| {
342+
list.iter().map(|tuple| {
343343
match *tuple {
344344
(ref c, _) => c.to_json()
345345
}
346-
})
346+
}).collect()
347347
}
348348
349349
@@ -426,11 +426,12 @@ impl ToJson for ComponentValue {
426426
CDC => JString(~"-->"),
427427
428428
Function(ref name, ref arguments)
429-
=> JList(~[JString(~"function"), name.to_json()] + arguments.map(|a| a.to_json())),
429+
=> JList(~[JString(~"function"), name.to_json()] +
430+
arguments.iter().map(|a| a.to_json()).collect::<~[json::Json]>()),
430431
ParenthesisBlock(ref content)
431-
=> JList(~[JString(~"()")] + content.map(|c| c.to_json())),
432+
=> JList(~[JString(~"()")] + content.iter().map(|c| c.to_json()).collect::<~[json::Json]>()),
432433
SquareBracketBlock(ref content)
433-
=> JList(~[JString(~"[]")] + content.map(|c| c.to_json())),
434+
=> JList(~[JString(~"[]")] + content.iter().map(|c| c.to_json()).collect::<~[json::Json]>()),
434435
CurlyBracketBlock(ref content)
435436
=> JList(~[JString(~"{}")] + list_to_json(content)),
436437

tokenizer.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ fn test_preprocess() {
4747

4848

4949
pub struct Tokenizer {
50-
priv input: ~str,
51-
priv length: uint, // All counted in bytes, not characters
52-
priv position: uint, // All counted in bytes, not characters
53-
priv line: uint,
54-
priv last_line_start: uint, // All counted in bytes, not characters
50+
input: ~str,
51+
length: uint, // All counted in bytes, not characters
52+
position: uint, // All counted in bytes, not characters
53+
line: uint,
54+
last_line_start: uint, // All counted in bytes, not characters
5555
}
5656

5757

0 commit comments

Comments
 (0)