mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Fix upstream build breaks from reinterpret_cast
This commit is contained in:
parent
4ef4c36fa7
commit
1b54eacbe1
23 changed files with 98 additions and 99 deletions
|
@ -34,7 +34,7 @@ import js::rust::compartment;
|
|||
import resource::resource_task;
|
||||
import resource_task::{ResourceTask};
|
||||
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import url_to_str = std::net::url::to_str;
|
||||
import util::url::make_url;
|
||||
import task::{task, SingleThreaded};
|
||||
|
@ -46,8 +46,8 @@ import js::jsapi::bindgen::JS_CallFunctionValue;
|
|||
import ptr::null;
|
||||
|
||||
enum ControlMsg {
|
||||
ParseMsg(url),
|
||||
ExecuteMsg(url),
|
||||
ParseMsg(Url),
|
||||
ExecuteMsg(Url),
|
||||
Timer(~dom::bindings::window::TimerData),
|
||||
ExitMsg
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ struct Content<C:Compositor> {
|
|||
|
||||
let mut document: Option<@Document>;
|
||||
let mut window: Option<@Window>;
|
||||
let mut doc_url: Option<url>;
|
||||
let mut doc_url: Option<Url>;
|
||||
|
||||
let resource_task: ResourceTask;
|
||||
|
||||
|
@ -221,7 +221,7 @@ struct Content<C:Compositor> {
|
|||
}
|
||||
}
|
||||
|
||||
fn relayout(document: Document, doc_url: &url) {
|
||||
fn relayout(document: Document, doc_url: &Url) {
|
||||
#debug("content: performing relayout");
|
||||
|
||||
// Now, join the layout so that they will see the latest
|
||||
|
|
|
@ -61,7 +61,7 @@ enum Element = int;
|
|||
|
||||
extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||
-> JSBool unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,14 +76,14 @@ extern fn getDocumentElement(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
|||
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Document> {
|
||||
//TODO: some kind of check if this is a Document object
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val))
|
||||
unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val))
|
||||
}
|
||||
|
||||
extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||
#debug("document finalize!");
|
||||
unsafe {
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
let _doc: @Document = unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val));
|
||||
let _doc: @Document = unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ fn init(compartment: bare_compartment, doc: @Document) {
|
|||
compartment.global_obj.ptr));
|
||||
|
||||
unsafe {
|
||||
let raw_ptr: *libc::c_void = unsafe::reinterpret_cast(squirrel_away(doc));
|
||||
let raw_ptr: *libc::c_void = unsafe::reinterpret_cast(&squirrel_away(doc));
|
||||
JS_SetReservedSlot(instance.ptr, 0, RUST_PRIVATE_TO_JSVAL(raw_ptr));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
|||
#debug("element finalize!");
|
||||
unsafe {
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
let _node: ~NodeBundle = unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val));
|
||||
let _node: ~NodeBundle = unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ fn init(compartment: bare_compartment) {
|
|||
|
||||
extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||
-> JSBool unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
|
|||
|
||||
extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||
-> JSBool unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
|
|||
extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||
-> JSBool {
|
||||
unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
|
|||
|
||||
unsafe {
|
||||
let raw_ptr: *libc::c_void =
|
||||
unsafe::reinterpret_cast(squirrel_away_unique(~NodeBundle(node, scope)));
|
||||
unsafe::reinterpret_cast(&squirrel_away_unique(~NodeBundle(node, scope)));
|
||||
JS_SetReservedSlot(obj.ptr, 0, RUST_PRIVATE_TO_JSVAL(raw_ptr));
|
||||
}
|
||||
return obj;
|
||||
|
|
|
@ -67,12 +67,12 @@ struct NodeBundle {
|
|||
|
||||
unsafe fn unwrap(obj: *JSObject) -> *rust_box<NodeBundle> {
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val))
|
||||
unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val))
|
||||
}
|
||||
|
||||
extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
|
||||
unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool
|
|||
|
||||
extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
|
||||
unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBoo
|
|||
|
||||
extern fn getNodeType(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool {
|
||||
unsafe {
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(vp));
|
||||
let obj = JS_THIS_OBJECT(cx, unsafe::reinterpret_cast(&vp));
|
||||
if obj.is_null() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval {
|
|||
}
|
||||
str(s) => {
|
||||
str::as_buf(s, |buf, len| {
|
||||
let cbuf = unsafe::reinterpret_cast(buf);
|
||||
let cbuf = unsafe::reinterpret_cast(&buf);
|
||||
RUST_STRING_TO_JSVAL(JS_NewStringCopyN(cx, cbuf, len as libc::size_t))
|
||||
})
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval {
|
|||
fn get_compartment(cx: *JSContext) -> *bare_compartment {
|
||||
unsafe {
|
||||
let priv: *libc::c_void = JS_GetContextPrivate(cx);
|
||||
let compartment: *bare_compartment = unsafe::reinterpret_cast(priv);
|
||||
let compartment: *bare_compartment = unsafe::reinterpret_cast(&priv);
|
||||
assert cx == (*compartment).cx.ptr;
|
||||
compartment
|
||||
}
|
||||
|
|
|
@ -65,14 +65,14 @@ extern fn setTimeout(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool unsafe
|
|||
|
||||
unsafe fn unwrap(obj: *JSObject) -> *rust_box<Window> {
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val))
|
||||
unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val))
|
||||
}
|
||||
|
||||
extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||
#debug("finalize!");
|
||||
unsafe {
|
||||
let val = JS_GetReservedSlot(obj, 0);
|
||||
let _: @Window = unsafe::reinterpret_cast(RUST_JSVAL_TO_PRIVATE(val));
|
||||
let _: @Window = unsafe::reinterpret_cast(&RUST_JSVAL_TO_PRIVATE(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ fn init(compartment: bare_compartment, win: @Window) {
|
|||
});
|
||||
|
||||
unsafe {
|
||||
let raw_ptr: *libc::c_void = unsafe::reinterpret_cast(squirrel_away(win));
|
||||
let raw_ptr: *libc::c_void = unsafe::reinterpret_cast(&squirrel_away(win));
|
||||
JS_SetReservedSlot(obj.ptr, 0, RUST_PRIVATE_TO_JSVAL(raw_ptr));
|
||||
}
|
||||
|
||||
|
|
|
@ -130,26 +130,26 @@ impl<T:send,A> Handle<T,A> {
|
|||
impl<T: copy send,A> Scope<T,A> {
|
||||
fn clone(v: *T) -> *T unsafe {
|
||||
let n: *mut T =
|
||||
unsafe::reinterpret_cast(libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
|
||||
unsafe::reinterpret_cast(&libc::calloc(sys::size_of::<T>() as size_t, 1u as size_t));
|
||||
|
||||
// n.b.: this assignment will run the drop glue for <T,A>. *Hopefully* the fact that
|
||||
// everything is initialized to NULL by calloc will make this ok. We may have to make the
|
||||
// take glue be tolerant of this.
|
||||
*n = unsafe{*v};
|
||||
|
||||
return unsafe::reinterpret_cast(n);
|
||||
return unsafe::reinterpret_cast(&n);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn free<T:send>(t: *T) {
|
||||
let _x <- *unsafe::reinterpret_cast::<*T,*mut T>(t);
|
||||
libc::free(unsafe::reinterpret_cast(t));
|
||||
let _x <- *unsafe::reinterpret_cast::<*T,*mut T>(&t);
|
||||
libc::free(unsafe::reinterpret_cast(&t));
|
||||
}
|
||||
|
||||
unsafe fn free_handle<T:send,A>(h: Handle<T,A>) {
|
||||
free(h.read_ptr());
|
||||
if h.write_ptr() != unsafe::reinterpret_cast(h.read_ptr()) {
|
||||
free(unsafe::reinterpret_cast::<*mut T,*T>(h.write_ptr()));
|
||||
if h.write_ptr() != unsafe::reinterpret_cast(&h.read_ptr()) {
|
||||
free(unsafe::reinterpret_cast::<*mut T,*T>(&h.write_ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ impl<T:copy send,A> Scope<T,A> {
|
|||
while (*handle).is_not_null() {
|
||||
free(handle.read_ptr());
|
||||
|
||||
handle.set_read_ptr(unsafe::reinterpret_cast(handle.write_ptr()));
|
||||
handle.set_read_ptr(unsafe::reinterpret_cast(&handle.write_ptr()));
|
||||
let next_handle = handle.next_dirty();
|
||||
handle.set_next_dirty(null_handle());
|
||||
handle = next_handle;
|
||||
|
@ -205,7 +205,7 @@ impl<T:copy send,A> Scope<T,A> {
|
|||
let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
|
||||
if self.d.layout_active && const_read_ptr == const_write_ptr {
|
||||
#debug["marking handle %? as dirty", h];
|
||||
h.set_write_ptr(unsafe::reinterpret_cast(self.clone(h.read_ptr())));
|
||||
h.set_write_ptr(unsafe::reinterpret_cast(&self.clone(h.read_ptr())));
|
||||
h.set_next_dirty(self.d.first_dirty);
|
||||
self.d.first_dirty = h;
|
||||
}
|
||||
|
@ -216,9 +216,9 @@ impl<T:copy send,A> Scope<T,A> {
|
|||
fn handle(v: T) -> Handle<T,A> unsafe {
|
||||
let d: *HandleData<T,A> =
|
||||
unsafe::reinterpret_cast(
|
||||
libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
|
||||
&libc::malloc(sys::size_of::<HandleData<T,A>>() as size_t));
|
||||
(*d).read_ptr = self.clone(ptr::addr_of(v));
|
||||
(*d).write_ptr = unsafe::reinterpret_cast((*d).read_ptr);
|
||||
(*d).write_ptr = unsafe::reinterpret_cast(&(*d).read_ptr);
|
||||
(*d).read_aux = ptr::null();
|
||||
(*d).next_dirty = null_handle();
|
||||
let h = _Handle(d);
|
||||
|
|
|
@ -10,7 +10,7 @@ import content::content_task;
|
|||
import content_task::{ContentTask};
|
||||
import resource::resource_task;
|
||||
import resource::resource_task::{ResourceTask};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import resource::image_cache_task;
|
||||
import image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
|
||||
|
||||
|
@ -101,7 +101,7 @@ impl<C: Compositor> Engine<C> {
|
|||
|
||||
proto! EngineProto(
|
||||
Running:send {
|
||||
LoadURL(url) -> Running,
|
||||
LoadURL(Url) -> Running,
|
||||
Exit -> Exiting
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import text::TextBox;
|
|||
import traverse::extended_full_traversal;
|
||||
import style::style::{SpecifiedStyle};
|
||||
import vec::{push, push_all};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import resource::image_cache_task;
|
||||
import image_cache_task::ImageCacheTask;
|
||||
import core::to_str::ToStr;
|
||||
|
@ -94,12 +94,12 @@ struct Box {
|
|||
struct ImageHolder {
|
||||
// Invariant: at least one of url and image is not none, except
|
||||
// occasionally while get_image is being called
|
||||
let mut url : Option<url>;
|
||||
let mut url : Option<Url>;
|
||||
let mut image : Option<ARC<~Image>>;
|
||||
let image_cache_task: ImageCacheTask;
|
||||
let reflow: fn~();
|
||||
|
||||
new(-url : url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
new(-url : Url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
self.url = Some(copy url);
|
||||
self.image = None;
|
||||
self.image_cache_task = image_cache_task;
|
||||
|
|
|
@ -30,7 +30,7 @@ impl @Box : InlineLayout {
|
|||
for tree::each_child(BTree, self) |kid| {
|
||||
kid.bounds.origin = Point2D(au(x), au(y));
|
||||
x += *kid.bounds.size.width;
|
||||
current_height = i32::max(¤t_height, &*kid.bounds.size.height);
|
||||
current_height = i32::max(current_height, *kid.bounds.size.height);
|
||||
}
|
||||
|
||||
let height = match self.appearance.height {
|
||||
|
@ -41,7 +41,7 @@ impl @Box : InlineLayout {
|
|||
|
||||
let width = match self.appearance.width {
|
||||
Px(p) => px_to_au(p.to_int()),
|
||||
Auto => au(i32::max(&x, &*self.bounds.size.width)),
|
||||
Auto => au(i32::max(x, *self.bounds.size.width)),
|
||||
_ => fail ~"inhereit_width failed, width is neither a Px or auto"
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import gfx::geometry::px_to_au;
|
|||
import gfx::render_task;
|
||||
import render_task::RenderTask;
|
||||
import resource::image_cache_task::ImageCacheTask;
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import style::apply::apply_style;
|
||||
import dom::event::{Event, ReflowEvent};
|
||||
import content::content_task;
|
||||
|
@ -22,7 +22,7 @@ import comm::*;
|
|||
type LayoutTask = Chan<Msg>;
|
||||
|
||||
enum Msg {
|
||||
BuildMsg(Node, ARC<Stylesheet>, url, Chan<Event>),
|
||||
BuildMsg(Node, ARC<Stylesheet>, Url, Chan<Event>),
|
||||
PingMsg(Chan<content_task::PingMsg>),
|
||||
ExitMsg
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@ import gfx::geometry::au_to_px;
|
|||
import base::{Box, BTree, NTree, LayoutData, SpecifiedStyle, ImageHolder,
|
||||
BlockBox, InlineBox, IntrinsicBox, TextBox};
|
||||
import traverse::{top_down_traversal};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import resource::image_cache_task::ImageCacheTask;
|
||||
|
||||
struct StyleApplicator {
|
||||
box: @Box;
|
||||
doc_url: &url;
|
||||
doc_url: &Url;
|
||||
image_cache_task: ImageCacheTask;
|
||||
reflow: fn~();
|
||||
}
|
||||
|
||||
fn apply_style(box: @Box, doc_url: &url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
fn apply_style(box: @Box, doc_url: &Url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
box: box,
|
||||
doc_url: doc_url,
|
||||
|
@ -29,7 +29,7 @@ fn apply_style(box: @Box, doc_url: &url, image_cache_task: ImageCacheTask, reflo
|
|||
|
||||
#[doc="A wrapper around a set of functions that can be applied as a top-down traversal of layout
|
||||
boxes."]
|
||||
fn inheritance_wrapper(box : @Box, doc_url: &url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
fn inheritance_wrapper(box : @Box, doc_url: &Url, image_cache_task: ImageCacheTask, reflow: fn~()) {
|
||||
let applicator = StyleApplicator {
|
||||
box: box,
|
||||
doc_url: doc_url,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[doc = "Interface for running tree-based traversals over layout boxes"]
|
||||
|
||||
import base::{Box, BTree, NodeMethods};
|
||||
import intrinsic::tydesc;
|
||||
import intrinsic::TyDesc;
|
||||
|
||||
export full_traversal;
|
||||
export top_down_traversal;
|
||||
|
|
|
@ -9,7 +9,7 @@ import pipes::{Port, Chan};
|
|||
|
||||
import lexer_util::*;
|
||||
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import resource::resource_task::{ResourceTask, ProgressMsg, Load};
|
||||
|
||||
enum ParserState {
|
||||
|
@ -268,7 +268,7 @@ fn spawn_css_lexer_from_string(-content : ~str) -> pipes::Port<Token> {
|
|||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn spawn_css_lexer_task(-url: url, resource_task: ResourceTask) -> pipes::Port<Token> {
|
||||
fn spawn_css_lexer_task(-url: Url, resource_task: ResourceTask) -> pipes::Port<Token> {
|
||||
let (result_chan, result_port) = pipes::stream();
|
||||
|
||||
do task::spawn || {
|
||||
|
|
|
@ -10,17 +10,17 @@ import parser = parser::html_lexer;
|
|||
import parser::Token;
|
||||
import dom::style::Stylesheet;
|
||||
import vec::{push, push_all_move, flat_map};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import resource::resource_task::{ResourceTask, Load, Payload, Done};
|
||||
import to_str::ToStr;
|
||||
|
||||
enum CSSMessage {
|
||||
File(url),
|
||||
File(Url),
|
||||
Exit
|
||||
}
|
||||
|
||||
enum js_message {
|
||||
js_file(url),
|
||||
js_file(Url),
|
||||
js_exit
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ fn js_script_listener(to_parent : comm::Chan<~[~[u8]]>, from_parent : comm::Port
|
|||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn build_dom(scope: NodeScope, stream: comm::Port<Token>, url: url,
|
||||
fn build_dom(scope: NodeScope, stream: comm::Port<Token>, url: Url,
|
||||
resource_task: ResourceTask) -> (Node, comm::Port<Stylesheet>, comm::Port<~[~[u8]]>) {
|
||||
// The current reference node.
|
||||
let mut cur_node = scope.new_node(Element(ElementData(~"html", ~HTMLDivElement)));
|
||||
|
|
|
@ -6,7 +6,7 @@ import vec::push;
|
|||
import lexer_util::*;
|
||||
import resource::resource_task;
|
||||
import resource_task::{ResourceTask, ProgressMsg, Load};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
|
||||
enum Token {
|
||||
StartOpeningTag(~str),
|
||||
|
@ -224,7 +224,7 @@ fn lexer(+input_port: Port<resource_task::ProgressMsg>, state : ParseState) -> H
|
|||
}
|
||||
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn spawn_html_lexer_task(-url: url, resource_task: ResourceTask) -> Port<Token> {
|
||||
fn spawn_html_lexer_task(-url: Url, resource_task: ResourceTask) -> Port<Token> {
|
||||
let html_port = Port();
|
||||
let html_chan = Chan(html_port);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use JSMessage = parser::html_builder::js_message;
|
|||
use comm::{Chan, Port};
|
||||
use str::from_slice;
|
||||
use unsafe::reinterpret_cast;
|
||||
use Url = std::net::url::url;
|
||||
use std::net::url::Url;
|
||||
|
||||
type JSResult = ~[~[u8]];
|
||||
|
||||
|
@ -149,7 +149,7 @@ fn parse_html(scope: NodeScope, url: Url, resource_task: ResourceTask) -> HtmlPa
|
|||
debug!("created new node");
|
||||
let parser = hubbub::Parser("UTF-8", false);
|
||||
debug!("created parser");
|
||||
parser.set_document_node(reinterpret_cast(root));
|
||||
parser.set_document_node(reinterpret_cast(&root));
|
||||
parser.enable_scripting(true);
|
||||
parser.set_tree_handler(@hubbub::TreeHandler {
|
||||
create_comment: |_data| {
|
||||
|
@ -159,7 +159,7 @@ fn parse_html(scope: NodeScope, url: Url, resource_task: ResourceTask) -> HtmlPa
|
|||
create_doctype: |_doctype| {
|
||||
debug!("create doctype");
|
||||
let new_node = scope.new_node(Element(ElementData(~"doctype", ~UnknownElement)));
|
||||
unsafe { reinterpret_cast(new_node) }
|
||||
unsafe { reinterpret_cast(&new_node) }
|
||||
},
|
||||
create_element: |tag| {
|
||||
debug!("create element");
|
||||
|
@ -210,18 +210,18 @@ fn parse_html(scope: NodeScope, url: Url, resource_task: ResourceTask) -> HtmlPa
|
|||
}
|
||||
}
|
||||
|
||||
unsafe { reinterpret_cast(node) }
|
||||
unsafe { reinterpret_cast(&node) }
|
||||
},
|
||||
create_text: |data| {
|
||||
debug!("create text");
|
||||
let new_node = scope.new_node(Text(from_slice(data)));
|
||||
unsafe { reinterpret_cast(new_node) }
|
||||
unsafe { reinterpret_cast(&new_node) }
|
||||
},
|
||||
ref_node: |_node| {},
|
||||
unref_node: |_node| {},
|
||||
append_child: |parent, child| unsafe {
|
||||
debug!("append child");
|
||||
scope.add_child(reinterpret_cast(parent), reinterpret_cast(child));
|
||||
scope.add_child(reinterpret_cast(&parent), reinterpret_cast(&child));
|
||||
child
|
||||
},
|
||||
insert_before: |_parent, _child| {
|
||||
|
@ -261,7 +261,7 @@ fn parse_html(scope: NodeScope, url: Url, resource_task: ResourceTask) -> HtmlPa
|
|||
debug!("encoding change");
|
||||
},
|
||||
complete_script: |script| unsafe {
|
||||
do scope.read(reinterpret_cast(script)) |node_contents| {
|
||||
do scope.read(reinterpret_cast(&script)) |node_contents| {
|
||||
match *node_contents.kind {
|
||||
Element(element) if element.tag_name == ~"script" => {
|
||||
match element.get_attr(~"src") {
|
||||
|
|
|
@ -3,12 +3,12 @@ export factory;
|
|||
import comm::Chan;
|
||||
import task::spawn;
|
||||
import resource_task::{ProgressMsg, Payload, Done};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import io::{file_reader, ReaderUtil};
|
||||
|
||||
const READ_SIZE: uint = 1024;
|
||||
|
||||
fn factory(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||
fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
assert url.scheme == ~"file";
|
||||
|
||||
do spawn {
|
||||
|
|
|
@ -3,10 +3,10 @@ export factory;
|
|||
import comm::Chan;
|
||||
import task::spawn;
|
||||
import resource_task::{ProgressMsg, Payload, Done};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import http_client::{uv_http_request};
|
||||
|
||||
fn factory(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||
fn factory(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
assert url.scheme == ~"http";
|
||||
|
||||
do spawn {
|
||||
|
|
|
@ -5,7 +5,7 @@ export ImageCacheTaskClient;
|
|||
export SyncImageCacheTask;
|
||||
|
||||
import image::base::{Image, load_from_memory, test_image_bin};
|
||||
import std::net::url::url;
|
||||
import std::net::url::Url;
|
||||
import util::url::{make_url, UrlMap, url_map};
|
||||
import comm::{Chan, Port};
|
||||
import task::{spawn, spawn_listener};
|
||||
|
@ -19,23 +19,23 @@ import to_str::ToStr;
|
|||
enum Msg {
|
||||
/// Tell the cache that we may need a particular image soon. Must be posted
|
||||
/// before Decode
|
||||
Prefetch(url),
|
||||
Prefetch(Url),
|
||||
|
||||
/// Used be the prefetch tasks to post back image binaries
|
||||
/*priv*/ StorePrefetchedImageData(url, Result<Cell<~[u8]>, ()>),
|
||||
/*priv*/ StorePrefetchedImageData(Url, Result<Cell<~[u8]>, ()>),
|
||||
|
||||
/// Tell the cache to decode an image. Must be posted before GetImage/WaitForImage
|
||||
Decode(url),
|
||||
Decode(Url),
|
||||
|
||||
/// Used by the decoder tasks to post decoded images back to the cache
|
||||
/*priv*/ StoreImage(url, Option<ARC<~Image>>),
|
||||
/*priv*/ StoreImage(Url, Option<ARC<~Image>>),
|
||||
|
||||
/// Request an Image object for a URL. If the image is not is not immediately
|
||||
/// available then ImageNotReady is returned.
|
||||
GetImage(url, Chan<ImageResponseMsg>),
|
||||
GetImage(Url, Chan<ImageResponseMsg>),
|
||||
|
||||
/// Wait for an image to become available (or fail to load).
|
||||
WaitForImage(url, Chan<ImageResponseMsg>),
|
||||
WaitForImage(Url, Chan<ImageResponseMsg>),
|
||||
|
||||
/// For testing
|
||||
/*priv*/ OnMsg(fn~(msg: &Msg)),
|
||||
|
@ -203,18 +203,18 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn get_state(+url: url) -> ImageState {
|
||||
/*priv*/ fn get_state(+url: Url) -> ImageState {
|
||||
match self.state_map.find(url) {
|
||||
Some(state) => state,
|
||||
None => Init
|
||||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn set_state(+url: url, state: ImageState) {
|
||||
/*priv*/ fn set_state(+url: Url, state: ImageState) {
|
||||
self.state_map.insert(url, state);
|
||||
}
|
||||
|
||||
/*priv*/ fn prefetch(+url: url) {
|
||||
/*priv*/ fn prefetch(+url: Url) {
|
||||
match self.get_state(copy url) {
|
||||
Init => {
|
||||
let to_cache = self.from_client.chan();
|
||||
|
@ -249,7 +249,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn store_prefetched_image_data(+url: url, data: &Result<Cell<~[u8]>, ()>) {
|
||||
/*priv*/ fn store_prefetched_image_data(+url: Url, data: &Result<Cell<~[u8]>, ()>) {
|
||||
match self.get_state(copy url) {
|
||||
Prefetching(next_step) => {
|
||||
match *data {
|
||||
|
@ -278,7 +278,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn decode(+url: url) {
|
||||
/*priv*/ fn decode(+url: Url) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"decoding image before prefetch",
|
||||
|
@ -324,7 +324,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn store_image(+url: url, image: &Option<ARC<~Image>>) {
|
||||
/*priv*/ fn store_image(+url: Url, image: &Option<ARC<~Image>>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Decoding => {
|
||||
|
@ -351,7 +351,7 @@ impl ImageCache {
|
|||
|
||||
}
|
||||
|
||||
/*priv*/ fn purge_waiters(+url: url, f: fn() -> ImageResponseMsg) {
|
||||
/*priv*/ fn purge_waiters(+url: Url, f: fn() -> ImageResponseMsg) {
|
||||
match self.wait_map.find(copy url) {
|
||||
Some(@waiters) => {
|
||||
for waiters.each |response| {
|
||||
|
@ -364,7 +364,7 @@ impl ImageCache {
|
|||
}
|
||||
|
||||
|
||||
/*priv*/ fn get_image(+url: url, response: Chan<ImageResponseMsg>) {
|
||||
/*priv*/ fn get_image(+url: Url, response: Chan<ImageResponseMsg>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"request for image before prefetch",
|
||||
|
@ -390,7 +390,7 @@ impl ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
/*priv*/ fn wait_for_image(+url: url, response: Chan<ImageResponseMsg>) {
|
||||
/*priv*/ fn wait_for_image(+url: Url, response: Chan<ImageResponseMsg>) {
|
||||
|
||||
match self.get_state(copy url) {
|
||||
Init => fail ~"request for image before prefetch",
|
||||
|
@ -438,7 +438,7 @@ impl ImageCacheTask: ImageCacheTaskClient {
|
|||
|
||||
}
|
||||
|
||||
fn load_image_data(+url: url, resource_task: ResourceTask) -> Result<~[u8], ()> {
|
||||
fn load_image_data(+url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
|
||||
let response_port = Port();
|
||||
resource_task.send(resource_task::Load(url, response_port.chan()));
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ export ResourceTask, ResourceManager, LoaderTaskFactory;
|
|||
|
||||
import comm::{Chan, Port};
|
||||
import task::{spawn, spawn_listener};
|
||||
import std::net::url;
|
||||
import std::net::url::url;
|
||||
import std::net::url::{Url, to_str};
|
||||
|
||||
enum ControlMsg {
|
||||
/// Request the data associated with a particular URL
|
||||
Load(url, Chan<ProgressMsg>),
|
||||
Load(Url, Chan<ProgressMsg>),
|
||||
Exit
|
||||
}
|
||||
|
||||
|
@ -48,7 +47,7 @@ Creates a task to load a specific resource
|
|||
The ResourceManager delegates loading to a different type of loader task for
|
||||
each URL scheme
|
||||
*/
|
||||
type LoaderTaskFactory = fn~(+url: url, Chan<ProgressMsg>);
|
||||
type LoaderTaskFactory = fn~(+url: Url, Chan<ProgressMsg>);
|
||||
|
||||
/// Create a ResourceTask with the default loaders
|
||||
fn ResourceTask() -> ResourceTask {
|
||||
|
@ -89,11 +88,11 @@ struct ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn load(+url: url, progress_chan: Chan<ProgressMsg>) {
|
||||
fn load(+url: Url, progress_chan: Chan<ProgressMsg>) {
|
||||
|
||||
match self.get_loader_factory(url) {
|
||||
Some(loader_factory) => {
|
||||
#debug("resource_task: loading url: %s", url::to_str(url));
|
||||
#debug("resource_task: loading url: %s", to_str(url));
|
||||
loader_factory(url, progress_chan);
|
||||
}
|
||||
None => {
|
||||
|
@ -103,7 +102,7 @@ struct ResourceManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_loader_factory(url: url) -> Option<LoaderTaskFactory> {
|
||||
fn get_loader_factory(url: Url) -> Option<LoaderTaskFactory> {
|
||||
for self.loaders.each |scheme_loader| {
|
||||
let (scheme, loader_factory) = copy scheme_loader;
|
||||
if scheme == url.scheme {
|
||||
|
|
|
@ -37,10 +37,10 @@ fn hsla(h : float, s : float, l : float, a : float) -> Color {
|
|||
let h = if h < 0.0 { h + 1.0 } else if h > 1.0 { h - 1.0 } else { h };
|
||||
|
||||
match h {
|
||||
0.0 to 1.0/6.0 => m1 + (m2 - m1)*h*6.0,
|
||||
1.0/6.0 to 1.0/2.0 => m2,
|
||||
1.0/2.0 to 2.0/3.0 => m1 + (m2 - m1)*(4.0 - 6.0*h),
|
||||
2.0/3.0 to 1.0 => return m1,
|
||||
0.0 .. 1.0/6.0 => m1 + (m2 - m1)*h*6.0,
|
||||
1.0/6.0 .. 1.0/2.0 => m2,
|
||||
1.0/2.0 .. 2.0/3.0 => m1 + (m2 - m1)*(4.0 - 6.0*h),
|
||||
2.0/3.0 .. 1.0 => return m1,
|
||||
_ => fail ~"unexpected hue value"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export make_url, UrlMap, url_map;
|
||||
|
||||
import std::net::url;
|
||||
import url::{get_scheme, url};
|
||||
import std::net::url::Url;
|
||||
import std::map::hashmap;
|
||||
import path::Path;
|
||||
|
||||
|
@ -15,8 +15,8 @@ Create a URL object from a string. Does various helpful browsery things like
|
|||
|
||||
*/
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn make_url(str_url: ~str, current_url: Option<url>) -> url {
|
||||
let mut schm = get_scheme(str_url);
|
||||
fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||
let mut schm = url::get_scheme(str_url);
|
||||
let str_url = if result::is_err(schm) {
|
||||
if current_url.is_none() {
|
||||
// If all we have is a filename, assume it's a local relative file
|
||||
|
@ -100,11 +100,11 @@ mod make_url_tests {
|
|||
|
||||
}
|
||||
|
||||
type UrlMap<T: copy> = hashmap<url, T>;
|
||||
type UrlMap<T: copy> = hashmap<Url, T>;
|
||||
|
||||
fn url_map<T: copy>() -> UrlMap<T> {
|
||||
import core::to_str::ToStr;
|
||||
|
||||
hashmap::<url, T>(|a| str::hash(&a.to_str()),
|
||||
hashmap::<Url, T>(|a| str::hash(&a.to_str()),
|
||||
|a, b| str::eq(&a.to_str(), &b.to_str()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue