diff options
author | Kresten Krab Thorup <krab@gcc.gnu.org> | 1993-09-22 18:00:23 +0000 |
---|---|---|
committer | Kresten Krab Thorup <krab@gcc.gnu.org> | 1993-09-22 18:00:23 +0000 |
commit | 214a36e8508ab10a3ef23f682a0469a2e5255bd3 (patch) | |
tree | 2292c1c01010fcde35f6c597c878ee33bb5ffd67 /gcc/objc | |
parent | d4b130122f43c3ec6b5ec5955de0887ef26c6dd5 (diff) | |
download | gcc-214a36e8508ab10a3ef23f682a0469a2e5255bd3.zip gcc-214a36e8508ab10a3ef23f682a0469a2e5255bd3.tar.gz gcc-214a36e8508ab10a3ef23f682a0469a2e5255bd3.tar.bz2 |
(-compare:, -shouldNotImplement:): Added.
From-SVN: r5399
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/Object.h | 2 | ||||
-rw-r--r-- | gcc/objc/Object.m | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gcc/objc/Object.h b/gcc/objc/Object.h index 917fed5..cb370ca 100644 --- a/gcc/objc/Object.h +++ b/gcc/objc/Object.h @@ -61,6 +61,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - self; - (unsigned int)hash; - (BOOL)isEqual:anObject; +- (int)compare:anotherObject; /* Testing object type */ - (BOOL)isMetaClass; @@ -102,6 +103,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Enforcing intentions */ - subclassResponsibility:(SEL)aSel; - notImplemented:(SEL)aSel; +- shouldNotImplement:(SEL)aSel; /* Error handling */ - doesNotRecognize:(SEL)aSel; diff --git a/gcc/objc/Object.m b/gcc/objc/Object.m index 166bff4..622dcbe 100644 --- a/gcc/objc/Object.m +++ b/gcc/objc/Object.m @@ -116,6 +116,18 @@ extern int errno; 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 { return NO; @@ -287,6 +299,12 @@ extern int errno; 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 { return [self error:"%s does not recognize %s", |