mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update serde to 0.9 (fixes #15325)
This commit is contained in:
parent
26d6c96b18
commit
fe3f4ff0c2
73 changed files with 630 additions and 604 deletions
|
@ -13,12 +13,12 @@ path = "lib.rs"
|
|||
devtools_traits = {path = "../devtools_traits"}
|
||||
encoding = "0.2"
|
||||
hyper = "0.9.9"
|
||||
hyper_serde = "0.1.4"
|
||||
ipc-channel = "0.6.3"
|
||||
hyper_serde = "0.5"
|
||||
ipc-channel = "0.7"
|
||||
log = "0.3.5"
|
||||
msg = {path = "../msg"}
|
||||
plugins = {path = "../plugins"}
|
||||
serde = "0.8"
|
||||
serde_derive = "0.8"
|
||||
serde_json = "0.8"
|
||||
serde = "0.9"
|
||||
serde_derive = "0.9"
|
||||
serde_json = "0.9"
|
||||
time = "0.1"
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
/// General actor system infrastructure.
|
||||
|
||||
use devtools_traits::PreciseTime;
|
||||
use serde_json::Value;
|
||||
use serde_json::{Map, Value};
|
||||
use std::any::Any;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::HashMap;
|
||||
use std::mem::replace;
|
||||
use std::net::TcpStream;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -26,7 +26,7 @@ pub trait Actor: Any + ActorAsAny {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()>;
|
||||
fn name(&self) -> String;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ 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: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream)
|
||||
-> Result<(), ()> {
|
||||
let to = msg.get("to").unwrap().as_str().unwrap();
|
||||
|
|
|
@ -16,9 +16,8 @@ use devtools_traits::EvaluateJSReply::{NullValue, NumberValue, VoidValue};
|
|||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use protocol::JsonPacketStream;
|
||||
use serde_json::{self, Value};
|
||||
use serde_json::{self, Map, Number, Value};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::TcpStream;
|
||||
|
||||
trait EncodableConsoleMessage {
|
||||
|
@ -50,7 +49,7 @@ struct StartedListenersReply {
|
|||
#[derive(Serialize)]
|
||||
struct GetCachedMessagesReply {
|
||||
from: String,
|
||||
messages: Vec<BTreeMap<String, Value>>,
|
||||
messages: Vec<Map<String, Value>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -98,7 +97,7 @@ impl Actor for ConsoleActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"getCachedMessages" => {
|
||||
|
@ -182,46 +181,46 @@ impl Actor for ConsoleActor {
|
|||
//TODO: extract conversion into protocol module or some other useful place
|
||||
let result = match try!(port.recv().map_err(|_| ())) {
|
||||
VoidValue => {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_owned(), serde_json::to_value("undefined"));
|
||||
let mut m = Map::new();
|
||||
m.insert("type".to_owned(), Value::String("undefined".to_owned()));
|
||||
Value::Object(m)
|
||||
}
|
||||
NullValue => {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_owned(), serde_json::to_value("null"));
|
||||
let mut m = Map::new();
|
||||
m.insert("type".to_owned(), Value::String("null".to_owned()));
|
||||
Value::Object(m)
|
||||
}
|
||||
BooleanValue(val) => Value::Bool(val),
|
||||
NumberValue(val) => {
|
||||
if val.is_nan() {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_owned(), serde_json::to_value("NaN"));
|
||||
let mut m = Map::new();
|
||||
m.insert("type".to_owned(), Value::String("NaN".to_owned()));
|
||||
Value::Object(m)
|
||||
} else if val.is_infinite() {
|
||||
let mut m = BTreeMap::new();
|
||||
let mut m = Map::new();
|
||||
if val < 0. {
|
||||
m.insert("type".to_owned(), serde_json::to_value("-Infinity"));
|
||||
m.insert("type".to_owned(), Value::String("-Infinity".to_owned()));
|
||||
} else {
|
||||
m.insert("type".to_owned(), serde_json::to_value("Infinity"));
|
||||
m.insert("type".to_owned(), Value::String("Infinity".to_owned()));
|
||||
}
|
||||
Value::Object(m)
|
||||
} else if val == 0. && val.is_sign_negative() {
|
||||
let mut m = BTreeMap::new();
|
||||
m.insert("type".to_owned(), serde_json::to_value("-0"));
|
||||
let mut m = Map::new();
|
||||
m.insert("type".to_owned(), Value::String("-0".to_owned()));
|
||||
Value::Object(m)
|
||||
} else {
|
||||
serde_json::to_value(&val)
|
||||
Value::Number(Number::from_f64(val).unwrap())
|
||||
}
|
||||
}
|
||||
StringValue(s) => Value::String(s),
|
||||
ActorValue { class, uuid } => {
|
||||
//TODO: make initial ActorValue message include these properties?
|
||||
let mut m = BTreeMap::new();
|
||||
let mut m = Map::new();
|
||||
let actor = ObjectActor::new(registry, uuid);
|
||||
|
||||
m.insert("type".to_owned(), serde_json::to_value("object"));
|
||||
m.insert("class".to_owned(), serde_json::to_value(&class));
|
||||
m.insert("actor".to_owned(), serde_json::to_value(&actor));
|
||||
m.insert("type".to_owned(), Value::String("object".to_owned()));
|
||||
m.insert("class".to_owned(), Value::String(class));
|
||||
m.insert("actor".to_owned(), Value::String(actor));
|
||||
m.insert("extensible".to_owned(), Value::Bool(true));
|
||||
m.insert("frozen".to_owned(), Value::Bool(false));
|
||||
m.insert("sealed".to_owned(), Value::Bool(false));
|
||||
|
@ -235,9 +234,9 @@ impl Actor for ConsoleActor {
|
|||
input: input,
|
||||
result: result,
|
||||
timestamp: 0,
|
||||
exception: Value::Object(BTreeMap::new()),
|
||||
exception: Value::Object(Map::new()),
|
||||
exceptionMessage: "".to_owned(),
|
||||
helperResult: Value::Object(BTreeMap::new()),
|
||||
helperResult: Value::Object(Map::new()),
|
||||
};
|
||||
stream.write_json_packet(&msg);
|
||||
ActorMessageStatus::Processed
|
||||
|
|
|
@ -7,8 +7,7 @@ use actors::timeline::HighResolutionStamp;
|
|||
use devtools_traits::DevtoolScriptControlMsg;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::mem;
|
||||
use std::net::TcpStream;
|
||||
use time::precise_time_ns;
|
||||
|
@ -31,7 +30,7 @@ impl Actor for FramerateActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
_msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(ActorMessageStatus::Ignored)
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@ use devtools_traits::DevtoolScriptControlMsg::{GetLayout, ModifyAttribute};
|
|||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use protocol::JsonPacketStream;
|
||||
use serde_json::{self, Value};
|
||||
use serde_json::{self, Map, Value};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct InspectorActor {
|
||||
|
@ -65,7 +64,7 @@ impl Actor for HighlighterActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"showBoxModel" => {
|
||||
|
@ -102,7 +101,7 @@ impl Actor for NodeActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"modifyAttributes" => {
|
||||
|
@ -276,7 +275,7 @@ impl Actor for WalkerActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"querySelector" => {
|
||||
|
@ -451,7 +450,7 @@ impl Actor for PageStyleActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"getApplied" => {
|
||||
|
@ -503,7 +502,7 @@ impl Actor for PageStyleActor {
|
|||
zIndex: zIndex,
|
||||
boxSizing: boxSizing,
|
||||
autoMargins: if auto_margins {
|
||||
let mut m = BTreeMap::new();
|
||||
let mut m = Map::new();
|
||||
let auto = serde_json::value::Value::String("auto".to_owned());
|
||||
if autoMargins.top { m.insert("top".to_owned(), auto.clone()); }
|
||||
if autoMargins.right { m.insert("right".to_owned(), auto.clone()); }
|
||||
|
@ -547,7 +546,7 @@ impl Actor for InspectorActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"getWalker" => {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -32,7 +31,7 @@ impl Actor for MemoryActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
_msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(ActorMessageStatus::Ignored)
|
||||
}
|
||||
|
|
|
@ -16,9 +16,8 @@ use hyper::header::Headers;
|
|||
use hyper::http::RawStatus;
|
||||
use hyper::method::Method;
|
||||
use protocol::JsonPacketStream;
|
||||
use serde_json::Value;
|
||||
use serde_json::{Map, Value};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::TcpStream;
|
||||
use time;
|
||||
use time::Tm;
|
||||
|
@ -185,7 +184,7 @@ impl Actor for NetworkEventActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"getRequestHeaders" => {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct ObjectActor {
|
||||
|
@ -19,7 +18,7 @@ impl Actor for ObjectActor {
|
|||
fn handle_message(&self,
|
||||
_: &ActorRegistry,
|
||||
_: &str,
|
||||
_: &BTreeMap<String, Value>,
|
||||
_: &Map<String, Value>,
|
||||
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(ActorMessageStatus::Ignored)
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use protocol::{ActorDescription, JsonPacketStream, Method};
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct PerformanceActor {
|
||||
|
@ -55,7 +54,7 @@ impl Actor for PerformanceActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"connect" => {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct ProfilerActor {
|
||||
|
@ -19,7 +18,7 @@ impl Actor for ProfilerActor {
|
|||
fn handle_message(&self,
|
||||
_registry: &ActorRegistry,
|
||||
_msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
_stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(ActorMessageStatus::Ignored)
|
||||
}
|
||||
|
|
|
@ -11,8 +11,7 @@ use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
|||
use actors::performance::PerformanceActor;
|
||||
use actors::tab::{TabActor, TabActorMsg};
|
||||
use protocol::{ActorDescription, JsonPacketStream};
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -69,7 +68,7 @@ impl Actor for RootActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"listAddons" => {
|
||||
|
|
|
@ -11,8 +11,7 @@ use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
|||
use actors::console::ConsoleActor;
|
||||
use devtools_traits::DevtoolScriptControlMsg::{self, WantsLiveNotifications};
|
||||
use protocol::JsonPacketStream;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -88,7 +87,7 @@ impl Actor for TabActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"reconfigure" => {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use protocol::JsonPacketStream;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -68,7 +67,7 @@ impl Actor for ThreadActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg: &BTreeMap<String, Value>,
|
||||
_msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"attach" => {
|
||||
|
|
|
@ -12,9 +12,8 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use protocol::JsonPacketStream;
|
||||
use serde::{Serialize, Serializer};
|
||||
use serde_json::Value;
|
||||
use serde_json::{Map, Value};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::net::TcpStream;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
@ -115,7 +114,7 @@ impl HighResolutionStamp {
|
|||
}
|
||||
|
||||
impl Serialize for HighResolutionStamp {
|
||||
fn serialize<S: Serializer>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
|
||||
self.0.serialize(s)
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ impl Actor for TimelineActor {
|
|||
fn handle_message(&self,
|
||||
registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
msg: &BTreeMap<String, Value>,
|
||||
msg: &Map<String, Value>,
|
||||
stream: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
"start" => {
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
|
||||
use actor::{Actor, ActorMessageStatus, ActorRegistry};
|
||||
use devtools_traits::WorkerId;
|
||||
use serde_json::Value;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json::{Map, Value};
|
||||
use std::net::TcpStream;
|
||||
|
||||
pub struct WorkerActor {
|
||||
|
@ -21,7 +20,7 @@ impl Actor for WorkerActor {
|
|||
fn handle_message(&self,
|
||||
_: &ActorRegistry,
|
||||
_: &str,
|
||||
_: &BTreeMap<String, Value>,
|
||||
_: &Map<String, Value>,
|
||||
_: &mut TcpStream) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(ActorMessageStatus::Processed)
|
||||
}
|
||||
|
|
|
@ -40,9 +40,9 @@ impl JsonPacketStream for TcpStream {
|
|||
}
|
||||
|
||||
fn write_merged_json_packet<T: Serialize, U: Serialize>(&mut self, base: &T, extra: &U) {
|
||||
let mut obj = serde_json::to_value(base);
|
||||
let mut obj = serde_json::to_value(base).unwrap();
|
||||
let obj = obj.as_object_mut().unwrap();
|
||||
let extra = serde_json::to_value(extra);
|
||||
let extra = serde_json::to_value(extra).unwrap();
|
||||
let extra = extra.as_object().unwrap();
|
||||
|
||||
for (key, value) in extra {
|
||||
|
@ -79,14 +79,7 @@ impl JsonPacketStream for TcpStream {
|
|||
debug!("{}", packet);
|
||||
return match serde_json::from_str(&packet) {
|
||||
Ok(json) => Ok(Some(json)),
|
||||
Err(err) => match err {
|
||||
serde_json::Error::Io(ioerr) => {
|
||||
return Err(ioerr.description().to_owned())
|
||||
},
|
||||
serde_json::Error::Syntax(_, l, c) => {
|
||||
return Err(format!("syntax at {}:{}", l, c))
|
||||
},
|
||||
},
|
||||
Err(err) => Err(err.description().to_owned()),
|
||||
};
|
||||
},
|
||||
c => buffer.push(c),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue