Update to latest Rust.

This commit is contained in:
Jack Moffitt 2013-10-14 23:11:35 -06:00
parent 8b47221ff8
commit 94202661c0
100 changed files with 439 additions and 379 deletions

View file

@ -16,7 +16,7 @@ use std::cast;
use std::libc;
use std::ptr;
use std::str;
use std::sys::size_of;
use std::mem::size_of;
type c_bool = libc::c_int;

View file

@ -39,7 +39,7 @@ use js;
static TOSTRING_CLASS_RESERVED_SLOT: libc::size_t = 0;
static TOSTRING_NAME_RESERVED_SLOT: libc::size_t = 1;
struct GlobalStaticData {
pub struct GlobalStaticData {
proxy_handlers: HashMap<uint, *libc::c_void>,
attribute_ids: HashMap<uint, ~[jsid]>,
method_ids: HashMap<uint, ~[jsid]>,
@ -165,7 +165,7 @@ pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<T, ()> {
unsafe {
do get_dom_class(obj).chain |dom_class| {
do get_dom_class(obj).and_then |dom_class| {
if dom_class.interface_chain[proto_depth] == proto_id {
debug!("good prototype");
Ok(unwrap(obj))
@ -671,7 +671,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
for &elem in attrs.iter() {
let (attr, attr_id) = elem;
if attr_id == JSID_VOID || attr_id != id {
loop;
continue;
}
(*desc).attrs = (attr.flags & !(JSPROP_NATIVE_ACCESSORS as u8)) as u32;
@ -783,7 +783,7 @@ pub fn FindEnumStringIndex(cx: *JSContext,
}
for (i, value) in values.iter().enumerate() {
if value.length != length as uint {
loop;
continue;
}
let mut equal = true;
for j in range(0, length as int) {

View file

@ -254,7 +254,10 @@ impl Document {
let key: &~str = &null_str_as_empty(id);
// TODO: "in tree order, within the context object's tree"
// http://dom.spec.whatwg.org/#dom-document-getelementbyid.
self.idmap.find_equiv(key).map(|node| **node)
match self.idmap.find_equiv(key) {
None => None,
Some(node) => Some(*node),
}
}
pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
@ -321,7 +324,7 @@ impl Document {
Some(root) => {
for node in root.traverse_preorder() {
if node.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
loop;
continue;
}
for child in node.children() {
if child.is_text() {
@ -355,12 +358,12 @@ impl Document {
Some(root) => {
for node in root.traverse_preorder() {
if node.type_id() != ElementNodeTypeId(HTMLHeadElementTypeId) {
loop;
continue;
}
let mut has_title = false;
for child in node.children() {
if child.type_id() != ElementNodeTypeId(HTMLTitleElementTypeId) {
loop;
continue;
}
has_title = true;
for title_child in child.children() {
@ -526,7 +529,7 @@ fn foreach_ided_elements(root: &AbstractNode<ScriptView>,
callback: &fn(&~str, &AbstractNode<ScriptView>)) {
for node in root.traverse_preorder() {
if !node.is_element() {
loop;
continue;
}
do node.with_imm_element |element| {

View file

@ -133,7 +133,7 @@ impl ElementLike for Element {
fn get_attr<'a>(&'a self, name: &str) -> Option<&'a str> {
// FIXME: only case-insensitive in the HTML namespace (as opposed to SVG, etc.)
let name = name.to_ascii_lower();
let value: Option<&str> = self.attrs.find_equiv(&name).map(|&value| {
let value: Option<&str> = self.attrs.find_equiv(&name).map(|value| {
let value: &str = *value;
value
});
@ -296,10 +296,10 @@ impl Element {
let scope = win.reflector().get_jsobject();
let rects = do rects.map |r| {
ClientRect::new(
r.origin.y.to_f32(),
(r.origin.y + r.size.height).to_f32(),
r.origin.x.to_f32(),
(r.origin.x + r.size.width).to_f32(),
r.origin.y.to_f32().unwrap(),
(r.origin.y + r.size.height).to_f32().unwrap(),
r.origin.x.to_f32().unwrap(),
(r.origin.x + r.size.width).to_f32().unwrap(),
cx,
scope)
};
@ -320,10 +320,10 @@ impl Element {
let cx = win.get_cx();
let scope = win.reflector().get_jsobject();
ClientRect::new(
rect.origin.y.to_f32(),
(rect.origin.y + rect.size.height).to_f32(),
rect.origin.x.to_f32(),
(rect.origin.x + rect.size.width).to_f32(),
rect.origin.y.to_f32().unwrap(),
(rect.origin.y + rect.size.height).to_f32().unwrap(),
rect.origin.x.to_f32().unwrap(),
(rect.origin.x + rect.size.width).to_f32().unwrap(),
cx,
scope)
}

View file

@ -46,7 +46,7 @@ impl FormData {
pub fn Append(&mut self, name: &DOMString, value: @mut Blob, filename: Option<DOMString>) {
let blob = BlobData {
blob: value,
name: filename.unwrap_or_default(Some(~"default"))
name: filename.unwrap_or(Some(~"default"))
};
self.data.insert(null_str_as_empty(name), blob);
}

View file

@ -44,7 +44,7 @@ struct IFrameSize {
impl IFrameSize {
pub fn set_rect(&mut self, rect: Rect<f32>) {
let future_chan = replace(&mut self.future_chan, None);
do future_chan.map_move |future_chan| {
do future_chan.map |future_chan| {
let Size2D { width, height } = rect.size;
future_chan.send(Size2D(width as uint, height as uint));
};

View file

@ -45,7 +45,7 @@ impl HTMLImageElement {
if "src" == name {
let document = self.htmlelement.element.node.owner_doc();
let window = document.document().window;
let url = window.page.url.map(|&(ref url, _)| url.clone());
let url = window.page.url.as_ref().map(|&(ref url, _)| url.clone());
self.update_image(window.image_cache_task.clone(), url);
}
}

View file

@ -455,7 +455,9 @@ impl<'self, View> AbstractNode<View> {
impl<View> Iterator<AbstractNode<View>> for AbstractNodeChildrenIterator<View> {
fn next(&mut self) -> Option<AbstractNode<View>> {
let node = self.current_node;
self.current_node = self.current_node.chain(|node| node.next_sibling());
self.current_node = do self.current_node.and_then |node| {
node.next_sibling()
};
node
}
}

View file

@ -27,7 +27,6 @@ use std::io;
use std::ptr;
use std::int;
use std::libc;
use std::rt::rtio::RtioTimer;
use std::rt::io::timer::Timer;
use std::task::spawn_with;
use js::jsapi::JSVal;
@ -58,7 +57,7 @@ impl Window {
#[unsafe_destructor]
impl Drop for Window {
fn drop(&self) {
fn drop(&mut self) {
self.timer_chan.send(TimerMessage_Close);
}
}