From 1b45723463b1a70aa1168bfcf1594c34a52159b8 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Mon, 5 Aug 2013 16:49:49 -0700 Subject: [PATCH] Update to latest Rust --- conversions.rs | 7 ++-- ll.rs | 108 ++++++++++++++++++++++++------------------------- netsurfcss.rc | 2 +- test.rs | 2 +- 4 files changed, 59 insertions(+), 60 deletions(-) diff --git a/conversions.rs b/conversions.rs index 8822aa2..9fe006c 100644 --- a/conversions.rs +++ b/conversions.rs @@ -28,7 +28,6 @@ use stylesheet::{CssStylesheetParams}; use ll::select::{css_pseudo_element}; use select::{CssPseudoElement}; use std::sys; -use std::str; pub trait ToLl { fn to_ll(&self) -> T; @@ -170,9 +169,9 @@ pub fn c_enum_to_rust_enum(val: c_enum) -> T { impl AsLl for CssStylesheetParams { pub fn as_ll(&self, f: &fn(&css_stylesheet_params) -> U) -> U { - do str::as_c_str(self.charset) |charset| { - do str::as_c_str(self.url) |url| { - do str::as_c_str(self.title) |title| { + do self.charset.as_c_str |charset| { + do self.url.as_c_str |url| { + do self.title.as_c_str |title| { let params = css_stylesheet_params { params_version: self.params_version as uint32_t, level: self.level.to_ll(), diff --git a/ll.rs b/ll.rs index 2094f53..bcc7981 100644 --- a/ll.rs +++ b/ll.rs @@ -474,15 +474,15 @@ pub mod stylesheet { pub type css_fixed = int32_t; - pub extern { - fn css_stylesheet_create(params: *css_stylesheet_params, - alloc: css_allocator_fn, - alloc_pw: *c_void, - stylesheet: *mut *css_stylesheet) -> css_error; - fn css_stylesheet_destroy(sheet: *css_stylesheet) -> css_error; - fn css_stylesheet_size(sheet: *css_stylesheet, size: *mut size_t) -> css_error; - fn css_stylesheet_append_data(sheet: *css_stylesheet, data: *uint8_t, len: size_t) -> css_error; - fn css_stylesheet_data_done(sheet: *css_stylesheet) -> css_error; + extern { + pub fn css_stylesheet_create(params: *css_stylesheet_params, + alloc: css_allocator_fn, + alloc_pw: *c_void, + stylesheet: *mut *css_stylesheet) -> css_error; + pub fn css_stylesheet_destroy(sheet: *css_stylesheet) -> css_error; + pub fn css_stylesheet_size(sheet: *css_stylesheet, size: *mut size_t) -> css_error; + pub fn css_stylesheet_append_data(sheet: *css_stylesheet, data: *uint8_t, len: size_t) -> css_error; + pub fn css_stylesheet_data_done(sheet: *css_stylesheet) -> css_error; } } @@ -556,13 +556,13 @@ pub mod select { compute_font_size: opaque_callback } - pub extern { - fn css_select_ctx_create(alloc: css_allocator_fn, pw: *c_void, result: *mut *css_select_ctx) -> css_error; - fn css_select_ctx_destroy(ctx: *css_select_ctx) -> css_error; - fn css_select_ctx_append_sheet(ctx: *css_select_ctx, sheet: *css_stylesheet, origin: css_origin, media: uint64_t) -> css_error; - fn css_select_ctx_count_sheets(ctx: *css_select_ctx, count: *mut uint32_t) -> css_error; - fn css_select_style(ctx: *css_select_ctx, node: *c_void, media: uint64_t, inline_style: *css_stylesheet, handler: *css_select_handler, pw: *c_void, result: *mut *css_select_results) -> css_error; - fn css_select_results_destroy(results: *css_select_results) -> css_error; + extern { + pub fn css_select_ctx_create(alloc: css_allocator_fn, pw: *c_void, result: *mut *css_select_ctx) -> css_error; + pub fn css_select_ctx_destroy(ctx: *css_select_ctx) -> css_error; + pub fn css_select_ctx_append_sheet(ctx: *css_select_ctx, sheet: *css_stylesheet, origin: css_origin, media: uint64_t) -> css_error; + pub fn css_select_ctx_count_sheets(ctx: *css_select_ctx, count: *mut uint32_t) -> css_error; + pub fn css_select_style(ctx: *css_select_ctx, node: *c_void, media: uint64_t, inline_style: *css_stylesheet, handler: *css_select_handler, pw: *c_void, result: *mut *css_select_results) -> css_error; + pub fn css_select_results_destroy(results: *css_select_results) -> css_error; } } @@ -579,43 +579,43 @@ pub mod computed { pub type compute_font_size_cb = *u8; // (pw: *c_void, parent: *css_hint, size: *mut css_hint) -> css_error - pub extern { - fn css_computed_style_compose(parent: *css_computed_style, - child: *css_computed_style, - compute_font_size: compute_font_size_cb, - pw: *c_void, - result: *mut css_computed_style) -> css_error; - - fn css_computed_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_background_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_border_top_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_border_right_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_border_bottom_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_border_left_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_border_top_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_border_right_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_border_bottom_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_border_left_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; - fn css_computed_margin_top(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_margin_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_margin_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_margin_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_padding_top(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_padding_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_padding_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_padding_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_display(style: *css_computed_style, root: bool) -> uint8_t; - fn css_computed_float(style: *css_computed_style) -> uint8_t; - fn css_computed_clear(style: *css_computed_style) -> uint8_t; - fn css_computed_position(style: *css_computed_style) -> uint8_t; - fn css_computed_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_font_family(style: *css_computed_style, names: *mut **lwc_string) -> uint8_t; - fn css_computed_font_size(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; - fn css_computed_font_style(style: *css_computed_style) -> uint8_t; - fn css_computed_font_weight(style: *css_computed_style) -> uint8_t; - fn css_computed_text_align(style: *css_computed_style) -> uint8_t; - fn css_computed_text_decoration(style: *css_computed_style) -> uint8_t; - fn css_computed_line_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + extern { + pub fn css_computed_style_compose(parent: *css_computed_style, + child: *css_computed_style, + compute_font_size: compute_font_size_cb, + pw: *c_void, + result: *mut css_computed_style) -> css_error; + + pub fn css_computed_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_background_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_border_top_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_border_right_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_border_bottom_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_border_left_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_border_top_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_border_right_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_border_bottom_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_border_left_color(style: *css_computed_style, color: *mut css_color) -> uint8_t; + pub fn css_computed_margin_top(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_margin_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_margin_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_margin_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_padding_top(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_padding_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_padding_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_padding_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_display(style: *css_computed_style, root: bool) -> uint8_t; + pub fn css_computed_float(style: *css_computed_style) -> uint8_t; + pub fn css_computed_clear(style: *css_computed_style) -> uint8_t; + pub fn css_computed_position(style: *css_computed_style) -> uint8_t; + pub fn css_computed_width(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_font_family(style: *css_computed_style, names: *mut **lwc_string) -> uint8_t; + pub fn css_computed_font_size(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_font_style(style: *css_computed_style) -> uint8_t; + pub fn css_computed_font_weight(style: *css_computed_style) -> uint8_t; + pub fn css_computed_text_align(style: *css_computed_style) -> uint8_t; + pub fn css_computed_text_decoration(style: *css_computed_style) -> uint8_t; + pub fn css_computed_line_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; } } diff --git a/netsurfcss.rc b/netsurfcss.rc index 6dbd502..e8400c4 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -564,7 +564,7 @@ pub mod hint { #[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86")] #[cfg(target_arch = "arm")] - fn status_field_offset() -> uint { 16 } + fn status_field_offset() -> int { 16 } priv fn hint_data_field(llhint: *mut css_hint) -> &mut T { unsafe { transmute(llhint) } diff --git a/test.rs b/test.rs index 75387c0..54d3d13 100644 --- a/test.rs +++ b/test.rs @@ -86,7 +86,7 @@ mod example1 { debug!("count sheets: %?", select_ctx.count_sheets()); assert!(select_ctx.count_sheets() == 1); - for ::std::uint::range(1, 7) |hh| { + for hh in range(1, 7) { let element = fmt!("h%u", hh); let element_name: @LwcString = @from_rust_string(element); let node = MyDomNode { name: element_name };