mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Eliminate more warnings
This commit is contained in:
parent
495946b92b
commit
e836269b8d
13 changed files with 73 additions and 72 deletions
|
@ -142,14 +142,14 @@ impl Content {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_msg(msg: Either<ControlMsg,Event>) -> bool {
|
fn handle_msg(+msg: Either<ControlMsg,Event>) -> bool {
|
||||||
match msg {
|
match msg {
|
||||||
Left(control_msg) => self.handle_control_msg(control_msg),
|
Left(control_msg) => self.handle_control_msg(control_msg),
|
||||||
Right(event) => self.handle_event(event)
|
Right(event) => self.handle_event(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_control_msg(control_msg: ControlMsg) -> bool {
|
fn handle_control_msg(+control_msg: ControlMsg) -> bool {
|
||||||
match control_msg {
|
match control_msg {
|
||||||
ParseMsg(url) => {
|
ParseMsg(url) => {
|
||||||
debug!("content: Received url `%s` to parse", url_to_str(copy url));
|
debug!("content: Received url `%s` to parse", url_to_str(copy url));
|
||||||
|
@ -173,14 +173,14 @@ impl Content {
|
||||||
|
|
||||||
let document = Document(root, self.scope, css_rules);
|
let document = Document(root, self.scope, css_rules);
|
||||||
let window = Window(self.from_master);
|
let window = Window(self.from_master);
|
||||||
self.relayout(document, &url);
|
self.relayout(&document, &url);
|
||||||
self.document = Some(@document);
|
self.document = Some(@document);
|
||||||
self.window = Some(@window);
|
self.window = Some(@window);
|
||||||
self.doc_url = Some(copy url);
|
self.doc_url = Some(copy url);
|
||||||
|
|
||||||
let compartment = option::expect(&self.compartment, ~"TODO error checking");
|
let compartment = option::expect(&self.compartment, ~"TODO error checking");
|
||||||
compartment.define_functions(debug_fns);
|
compartment.define_functions(debug_fns);
|
||||||
define_bindings(*compartment,
|
define_bindings(compartment,
|
||||||
option::get(&self.document),
|
option::get(&self.document),
|
||||||
option::get(&self.window));
|
option::get(&self.window));
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ impl Content {
|
||||||
//TODO: support extra args. requires passing a *jsval argv
|
//TODO: support extra args. requires passing a *jsval argv
|
||||||
JS_CallFunctionValue(self.cx.ptr, thisValue, timerData.funval,
|
JS_CallFunctionValue(self.cx.ptr, thisValue, timerData.funval,
|
||||||
0, null(), ptr::to_unsafe_ptr(&rval));
|
0, null(), ptr::to_unsafe_ptr(&rval));
|
||||||
self.relayout(*option::get(&self.document), &option::get(&self.doc_url));
|
self.relayout(self.document.get(), &option::get(&self.doc_url));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ impl Content {
|
||||||
join the layout task, and then request a new layout run. It won't wait for the
|
join the layout task, and then request a new layout run. It won't wait for the
|
||||||
new layout computation to finish.
|
new layout computation to finish.
|
||||||
*/
|
*/
|
||||||
fn relayout(document: Document, doc_url: &Url) {
|
fn relayout(document: &Document, doc_url: &Url) {
|
||||||
debug!("content: performing relayout");
|
debug!("content: performing relayout");
|
||||||
|
|
||||||
// Now, join the layout so that they will see the latest
|
// Now, join the layout so that they will see the latest
|
||||||
|
@ -266,7 +266,7 @@ impl Content {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_layout(query: layout_task::LayoutQuery) -> layout_task::LayoutQueryResponse {
|
fn query_layout(query: layout_task::LayoutQuery) -> layout_task::LayoutQueryResponse {
|
||||||
self.relayout(*self.document.get(), &self.doc_url.get());
|
self.relayout(self.document.get(), &self.doc_url.get());
|
||||||
self.join_layout();
|
self.join_layout();
|
||||||
|
|
||||||
let response_port = Port();
|
let response_port = Port();
|
||||||
|
@ -288,7 +288,7 @@ impl Content {
|
||||||
}
|
}
|
||||||
Some(document) => {
|
Some(document) => {
|
||||||
assert self.doc_url.is_some();
|
assert self.doc_url.is_some();
|
||||||
self.relayout(*document, &self.doc_url.get());
|
self.relayout(document, &self.doc_url.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -301,7 +301,7 @@ impl Content {
|
||||||
}
|
}
|
||||||
Some(document) => {
|
Some(document) => {
|
||||||
assert self.doc_url.is_some();
|
assert self.doc_url.is_some();
|
||||||
self.relayout(*document, &self.doc_url.get());
|
self.relayout(document, &self.doc_url.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -119,7 +119,7 @@ impl Node : StyleMethods {
|
||||||
fail ~"get_style() called on a node without a style!";
|
fail ~"get_style() called on a node without a style!";
|
||||||
}
|
}
|
||||||
// TODO: return a safe reference; don't copy!
|
// TODO: return a safe reference; don't copy!
|
||||||
return copy *self.aux(|x| copy x).style;
|
return copy *self.aux(|x| copy *x).style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,7 +88,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(compartment: bare_compartment, doc: @Document) {
|
pub fn init(compartment: &bare_compartment, doc: @Document) {
|
||||||
let obj = utils::define_empty_prototype(~"Document", None, compartment);
|
let obj = utils::define_empty_prototype(~"Document", None, compartment);
|
||||||
|
|
||||||
let attrs = @~[
|
let attrs = @~[
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(compartment: bare_compartment) {
|
pub fn init(compartment: &bare_compartment) {
|
||||||
let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment);
|
let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment);
|
||||||
let attrs = @~[
|
let attrs = @~[
|
||||||
{name: compartment.add_name(~"tagName"),
|
{name: compartment.add_name(~"tagName"),
|
||||||
|
@ -74,7 +74,7 @@ extern fn HTMLImageElement_getWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
|
||||||
let bundle = unwrap(obj);
|
let bundle = unwrap(obj);
|
||||||
let node = (*bundle).payload.node;
|
let node = (*bundle).payload.node;
|
||||||
let scope = (*bundle).payload.scope;
|
let scope = (*bundle).payload.scope;
|
||||||
let width = scope.write(node, |nd| {
|
let width = scope.write(&node, |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(ed) => {
|
~Element(ed) => {
|
||||||
match ed.kind {
|
match ed.kind {
|
||||||
|
@ -105,7 +105,7 @@ extern fn HTMLImageElement_setWidth(cx: *JSContext, _argc: c_uint, vp: *mut jsva
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundle = unwrap(obj);
|
let bundle = unwrap(obj);
|
||||||
do (*bundle).payload.scope.write((*bundle).payload.node) |nd| {
|
do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(ed) => {
|
~Element(ed) => {
|
||||||
match ed.kind {
|
match ed.kind {
|
||||||
|
@ -131,11 +131,11 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundle = unwrap(obj);
|
let bundle = unwrap(obj);
|
||||||
do (*bundle).payload.scope.write((*bundle).payload.node) |nd| {
|
do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(ed) => {
|
~Element(ed) => {
|
||||||
let s = str(copy ed.tag_name);
|
let s = str(copy ed.tag_name);
|
||||||
*vp = domstring_to_jsval(cx, s);
|
*vp = domstring_to_jsval(cx, &s);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
//XXXjdm should probably read the spec to figure out what to do here
|
//XXXjdm should probably read the spec to figure out what to do here
|
||||||
|
@ -148,7 +148,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut jsval)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
|
pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
|
||||||
let proto = scope.write(node, |nd| {
|
let proto = scope.write(&node, |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(ed) => {
|
~Element(ed) => {
|
||||||
match ed.kind {
|
match ed.kind {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use utils::{rust_box, squirrel_away_unique, get_compartment, domstring_to_jsval,
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use ptr::null;
|
use ptr::null;
|
||||||
|
|
||||||
pub fn init(compartment: bare_compartment) {
|
pub fn init(compartment: &bare_compartment) {
|
||||||
let obj = utils::define_empty_prototype(~"Node", None, compartment);
|
let obj = utils::define_empty_prototype(~"Node", None, compartment);
|
||||||
|
|
||||||
let attrs = @~[
|
let attrs = @~[
|
||||||
|
@ -42,7 +42,7 @@ pub fn init(compartment: bare_compartment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
|
pub fn create(cx: *JSContext, node: Node, scope: NodeScope) -> jsobj unsafe {
|
||||||
do scope.write(node) |nd| {
|
do scope.write(&node) |nd| {
|
||||||
match nd.kind {
|
match nd.kind {
|
||||||
~Element(*) => {
|
~Element(*) => {
|
||||||
element::create(cx, node, scope)
|
element::create(cx, node, scope)
|
||||||
|
@ -85,7 +85,7 @@ extern fn getFirstChild(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBool
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundle = unwrap(obj);
|
let bundle = unwrap(obj);
|
||||||
do (*bundle).payload.scope.write((*bundle).payload.node) |nd| {
|
do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
|
||||||
match nd.tree.first_child {
|
match nd.tree.first_child {
|
||||||
Some(n) => {
|
Some(n) => {
|
||||||
let obj = create(cx, n, (*bundle).payload.scope).ptr;
|
let obj = create(cx, n, (*bundle).payload.scope).ptr;
|
||||||
|
@ -108,7 +108,7 @@ extern fn getNextSibling(cx: *JSContext, _argc: c_uint, vp: *mut jsval) -> JSBoo
|
||||||
}
|
}
|
||||||
|
|
||||||
let bundle = unwrap(obj);
|
let bundle = unwrap(obj);
|
||||||
do (*bundle).payload.scope.write((*bundle).payload.node) |nd| {
|
do (*bundle).payload.scope.write(&(*bundle).payload.node) |nd| {
|
||||||
match nd.tree.next_sibling {
|
match nd.tree.next_sibling {
|
||||||
Some(n) => {
|
Some(n) => {
|
||||||
let obj = create(cx, n, (*bundle).payload.scope).ptr;
|
let obj = create(cx, n, (*bundle).payload.scope).ptr;
|
||||||
|
|
|
@ -56,8 +56,8 @@ fn jsval_to_str(cx: *JSContext, v: jsval) -> Result<~str, ()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn domstring_to_jsval(cx: *JSContext, str: DOMString) -> jsval {
|
unsafe fn domstring_to_jsval(cx: *JSContext, str: &DOMString) -> jsval {
|
||||||
match str {
|
match *str {
|
||||||
null_string => {
|
null_string => {
|
||||||
JSVAL_NULL
|
JSVAL_NULL
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,8 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *jsval, bp: *mut JSB
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prototype_jsclass(name: ~str) -> fn(+compartment: bare_compartment) -> JSClass {
|
pub fn prototype_jsclass(+name: ~str) -> fn(+compartment: bare_compartment) -> JSClass {
|
||||||
|+compartment: bare_compartment, copy name| {
|
|+compartment: bare_compartment| {
|
||||||
{name: compartment.add_name(name),
|
{name: compartment.add_name(name),
|
||||||
flags: 0,
|
flags: 0,
|
||||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||||
|
@ -122,9 +122,9 @@ pub fn prototype_jsclass(name: ~str) -> fn(+compartment: bare_compartment) -> JS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instance_jsclass(name: ~str, finalize: *u8)
|
pub fn instance_jsclass(+name: ~str, finalize: *u8)
|
||||||
-> fn(+compartment: bare_compartment) -> JSClass {
|
-> fn(+compartment: bare_compartment) -> JSClass {
|
||||||
|+compartment: bare_compartment, copy name| {
|
|+compartment: bare_compartment| {
|
||||||
{name: compartment.add_name(name),
|
{name: compartment.add_name(name),
|
||||||
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||||
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
|
||||||
|
@ -151,7 +151,7 @@ pub fn instance_jsclass(name: ~str, finalize: *u8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: bare_compartment)
|
pub fn define_empty_prototype(+name: ~str, +proto: Option<~str>, compartment: &bare_compartment)
|
||||||
-> js::rust::jsobj {
|
-> js::rust::jsobj {
|
||||||
compartment.register_class(utils::prototype_jsclass(name));
|
compartment.register_class(utils::prototype_jsclass(name));
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(compartment: bare_compartment, win: @Window) {
|
pub fn init(compartment: &bare_compartment, win: @Window) {
|
||||||
let proto = utils::define_empty_prototype(~"Window", None, compartment);
|
let proto = utils::define_empty_prototype(~"Window", None, compartment);
|
||||||
compartment.register_class(utils::instance_jsclass(~"WindowInstance", finalize));
|
compartment.register_class(utils::instance_jsclass(~"WindowInstance", finalize));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct Document {
|
||||||
css_rules: ARC<Stylesheet>,
|
css_rules: ARC<Stylesheet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Document(root: Node, scope: NodeScope, -css_rules: Stylesheet) -> Document {
|
fn Document(+root: Node, +scope: NodeScope, +css_rules: Stylesheet) -> Document {
|
||||||
Document {
|
Document {
|
||||||
root : root,
|
root : root,
|
||||||
scope : scope,
|
scope : scope,
|
||||||
|
|
|
@ -11,24 +11,24 @@ struct ElementData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ElementData {
|
impl ElementData {
|
||||||
fn get_attr(name: ~str) -> Option<~str> {
|
fn get_attr(name: &str) -> Option<~str> {
|
||||||
let found = do self.attrs.find |attr| { attr.name == name };
|
let found = do self.attrs.find |attr| { name == attr.name };
|
||||||
match found {
|
match found {
|
||||||
Some(attr) => Some(copy attr.value),
|
Some(attr) => Some(copy attr.value),
|
||||||
None => None
|
None => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_attr(name: ~str, value: ~str) {
|
fn set_attr(name: &str, +value: ~str) {
|
||||||
let idx = do self.attrs.position |attr| { attr.name == name };
|
let idx = do self.attrs.position |attr| { name == attr.name };
|
||||||
match idx {
|
match idx {
|
||||||
Some(idx) => self.attrs.set_elt(idx, ~Attr(name, value)),
|
Some(idx) => self.attrs.set_elt(idx, ~Attr(name.to_str(), value)),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ElementData(tag_name: ~str, kind: ~ElementKind) -> ElementData {
|
fn ElementData(+tag_name: ~str, +kind: ~ElementKind) -> ElementData {
|
||||||
ElementData {
|
ElementData {
|
||||||
tag_name : tag_name,
|
tag_name : tag_name,
|
||||||
kind : kind,
|
kind : kind,
|
||||||
|
@ -41,7 +41,7 @@ struct Attr {
|
||||||
value: ~str,
|
value: ~str,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Attr(name: ~str, value: ~str) -> Attr {
|
fn Attr(+name: ~str, +value: ~str) -> Attr {
|
||||||
Attr {
|
Attr {
|
||||||
name : name,
|
name : name,
|
||||||
value : value,
|
value : value,
|
||||||
|
|
|
@ -53,8 +53,8 @@ impl Node {
|
||||||
with a generic implementation of rcu::Handle */
|
with a generic implementation of rcu::Handle */
|
||||||
impl Node : cmp::Eq {
|
impl Node : cmp::Eq {
|
||||||
pure fn eq(other : &Node) -> bool unsafe {
|
pure fn eq(other : &Node) -> bool unsafe {
|
||||||
let my_data : @LayoutData = @self.aux(|a| a);
|
let my_data : @LayoutData = @self.aux(|a| *a);
|
||||||
let ot_data : @LayoutData = @other.aux(|a| a);
|
let ot_data : @LayoutData = @other.aux(|a| *a);
|
||||||
core::box::ptr_eq(my_data, ot_data)
|
core::box::ptr_eq(my_data, ot_data)
|
||||||
}
|
}
|
||||||
pure fn ne(other : &Node) -> bool unsafe {
|
pure fn ne(other : &Node) -> bool unsafe {
|
||||||
|
@ -101,8 +101,8 @@ struct DoctypeData {
|
||||||
force_quirks: bool
|
force_quirks: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
fn DoctypeData(name: ~str, public_id: Option<~str>,
|
fn DoctypeData(+name: ~str, +public_id: Option<~str>,
|
||||||
system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
|
+system_id: Option<~str>, force_quirks: bool) -> DoctypeData {
|
||||||
DoctypeData {
|
DoctypeData {
|
||||||
name : name,
|
name : name,
|
||||||
public_id : public_id,
|
public_id : public_id,
|
||||||
|
@ -113,7 +113,7 @@ fn DoctypeData(name: ~str, public_id: Option<~str>,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn define_bindings(compartment: bare_compartment, doc: @Document,
|
fn define_bindings(compartment: &bare_compartment, doc: @Document,
|
||||||
win: @Window) {
|
win: @Window) {
|
||||||
bindings::window::init(compartment, win);
|
bindings::window::init(compartment, win);
|
||||||
bindings::document::init(compartment, doc);
|
bindings::document::init(compartment, doc);
|
||||||
|
@ -141,13 +141,13 @@ fn NodeScope() -> NodeScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait NodeScopeExtensions {
|
trait NodeScopeExtensions {
|
||||||
fn new_node(-k: NodeKind) -> Node;
|
fn new_node(+k: NodeKind) -> Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
impl NodeScope : NodeScopeExtensions {
|
impl NodeScope : NodeScopeExtensions {
|
||||||
fn new_node(-k: NodeKind) -> Node {
|
fn new_node(+k: NodeKind) -> Node {
|
||||||
self.handle(NodeData({tree: tree::empty(), kind: ~k}))
|
self.handle(&NodeData({tree: tree::empty(), kind: ~k}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ impl NodeScope : tree::ReadMethods<Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
|
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
|
||||||
self.read(*node, |n| f(&n.tree))
|
self.read(node, |n| f(&n.tree))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +173,6 @@ impl NodeScope : tree::WriteMethods<Node> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
|
fn with_tree_fields<R>(node: &Node, f: fn(&tree::Tree<Node>) -> R) -> R {
|
||||||
self.write(*node, |n| f(&n.tree))
|
self.write(node, |n| f(&n.tree))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct ScopeResource<T:Send,A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ScopeResource<T:Send,A>(d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
fn ScopeResource<T:Send,A>(+d : ScopeData<T,A>) -> ScopeResource<T,A> {
|
||||||
ScopeResource { d: d }
|
ScopeResource { d: d }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ impl<T:Send,A> Handle<T,A> {
|
||||||
|
|
||||||
impl<T:Send,A> Handle<T,A> {
|
impl<T:Send,A> Handle<T,A> {
|
||||||
#[doc(str = "Access the reader's view of the handle's data.")]
|
#[doc(str = "Access the reader's view of the handle's data.")]
|
||||||
fn read<U>(f: fn(T) -> U) -> U unsafe {
|
fn read<U>(f: fn(&T) -> U) -> U unsafe {
|
||||||
f(*self.read_ptr())
|
f(&*self.read_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(str = "True if auxiliary data is associated with this handle.")]
|
#[doc(str = "True if auxiliary data is associated with this handle.")]
|
||||||
|
@ -117,9 +117,9 @@ impl<T:Send,A> Handle<T,A> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(str = "access the auxiliary data associated with this handle.")]
|
#[doc(str = "access the auxiliary data associated with this handle.")]
|
||||||
fn aux<U>(f: fn(A) -> U) -> U unsafe {
|
fn aux<U>(f: fn(&A) -> U) -> U unsafe {
|
||||||
assert self.has_aux();
|
assert self.has_aux();
|
||||||
f(*self.read_aux())
|
f(&*self.read_aux())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,29 +192,30 @@ impl<T:Copy Send,A> Scope<T,A> {
|
||||||
self.d.layout_active = false;
|
self.d.layout_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read<U>(h: Handle<T,A>, f: fn(T) -> U) -> U unsafe {
|
fn read<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U unsafe {
|
||||||
// Use the write_ptr, which may be more up to date than the read_ptr or may not
|
// Use the write_ptr, which may be more up to date than the read_ptr or may not
|
||||||
f(*h.write_ptr())
|
f(&*h.write_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write<U>(h: Handle<T,A>, f: fn(T) -> U) -> U unsafe {
|
fn write<U>(h: &Handle<T,A>, f: fn(&T) -> U) -> U unsafe {
|
||||||
let const_read_ptr = ptr::const_offset(h.read_ptr(), 0);
|
let const_read_ptr = ptr::const_offset(h.read_ptr(), 0);
|
||||||
let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
|
let const_write_ptr = ptr::const_offset(h.write_ptr(), 0);
|
||||||
if self.d.layout_active && const_read_ptr == const_write_ptr {
|
if self.d.layout_active && const_read_ptr == const_write_ptr {
|
||||||
#debug["marking handle %? as dirty", h];
|
#debug["marking handle %? as dirty", h];
|
||||||
h.set_write_ptr(cast::reinterpret_cast(&self.clone(h.read_ptr())));
|
h.set_write_ptr(cast::reinterpret_cast(&self.clone(h.read_ptr())));
|
||||||
h.set_next_dirty(self.d.first_dirty);
|
h.set_next_dirty(self.d.first_dirty);
|
||||||
self.d.first_dirty = h;
|
self.d.first_dirty = *h;
|
||||||
}
|
}
|
||||||
f(*h.write_ptr())
|
f(&*h.write_ptr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: This could avoid a deep copy by taking ownership of `v`
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
fn handle(v: T) -> Handle<T,A> unsafe {
|
fn handle(v: &T) -> Handle<T,A> unsafe {
|
||||||
let d: *HandleData<T,A> =
|
let d: *HandleData<T,A> =
|
||||||
cast::reinterpret_cast(
|
cast::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::to_unsafe_ptr(&v));
|
(*d).read_ptr = self.clone(ptr::to_unsafe_ptr(v));
|
||||||
(*d).write_ptr = cast::reinterpret_cast(&(*d).read_ptr);
|
(*d).write_ptr = cast::reinterpret_cast(&(*d).read_ptr);
|
||||||
(*d).read_aux = ptr::null();
|
(*d).read_aux = ptr::null();
|
||||||
(*d).next_dirty = null_handle();
|
(*d).next_dirty = null_handle();
|
||||||
|
@ -242,18 +243,18 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn handles_get_freed() {
|
fn handles_get_freed() {
|
||||||
let s: animal_scope = Scope();
|
let s: animal_scope = Scope();
|
||||||
s.handle({name:~"henrietta", species:chicken(~{mut eggs_per_day:22u})});
|
s.handle(&{name:~"henrietta", species:chicken(~{mut eggs_per_day:22u})});
|
||||||
s.handle({name:~"ferdinand", species:bull(~{mut horns:3u})});
|
s.handle(&{name:~"ferdinand", species:bull(~{mut horns:3u})});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate(a: animal) {
|
fn mutate(a: &animal) {
|
||||||
match a.species {
|
match a.species {
|
||||||
chicken(c) => c.eggs_per_day += 1u,
|
chicken(c) => c.eggs_per_day += 1u,
|
||||||
bull(c) => c.horns += 1u
|
bull(c) => c.horns += 1u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_characteristic(a: animal) -> uint {
|
fn read_characteristic(a: &animal) -> uint {
|
||||||
match a.species {
|
match a.species {
|
||||||
chicken(c) => c.eggs_per_day,
|
chicken(c) => c.eggs_per_day,
|
||||||
bull(c) => c.horns
|
bull(c) => c.horns
|
||||||
|
@ -264,10 +265,10 @@ mod test {
|
||||||
fn interspersed_execution() {
|
fn interspersed_execution() {
|
||||||
let s: animal_scope = Scope();
|
let s: animal_scope = Scope();
|
||||||
let henrietta =
|
let henrietta =
|
||||||
s.handle({name:~"henrietta",
|
s.handle(&{name:~"henrietta",
|
||||||
species:chicken(~{mut eggs_per_day:0u})});
|
species:chicken(~{mut eggs_per_day:0u})});
|
||||||
let ferdinand =
|
let ferdinand =
|
||||||
s.handle({name:~"ferdinand",
|
s.handle(&{name:~"ferdinand",
|
||||||
species:bull(~{mut horns:0u})});
|
species:bull(~{mut horns:0u})});
|
||||||
|
|
||||||
let iter1 = 3u;
|
let iter1 = 3u;
|
||||||
|
@ -294,9 +295,9 @@ mod test {
|
||||||
|
|
||||||
for uint::range(0u, iter2) |_i| {
|
for uint::range(0u, iter2) |_i| {
|
||||||
assert hrc == comm::recv(read_port);
|
assert hrc == comm::recv(read_port);
|
||||||
s.write(henrietta, mutate);
|
s.write(&henrietta, mutate);
|
||||||
assert frc == comm::recv(read_port);
|
assert frc == comm::recv(read_port);
|
||||||
s.write(ferdinand, mutate);
|
s.write(&ferdinand, mutate);
|
||||||
comm::send(wait_chan, ());
|
comm::send(wait_chan, ());
|
||||||
}
|
}
|
||||||
s.reader_joined();
|
s.reader_joined();
|
||||||
|
|
|
@ -22,9 +22,9 @@ pub struct Engine<C:Compositor Send Copy> {
|
||||||
content_task: ContentTask
|
content_task: ContentTask
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Engine<C:Compositor Send Copy>(compositor: C,
|
pub fn Engine<C:Compositor Send Copy>(+compositor: C,
|
||||||
resource_task: ResourceTask,
|
+resource_task: ResourceTask,
|
||||||
image_cache_task: ImageCacheTask) -> Engine<C> {
|
+image_cache_task: ImageCacheTask) -> Engine<C> {
|
||||||
let render_task = RenderTask(compositor);
|
let render_task = RenderTask(compositor);
|
||||||
let layout_task = LayoutTask(render_task, image_cache_task);
|
let layout_task = LayoutTask(render_task, image_cache_task);
|
||||||
let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task);
|
let content_task = ContentTask(layout_task, compositor, resource_task, image_cache_task);
|
||||||
|
@ -48,7 +48,7 @@ impl<C: Compositor Copy Send> Engine<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_request(request: Msg) -> bool {
|
fn handle_request(+request: Msg) -> bool {
|
||||||
match request {
|
match request {
|
||||||
LoadURLMsg(url) => {
|
LoadURLMsg(url) => {
|
||||||
// TODO: change copy to move once we have match move
|
// TODO: change copy to move once we have match move
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl Layout {
|
||||||
match query {
|
match query {
|
||||||
ContentBox(node) => {
|
ContentBox(node) => {
|
||||||
// TODO: extract me to a method when I get sibling arms
|
// TODO: extract me to a method when I get sibling arms
|
||||||
let response = match node.aux(|a| a).flow {
|
let response = match node.aux(|a| *a).flow {
|
||||||
None => Err(()),
|
None => Err(()),
|
||||||
Some(flow) => {
|
Some(flow) => {
|
||||||
let start_val : Option<Rect<au>> = None;
|
let start_val : Option<Rect<au>> = None;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue