2001-12-17 07:11:23 +00:00
|
|
|
/**Interface for NSObject for GNUStep
|
1998-11-02 10:23:56 +00:00
|
|
|
Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
|
1995-07-01 19:01:11 +00:00
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1995-07-01 19:01:11 +00:00
|
|
|
Date: 1995
|
1995-03-12 15:50:58 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-03-12 15:50:58 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1995-03-12 15:50:58 +00:00
|
|
|
*/
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSObject_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSObject_h_GNUSTEP_BASE_INCLUDE
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1998-11-02 10:23:56 +00:00
|
|
|
/*
|
|
|
|
* Check consistency of definitions for system compatibility.
|
|
|
|
*/
|
1998-11-02 10:25:43 +00:00
|
|
|
#if defined(STRICT_OPENSTEP)
|
1998-11-02 10:23:56 +00:00
|
|
|
#define NO_GNUSTEP 1
|
1998-11-02 10:25:43 +00:00
|
|
|
#elif defined(STRICT_MACOS_X)
|
1998-11-02 10:23:56 +00:00
|
|
|
#define NO_GNUSTEP 1
|
|
|
|
#else
|
|
|
|
#undef NO_GNUSTEP
|
|
|
|
#endif
|
|
|
|
|
2000-06-15 14:36:29 +00:00
|
|
|
#include <Foundation/NSObjCRuntime.h>
|
2003-07-31 23:49:32 +00:00
|
|
|
#include <GNUstepBase/preface.h>
|
1999-01-05 16:55:29 +00:00
|
|
|
#include <GSConfig.h>
|
1994-11-08 16:44:01 +00:00
|
|
|
#include <objc/objc.h>
|
|
|
|
#include <objc/Protocol.h>
|
1995-04-17 21:13:20 +00:00
|
|
|
#include <Foundation/NSZone.h>
|
1995-03-12 15:50:58 +00:00
|
|
|
|
|
|
|
@class NSArchiver;
|
1998-04-02 14:27:40 +00:00
|
|
|
@class NSArray;
|
1995-03-12 15:50:58 +00:00
|
|
|
@class NSCoder;
|
1998-12-18 17:05:44 +00:00
|
|
|
@class NSDictionary;
|
1997-09-01 21:59:51 +00:00
|
|
|
@class NSPortCoder;
|
1995-03-12 15:50:58 +00:00
|
|
|
@class NSMethodSignature;
|
1998-12-18 17:05:44 +00:00
|
|
|
@class NSMutableString;
|
1997-09-13 17:52:31 +00:00
|
|
|
@class NSRecursiveLock;
|
1995-03-12 15:50:58 +00:00
|
|
|
@class NSString;
|
|
|
|
@class NSInvocation;
|
|
|
|
@class Protocol;
|
|
|
|
|
2002-06-02 09:05:11 +00:00
|
|
|
/**
|
|
|
|
* The NSObject protocol describes a minimal set of methods that all
|
|
|
|
* objects are expected to support. You should be able to send any
|
|
|
|
* of the messages listed in this protocol to an object, and be safe
|
|
|
|
* in assuming that the receiver can handle it.
|
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSObject
|
2002-06-02 09:05:11 +00:00
|
|
|
- (Class) class; /** See [NSObject-class] */
|
|
|
|
- (Class) superclass; /** See [NSObject-superclass] */
|
|
|
|
- (BOOL) isEqual: (id)anObject; /** See [NSObject-isEqual:] */
|
|
|
|
- (BOOL) isKindOfClass: (Class)aClass; /** See [NSObject-isKindOfClass:] */
|
|
|
|
- (BOOL) isMemberOfClass: (Class)aClass;/** See [NSObject-isMemberOfClass:] */
|
|
|
|
- (BOOL) isProxy; /** See [NSObject-isProxy] */
|
|
|
|
- (unsigned) hash; /** See [NSObject-hash] */
|
|
|
|
- (id) self; /** See [NSObject-self] */
|
|
|
|
- (id) performSelector: (SEL)aSelector; /** See [NSObject-performSelector:] */
|
|
|
|
/** See [NSObject-performSelector:withObject:] */
|
|
|
|
- (id) performSelector: (SEL)aSelector
|
|
|
|
withObject: (id)anObject;
|
|
|
|
/** See [NSObject-performSelector:withObject:withObject:] */
|
|
|
|
- (id) performSelector: (SEL)aSelector
|
|
|
|
withObject: (id)object1
|
|
|
|
withObject: (id)object2;
|
|
|
|
/** See [NSObject-respondsToSelector:] */
|
1995-03-12 15:50:58 +00:00
|
|
|
- (BOOL) respondsToSelector: (SEL)aSelector;
|
2002-06-02 09:05:11 +00:00
|
|
|
/** See [NSObject-conformsToProtocol:] */
|
|
|
|
- (BOOL) conformsToProtocol: (Protocol*)aProtocol;
|
|
|
|
- (id) retain; /** See [NSObject-retain] */
|
|
|
|
- (id) autorelease /** See [NSObject-autorelease] */;
|
|
|
|
- (oneway void) release; /** See [NSObject-release] */
|
|
|
|
- (unsigned) retainCount; /** See [NSObject-retainCount] */
|
|
|
|
- (NSZone*) zone; /** See [NSObject-zone] */
|
|
|
|
- (NSString*) description; /** See [NSObject-description] */
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1994-11-08 16:44:01 +00:00
|
|
|
|
2002-06-02 09:05:11 +00:00
|
|
|
/**
|
2003-01-20 17:18:06 +00:00
|
|
|
* This protocol must be adopted by any class wishing to support copying -
|
|
|
|
* ie where instances of the class should be able to create new instances
|
|
|
|
* which are copies of the original and, where a class has mutable and
|
|
|
|
* immutable versions, where the copies are immutable.
|
2002-06-02 09:05:11 +00:00
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSCopying
|
2003-01-20 17:18:06 +00:00
|
|
|
/**
|
|
|
|
* Called by [NSObject-copy] passing NSDefaultMallocZone() as zone.<br />
|
|
|
|
* This method returns a copy of the receiver and, where the receiver is a
|
|
|
|
* mutable variant of a class which has an immutable partner class, the
|
|
|
|
* object returned is an instance of that immutable class.<br />
|
|
|
|
* The new object is <em>not</em> autoreleased, and is considered to be
|
|
|
|
* 'owned' by the calling code ... which is therefore responsible for
|
|
|
|
* releasing it.<br />
|
|
|
|
* In the case where the receiver is an instance of a container class,
|
|
|
|
* it is undefined whether contained objects are merely retained in the
|
|
|
|
* new copy, or are themselves copied, or whether some other mechanism
|
|
|
|
* entirely is used.
|
|
|
|
*/
|
2002-06-02 09:05:11 +00:00
|
|
|
- (id) copyWithZone: (NSZone*)zone;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1994-11-08 16:44:01 +00:00
|
|
|
|
2002-06-02 09:05:11 +00:00
|
|
|
/**
|
|
|
|
* This protocol must be adopted by any class wishing to support
|
2003-01-20 17:18:06 +00:00
|
|
|
* mutable copying - ie where instances of the class should be able
|
|
|
|
* to create mutable copies of themselves.
|
2002-06-02 09:05:11 +00:00
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSMutableCopying
|
2003-01-20 17:18:06 +00:00
|
|
|
/**
|
|
|
|
* Called by [NSObject-mutableCopy] passing NSDefaultMallocZone() as zone.<br />
|
|
|
|
* This method returns a copy of the receiver and, where the receiver is an
|
|
|
|
* immmutable variant of a class which has a mutable partner class, the
|
|
|
|
* object returned is an instance of that mutable class.
|
|
|
|
* The new object is <em>not</em> autoreleased, and is considered to be
|
|
|
|
* 'owned' by the calling code ... which is therefore responsible for
|
|
|
|
* releasing it.<br />
|
|
|
|
* In the case where the receiver is an instance of a container class,
|
|
|
|
* it is undefined whether contained objects are merely retained in the
|
|
|
|
* new copy, or are themselves copied, or whether some other mechanism
|
|
|
|
* entirely is used.
|
|
|
|
*/
|
2002-06-02 09:05:11 +00:00
|
|
|
- (id) mutableCopyWithZone: (NSZone*)zone;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
|
|
|
|
2002-06-09 04:57:04 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSCoding
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when it is time for receiver to be serialized for writing to an
|
|
|
|
* archive or network connection. Receiver should record all of its instance
|
|
|
|
* variables using methods on aCoder. See documentation for [NSCoder],
|
|
|
|
* [NSArchiver], [NSKeyedArchiver], and/or [NSPortCoder] for more information.
|
|
|
|
*/
|
1995-04-09 02:06:39 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called on a freshly allocated receiver when it is time to reconstitute from
|
|
|
|
* serialized bytes in an archive or from a network connection. Receiver
|
|
|
|
* should load all of its instance variables using methods on aCoder. See
|
|
|
|
* documentation for [NSCoder], [NSUnarchiver], [NSKeyedUnarchiver], and/or
|
|
|
|
* [NSPortCoder] for more information.
|
|
|
|
*/
|
1995-04-09 02:06:39 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
1998-07-15 12:43:56 +00:00
|
|
|
@interface NSObject <NSObject>
|
1994-11-08 16:44:01 +00:00
|
|
|
{
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Points to instance's class. Used by runtime to access method
|
|
|
|
* implementations, etc.. Set in +alloc, Unlike other instance variables,
|
|
|
|
* which are cleared there.
|
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
Class isa;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
2002-01-07 11:24:52 +00:00
|
|
|
#ifndef NO_GNUSTEP
|
2000-07-04 11:05:46 +00:00
|
|
|
#if GS_WITH_GC
|
|
|
|
+ (BOOL) requiresTypedMemory;
|
|
|
|
#endif
|
2002-01-07 11:24:52 +00:00
|
|
|
#endif
|
2002-06-09 04:57:04 +00:00
|
|
|
|
|
|
|
#ifndef STRICT_OPENSTEP
|
|
|
|
- (NSString*) className;
|
|
|
|
#endif
|
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
+ (id) allocWithZone: (NSZone*)z;
|
1995-03-12 15:50:58 +00:00
|
|
|
+ (id) alloc;
|
1998-09-28 20:38:02 +00:00
|
|
|
+ (Class) class;
|
2002-06-01 08:55:19 +00:00
|
|
|
+ (NSString*) description;
|
2002-06-09 04:57:04 +00:00
|
|
|
+ (void) initialize;
|
1994-11-08 16:44:01 +00:00
|
|
|
+ (IMP) instanceMethodForSelector: (SEL)aSelector;
|
1998-07-15 16:33:33 +00:00
|
|
|
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector;
|
2002-06-01 08:55:19 +00:00
|
|
|
+ (BOOL) instancesRespondToSelector: (SEL)aSelector;
|
2002-08-27 14:24:54 +00:00
|
|
|
+ (BOOL) isSubclassOfClass: (Class)aClass;
|
2002-06-01 08:55:19 +00:00
|
|
|
+ (id) new;
|
2001-12-17 14:31:42 +00:00
|
|
|
+ (void) poseAsClass: (Class)aClassObject;
|
2002-06-01 08:55:19 +00:00
|
|
|
+ (id) setVersion: (int)aVersion;
|
|
|
|
+ (Class) superclass;
|
|
|
|
+ (int) version;
|
1994-11-08 16:44:01 +00:00
|
|
|
|
2002-06-01 08:55:19 +00:00
|
|
|
- (id) autorelease;
|
1995-03-12 15:50:58 +00:00
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder;
|
2002-06-01 08:55:19 +00:00
|
|
|
- (Class) class;
|
1998-10-11 06:26:40 +00:00
|
|
|
- (Class) classForArchiver;
|
1994-11-08 16:44:01 +00:00
|
|
|
- (Class) classForCoder;
|
1998-10-11 06:26:40 +00:00
|
|
|
- (Class) classForPortCoder;
|
2002-06-09 04:57:04 +00:00
|
|
|
- (BOOL) conformsToProtocol: (Protocol*)aProtocol;
|
2002-06-01 08:55:19 +00:00
|
|
|
- (id) copy;
|
|
|
|
- (void) dealloc;
|
|
|
|
- (NSString*) description;
|
|
|
|
- (void) doesNotRecognizeSelector: (SEL)aSelector;
|
|
|
|
- (void) forwardInvocation: (NSInvocation*)anInvocation;
|
|
|
|
- (unsigned) hash;
|
|
|
|
- (id) init;
|
|
|
|
- (BOOL) isEqual: anObject;
|
|
|
|
- (BOOL) isKindOfClass: (Class)aClass;
|
|
|
|
- (BOOL) isMemberOfClass: (Class)aClass;
|
|
|
|
- (BOOL) isProxy;
|
|
|
|
- (IMP) methodForSelector: (SEL)aSelector;
|
|
|
|
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
|
|
|
|
- (id) mutableCopy;
|
|
|
|
- (id) performSelector: (SEL)aSelector;
|
2002-06-09 04:57:04 +00:00
|
|
|
- (id) performSelector: (SEL)aSelector
|
|
|
|
withObject: (id)anObject;
|
|
|
|
- (id) performSelector: (SEL)aSelector
|
|
|
|
withObject: (id)object1
|
|
|
|
withObject: (id)object2;
|
2002-06-01 08:55:19 +00:00
|
|
|
- (void) release;
|
2001-12-17 14:31:42 +00:00
|
|
|
- (id) replacementObjectForArchiver: (NSArchiver*)anArchiver;
|
1994-11-08 16:44:01 +00:00
|
|
|
- (id) replacementObjectForCoder: (NSCoder*)anEncoder;
|
2001-12-17 14:31:42 +00:00
|
|
|
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder;
|
2002-06-01 08:55:19 +00:00
|
|
|
- (BOOL) respondsToSelector: (SEL)aSelector;
|
|
|
|
- (id) retain;
|
|
|
|
- (unsigned) retainCount;
|
|
|
|
- (id) self;
|
|
|
|
- (Class) superclass;
|
|
|
|
- (NSZone*) zone;
|
1994-11-08 16:44:01 +00:00
|
|
|
@end
|
|
|
|
|
2002-06-01 08:55:19 +00:00
|
|
|
/**
|
|
|
|
* Used to allocate memory to hold an object, and initialise the
|
|
|
|
* class of the object to be aClass etc. The allocated memory will
|
|
|
|
* be extraBytes larger than the space actually needed to hold the
|
|
|
|
* instance variables of the object.<br />
|
2002-10-14 11:05:49 +00:00
|
|
|
* This function is used by the [NSObject+allocWithZone:] mnethod.
|
2002-06-01 08:55:19 +00:00
|
|
|
*/
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT NSObject *
|
|
|
|
NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
|
2002-06-01 08:55:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to release the memory used by an object.<br />
|
|
|
|
* This function is used by the [NSObject-dealloc] mnethod.
|
|
|
|
*/
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT void
|
|
|
|
NSDeallocateObject(NSObject *anObject);
|
2002-06-01 08:55:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to copy anObject. This makes a bitwise copy of anObject to
|
|
|
|
* memory allocated from zone. The allocated memory will be extraBytes
|
|
|
|
* longer than that necessary to actually store the instance variables
|
|
|
|
* of the copied object.<br />
|
2002-10-14 11:05:49 +00:00
|
|
|
* This is used by the NSObject implementation of the
|
|
|
|
* [(NSCopying)-copyWithZone:] method.
|
2002-06-01 08:55:19 +00:00
|
|
|
*/
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT NSObject *
|
|
|
|
NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone);
|
|
|
|
|
2002-06-01 08:55:19 +00:00
|
|
|
/**
|
|
|
|
* Returns a flag to indicate whether anObject should be retained or
|
|
|
|
* copied in order to make a copy in the specified zone.<br />
|
|
|
|
* Basically, this tests to see if anObject was allocated from
|
|
|
|
* requestedZone and returns YES if it was.
|
|
|
|
*/
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT BOOL
|
|
|
|
NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone);
|
2002-06-01 05:08:10 +00:00
|
|
|
|
2002-06-05 12:39:28 +00:00
|
|
|
GS_EXPORT BOOL
|
|
|
|
NSDecrementExtraRefCountWasZero(id anObject);
|
|
|
|
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT unsigned
|
|
|
|
NSExtraRefCount(id anObject);
|
2002-06-01 05:08:10 +00:00
|
|
|
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT void
|
|
|
|
NSIncrementExtraRefCount(id anObject);
|
2002-06-01 05:08:10 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Contains values <code>NSOrderedSame</code>, <code>NSOrderedAscending</code>
|
|
|
|
* <code>NSOrderedDescending</code>, for left hand side equals, less than, or
|
|
|
|
* greater than right hand side.
|
|
|
|
*/
|
1995-03-12 15:50:58 +00:00
|
|
|
typedef enum _NSComparisonResult
|
|
|
|
{
|
|
|
|
NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending
|
|
|
|
}
|
|
|
|
NSComparisonResult;
|
|
|
|
|
|
|
|
enum {NSNotFound = 0x7fffffff};
|
|
|
|
|
2002-01-07 11:24:52 +00:00
|
|
|
#ifndef NO_GNUSTEP
|
|
|
|
|
1995-03-12 19:34:43 +00:00
|
|
|
@interface NSObject (NEXTSTEP)
|
1995-03-12 15:50:58 +00:00
|
|
|
- error:(const char *)aString, ...;
|
1996-03-03 00:35:05 +00:00
|
|
|
/* - (const char *) name;
|
|
|
|
Removed because OpenStep has -(NSString*)name; */
|
1995-03-12 19:34:43 +00:00
|
|
|
@end
|
|
|
|
|
1998-11-02 10:23:56 +00:00
|
|
|
/* Global lock to be used by classes when operating on any global
|
|
|
|
data that invoke other methods which also access global; thus,
|
|
|
|
creating the potential for deadlock. */
|
2001-07-30 19:36:39 +00:00
|
|
|
GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
1998-11-02 10:23:56 +00:00
|
|
|
|
2004-04-16 23:21:26 +00:00
|
|
|
@interface NSObject (GNUstep)
|
2002-10-14 08:52:39 +00:00
|
|
|
- (id) makeImmutableCopyOnFail: (BOOL)force;
|
2000-03-17 13:13:08 +00:00
|
|
|
- (Class) transmuteClassTo: (Class)aClassObject;
|
1995-03-23 03:33:07 +00:00
|
|
|
+ (Class) autoreleaseClass;
|
|
|
|
+ (void) setAutoreleaseClass: (Class)aClass;
|
1995-08-04 20:53:05 +00:00
|
|
|
+ (void) enableDoubleReleaseCheck: (BOOL)enable;
|
2002-06-02 09:05:11 +00:00
|
|
|
- (id) read: (TypedStream*)aStream;
|
|
|
|
- (id) write: (TypedStream*)aStream;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1999-01-28 17:21:03 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Provides a number of GNUstep-specific methods that are used to aid
|
|
|
|
* implementation of the Base library.
|
|
|
|
*/
|
2003-01-26 19:38:42 +00:00
|
|
|
@interface NSObject (GSCategories)
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Message sent when an implementation wants to explicitly exclude a method
|
|
|
|
* (but cannot due to compiler constraint), and wants to make sure it is not
|
|
|
|
* called by mistake. Default implementation raises an exception at runtime.
|
|
|
|
*/
|
2003-01-26 19:38:42 +00:00
|
|
|
- notImplemented:(SEL)aSel;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Message sent when an implementation wants to explicitly require a subclass
|
|
|
|
* to implement a method (but cannot at compile time since there is no
|
|
|
|
* <code>abstract</code> keyword in Objective-C). Default implementation
|
|
|
|
* raises an exception at runtime to alert developer that he/she forgot to
|
|
|
|
* override a method.
|
|
|
|
*/
|
2003-01-26 19:38:42 +00:00
|
|
|
- (id) subclassResponsibility: (SEL)aSel;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Message sent when an implementation wants to explicitly exclude a method
|
|
|
|
* (but cannot due to compiler constraint) and forbid that subclasses
|
|
|
|
* implement it. Default implementation raises an exception at runtime. If a
|
|
|
|
* subclass <em>does</em> implement this method, however, the superclass's
|
|
|
|
* implementation will not be called, so this is not a perfect mechanism.
|
|
|
|
*/
|
2003-01-26 19:38:42 +00:00
|
|
|
- (id) shouldNotImplement: (SEL)aSel;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
2003-09-13 22:42:50 +00:00
|
|
|
WARNING: The -compare: method for NSObject is deprecated
|
|
|
|
due to subclasses declaring the same selector with
|
|
|
|
conflicting signatures.
|
|
|
|
Comparision of arbitrary objects is not just meaningless
|
|
|
|
but also dangerous as most concrete implementations
|
|
|
|
expect comparable objects as arguments often accessing
|
|
|
|
instance variables directly.
|
|
|
|
This method will be removed in a future release.
|
|
|
|
*/
|
2003-01-26 19:38:42 +00:00
|
|
|
- (NSComparisonResult) compare: (id)anObject;
|
|
|
|
@end
|
|
|
|
|
2002-03-10 06:21:24 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
1999-01-28 17:21:03 +00:00
|
|
|
* Protocol for garbage collection finalization - same as libFoundation
|
|
|
|
* for compatibility.
|
|
|
|
*/
|
|
|
|
@protocol GCFinalization
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Called before receiver is deallocated by garbage collector. If you want
|
|
|
|
* to do anything special before [NSObject -dealloc] is called, do it here.
|
|
|
|
*/
|
1999-01-28 17:21:03 +00:00
|
|
|
- (void) gcFinalize;
|
|
|
|
@end
|
|
|
|
|
1998-04-02 14:27:40 +00:00
|
|
|
#include <Foundation/NSDate.h>
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Declares some methods for sending messages to self after a fixed delay.
|
|
|
|
* (These methods <em>are</em> in OpenStep and OS X.)
|
|
|
|
*/
|
1998-04-02 14:27:40 +00:00
|
|
|
@interface NSObject (TimedPerformers)
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels any perform operations set up for the specified target
|
|
|
|
* in the current run loop.
|
|
|
|
*/
|
2002-08-27 14:24:54 +00:00
|
|
|
+ (void) cancelPreviousPerformRequestsWithTarget: (id)obj;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels any perform operations set up for the specified target
|
|
|
|
* in the current loop, but only if the value of aSelector and argument
|
|
|
|
* with which the performs were set up match those supplied.<br />
|
|
|
|
* Matching of the argument may be either by pointer equality or by
|
|
|
|
* use of the [NSObject-isEqual:] method.
|
|
|
|
*/
|
1998-04-02 14:27:40 +00:00
|
|
|
+ (void) cancelPreviousPerformRequestsWithTarget: (id)obj
|
|
|
|
selector: (SEL)s
|
|
|
|
object: (id)arg;
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* Sets given message to be sent to this instance after given delay,
|
|
|
|
* in any run loop mode. See [NSRunLoop].
|
|
|
|
*/
|
1998-04-02 14:27:40 +00:00
|
|
|
- (void) performSelector: (SEL)s
|
|
|
|
withObject: (id)arg
|
|
|
|
afterDelay: (NSTimeInterval)seconds;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets given message to be sent to this instance after given delay,
|
|
|
|
* in given run loop modes. See [NSRunLoop].
|
|
|
|
*/
|
1998-04-02 14:27:40 +00:00
|
|
|
- (void) performSelector: (SEL)s
|
|
|
|
withObject: (id)arg
|
|
|
|
afterDelay: (NSTimeInterval)seconds
|
|
|
|
inModes: (NSArray*)modes;
|
|
|
|
@end
|
|
|
|
|
1998-11-11 06:09:36 +00:00
|
|
|
/*
|
|
|
|
* RETAIN(), RELEASE(), and AUTORELEASE() are placeholders for the
|
1999-01-28 17:21:03 +00:00
|
|
|
* future day when we have garbage collecting.
|
1998-11-11 06:09:36 +00:00
|
|
|
*/
|
1999-01-28 17:21:03 +00:00
|
|
|
#ifndef GS_WITH_GC
|
|
|
|
#define GS_WITH_GC 0
|
|
|
|
#endif
|
|
|
|
#if GS_WITH_GC
|
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef RETAIN
|
1999-01-28 17:21:03 +00:00
|
|
|
#define RETAIN(object) ((id)object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RELEASE
|
1999-01-28 17:21:03 +00:00
|
|
|
#define RELEASE(object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef AUTORELEASE
|
1999-01-28 17:21:03 +00:00
|
|
|
#define AUTORELEASE(object) ((id)object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-01-28 17:21:03 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef TEST_RETAIN
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_RETAIN(object) ((id)object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_RELEASE
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_RELEASE(object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_AUTORELEASE
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_AUTORELEASE(object) ((id)object)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-04-21 20:16:25 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef ASSIGN
|
1999-01-28 17:21:03 +00:00
|
|
|
#define ASSIGN(object,value) (object = value)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef ASSIGNCOPY
|
1999-03-02 08:58:30 +00:00
|
|
|
#define ASSIGNCOPY(object,value) (object = [value copy])
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef DESTROY
|
1999-01-28 17:21:03 +00:00
|
|
|
#define DESTROY(object) (object = nil)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-01-28 17:21:03 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef CREATE_AUTORELEASE_POOL
|
1999-03-02 08:58:30 +00:00
|
|
|
#define CREATE_AUTORELEASE_POOL(X)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-03-02 08:58:30 +00:00
|
|
|
|
2000-09-26 11:45:32 +00:00
|
|
|
#ifndef RECREATE_AUTORELEASE_POOL
|
|
|
|
#define RECREATE_AUTORELEASE_POOL(X)
|
|
|
|
#endif
|
|
|
|
|
1999-09-28 19:35:09 +00:00
|
|
|
#define IF_NO_GC(X)
|
|
|
|
|
1999-01-28 17:21:03 +00:00
|
|
|
#else
|
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef RETAIN
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Basic retain operation ... calls [NSObject-retain]
|
|
|
|
*/
|
1998-11-11 06:09:36 +00:00
|
|
|
#define RETAIN(object) [object retain]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
2003-06-15 05:18:27 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef RELEASE
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Basic release operation ... calls [NSObject-release]
|
|
|
|
*/
|
1998-11-11 06:09:36 +00:00
|
|
|
#define RELEASE(object) [object release]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
2003-06-15 05:18:27 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef AUTORELEASE
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Basic autorelease operation ... calls [NSObject-autorelease]
|
|
|
|
*/
|
1998-11-11 06:09:36 +00:00
|
|
|
#define AUTORELEASE(object) [object autorelease]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1998-11-11 06:09:36 +00:00
|
|
|
|
2003-06-15 05:18:27 +00:00
|
|
|
#ifndef TEST_RETAIN
|
|
|
|
/**
|
|
|
|
* Tested retain - only invoke the
|
1999-04-21 20:16:25 +00:00
|
|
|
* objective-c method if the receiver is not nil.
|
|
|
|
*/
|
2002-08-08 19:25:17 +00:00
|
|
|
#define TEST_RETAIN(object) ({\
|
|
|
|
id __object = (id)(object); (__object != nil) ? [__object retain] : nil; })
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_RELEASE
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Tested release - only invoke the
|
|
|
|
* objective-c method if the receiver is not nil.
|
|
|
|
*/
|
2002-08-08 19:25:17 +00:00
|
|
|
#define TEST_RELEASE(object) ({\
|
2002-08-14 07:36:25 +00:00
|
|
|
id __object = (id)(object); if (__object != nil) [__object release]; })
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_AUTORELEASE
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Tested autorelease - only invoke the
|
|
|
|
* objective-c method if the receiver is not nil.
|
|
|
|
*/
|
2002-08-08 19:25:17 +00:00
|
|
|
#define TEST_AUTORELEASE(object) ({\
|
|
|
|
id __object = (id)(object); (__object != nil) ? [__object autorelease] : nil; })
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-04-21 20:16:25 +00:00
|
|
|
|
2003-06-15 05:18:27 +00:00
|
|
|
#ifndef ASSIGN
|
|
|
|
/**
|
1999-06-18 10:28:11 +00:00
|
|
|
* ASSIGN(object,value) assigns the value to the object with
|
1998-11-11 06:09:36 +00:00
|
|
|
* appropriate retain and release operations.
|
|
|
|
*/
|
|
|
|
#define ASSIGN(object,value) ({\
|
1999-06-18 10:28:11 +00:00
|
|
|
id __value = (id)(value); \
|
1999-09-28 19:35:09 +00:00
|
|
|
id __object = (id)(object); \
|
|
|
|
if (__value != __object) \
|
1998-12-17 05:53:08 +00:00
|
|
|
{ \
|
1999-09-28 19:35:09 +00:00
|
|
|
if (__value != nil) \
|
1998-12-17 05:53:08 +00:00
|
|
|
{ \
|
1999-02-05 06:10:49 +00:00
|
|
|
[__value retain]; \
|
1998-12-17 05:53:08 +00:00
|
|
|
} \
|
2001-07-31 15:43:57 +00:00
|
|
|
object = __value; \
|
1999-09-28 19:35:09 +00:00
|
|
|
if (__object != nil) \
|
1998-12-17 05:53:08 +00:00
|
|
|
{ \
|
1999-09-28 19:35:09 +00:00
|
|
|
[__object release]; \
|
1998-12-17 05:53:08 +00:00
|
|
|
} \
|
|
|
|
} \
|
1998-11-11 06:09:36 +00:00
|
|
|
})
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1998-11-11 06:09:36 +00:00
|
|
|
|
2003-06-15 05:18:27 +00:00
|
|
|
#ifndef ASSIGNCOPY
|
|
|
|
/**
|
2002-08-08 19:25:17 +00:00
|
|
|
* ASSIGNCOPY(object,value) assigns a copy of the value to the object
|
|
|
|
* with release of the original.
|
1999-02-13 00:50:41 +00:00
|
|
|
*/
|
|
|
|
#define ASSIGNCOPY(object,value) ({\
|
2002-08-08 19:25:17 +00:00
|
|
|
id __value = (id)(value); \
|
2001-07-31 15:43:57 +00:00
|
|
|
id __object = (id)(object); \
|
|
|
|
if (__value != __object) \
|
1999-02-13 00:50:41 +00:00
|
|
|
{ \
|
2001-07-31 15:43:57 +00:00
|
|
|
if (__value != nil) \
|
1999-02-13 00:50:41 +00:00
|
|
|
{ \
|
1999-03-02 08:58:30 +00:00
|
|
|
__value = [__value copy]; \
|
1999-02-13 00:50:41 +00:00
|
|
|
} \
|
2004-02-04 00:14:00 +00:00
|
|
|
object = __value; \
|
2001-07-31 15:43:57 +00:00
|
|
|
if (__object != nil) \
|
1999-02-13 00:50:41 +00:00
|
|
|
{ \
|
2001-07-31 15:43:57 +00:00
|
|
|
[__object release]; \
|
1999-02-13 00:50:41 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
})
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-02-13 00:50:41 +00:00
|
|
|
|
2003-06-15 05:18:27 +00:00
|
|
|
#ifndef DESTROY
|
|
|
|
/**
|
1999-09-28 19:35:09 +00:00
|
|
|
* DESTROY() is a release operation which also sets the variable to be
|
1998-11-11 06:09:36 +00:00
|
|
|
* a nil pointer for tidyness - we can't accidentally use a DESTROYED
|
1999-09-28 19:35:09 +00:00
|
|
|
* object later. It also makes sure to set the variable to nil before
|
|
|
|
* releasing the object - to avoid side-effects of the release trying
|
|
|
|
* to reference the object being released through the variable.
|
1998-11-11 06:09:36 +00:00
|
|
|
*/
|
1999-04-21 20:16:25 +00:00
|
|
|
#define DESTROY(object) ({ \
|
|
|
|
if (object) \
|
|
|
|
{ \
|
1999-09-28 19:35:09 +00:00
|
|
|
id __o = object; \
|
1999-04-21 20:16:25 +00:00
|
|
|
object = nil; \
|
1999-09-28 19:35:09 +00:00
|
|
|
[__o release]; \
|
1999-04-21 20:16:25 +00:00
|
|
|
} \
|
|
|
|
})
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-03-02 08:58:30 +00:00
|
|
|
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef CREATE_AUTORELEASE_POOL
|
2003-06-15 05:18:27 +00:00
|
|
|
/**
|
|
|
|
* Declares an autorelease pool variable and creates and initialises
|
|
|
|
* an autorelease pool object.
|
|
|
|
*/
|
1999-03-02 08:58:30 +00:00
|
|
|
#define CREATE_AUTORELEASE_POOL(X) \
|
2000-09-30 05:16:53 +00:00
|
|
|
NSAutoreleasePool *(X) = [NSAutoreleasePool new]
|
2000-09-26 11:45:32 +00:00
|
|
|
#endif
|
|
|
|
|
2003-06-15 05:18:27 +00:00
|
|
|
#ifndef RECREATE_AUTORELEASE_POOL
|
|
|
|
/**
|
2000-09-26 11:45:32 +00:00
|
|
|
* Similar, but allows reuse of variables. Be sure to use DESTROY()
|
|
|
|
* so the object variable stays nil.
|
|
|
|
*/
|
|
|
|
#define RECREATE_AUTORELEASE_POOL(X) \
|
|
|
|
if (X == nil) \
|
2000-09-30 05:16:53 +00:00
|
|
|
(X) = [NSAutoreleasePool new]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-03-02 08:58:30 +00:00
|
|
|
|
1999-09-28 19:35:09 +00:00
|
|
|
#define IF_NO_GC(X) X
|
|
|
|
|
1999-01-28 17:21:03 +00:00
|
|
|
#endif
|
1998-11-11 06:09:36 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __NSObject_h_GNUSTEP_BASE_INCLUDE */
|