Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit ca1ce19

Browse files
committed
Merge pull request #1 from metajack/rust-0.6-syntax
Update to Rust 0.6 syntax.
2 parents 9f406c7 + bdb150f commit ca1ce19

File tree

11 files changed

+67
-56
lines changed

11 files changed

+67
-56
lines changed

color.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::float::round;
22
use core::libc::types::os::arch::c95::c_double;
33
use core::cmp::Eq;
44

5-
#[deriving_eq]
5+
#[deriving(Eq)]
66
pub struct Color {
77
red: u8,
88
green: u8,
@@ -96,7 +96,11 @@ pub mod parsing {
9696
let only_colors = color.substr(4u, color.len() - 5u);
9797
9898
// split up r, g, and b
99-
let cols = only_colors.split_char(',');
99+
let mut cols = ~[];
100+
for str::each_split_char(only_colors, ',') |s| {
101+
cols.push(s);
102+
};
103+
100104
if cols.len() != 3u { return fail_unrecognized(color); }
101105
102106
match (u8::from_str(cols[0]), u8::from_str(cols[1]),
@@ -112,7 +116,11 @@ pub mod parsing {
112116
let only_vals = color.substr(5u, color.len() - 6u);
113117
114118
// split up r, g, and b
115-
let cols = only_vals.split_char(',');
119+
let mut cols = ~[];
120+
for str::each_split_char(only_vals, ',') |s| {
121+
cols.push(s);
122+
};
123+
116124
if cols.len() != 4u { return fail_unrecognized(color); }
117125
118126
match (u8::from_str(cols[0]), u8::from_str(cols[1]),
@@ -128,7 +136,11 @@ pub mod parsing {
128136
let only_vals = color.substr(4u, color.len() - 5u);
129137
130138
// split up h, s, and l
131-
let vals = only_vals.split_char(',');
139+
let mut vals = ~[];
140+
for str::each_split_char(only_vals, ',') |s| {
141+
vals.push(s);
142+
};
143+
132144
if vals.len() != 3u { return fail_unrecognized(color); }
133145
134146
match (float::from_str(vals[0]), float::from_str(vals[1]),
@@ -143,7 +155,11 @@ pub mod parsing {
143155
// Shave off the hsla( and the )
144156
let only_vals = color.substr(5u, color.len() - 6u);
145157
146-
let vals = only_vals.split_char(',');
158+
let mut vals = ~[];
159+
for str::each_split_char(only_vals, ',') |s| {
160+
vals.push(s);
161+
};
162+
147163
if vals.len() != 4u { return fail_unrecognized(color); }
148164
149165
match (float::from_str(vals[0]), float::from_str(vals[1]),

complete.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ pub struct CompleteSelectResults {
1111
}
1212

1313
pub impl CompleteSelectResults {
14-
static fn new_root(root: SelectResults) -> CompleteSelectResults {
14+
fn new_root(root: SelectResults) -> CompleteSelectResults {
1515
CompleteSelectResults {
1616
inner: root
1717
}
1818
}
1919

20-
static fn new_from_parent(parent: &CompleteSelectResults,
21-
child: SelectResults) -> CompleteSelectResults {
20+
fn new_from_parent(parent: &CompleteSelectResults,
21+
child: SelectResults) -> CompleteSelectResults {
2222
let mut child = child;
2323

2424
// New lifetime
@@ -63,18 +63,18 @@ pub impl CompleteSelectResults {
6363
}
6464
}
6565

66-
fn computed_style(&self) -> CompleteStyle/&self {
66+
fn computed_style(&self) -> CompleteStyle<'self> {
6767
CompleteStyle {
6868
inner: self.inner.computed_style()
6969
}
7070
}
7171
}
7272

73-
pub struct CompleteStyle {
73+
pub struct CompleteStyle<'self> {
7474
inner: ComputedStyle<'self>
7575
}
7676

77-
impl CompleteStyle<'self> {
77+
impl<'self> CompleteStyle<'self> {
7878

7979
// CSS 2.1, Section 8 - Box model
8080

computed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::either::{Either, Left, Right};
55
use n;
66
use values::*;
77

8-
pub struct ComputedStyle {
8+
pub struct ComputedStyle<'self> {
99
inner: n::c::CssComputedStyle<'self>
1010
}
1111

css.rc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ mod test;
3939

4040
// Shortcuts to the netsurfcss types
4141
pub mod n {
42-
pub mod ll {
43-
pub use p = netsurfcss::ll::properties;
44-
pub use s = netsurfcss::ll::select;
45-
pub use t = netsurfcss::ll::types;
46-
pub use c = netsurfcss::ll::computed;
47-
}
48-
4942
pub use p = netsurfcss::properties;
5043
pub use s = netsurfcss::select;
5144
pub use t = netsurfcss::types;
5245
pub use c = netsurfcss::computed;
5346
pub use v = netsurfcss::values;
5447
pub use h = netsurfcss::hint;
5548
pub use u = netsurfcss::util;
49+
50+
pub mod ll {
51+
pub use p = netsurfcss::ll::properties;
52+
pub use s = netsurfcss::ll::select;
53+
pub use t = netsurfcss::ll::types;
54+
pub use c = netsurfcss::ll::computed;
55+
}
5656
}

parser.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Constructs a list of css style rules from a token stream
66
// are not as expected
77

88
use util::DataStream;
9-
use core::cell::Cell;
109
use netsurfcss::stylesheet::{CssStylesheet, CssStylesheetParams, CssStylesheetParamsVersion1, css_stylesheet_create};
1110
use netsurfcss::types::CssLevel21;
1211
use netsurfcss::CssResult;

select.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ encapsulates the cascade. Individual node styles can be requested with
2727
the `select_style` method.
2828
*/
2929
pub impl SelectCtx {
30-
static fn new() -> SelectCtx {
30+
fn new() -> SelectCtx {
3131
SelectCtx {
3232
inner: n::s::css_select_ctx_create()
3333
}
@@ -67,9 +67,9 @@ pub struct SelectResults {
6767
inner: n::s::CssSelectResults
6868
}
6969

70-
pub impl SelectResults {
70+
pub impl<'self> SelectResults {
7171
/** Retrieve the computed style of a single pseudo-element */
72-
fn computed_style(&self) -> ComputedStyle/&self {
72+
fn computed_style(&self) -> ComputedStyle<'self> {
7373
ComputedStyle {
7474
inner: self.inner.computed_style(n::s::CssPseudoElementNone)
7575
}
@@ -95,8 +95,8 @@ struct SelectHandlerWrapper<N, H> {
9595
inner: *H
9696
}
9797

98-
priv impl<N, H: SelectHandler<N>> SelectHandlerWrapper<N, H> {
99-
priv fn inner_ref(&self) -> &self/H {
98+
priv impl<'self, N, H: SelectHandler<N>> SelectHandlerWrapper<N, H> {
99+
priv fn inner_ref(&self) -> &'self H {
100100
unsafe { &*self.inner }
101101
}
102102
}

stylesheet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Stylesheet {
1212
}
1313

1414
pub impl Stylesheet {
15-
static fn new(url: Url, input: DataStream) -> Stylesheet {
15+
fn new(url: Url, input: DataStream) -> Stylesheet {
1616
Stylesheet {
1717
inner: parse_stylesheet(url, input)
1818
}

test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct NodeData {
3838
}
3939

4040
impl VoidPtrLike for TestNode {
41-
static fn from_void_ptr(node: *libc::c_void) -> TestNode {
41+
fn from_void_ptr(node: *libc::c_void) -> TestNode {
4242
fail_unless!(node.is_not_null());
4343
TestNode(unsafe {
4444
let box = cast::reinterpret_cast(&node);
@@ -57,7 +57,7 @@ struct TestHandler {
5757
}
5858

5959
impl TestHandler {
60-
static fn new() -> TestHandler {
60+
fn new() -> TestHandler {
6161
TestHandler {
6262
bogus: 0
6363
}

units.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
Units used by CSS
33
*/
44

5-
#[deriving_eq]
5+
#[deriving(Eq)]
66
pub enum Length {
77
Em(float), // normalized to 'em'
88
Px(float), // normalized to 'px'
99
Pt(float)
1010
}
1111

1212
impl Length {
13-
pure fn rel(self) -> float {
13+
fn rel(self) -> float {
1414
match self {
1515
Em(x) => x,
1616
_ => fail!(~"attempted to access relative unit of an absolute length")
1717
}
1818
}
19-
pure fn abs(self) -> float {
19+
fn abs(self) -> float {
2020
match self {
2121
Em(x) => x,
2222
_ => fail!(~"attempted to access relative unit of an absolute length")
2323
}
2424
}
2525
}
2626

27-
#[deriving_eq]
27+
#[deriving(Eq)]
2828
pub enum BoxSizing { // used by width, height, top, left, etc
2929
BoxLength(Length),
3030
BoxPercent(float),
3131
BoxAuto
3232
}
3333

34-
#[deriving_eq]
34+
#[deriving(Eq)]
3535
pub enum AbsoluteSize {
3636
XXSmall,
3737
XSmall,
@@ -42,13 +42,13 @@ pub enum AbsoluteSize {
4242
XXLarge
4343
}
4444

45-
#[deriving_eq]
45+
#[deriving(Eq)]
4646
pub enum RelativeSize {
4747
Larger,
4848
Smaller
4949
}
5050

51-
#[deriving_eq]
51+
#[deriving(Eq)]
5252
pub enum GenericFontFamily {
5353
Serif,
5454
SansSerif,

util.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
pub type DataStream = @fn() -> Option<~[u8]>;
2-
31
pub use netsurfcss::util::VoidPtrLike;
42

5-
3+
pub type DataStream = @fn() -> Option<~[u8]>;

0 commit comments

Comments
 (0)