Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Rust 0.6 syntax. #1

Merged
merged 1 commit into from Mar 29, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -2,7 +2,7 @@ use core::float::round;
use core::libc::types::os::arch::c95::c_double;
use core::cmp::Eq;

#[deriving_eq]
#[deriving(Eq)]
pub struct Color {
red: u8,
green: u8,
@@ -96,7 +96,11 @@ pub mod parsing {
let only_colors = color.substr(4u, color.len() - 5u);

// split up r, g, and b
let cols = only_colors.split_char(',');
let mut cols = ~[];
for str::each_split_char(only_colors, ',') |s| {
cols.push(s);
};

if cols.len() != 3u { return fail_unrecognized(color); }

match (u8::from_str(cols[0]), u8::from_str(cols[1]),
@@ -112,7 +116,11 @@ pub mod parsing {
let only_vals = color.substr(5u, color.len() - 6u);

// split up r, g, and b
let cols = only_vals.split_char(',');
let mut cols = ~[];
for str::each_split_char(only_vals, ',') |s| {
cols.push(s);
};

if cols.len() != 4u { return fail_unrecognized(color); }

match (u8::from_str(cols[0]), u8::from_str(cols[1]),
@@ -128,7 +136,11 @@ pub mod parsing {
let only_vals = color.substr(4u, color.len() - 5u);

// split up h, s, and l
let vals = only_vals.split_char(',');
let mut vals = ~[];
for str::each_split_char(only_vals, ',') |s| {
vals.push(s);
};

if vals.len() != 3u { return fail_unrecognized(color); }

match (float::from_str(vals[0]), float::from_str(vals[1]),
@@ -143,7 +155,11 @@ pub mod parsing {
// Shave off the hsla( and the )
let only_vals = color.substr(5u, color.len() - 6u);

let vals = only_vals.split_char(',');
let mut vals = ~[];
for str::each_split_char(only_vals, ',') |s| {
vals.push(s);
};

if vals.len() != 4u { return fail_unrecognized(color); }

match (float::from_str(vals[0]), float::from_str(vals[1]),
@@ -11,14 +11,14 @@ pub struct CompleteSelectResults {
}

pub impl CompleteSelectResults {
static fn new_root(root: SelectResults) -> CompleteSelectResults {
fn new_root(root: SelectResults) -> CompleteSelectResults {
CompleteSelectResults {
inner: root
}
}

static fn new_from_parent(parent: &CompleteSelectResults,
child: SelectResults) -> CompleteSelectResults {
fn new_from_parent(parent: &CompleteSelectResults,
child: SelectResults) -> CompleteSelectResults {
let mut child = child;

// New lifetime
@@ -63,18 +63,18 @@ pub impl CompleteSelectResults {
}
}

fn computed_style(&self) -> CompleteStyle/&self {
fn computed_style(&self) -> CompleteStyle<'self> {
CompleteStyle {
inner: self.inner.computed_style()
}
}
}

pub struct CompleteStyle {
pub struct CompleteStyle<'self> {
inner: ComputedStyle<'self>
}

impl CompleteStyle<'self> {
impl<'self> CompleteStyle<'self> {

// CSS 2.1, Section 8 - Box model

@@ -5,7 +5,7 @@ use core::either::{Either, Left, Right};
use n;
use values::*;

pub struct ComputedStyle {
pub struct ComputedStyle<'self> {
inner: n::c::CssComputedStyle<'self>
}

14 css.rc
@@ -39,18 +39,18 @@ mod test;

// Shortcuts to the netsurfcss types
pub mod n {
pub mod ll {
pub use p = netsurfcss::ll::properties;
pub use s = netsurfcss::ll::select;
pub use t = netsurfcss::ll::types;
pub use c = netsurfcss::ll::computed;
}

pub use p = netsurfcss::properties;
pub use s = netsurfcss::select;
pub use t = netsurfcss::types;
pub use c = netsurfcss::computed;
pub use v = netsurfcss::values;
pub use h = netsurfcss::hint;
pub use u = netsurfcss::util;

pub mod ll {
pub use p = netsurfcss::ll::properties;
pub use s = netsurfcss::ll::select;
pub use t = netsurfcss::ll::types;
pub use c = netsurfcss::ll::computed;
}
}
@@ -6,7 +6,6 @@ Constructs a list of css style rules from a token stream
// are not as expected

use util::DataStream;
use core::cell::Cell;
use netsurfcss::stylesheet::{CssStylesheet, CssStylesheetParams, CssStylesheetParamsVersion1, css_stylesheet_create};
use netsurfcss::types::CssLevel21;
use netsurfcss::CssResult;
@@ -27,7 +27,7 @@ encapsulates the cascade. Individual node styles can be requested with
the `select_style` method.
*/
pub impl SelectCtx {
static fn new() -> SelectCtx {
fn new() -> SelectCtx {
SelectCtx {
inner: n::s::css_select_ctx_create()
}
@@ -67,9 +67,9 @@ pub struct SelectResults {
inner: n::s::CssSelectResults
}

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

priv impl<N, H: SelectHandler<N>> SelectHandlerWrapper<N, H> {
priv fn inner_ref(&self) -> &self/H {
priv impl<'self, N, H: SelectHandler<N>> SelectHandlerWrapper<N, H> {
priv fn inner_ref(&self) -> &'self H {
unsafe { &*self.inner }
}
}
@@ -12,7 +12,7 @@ pub struct Stylesheet {
}

pub impl Stylesheet {
static fn new(url: Url, input: DataStream) -> Stylesheet {
fn new(url: Url, input: DataStream) -> Stylesheet {
Stylesheet {
inner: parse_stylesheet(url, input)
}
@@ -38,7 +38,7 @@ struct NodeData {
}

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

impl TestHandler {
static fn new() -> TestHandler {
fn new() -> TestHandler {
TestHandler {
bogus: 0
}
@@ -2,36 +2,36 @@
Units used by CSS
*/

#[deriving_eq]
#[deriving(Eq)]
pub enum Length {
Em(float), // normalized to 'em'
Px(float), // normalized to 'px'
Pt(float)
}

impl Length {
pure fn rel(self) -> float {
fn rel(self) -> float {
match self {
Em(x) => x,
_ => fail!(~"attempted to access relative unit of an absolute length")
}
}
pure fn abs(self) -> float {
fn abs(self) -> float {
match self {
Em(x) => x,
_ => fail!(~"attempted to access relative unit of an absolute length")
}
}
}

#[deriving_eq]
#[deriving(Eq)]
pub enum BoxSizing { // used by width, height, top, left, etc
BoxLength(Length),
BoxPercent(float),
BoxAuto
}

#[deriving_eq]
#[deriving(Eq)]
pub enum AbsoluteSize {
XXSmall,
XSmall,
@@ -42,13 +42,13 @@ pub enum AbsoluteSize {
XXLarge
}

#[deriving_eq]
#[deriving(Eq)]
pub enum RelativeSize {
Larger,
Smaller
}

#[deriving_eq]
#[deriving(Eq)]
pub enum GenericFontFamily {
Serif,
SansSerif,
@@ -1,5 +1,3 @@
pub type DataStream = @fn() -> Option<~[u8]>;

pub use netsurfcss::util::VoidPtrLike;


pub type DataStream = @fn() -> Option<~[u8]>;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.