mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.
This commit is contained in:
parent
7b87085c18
commit
ef8edd4e87
168 changed files with 2247 additions and 2408 deletions
|
@ -8,6 +8,7 @@ use rustc_serialize::json;
|
|||
use std::any::{Any, TypeId};
|
||||
use std::collections::HashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::marker::Reflect;
|
||||
use std::mem::{replace, transmute};
|
||||
use std::net::TcpStream;
|
||||
use std::raw::TraitObject;
|
||||
|
@ -26,10 +27,10 @@ pub trait Actor: Any {
|
|||
fn name(&self) -> String;
|
||||
}
|
||||
|
||||
impl Actor {
|
||||
impl Actor + Send {
|
||||
/// Returns true if the boxed type is the same as `T`
|
||||
#[inline]
|
||||
pub fn is<T: 'static>(&self) -> bool {
|
||||
pub fn is<T: Reflect + 'static>(&self) -> bool {
|
||||
// Get TypeId of the type this function is instantiated with
|
||||
let t = TypeId::of::<T>();
|
||||
|
||||
|
@ -43,7 +44,7 @@ impl Actor {
|
|||
/// Returns some reference to the boxed value if it is of type `T`, or
|
||||
/// `None` if it isn't.
|
||||
#[inline]
|
||||
pub fn downcast_ref<T: 'static>(&self) -> Option<&T> {
|
||||
pub fn downcast_ref<T: Reflect + 'static>(&self) -> Option<&T> {
|
||||
if self.is::<T>() {
|
||||
unsafe {
|
||||
// Get the raw representation of the trait object
|
||||
|
@ -60,7 +61,7 @@ impl Actor {
|
|||
/// Returns some mutable reference to the boxed value if it is of type `T`, or
|
||||
/// `None` if it isn't.
|
||||
#[inline]
|
||||
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> {
|
||||
pub fn downcast_mut<T: Reflect + 'static>(&mut self) -> Option<&mut T> {
|
||||
if self.is::<T>() {
|
||||
unsafe {
|
||||
// Get the raw representation of the trait object
|
||||
|
@ -168,13 +169,13 @@ impl ActorRegistry {
|
|||
}
|
||||
|
||||
/// Find an actor by registered name
|
||||
pub fn find<'a, T: 'static>(&'a self, name: &str) -> &'a T {
|
||||
pub fn find<'a, T: Reflect + 'static>(&'a self, name: &str) -> &'a T {
|
||||
let actor = self.actors.get(&name.to_string()).unwrap();
|
||||
actor.downcast_ref::<T>().unwrap()
|
||||
}
|
||||
|
||||
/// Find an actor by registered name
|
||||
pub fn find_mut<'a, T: 'static>(&'a mut self, name: &str) -> &'a mut T {
|
||||
pub fn find_mut<'a, T: Reflect + 'static>(&'a mut self, name: &str) -> &'a mut T {
|
||||
let actor = self.actors.get_mut(&name.to_string()).unwrap();
|
||||
actor.downcast_mut::<T>().unwrap()
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ use collections::BTreeMap;
|
|||
use core::cell::RefCell;
|
||||
use rustc_serialize::json::{self, Json, ToJson};
|
||||
use std::net::TcpStream;
|
||||
use std::num::Float;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
|
@ -251,7 +250,7 @@ impl Actor for ConsoleActor {
|
|||
m.insert("type".to_string(), "Infinity".to_string().to_json());
|
||||
}
|
||||
Json::Object(m)
|
||||
} else if val == Float::neg_zero() {
|
||||
} else if val == 0. && val.is_sign_negative() {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_string(), "-0".to_string().to_json());
|
||||
Json::Object(m)
|
||||
|
|
|
@ -16,7 +16,6 @@ use msg::constellation_msg::PipelineId;
|
|||
use rustc_serialize::json::{self, Json, ToJson};
|
||||
use std::cell::RefCell;
|
||||
use std::net::TcpStream;
|
||||
use std::num::Float;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
pub struct InspectorActor {
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use core::iter::FromIterator;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use rustc_serialize::{json, Encoder, Encodable};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
use std::net::TcpStream;
|
||||
use std::old_io::timer::sleep;
|
||||
use std::thread::sleep_ms;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::duration::Duration;
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use time::PreciseTime;
|
||||
|
||||
|
@ -117,7 +116,7 @@ impl Encodable for HighResolutionStamp {
|
|||
}
|
||||
}
|
||||
|
||||
static DEFAULT_TIMELINE_DATA_PULL_TIMEOUT: usize = 200; //ms
|
||||
static DEFAULT_TIMELINE_DATA_PULL_TIMEOUT: u32 = 200; //ms
|
||||
|
||||
impl TimelineActor {
|
||||
pub fn new(name: String,
|
||||
|
@ -214,7 +213,7 @@ impl TimelineActor {
|
|||
}
|
||||
emitter.send();
|
||||
|
||||
sleep(Duration::milliseconds(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT as i64));
|
||||
sleep_ms(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -344,7 +343,7 @@ impl Emitter {
|
|||
let end_time = PreciseTime::now();
|
||||
let reply = MarkersEmitterReply {
|
||||
__type__: "markers".to_string(),
|
||||
markers: Vec::from_iter(self.markers.drain()),
|
||||
markers: mem::replace(&mut self.markers, Vec::new()),
|
||||
from: self.from.clone(),
|
||||
endTime: HighResolutionStamp::new(self.start_stamp, end_time),
|
||||
};
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
#![crate_type = "rlib"]
|
||||
|
||||
#![feature(box_syntax, core, rustc_private)]
|
||||
#![feature(collections, std_misc)]
|
||||
#![feature(io)]
|
||||
#![feature(net)]
|
||||
#![feature(old_io)]
|
||||
#![feature(collections)]
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
|
@ -24,7 +21,7 @@ extern crate log;
|
|||
extern crate collections;
|
||||
extern crate core;
|
||||
extern crate devtools_traits;
|
||||
extern crate "rustc-serialize" as rustc_serialize;
|
||||
extern crate rustc_serialize;
|
||||
extern crate msg;
|
||||
extern crate time;
|
||||
extern crate util;
|
||||
|
@ -46,6 +43,7 @@ use util::task::spawn_named;
|
|||
use std::borrow::ToOwned;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender, RecvError};
|
||||
use std::net::{TcpListener, TcpStream, Shutdown};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -128,7 +126,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
|
||||
'outer: loop {
|
||||
match stream.read_json_packet() {
|
||||
Ok(json_packet) => {
|
||||
Ok(Some(json_packet)) => {
|
||||
match actors.lock().unwrap().handle_message(json_packet.as_object().unwrap(),
|
||||
&mut stream) {
|
||||
Ok(()) => {},
|
||||
|
@ -139,6 +137,10 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
}
|
||||
}
|
||||
}
|
||||
Ok(None) => {
|
||||
println!("error: EOF");
|
||||
break 'outer
|
||||
}
|
||||
Err(e) => {
|
||||
println!("error: {}", e.description());
|
||||
break 'outer
|
||||
|
@ -244,7 +246,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
|
|||
id: PipelineId,
|
||||
actor_pipelines: &HashMap<PipelineId, String>) -> String {
|
||||
let actors = actors.lock().unwrap();
|
||||
let ref tab_actor_name = (*actor_pipelines)[id];
|
||||
let ref tab_actor_name = (*actor_pipelines)[&id];
|
||||
let tab_actor = actors.find::<TabActor>(tab_actor_name);
|
||||
let console_actor_name = tab_actor.console.clone();
|
||||
return console_actor_name;
|
||||
|
|
|
@ -8,13 +8,12 @@
|
|||
|
||||
use rustc_serialize::{json, Encodable};
|
||||
use rustc_serialize::json::Json;
|
||||
use std::io::{self, Read, ReadExt, Write, ErrorKind};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::net::TcpStream;
|
||||
use std::num;
|
||||
|
||||
pub trait JsonPacketStream {
|
||||
fn write_json_packet<'a, T: Encodable>(&mut self, obj: &T);
|
||||
fn read_json_packet(&mut self) -> io::Result<Json>;
|
||||
fn read_json_packet(&mut self) -> io::Result<Option<Json>>;
|
||||
}
|
||||
|
||||
impl JsonPacketStream for TcpStream {
|
||||
|
@ -26,25 +25,25 @@ impl JsonPacketStream for TcpStream {
|
|||
self.write_all(s.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
fn read_json_packet<'a>(&mut self) -> io::Result<Json> {
|
||||
fn read_json_packet<'a>(&mut self) -> io::Result<Option<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!();
|
||||
loop {
|
||||
let mut buf = [0];
|
||||
let byte = match try!(self.read(&mut buf)) {
|
||||
0 => return Err(io::Error::new(ErrorKind::Other, "EOF", None)),
|
||||
0 => return Ok(None), // EOF
|
||||
1 => buf[0],
|
||||
_ => unreachable!(),
|
||||
};
|
||||
match byte {
|
||||
b':' => {
|
||||
let packet_len_str = String::from_utf8(buffer).unwrap();
|
||||
let packet_len = num::from_str_radix(&packet_len_str, 10).unwrap();
|
||||
let packet_len = u64::from_str_radix(&packet_len_str, 10).unwrap();
|
||||
let mut packet = String::new();
|
||||
self.take(packet_len).read_to_string(&mut packet).unwrap();
|
||||
println!("{}", packet);
|
||||
return Ok(Json::from_str(&packet).unwrap())
|
||||
return Ok(Some(Json::from_str(&packet).unwrap()))
|
||||
},
|
||||
c => buffer.push(c),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue