servo: Update for Eq trait with explicit self

This commit is contained in:
Patrick Walton 2012-11-27 15:32:39 -08:00
parent 29e46273f9
commit b04c68091d
11 changed files with 57 additions and 46 deletions

@ -1 +1 @@
Subproject commit 05de2b7203ece02c28b39242e572ee50c94a7aa0
Subproject commit 0578eb42ae1ef2f303918c4197a09ef69e8a07c7

@ -1 +1 @@
Subproject commit 06cff4a8b761e07a6b8f0a74e3c2feb40358ec6b
Subproject commit 9dddb337cc9dea2f4f871b34f9766608cd07cb83

@ -1 +1 @@
Subproject commit 2f3c63579c01f9e3cb07f03fd172a7a812da7285
Subproject commit 9421b6c7353a0ae109faf44163b437f2787f52af

View file

@ -108,10 +108,8 @@ enum CSSFontWeight {
FontWeight900,
}
pub impl CSSFontWeight : cmp::Eq {
pure fn eq(other: &CSSFontWeight) -> bool {
(self as uint) == (*other as uint)
}
pure fn ne(other: &CSSFontWeight) -> bool { !self.eq(other) }
pure fn eq(&self, other: &CSSFontWeight) -> bool { (*self as uint) == (*other as uint) }
pure fn ne(&self, other: &CSSFontWeight) -> bool { !(*self).eq(other) }
}
pub impl CSSFontWeight {
@ -140,7 +138,7 @@ pub struct FontStyle {
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
pub impl FontStyle : cmp::Eq {
pure fn eq(other: &FontStyle) -> bool {
pure fn eq(&self, other: &FontStyle) -> bool {
use std::cmp::FuzzyEq;
self.pt_size.fuzzy_eq(&other.pt_size) &&
@ -149,7 +147,7 @@ pub impl FontStyle : cmp::Eq {
self.oblique == other.oblique &&
self.families == other.families
}
pure fn ne(other: &FontStyle) -> bool { !self.eq(other) }
pure fn ne(&self, other: &FontStyle) -> bool { !(*self).eq(other) }
}
pub type SpecifiedFontStyle = FontStyle;
@ -175,11 +173,11 @@ pub struct FontDescriptor {
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
pub impl FontDescriptor : cmp::Eq {
pure fn eq(other: &FontDescriptor) -> bool {
pure fn eq(&self, other: &FontDescriptor) -> bool {
self.style == other.style &&
self.selector == other.selector
}
pure fn ne(other: &FontDescriptor) -> bool { !self.eq(other) }
pure fn ne(&self, other: &FontDescriptor) -> bool { !(*self).eq(other) }
}
pub impl FontDescriptor {
@ -199,14 +197,14 @@ pub enum FontSelector {
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
pub impl FontSelector : cmp::Eq {
pure fn eq(other: &FontSelector) -> bool {
match (&self, other) {
pure fn eq(&self, other: &FontSelector) -> bool {
match (self, other) {
(&SelectorPlatformIdentifier(a), &SelectorPlatformIdentifier(b)) => a == b,
(&SelectorStubDummy, &SelectorStubDummy) => true,
_ => false
}
}
pure fn ne(other: &FontSelector) -> bool { !self.eq(other) }
pure fn ne(&self, other: &FontSelector) -> bool { !(*self).eq(other) }
}
// This struct is the result of mapping a specified FontStyle into the

View file

@ -21,15 +21,15 @@ impl Au : Num {
}
impl Au : cmp::Ord {
pure fn lt(other: &Au) -> bool { *self < **other }
pure fn le(other: &Au) -> bool { *self <= **other }
pure fn ge(other: &Au) -> bool { *self >= **other }
pure fn gt(other: &Au) -> bool { *self > **other }
pure fn lt(&self, other: &Au) -> bool { **self < **other }
pure fn le(&self, other: &Au) -> bool { **self <= **other }
pure fn ge(&self, other: &Au) -> bool { **self >= **other }
pure fn gt(&self, other: &Au) -> bool { **self > **other }
}
impl Au : cmp::Eq {
pure fn eq(other: &Au) -> bool { *self == **other }
pure fn ne(other: &Au) -> bool { *self != **other }
pure fn eq(&self, other: &Au) -> bool { **self == **other }
pure fn ne(&self, other: &Au) -> bool { **self != **other }
}
pub pure fn min(x: Au, y: Au) -> Au { if x < y { x } else { y } }

View file

@ -58,7 +58,7 @@ impl ImageResponseMsg {
}
impl ImageResponseMsg: cmp::Eq {
pure fn eq(other: &ImageResponseMsg) -> bool {
pure fn eq(&self, other: &ImageResponseMsg) -> bool {
// FIXME: Bad copies
match (self.clone(), other.clone()) {
(ImageReady(*), ImageReady(*)) => fail ~"unimplemented comparison",
@ -70,8 +70,8 @@ impl ImageResponseMsg: cmp::Eq {
| (ImageFailed, _) => false
}
}
pure fn ne(other: &ImageResponseMsg) -> bool {
return !self.eq(other);
pure fn ne(&self, other: &ImageResponseMsg) -> bool {
return !(*self).eq(other);
}
}

View file

@ -24,8 +24,9 @@ pub enum ProgressMsg {
}
impl ProgressMsg: cmp::Eq {
pure fn eq(other: &ProgressMsg) -> bool {
match (copy self, copy *other) {
pure fn eq(&self, other: &ProgressMsg) -> bool {
// FIXME: Bad copies
match (copy *self, copy *other) {
(Payload(a), Payload(b)) => a == b,
(Done(a), Done(b)) => a == b,
@ -33,8 +34,8 @@ impl ProgressMsg: cmp::Eq {
| (Done(*), _) => false
}
}
pure fn ne(other: &ProgressMsg) -> bool {
return !self.eq(other);
pure fn ne(&self, other: &ProgressMsg) -> bool {
return !(*self).eq(other);
}
}

View file

@ -6,12 +6,12 @@ pub enum format {
}
impl format: cmp::Eq {
pure fn eq(other: &format) -> bool {
match (self, *other) {
pure fn eq(&self, other: &format) -> bool {
match (*self, *other) {
(fo_rgba_8888, fo_rgba_8888) => true,
}
}
pure fn ne(other: &format) -> bool {
pure fn ne(&self, other: &format) -> bool {
return !self.eq(other);
}
}

View file

@ -39,16 +39,16 @@ enum BreakType {
}
impl BreakType : Eq {
pure fn eq(other: &BreakType) -> bool {
match (self, *other) {
pure fn eq(&self, other: &BreakType) -> bool {
match (*self, *other) {
(BreakTypeNone, BreakTypeNone) => true,
(BreakTypeNormal, BreakTypeNormal) => true,
(BreakTypeHyphen, BreakTypeHyphen) => true,
(_,_) => false,
}
}
pure fn ne(other: &BreakType) -> bool {
!self.eq(other)
pure fn ne(&self, other: &BreakType) -> bool {
!(*self).eq(other)
}
}
@ -288,15 +288,27 @@ struct DetailedGlyphRecord {
}
impl DetailedGlyphRecord : Ord {
pure fn lt(other: &DetailedGlyphRecord) -> bool { self.entry_offset < other.entry_offset }
pure fn le(other: &DetailedGlyphRecord) -> bool { self.entry_offset <= other.entry_offset }
pure fn ge(other: &DetailedGlyphRecord) -> bool { self.entry_offset >= other.entry_offset }
pure fn gt(other: &DetailedGlyphRecord) -> bool { self.entry_offset > other.entry_offset }
pure fn lt(&self, other: &DetailedGlyphRecord) -> bool {
self.entry_offset < other.entry_offset
}
pure fn le(&self, other: &DetailedGlyphRecord) -> bool {
self.entry_offset <= other.entry_offset
}
pure fn ge(&self, other: &DetailedGlyphRecord) -> bool {
self.entry_offset >= other.entry_offset
}
pure fn gt(&self, other: &DetailedGlyphRecord) -> bool {
self.entry_offset > other.entry_offset
}
}
impl DetailedGlyphRecord : Eq {
pure fn eq(other : &DetailedGlyphRecord) -> bool { self.entry_offset == other.entry_offset }
pure fn ne(other : &DetailedGlyphRecord) -> bool { self.entry_offset != other.entry_offset }
pure fn eq(&self, other : &DetailedGlyphRecord) -> bool {
self.entry_offset == other.entry_offset
}
pure fn ne(&self, other : &DetailedGlyphRecord) -> bool {
self.entry_offset != other.entry_offset
}
}
// Manages the lookup table for detailed glyphs. Sorting is deferred

View file

@ -6,8 +6,8 @@ enum CompressionMode {
}
impl CompressionMode : cmp::Eq {
pure fn eq(other: &CompressionMode) -> bool {
match (self, *other) {
pure fn eq(&self, other: &CompressionMode) -> bool {
match (*self, *other) {
(CompressNone, CompressNone) => true,
(CompressWhitespace, CompressWhitespace) => true,
(CompressWhitespaceNewline, CompressWhitespaceNewline) => true,
@ -15,8 +15,8 @@ impl CompressionMode : cmp::Eq {
_ => false
}
}
pure fn ne(other: &CompressionMode) -> bool {
!self.eq(other)
pure fn ne(&self, other: &CompressionMode) -> bool {
!(*self).eq(other)
}
}

View file

@ -134,8 +134,8 @@ impl<T:Send,A> Handle<T,A> {
}
impl <T: Send,A> Handle<T,A> : cmp::Eq {
pure fn eq(other: &Handle<T,A>) -> bool { *self == **other }
pure fn ne(other: &Handle<T,A>) -> bool { *self != **other }
pure fn eq(&self, other: &Handle<T,A>) -> bool { **self == **other }
pure fn ne(&self, other: &Handle<T,A>) -> bool { **self != **other }
}
// Private methods