Commit 214a36e8 by Kresten Krab Thorup

(-compare:, -shouldNotImplement:): Added.

From-SVN: r5399
parent d4b13012
...@@ -61,6 +61,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -61,6 +61,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
- - self; - - self;
- (unsigned int)hash; - (unsigned int)hash;
- (BOOL)isEqual:anObject; - (BOOL)isEqual:anObject;
- (int)compare:anotherObject;
/* Testing object type */ /* Testing object type */
- (BOOL)isMetaClass; - (BOOL)isMetaClass;
...@@ -102,6 +103,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -102,6 +103,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Enforcing intentions */ /* Enforcing intentions */
- - subclassResponsibility:(SEL)aSel; - - subclassResponsibility:(SEL)aSel;
- - notImplemented:(SEL)aSel; - - notImplemented:(SEL)aSel;
- - shouldNotImplement:(SEL)aSel;
/* Error handling */ /* Error handling */
- - doesNotRecognize:(SEL)aSel; - - doesNotRecognize:(SEL)aSel;
......
...@@ -116,6 +116,18 @@ extern int errno; ...@@ -116,6 +116,18 @@ extern int errno;
return self==anObject; return self==anObject;
} }
- (int)compare:anotherObject;
{
if ([self isEqual:anotherObject])
return 0;
// Ordering objects by their address is pretty useless,
// so subclasses should override this is some useful way.
else if (self > anotherObject)
return 1;
else
return -1;
}
- (BOOL)isMetaClass - (BOOL)isMetaClass
{ {
return NO; return NO;
...@@ -287,6 +299,12 @@ extern int errno; ...@@ -287,6 +299,12 @@ extern int errno;
return [self error:"method %s not implemented", sel_get_name(aSel)]; return [self error:"method %s not implemented", sel_get_name(aSel)];
} }
- shouldNotImplement:(SEL)aSel
{
return [self error:"%s should not implement %s",
object_get_class_name(self), sel_get_name(aSel)];
}
- doesNotRecognize:(SEL)aSel - doesNotRecognize:(SEL)aSel
{ {
return [self error:"%s does not recognize %s", return [self error:"%s does not recognize %s",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment