diff --git a/ChangeLog b/ChangeLog index 33847c369..ddba7a12a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2002-06-09 Richard Frith-Macdonald + + * Source/NSObject.m: Implemented and documented -className + 2002-06-06 Adam Fedor * Source/cifframe.m (cifframe_from_info): Set value locations diff --git a/Headers/gnustep/base/NSObject.h b/Headers/gnustep/base/NSObject.h index 1d64a3472..a7b97bd2e 100644 --- a/Headers/gnustep/base/NSObject.h +++ b/Headers/gnustep/base/NSObject.h @@ -104,6 +104,11 @@ - (id) mutableCopyWithZone: (NSZone*)zone; @end +/** + * This protocol must be adopted by any class wishing to support + * saving and restoring instances to an archive, or copying them + * to remote processes via the Distributed Objects mechanism. + */ @protocol NSCoding - (void) encodeWithCoder: (NSCoder*)aCoder; - (id) initWithCoder: (NSCoder*)aDecoder; @@ -120,11 +125,16 @@ + (BOOL) requiresTypedMemory; #endif #endif -+ (void) initialize; + +#ifndef STRICT_OPENSTEP +- (NSString*) className; +#endif + + (id) allocWithZone: (NSZone*)z; + (id) alloc; + (Class) class; + (NSString*) description; ++ (void) initialize; + (IMP) instanceMethodForSelector: (SEL)aSelector; + (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector; + (BOOL) instancesRespondToSelector: (SEL)aSelector; @@ -140,7 +150,7 @@ - (Class) classForArchiver; - (Class) classForCoder; - (Class) classForPortCoder; -- (BOOL) conformsToProtocol: (Protocol *)aProtocol; +- (BOOL) conformsToProtocol: (Protocol*)aProtocol; - (id) copy; - (void) dealloc; - (NSString*) description; @@ -156,8 +166,11 @@ - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector; - (id) mutableCopy; - (id) performSelector: (SEL)aSelector; -- (id) performSelector: (SEL)aSelector withObject: anObject; -- (id) performSelector: (SEL)aSelector withObject: object1 withObject: object2; +- (id) performSelector: (SEL)aSelector + withObject: (id)anObject; +- (id) performSelector: (SEL)aSelector + withObject: (id)object1 + withObject: (id)object2; - (void) release; - (id) replacementObjectForArchiver: (NSArchiver*)anArchiver; - (id) replacementObjectForCoder: (NSCoder*)anEncoder; diff --git a/Source/NSObject.m b/Source/NSObject.m index a16a303ef..19888657e 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -802,6 +802,30 @@ static BOOL double_release_check_enabled = NO; return [[self alloc] init]; } +/** + * Returns the class of which the receiver is an instance.
+ * The default implementation returns the private isa + * instance variable of NSObject, which is used to store a pointer + * to the objects class.
+ * NB. When NSZombie is enabled (see NSDebug.h) this pointer is + * changed upon object deallocation. + */ +- (Class) class +{ + return object_get_class(self); +} + +/** + * Returns the name of the class of the receiving object by using + * the NSStringFromClass() function.
+ * This is a MacOS-X addition for apple scripting, which is also + * generally useful. + */ +- (NSString*) className +{ + return NSStringFromClass([self class]); +} + /** * Creates and returns a copy of the reciever by calling -copyWithZone: * passing NSDefaultMallocZone() @@ -1164,19 +1188,6 @@ static BOOL double_release_check_enabled = NO; return self; } -/** - * Returns the class of which the receiver is an instance.
- * The default implementation returns the private isa - * instance variable of NSObject, which is used to store a pointer - * to the objects class.
- * NB. When NSZombie is enabled (see NSDebug.h) this pointer is - * changed upon object deallocation. - */ -- (Class) class -{ - return object_get_class(self); -} - /** * Returns the hash of the receiver. Subclasses should ensure that their * implementations of this method obey the rule that if the -isEqual: method