Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.

This commit is contained in:
Ms2ger 2015-01-02 12:45:28 +01:00 committed by Josh Matthews
parent cf616b90a2
commit 16c7060bc8
153 changed files with 2095 additions and 1298 deletions

View file

@ -20,7 +20,7 @@ pub trait Actor : Any {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()>;
fn name(&self) -> String;
}
@ -149,14 +149,14 @@ impl ActorRegistry {
/// Attempt to process a message as directed by its `to` property. If the actor is not
/// found or does not indicate that it knew how to process the message, ignore the failure.
pub fn handle_message(&mut self,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream)
-> Result<(), ()> {
let to = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
let to = msg.get("to").unwrap().as_string().unwrap();
match self.actors.get(&to.to_string()) {
None => println!("message received for unknown actor \"{}\"", to),
Some(actor) => {
let msg_type = msg.get(&"type".to_string()).unwrap().as_string().unwrap();
let msg_type = msg.get("type").unwrap().as_string().unwrap();
if !try!(actor.handle_message(self, &msg_type.to_string(), msg, stream)) {
println!("unexpected message type \"{}\" found for actor \"{}\"",
msg_type, to);

View file

@ -15,8 +15,7 @@ use servo_msg::constellation_msg::PipelineId;
use collections::TreeMap;
use core::cell::RefCell;
use serialize::json;
use serialize::json::ToJson;
use serialize::json::{mod, Json, ToJson};
use std::io::TcpStream;
use std::num::Float;
@ -76,7 +75,7 @@ enum ConsoleMessageType {
#[deriving(Encodable)]
struct GetCachedMessagesReply {
from: String,
messages: Vec<json::JsonObject>,
messages: Vec<json::Object>,
}
#[deriving(Encodable)]
@ -96,11 +95,11 @@ struct AutocompleteReply {
struct EvaluateJSReply {
from: String,
input: String,
result: json::Json,
result: Json,
timestamp: uint,
exception: json::Json,
exception: Json,
exceptionMessage: String,
helperResult: json::Json,
helperResult: Json,
}
pub struct ConsoleActor {
@ -118,11 +117,11 @@ impl Actor for ConsoleActor {
fn handle_message(&self,
_registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"getCachedMessages" => {
let types = msg.get(&"messageTypes".to_string()).unwrap().as_list().unwrap();
let types = msg.get(&"messageTypes".to_string()).unwrap().as_array().unwrap();
let /*mut*/ messages = vec!();
for msg_type in types.iter() {
let msg_type = msg_type.as_string().unwrap();
@ -196,7 +195,7 @@ impl Actor for ConsoleActor {
from: self.name(),
stoppedListeners: msg.get(&"listeners".to_string())
.unwrap()
.as_list()
.as_array()
.unwrap_or(&vec!())
.iter()
.map(|listener| listener.as_string().unwrap().to_string())
@ -228,19 +227,19 @@ impl Actor for ConsoleActor {
VoidValue => {
let mut m = TreeMap::new();
m.insert("type".to_string(), "undefined".to_string().to_json());
json::Object(m)
Json::Object(m)
}
NullValue => {
let mut m = TreeMap::new();
m.insert("type".to_string(), "null".to_string().to_json());
json::Object(m)
Json::Object(m)
}
BooleanValue(val) => val.to_json(),
NumberValue(val) => {
if val.is_nan() {
let mut m = TreeMap::new();
m.insert("type".to_string(), "NaN".to_string().to_json());
json::Object(m)
Json::Object(m)
} else if val.is_infinite() {
let mut m = TreeMap::new();
if val < 0. {
@ -248,11 +247,11 @@ impl Actor for ConsoleActor {
} else {
m.insert("type".to_string(), "Infinity".to_string().to_json());
}
json::Object(m)
Json::Object(m)
} else if val == Float::neg_zero() {
let mut m = TreeMap::new();
m.insert("type".to_string(), "-0".to_string().to_json());
json::Object(m)
Json::Object(m)
} else {
val.to_json()
}
@ -267,7 +266,7 @@ impl Actor for ConsoleActor {
m.insert("extensible".to_string(), true.to_json());
m.insert("frozen".to_string(), false.to_json());
m.insert("sealed".to_string(), false.to_json());
json::Object(m)
Json::Object(m)
}
};
@ -277,9 +276,9 @@ impl Actor for ConsoleActor {
input: input,
result: result,
timestamp: 0,
exception: json::Object(TreeMap::new()),
exception: Json::Object(TreeMap::new()),
exceptionMessage: "".to_string(),
helperResult: json::Object(TreeMap::new()),
helperResult: Json::Object(TreeMap::new()),
};
stream.write_json_packet(&msg);
true

View file

@ -12,8 +12,7 @@ use protocol::JsonPacketStream;
use collections::TreeMap;
use servo_msg::constellation_msg::PipelineId;
use serialize::json;
use serialize::json::ToJson;
use serialize::json::{mod, Json, ToJson};
use std::cell::RefCell;
use std::io::TcpStream;
use std::num::Float;
@ -66,7 +65,7 @@ impl Actor for HighlighterActor {
fn handle_message(&self,
_registry: &ActorRegistry,
msg_type: &String,
_msg: &json::JsonObject,
_msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"showBoxModel" => {
@ -103,12 +102,12 @@ impl Actor for NodeActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"modifyAttributes" => {
let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
let mods = msg.get(&"modifications".to_string()).unwrap().as_list().unwrap();
let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap();
let modifications = mods.iter().map(|json_mod| {
json::decode(json_mod.to_string().as_slice()).unwrap()
}).collect();
@ -276,7 +275,7 @@ impl Actor for WalkerActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"querySelector" => {
@ -368,7 +367,7 @@ struct GetComputedReply {
#[deriving(Encodable)]
struct AppliedEntry {
rule: String,
pseudoElement: json::Json,
pseudoElement: Json,
isSystem: bool,
matchedSelectors: Vec<String>,
}
@ -400,7 +399,7 @@ struct AppliedSheet {
struct GetLayoutReply {
width: int,
height: int,
autoMargins: json::Json,
autoMargins: Json,
from: String,
}
@ -421,7 +420,7 @@ impl Actor for PageStyleActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
msg: &json::JsonObject,
msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"getApplied" => {
@ -469,9 +468,9 @@ impl Actor for PageStyleActor {
m.insert("bottom".to_string(), "auto".to_string().to_json());
m.insert("left".to_string(), "auto".to_string().to_json());
m.insert("right".to_string(), "auto".to_string().to_json());
json::Object(m)
Json::Object(m)
} else {
json::Null
Json::Null
},
from: self.name(),
};
@ -492,7 +491,7 @@ impl Actor for InspectorActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
_msg: &json::JsonObject,
_msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"getWalker" => {

View file

@ -53,7 +53,7 @@ impl Actor for RootActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
_msg: &json::JsonObject,
_msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"listAddons" => {

View file

@ -77,7 +77,7 @@ impl Actor for TabActor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
_msg: &json::JsonObject,
_msg: &json::Object,
stream: &mut TcpStream) -> Result<bool, ()> {
Ok(match msg_type.as_slice() {
"reconfigure" => {

View file

@ -21,7 +21,6 @@ extern crate collections;
extern crate core;
extern crate devtools_traits;
extern crate serialize;
extern crate sync;
extern crate "msg" as servo_msg;
extern crate "util" as servo_util;
@ -42,7 +41,7 @@ use std::comm;
use std::comm::{Disconnected, Empty};
use std::io::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener, TimedOut};
use sync::{Arc, Mutex};
use std::sync::{Arc, Mutex};
mod actor;
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/

View file

@ -5,12 +5,13 @@
/// Low-level wire protocol implementation. Currently only supports [JSON packets](https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets).
use serialize::{json, Encodable};
use serialize::json::Json;
use std::io::{IoError, OtherIoError, EndOfFile, TcpStream, IoResult};
use std::num;
pub trait JsonPacketStream {
fn write_json_packet<'a, T: Encodable<json::Encoder<'a>,IoError>>(&mut self, obj: &T);
fn read_json_packet(&mut self) -> IoResult<json::Json>;
fn read_json_packet(&mut self) -> IoResult<Json>;
}
impl JsonPacketStream for TcpStream {
@ -22,7 +23,7 @@ impl JsonPacketStream for TcpStream {
self.write_str(s.as_slice()).unwrap();
}
fn read_json_packet<'a>(&mut self) -> IoResult<json::Json> {
fn read_json_packet<'a>(&mut self) -> IoResult<Json> {
// https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport
// In short, each JSON packet is [ascii length]:[JSON data of given length]
let mut buffer = vec!();