mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Rust upgrades
This commit is contained in:
parent
caf1ed9446
commit
bbac8aa5c3
130 changed files with 1236 additions and 985 deletions
|
@ -35,7 +35,7 @@ impl AttrList {
|
|||
}
|
||||
|
||||
pub fn Item(&self, index: u32) -> Option<JS<Attr>> {
|
||||
self.owner.get().attrs.get_opt(index as uint).map(|x| x.clone())
|
||||
self.owner.get().attrs.get(index as uint).map(|x| x.clone())
|
||||
}
|
||||
|
||||
pub fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<JS<Attr>> {
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::cast;
|
|||
use std::libc;
|
||||
use std::ptr;
|
||||
|
||||
use extra::serialize::{Encodable, Encoder};
|
||||
use serialize::{Encodable, Encoder};
|
||||
|
||||
pub enum ExceptionHandling {
|
||||
// Report any exception and don't throw it to the caller code.
|
||||
|
|
|
@ -370,7 +370,7 @@ class CGMethodCall(CGThing):
|
|||
|
||||
overloadCGThings = []
|
||||
overloadCGThings.append(
|
||||
CGGeneric("let argcount = argc.min(&%d);" %
|
||||
CGGeneric("let argcount = cmp::min(argc,%d);" %
|
||||
maxArgCount))
|
||||
overloadCGThings.append(
|
||||
CGSwitch("argcount",
|
||||
|
@ -720,7 +720,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
return handleDefault(conversionCode,
|
||||
"${declName}.SetNull()")
|
||||
|
||||
value = "str::from_utf8(data).to_owned()"
|
||||
value = "str::from_utf8(data).unwrap().to_owned()"
|
||||
if type.nullable():
|
||||
value = "Some(%s)" % value
|
||||
|
||||
|
@ -1132,7 +1132,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
|||
raise TypeError("We don't support nullable enumerated return types "
|
||||
"yet")
|
||||
return ("""assert!((%(result)s as uint) < %(strings)s.len());
|
||||
let %(resultStr)s: *JSString = JS_NewStringCopyN(cx, ptr::to_unsafe_ptr(&%(strings)s[%(result)s as u32].value[0]) as *i8, %(strings)s[%(result)s as u32].length as libc::size_t);
|
||||
let %(resultStr)s: *JSString = JS_NewStringCopyN(cx, &%(strings)s[%(result)s as u32].value[0] as *i8, %(strings)s[%(result)s as u32].length as libc::size_t);
|
||||
if %(resultStr)s.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -2066,7 +2066,7 @@ def CreateBindingJSObject(descriptor, parent=None):
|
|||
let handler = js_info.get().get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
|
||||
""" % descriptor.name
|
||||
create += handler + """ let obj = NewProxyObject(aCx, *handler,
|
||||
ptr::to_unsafe_ptr(&PrivateValue(squirrel_away_unique(aObject) as *libc::c_void)),
|
||||
&PrivateValue(squirrel_away_unique(aObject) as *libc::c_void),
|
||||
proto, %s,
|
||||
ptr::null(), ptr::null());
|
||||
if obj.is_null() {
|
||||
|
@ -2230,7 +2230,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
|||
val = ('%(' + name + ')s') % self.properties.variableNames(False)
|
||||
if val == "ptr::null()":
|
||||
return val
|
||||
return "ptr::to_unsafe_ptr(&%s[0])" % val
|
||||
return "&%s[0]" % val
|
||||
|
||||
call = """return CreateInterfaceObjects2(aCx, aGlobal, aReceiver, parentProto,
|
||||
%s, %s, %d,
|
||||
|
@ -2376,7 +2376,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
|||
trace: %s
|
||||
};
|
||||
js_info.dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
|
||||
CreateProxyHandler(ptr::to_unsafe_ptr(&traps), ptr::to_unsafe_ptr(&Class) as *libc::c_void));
|
||||
CreateProxyHandler(&traps, cast::transmute(&Class)));
|
||||
|
||||
""" % (FINALIZE_HOOK_NAME,
|
||||
('Some(%s)' % TRACE_HOOK_NAME),
|
||||
|
@ -3892,7 +3892,7 @@ class CGProxyUnwrap(CGAbstractMethod):
|
|||
}*/
|
||||
//MOZ_ASSERT(IsProxy(obj));
|
||||
let box_: *Box<%s> = cast::transmute(GetProxyPrivate(obj).to_private());
|
||||
return ptr::to_unsafe_ptr(&(*box_).data);""" % (self.descriptor.concreteType)
|
||||
return cast::transmute(&(*box_).data);""" % (self.descriptor.concreteType)
|
||||
|
||||
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
|
@ -3913,7 +3913,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
if indexedGetter:
|
||||
readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None)
|
||||
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn 1;" % readonly
|
||||
templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_mut_unsafe_ptr(&mut (*desc).value)',
|
||||
templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': '&mut (*desc).value',
|
||||
'obj': 'proxy', 'successCode': fillDescriptor}
|
||||
get = ("if index.is_some() {\n" +
|
||||
" let index = index.unwrap();\n" +
|
||||
|
@ -3955,7 +3955,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
if namedGetter:
|
||||
readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None)
|
||||
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn 1;" % readonly
|
||||
templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': 'ptr::to_unsafe_ptr(&(*desc).value)',
|
||||
templateValues = {'jsvalRef': '(*desc).value', 'jsvalPtr': '&mut(*desc).value',
|
||||
'obj': 'proxy', 'successCode': fillDescriptor}
|
||||
# Once we start supporting OverrideBuiltins we need to make
|
||||
# ResolveOwnProperty or EnumerateOwnProperties filter out named
|
||||
|
@ -4101,7 +4101,7 @@ class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
|||
getFromExpando = """let expando = GetExpandoObject(proxy);
|
||||
if expando.is_not_null() {
|
||||
let hasProp = 0;
|
||||
if JS_HasPropertyById(cx, expando, id, ptr::to_unsafe_ptr(&hasProp)) == 0 {
|
||||
if JS_HasPropertyById(cx, expando, id, &hasProp) == 0 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4604,15 +4604,15 @@ class CGDictionary(CGThing):
|
|||
|
||||
if True: #XXXjdm hack until 'static mut' exists for global jsids
|
||||
propName = member.identifier.name
|
||||
propCheck = ('"%s".to_c_str().with_ref(|s| { JS_HasProperty(cx, val.to_object(), s, ptr::to_unsafe_ptr(&found)) })' %
|
||||
propCheck = ('"%s".to_c_str().with_ref(|s| { JS_HasProperty(cx, val.to_object(), s, &found) })' %
|
||||
propName)
|
||||
propGet = ('"%s".to_c_str().with_ref(|s| { JS_GetProperty(cx, val.to_object(), s, ptr::to_unsafe_ptr(&temp)) })' %
|
||||
propGet = ('"%s".to_c_str().with_ref(|s| { JS_GetProperty(cx, val.to_object(), s, &temp) })' %
|
||||
propName)
|
||||
else:
|
||||
propId = self.makeIdName(member.identifier.name);
|
||||
propCheck = ("JS_HasPropertyById(cx, val.to_object(), %s, ptr::to_unsafe_ptr(&found))" %
|
||||
propCheck = ("JS_HasPropertyById(cx, val.to_object(), %s, &found)" %
|
||||
propId)
|
||||
propGet = ("JS_GetPropertyById(cx, val.to_object(), %s, ptr::to_unsafe_ptr(&temp))" %
|
||||
propGet = ("JS_GetPropertyById(cx, val.to_object(), %s, &temp)" %
|
||||
propId)
|
||||
|
||||
conversionReplacements = {
|
||||
|
@ -4818,12 +4818,14 @@ class CGBindingRoot(CGThing):
|
|||
'servo_util::str::DOMString',
|
||||
'servo_util::vec::zip_copies',
|
||||
'std::cast',
|
||||
'std::cmp',
|
||||
'std::libc',
|
||||
'std::ptr',
|
||||
'std::vec',
|
||||
'std::str',
|
||||
'std::num',
|
||||
'std::unstable::raw::Box',
|
||||
'std::intrinsics::uninit',
|
||||
'std::raw::Box',
|
||||
])
|
||||
|
||||
# Add the auto-generated comment.
|
||||
|
@ -5767,7 +5769,7 @@ class GlobalGenRoots():
|
|||
CGGeneric("use dom::types::*;\n"),
|
||||
CGGeneric("use dom::bindings::js::JS;\n"),
|
||||
CGGeneric("use dom::bindings::trace::Traceable;\n"),
|
||||
CGGeneric("use extra::serialize::{Encodable, Encoder};\n"),
|
||||
CGGeneric("use serialize::{Encodable, Encoder};\n"),
|
||||
CGGeneric("use js::jsapi::JSTracer;\n\n")]
|
||||
for descriptor in descriptors:
|
||||
name = descriptor.name
|
||||
|
|
|
@ -7,7 +7,7 @@ use js::jsapi::{JS_IsExceptionPending};
|
|||
|
||||
use js::glue::{ReportError};
|
||||
|
||||
#[deriving(ToStr)]
|
||||
#[deriving(Show)]
|
||||
pub enum Error {
|
||||
FailureUnknown,
|
||||
NotFound,
|
||||
|
|
|
@ -9,7 +9,7 @@ use layout_interface::TrustedNodeAddress;
|
|||
|
||||
use std::cast;
|
||||
use std::cell::RefCell;
|
||||
use std::unstable::raw::Box;
|
||||
use std::raw::Box;
|
||||
|
||||
pub struct JS<T> {
|
||||
priv ptr: RefCell<*mut T>
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::cast;
|
|||
use std::libc;
|
||||
use std::ptr;
|
||||
use std::ptr::null;
|
||||
use extra::serialize::{Encodable, Encoder};
|
||||
use serialize::{Encodable, Encoder};
|
||||
|
||||
// IMPORTANT: We rely on the fact that we never attempt to encode DOM objects using
|
||||
// any encoder but JSTracer. Since we derive trace hooks automatically,
|
||||
|
|
|
@ -8,16 +8,16 @@ use dom::bindings::js::JS;
|
|||
use dom::window;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use std::libc::c_uint;
|
||||
use std::cast;
|
||||
use std::cmp::Eq;
|
||||
use std::hashmap::HashMap;
|
||||
use std::libc;
|
||||
use std::ptr;
|
||||
use std::ptr::null;
|
||||
use std::str;
|
||||
use std::vec;
|
||||
use std::unstable::raw::Box;
|
||||
use std::raw::Box;
|
||||
use js::glue::*;
|
||||
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
|
||||
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction};
|
||||
|
@ -149,7 +149,7 @@ pub fn jsstring_to_str(cx: *JSContext, s: *JSString) -> DOMString {
|
|||
let length = 0;
|
||||
let chars = JS_GetStringCharsAndLength(cx, s, &length);
|
||||
vec::raw::buf_as_slice(chars, length as uint, |char_vec| {
|
||||
str::from_utf16(char_vec)
|
||||
str::from_utf16(char_vec).unwrap()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found:
|
|||
return true;
|
||||
}
|
||||
let hasProp = 0;
|
||||
if JS_HasPropertyById(cx, proto, id, ptr::to_unsafe_ptr(&hasProp)) == 0 {
|
||||
if JS_HasPropertyById(cx, proto, id, &hasProp) == 0 {
|
||||
return false;
|
||||
}
|
||||
*found = hasProp != 0;
|
||||
|
|
|
@ -38,12 +38,12 @@ use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
|
|||
use servo_util::namespace::{Namespace, Null};
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use collections::hashmap::HashMap;
|
||||
use extra::url::{Url, from_str};
|
||||
use js::jsapi::{JSObject, JSContext};
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::hashmap::HashMap;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
pub enum IsHTMLDocument {
|
||||
|
@ -435,7 +435,7 @@ impl Document {
|
|||
}
|
||||
|
||||
let element: JS<Element> = ElementCast::to(node);
|
||||
element.get().get_attribute(Null, "name").map_default(false, |attr| {
|
||||
element.get().get_attribute(Null, "name").map_or(false, |attr| {
|
||||
attr.get().value_ref() == name
|
||||
})
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::window::Window;
|
|||
use servo_util::str::DOMString;
|
||||
|
||||
#[repr(uint)]
|
||||
#[deriving(ToStr, Encodable)]
|
||||
#[deriving(Show, Encodable)]
|
||||
enum DOMErrorName {
|
||||
IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR,
|
||||
HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR,
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::eventdispatcher::dispatch_event;
|
|||
use dom::node::NodeTypeId;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use std::hashmap::HashMap;
|
||||
use collections::hashmap::HashMap;
|
||||
|
||||
#[deriving(Eq,Encodable)]
|
||||
pub enum ListenerPhase {
|
||||
|
|
|
@ -11,7 +11,7 @@ use dom::htmlformelement::HTMLFormElement;
|
|||
use dom::window::Window;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use std::hashmap::HashMap;
|
||||
use collections::hashmap::HashMap;
|
||||
|
||||
#[deriving(Encodable)]
|
||||
enum FormDatum {
|
||||
|
|
|
@ -15,9 +15,9 @@ use dom::windowproxy::WindowProxy;
|
|||
use servo_util::str::DOMString;
|
||||
|
||||
use extra::url::Url;
|
||||
use serialize::{Encoder, Encodable};
|
||||
use servo_msg::constellation_msg::{PipelineId, SubpageId};
|
||||
use std::ascii::StrAsciiExt;
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
|
||||
enum SandboxAllowance {
|
||||
AllowNothing = 0x00,
|
||||
|
|
|
@ -19,7 +19,7 @@ use servo_net::image_cache_task;
|
|||
use servo_util::url::parse_url;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
|
||||
#[deriving(Encodable)]
|
||||
pub struct HTMLImageElement {
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
|||
|
||||
for node in *iterator {
|
||||
while open_elements.len() > iterator.depth {
|
||||
html.push_str(~"</" + open_elements.pop() + ">");
|
||||
html.push_str(~"</" + open_elements.pop().unwrap().as_slice() + ">");
|
||||
}
|
||||
html.push_str(
|
||||
match node.type_id() {
|
||||
|
@ -59,7 +59,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
|||
);
|
||||
}
|
||||
while open_elements.len() > 0 {
|
||||
html.push_str(~"</" + open_elements.pop() + ">");
|
||||
html.push_str(~"</" + open_elements.pop().unwrap().as_slice() + ">");
|
||||
}
|
||||
html
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use servo_util::str::DOMString;
|
|||
use script_task::{Page};
|
||||
use std::rc::Rc;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
|
||||
|
||||
#[deriving(Encodable)]
|
||||
|
|
|
@ -36,12 +36,11 @@ use std::cast::transmute;
|
|||
use std::cast;
|
||||
use std::cell::{RefCell, Ref, RefMut};
|
||||
use std::iter::{Map, Filter};
|
||||
use std::libc::uintptr_t;
|
||||
use std::ptr;
|
||||
use std::unstable::raw::Box;
|
||||
use std::util;
|
||||
use std::libc::{c_void, uintptr_t};
|
||||
use std::mem;
|
||||
use std::raw::Box;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
|
||||
//
|
||||
// The basic Node structure
|
||||
|
@ -806,11 +805,14 @@ impl Node {
|
|||
/// Sends layout data, if any, back to the script task to be destroyed.
|
||||
pub unsafe fn reap_layout_data(&mut self) {
|
||||
if self.layout_data.is_present() {
|
||||
let layout_data = util::replace(&mut self.layout_data, LayoutDataRef::new());
|
||||
let layout_data = mem::replace(&mut self.layout_data, LayoutDataRef::new());
|
||||
let layout_chan = layout_data.take_chan();
|
||||
match layout_chan {
|
||||
None => {}
|
||||
Some(chan) => chan.send(ReapLayoutDataMsg(layout_data)),
|
||||
Some(chan) => {
|
||||
let LayoutChan(chan) = chan;
|
||||
chan.send(ReapLayoutDataMsg(layout_data))
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1268,7 +1270,7 @@ impl Node {
|
|||
|
||||
// http://dom.spec.whatwg.org/#concept-node-remove
|
||||
fn remove(node: &mut JS<Node>, parent: &mut JS<Node>, suppress_observers: SuppressObserver) {
|
||||
assert!(node.parent_node().map_default(false, |ref node_parent| node_parent == parent));
|
||||
assert!(node.parent_node().map_or(false, |ref node_parent| node_parent == parent));
|
||||
|
||||
// Step 1-5: ranges.
|
||||
// Step 6-7: mutation observers.
|
||||
|
@ -1685,15 +1687,20 @@ impl Node {
|
|||
}
|
||||
|
||||
if lastself != lastother {
|
||||
let random = if ptr::to_unsafe_ptr(abstract_self.get()) < ptr::to_unsafe_ptr(other.get()) {
|
||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING
|
||||
} else {
|
||||
NodeConstants::DOCUMENT_POSITION_PRECEDING
|
||||
};
|
||||
// step 3.
|
||||
return random +
|
||||
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
|
||||
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
|
||||
unsafe {
|
||||
let abstract_uint: uintptr_t = cast::transmute(abstract_self.get());
|
||||
let other_uint: uintptr_t = cast::transmute(other.get());
|
||||
|
||||
let random = if (abstract_uint < other_uint) {
|
||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING
|
||||
} else {
|
||||
NodeConstants::DOCUMENT_POSITION_PRECEDING
|
||||
};
|
||||
// step 3.
|
||||
return random +
|
||||
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
|
||||
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
|
||||
}
|
||||
}
|
||||
|
||||
for child in lastself.traverse_preorder() {
|
||||
|
|
|
@ -25,16 +25,16 @@ use js::jsval::JSVal;
|
|||
use js::jsval::{NullValue, ObjectValue};
|
||||
use js::JSPROP_ENUMERATE;
|
||||
|
||||
use collections::hashmap::HashSet;
|
||||
use std::cast;
|
||||
use std::comm::SharedChan;
|
||||
use std::cmp;
|
||||
use std::comm::Chan;
|
||||
use std::comm::Select;
|
||||
use std::hashmap::HashSet;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::io::timer::Timer;
|
||||
use std::num;
|
||||
use std::rc::Rc;
|
||||
use std::to_bytes::Cb;
|
||||
|
||||
use extra::serialize::{Encoder, Encodable};
|
||||
use serialize::{Encoder, Encodable};
|
||||
use extra::url::{Url};
|
||||
|
||||
pub enum TimerControlMsg {
|
||||
|
@ -53,9 +53,9 @@ impl<S: Encoder> Encodable<S> for TimerHandle {
|
|||
}
|
||||
}
|
||||
|
||||
impl IterBytes for TimerHandle {
|
||||
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
|
||||
self.handle.iter_bytes(lsb0, f)
|
||||
impl Hash for TimerHandle {
|
||||
fn hash(&self, state: &mut sip::SipState) {
|
||||
self.handle.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ pub struct Window {
|
|||
struct Untraceable {
|
||||
page: Rc<Page>,
|
||||
compositor: ~ScriptListener,
|
||||
timer_chan: SharedChan<TimerControlMsg>,
|
||||
timer_chan: Chan<TimerControlMsg>,
|
||||
}
|
||||
|
||||
impl<S: Encoder> Encodable<S> for Untraceable {
|
||||
|
@ -134,7 +134,7 @@ pub struct TimerData {
|
|||
impl Window {
|
||||
pub fn Alert(&self, s: DOMString) {
|
||||
// Right now, just print to the console
|
||||
println(format!("ALERT: {:s}", s));
|
||||
println!("ALERT: {:s}", s);
|
||||
}
|
||||
|
||||
pub fn Close(&self) {
|
||||
|
@ -226,7 +226,7 @@ impl Reflectable for Window {
|
|||
|
||||
impl Window {
|
||||
pub fn SetTimeout(&mut self, _cx: *JSContext, callback: JSVal, timeout: i32) -> i32 {
|
||||
let timeout = num::max(0, timeout) as u64;
|
||||
let timeout = cmp::max(0, timeout) as u64;
|
||||
let handle = self.next_timer_handle;
|
||||
self.next_timer_handle += 1;
|
||||
|
||||
|
@ -241,10 +241,12 @@ impl Window {
|
|||
let mut cancel_port = cancel_port;
|
||||
|
||||
let select = Select::new();
|
||||
let timeout_handle = select.add(&mut timeout_port);
|
||||
let _cancel_handle = select.add(&mut cancel_port);
|
||||
let mut timeout_handle = select.handle(&timeout_port);
|
||||
unsafe { timeout_handle.add() };
|
||||
let mut _cancel_handle = select.handle(&cancel_port);
|
||||
unsafe { _cancel_handle.add() };
|
||||
let id = select.wait();
|
||||
if id == timeout_handle.id {
|
||||
if id == timeout_handle.id() {
|
||||
chan.send(TimerMessage_Fire(~TimerData {
|
||||
handle: handle,
|
||||
funval: callback,
|
||||
|
@ -290,9 +292,10 @@ impl Window {
|
|||
compositor: compositor,
|
||||
page: page.clone(),
|
||||
timer_chan: {
|
||||
let (timer_port, timer_chan): (Port<TimerControlMsg>, SharedChan<TimerControlMsg>) = SharedChan::new();
|
||||
let (timer_port, timer_chan): (Port<TimerControlMsg>, Chan<TimerControlMsg>) = Chan::new();
|
||||
let id = page.borrow().id.clone();
|
||||
spawn_named("timer controller", proc() {
|
||||
let ScriptChan(script_chan) = script_chan;
|
||||
loop {
|
||||
match timer_port.recv() {
|
||||
TimerMessage_Close => break,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue