Skip to content

Commit

Permalink
Make matrices, points, rects, side offsets, and sizes serializable using
Browse files Browse the repository at this point in the history
`serde`.

This is preparation for multiprocess Servo.
  • Loading branch information
pcwalton committed Jul 8, 2015
1 parent 7734141 commit bb07108
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ rustc-serialize = "0.3.2"
rand = "0.3.7"
num = "0.1.24"
log = "0.3.1"
serde = "*"
serde_macros = "*"
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(asm, simd, zero_one, test)]
#![feature(asm, custom_derive, plugin, simd, zero_one, test)]

#![plugin(serde_macros)]

#[macro_use]
extern crate log;
extern crate rustc_serialize;
extern crate serde;

extern crate rand;
extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use approxeq::ApproxEq;
use point::{Point2D, Point4D};


#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Deserialize, Serialize)]
pub struct Matrix4 {
pub m11: f32, pub m12: f32, pub m13: f32, pub m14: f32,
pub m21: f32, pub m22: f32, pub m23: f32, pub m24: f32,
Expand Down
2 changes: 1 addition & 1 deletion src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use num_lib::NumCast;
use std::fmt::{self, Formatter};
use std::ops::{Add, Neg, Mul, Sub, Div};

#[derive(Clone, Copy, RustcDecodable, RustcEncodable, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, RustcDecodable, RustcEncodable, Eq, Hash, PartialEq, Deserialize, Serialize)]
pub struct Point2D<T> {
pub x: T,
pub y: T
Expand Down
2 changes: 1 addition & 1 deletion src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::cmp::PartialOrd;
use std::fmt::{self, Formatter};
use std::ops::{Add, Sub, Mul, Div};

#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq)]
#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq, Deserialize, Serialize)]
pub struct Rect<T> {
pub origin: Point2D<T>,
pub size: Size2D<T>,
Expand Down
2 changes: 1 addition & 1 deletion src/side_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::ops::Add;

/// A group of side offsets, which correspond to top/left/bottom/right for borders, padding,
/// and margins in CSS.
#[derive(Clone, Copy, PartialEq, Debug)]
#[derive(Clone, Copy, PartialEq, Debug, Deserialize, Serialize)]
pub struct SideOffsets2D<T> {
pub top: T,
pub right: T,
Expand Down
2 changes: 1 addition & 1 deletion src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use num_lib::NumCast;
use std::fmt::{self, Formatter};
use std::ops::{Mul, Div};

#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq)]
#[derive(Clone, Copy, RustcDecodable, RustcEncodable, PartialEq, Deserialize, Serialize)]
pub struct Size2D<T> {
pub width: T,
pub height: T
Expand Down

0 comments on commit bb07108

Please sign in to comment.