1995-03-12 15:50:58 +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
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
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>
|
1998-12-20 21:27:47 +00:00
|
|
|
#include <base/fake-main.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;
|
|
|
|
|
|
|
|
@protocol NSObject
|
|
|
|
- (Class) class;
|
1998-09-28 20:38:02 +00:00
|
|
|
- (Class) superclass;
|
1995-03-12 15:50:58 +00:00
|
|
|
- (BOOL) isEqual: anObject;
|
|
|
|
- (BOOL) isKindOfClass: (Class)aClass;
|
|
|
|
- (BOOL) isMemberOfClass: (Class)aClass;
|
|
|
|
- (BOOL) isProxy;
|
1998-09-28 20:38:02 +00:00
|
|
|
- (unsigned) hash;
|
|
|
|
- self;
|
|
|
|
- performSelector: (SEL)aSelector;
|
|
|
|
- performSelector: (SEL)aSelector withObject: anObject;
|
|
|
|
- performSelector: (SEL)aSelector withObject: object1 withObject: object2;
|
1995-03-12 15:50:58 +00:00
|
|
|
- (BOOL) respondsToSelector: (SEL)aSelector;
|
1998-09-28 20:38:02 +00:00
|
|
|
- (BOOL) conformsToProtocol: (Protocol *)aProtocol;
|
1995-03-12 15:50:58 +00:00
|
|
|
- retain;
|
1998-09-28 20:38:02 +00:00
|
|
|
- autorelease;
|
|
|
|
- (oneway void) release;
|
1995-03-12 15:50:58 +00:00
|
|
|
- (unsigned) retainCount;
|
1996-02-22 16:00:04 +00:00
|
|
|
- (NSZone *) zone;
|
|
|
|
- (NSString *) description;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSCopying
|
1998-07-15 12:43:56 +00:00
|
|
|
- (id) copyWithZone: (NSZone *)zone;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
@protocol NSMutableCopying
|
1998-07-15 12:43:56 +00:00
|
|
|
- (id) mutableCopyWithZone: (NSZone *)zone;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol NSCoding
|
1995-04-09 02:06:39 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder;
|
|
|
|
- (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
|
|
|
{
|
1995-03-12 15:50:58 +00:00
|
|
|
Class isa;
|
1994-11-08 16:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) initialize;
|
|
|
|
+ (id) allocWithZone: (NSZone*)z;
|
1995-03-12 15:50:58 +00:00
|
|
|
+ (id) alloc;
|
1994-11-08 16:44:01 +00:00
|
|
|
+ (id) new;
|
|
|
|
- (id) copy;
|
|
|
|
- (void) dealloc;
|
|
|
|
- (id) init;
|
|
|
|
- (id) mutableCopy;
|
|
|
|
|
1998-09-28 20:38:02 +00:00
|
|
|
+ (Class) class;
|
|
|
|
+ (Class) superclass;
|
1994-11-08 16:44:01 +00:00
|
|
|
|
|
|
|
+ (BOOL) instancesRespondToSelector: (SEL)aSelector;
|
|
|
|
|
|
|
|
+ (IMP) instanceMethodForSelector: (SEL)aSelector;
|
|
|
|
- (IMP) methodForSelector: (SEL)aSelector;
|
1998-07-15 16:33:33 +00:00
|
|
|
+ (NSMethodSignature*) instanceMethodSignatureForSelector: (SEL)aSelector;
|
1994-11-08 16:44:01 +00:00
|
|
|
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector;
|
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
- (NSString*) description;
|
1994-11-08 16:44:01 +00:00
|
|
|
+ (NSString*) description;
|
|
|
|
|
|
|
|
+ (void) poseAsClass: (Class)aClass;
|
|
|
|
|
|
|
|
- (void) doesNotRecognizeSelector: (SEL)aSelector;
|
|
|
|
|
|
|
|
- (void) forwardInvocation: (NSInvocation*)anInvocation;
|
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder*)aDecoder;
|
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;
|
1998-10-22 10:02:39 +00:00
|
|
|
- (id) replacementObjectForArchiver: (NSArchiver*)anEncoder;
|
1994-11-08 16:44:01 +00:00
|
|
|
- (id) replacementObjectForCoder: (NSCoder*)anEncoder;
|
1998-10-11 06:26:40 +00:00
|
|
|
- (id) replacementObjectForPortCoder: (NSPortCoder*)anEncoder;
|
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
|
1998-09-28 20:38:02 +00:00
|
|
|
+ setVersion: (int)aVersion;
|
|
|
|
+ (int) version;
|
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
@end
|
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
NSObject *NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
|
|
|
|
void NSDeallocateObject(NSObject *anObject);
|
|
|
|
NSObject *NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone);
|
1995-04-09 02:06:39 +00:00
|
|
|
|
1995-03-12 15:50:58 +00:00
|
|
|
BOOL NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone);
|
|
|
|
void NSIncrementExtraRefCount(id anObject);
|
|
|
|
BOOL NSDecrementExtraRefCountWasZero(id anObject);
|
|
|
|
|
|
|
|
typedef enum _NSComparisonResult
|
|
|
|
{
|
|
|
|
NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending
|
|
|
|
}
|
|
|
|
NSComparisonResult;
|
|
|
|
|
|
|
|
enum {NSNotFound = 0x7fffffff};
|
|
|
|
|
1995-03-12 19:34:43 +00:00
|
|
|
@interface NSObject (NEXTSTEP)
|
1995-03-12 15:50:58 +00:00
|
|
|
- error:(const char *)aString, ...;
|
|
|
|
- notImplemented:(SEL)aSel;
|
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
|
|
|
#ifndef NO_GNUSTEP
|
|
|
|
/* 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. */
|
|
|
|
extern NSRecursiveLock *gnustep_global_lock;
|
|
|
|
|
1998-12-18 17:05:44 +00:00
|
|
|
/*
|
|
|
|
* The GNUDescriptionDestination protocol declares a single method used
|
|
|
|
* to append a property-list description string to some output destination
|
|
|
|
* so that property-lists can be converted to strings in a stream avoiding
|
|
|
|
* the use of ridiculous amounts of memory for deeply nested data structures.
|
|
|
|
*/
|
|
|
|
@protocol GNUDescriptionDestination
|
|
|
|
- (void) appendString: (NSString*)str;
|
|
|
|
@end
|
|
|
|
|
1995-03-12 19:34:43 +00:00
|
|
|
@interface NSObject (GNU)
|
1995-03-23 03:33:07 +00:00
|
|
|
- (int) compare: anObject;
|
1998-12-18 17:05:44 +00:00
|
|
|
- (void) descriptionTo: (id<GNUDescriptionDestination>)output;
|
|
|
|
- (void) descriptionWithLocale: (NSDictionary*)aLocale
|
|
|
|
to: (id<GNUDescriptionDestination>)output;
|
|
|
|
- (void) descriptionWithLocale: (NSDictionary*)aLocale
|
|
|
|
indent: (unsigned)level
|
|
|
|
to: (id<GNUDescriptionDestination>)output;
|
1995-03-12 19:34:43 +00:00
|
|
|
- (Class)transmuteClassTo:(Class)aClassObject;
|
|
|
|
- subclassResponsibility:(SEL)aSel;
|
|
|
|
- shouldNotImplement:(SEL)aSel;
|
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;
|
1995-03-23 03:33:07 +00:00
|
|
|
- read: (TypedStream*)aStream;
|
|
|
|
- write: (TypedStream*)aStream;
|
1995-03-12 15:50:58 +00:00
|
|
|
@end
|
1999-01-28 17:21:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Protocol for garbage collection finalization - same as libFoundation
|
|
|
|
* for compatibility.
|
|
|
|
*/
|
|
|
|
@protocol GCFinalization
|
|
|
|
- (void) gcFinalize;
|
|
|
|
@end
|
|
|
|
|
1998-11-02 10:23:56 +00:00
|
|
|
#endif
|
1995-03-12 15:50:58 +00:00
|
|
|
|
1998-04-02 14:27:40 +00:00
|
|
|
#include <Foundation/NSDate.h>
|
|
|
|
@interface NSObject (TimedPerformers)
|
|
|
|
+ (void) cancelPreviousPerformRequestsWithTarget: (id)obj
|
|
|
|
selector: (SEL)s
|
|
|
|
object: (id)arg;
|
|
|
|
- (void) performSelector: (SEL)s
|
|
|
|
withObject: (id)arg
|
|
|
|
afterDelay: (NSTimeInterval)seconds;
|
|
|
|
- (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
|
|
|
|
|
|
|
|
#define RETAIN(object) ((id)object)
|
|
|
|
#define RELEASE(object)
|
|
|
|
#define AUTORELEASE(object) ((id)object)
|
|
|
|
|
|
|
|
#define ASSIGN(object,value) (object = value)
|
1999-03-02 08:58:30 +00:00
|
|
|
#define ASSIGNCOPY(object,value) (object = [value copy])
|
1999-01-28 17:21:03 +00:00
|
|
|
#define DESTROY(object) (object = nil)
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
#define CREATE_AUTORELEASE_POOL(X)
|
|
|
|
|
1999-01-28 17:21:03 +00:00
|
|
|
#else
|
|
|
|
|
1998-11-11 06:09:36 +00:00
|
|
|
#define RETAIN(object) [object retain]
|
|
|
|
#define RELEASE(object) [object release]
|
|
|
|
#define AUTORELEASE(object) [object autorelease]
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ASSIGN(object,value) assignes the value to the object with
|
|
|
|
* appropriate retain and release operations.
|
|
|
|
*/
|
|
|
|
#define ASSIGN(object,value) ({\
|
1999-02-05 06:10:49 +00:00
|
|
|
typeof (value) __value = (value); \
|
|
|
|
if (__value != object) \
|
1998-12-17 05:53:08 +00:00
|
|
|
{ \
|
1999-02-05 06:10:49 +00:00
|
|
|
if (__value) \
|
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
|
|
|
} \
|
|
|
|
if (object) \
|
|
|
|
{ \
|
|
|
|
[object release]; \
|
|
|
|
} \
|
1999-02-05 06:10:49 +00:00
|
|
|
object = __value; \
|
1998-12-17 05:53:08 +00:00
|
|
|
} \
|
1998-11-11 06:09:36 +00:00
|
|
|
})
|
|
|
|
|
1999-02-13 00:50:41 +00:00
|
|
|
/*
|
|
|
|
* ASSIGNCOPY(object,value) assignes a copy of the value to the object with
|
|
|
|
* and release operations.
|
|
|
|
*/
|
|
|
|
#define ASSIGNCOPY(object,value) ({\
|
|
|
|
typeof (value) __value = (value); \
|
|
|
|
if (__value != object) \
|
|
|
|
{ \
|
|
|
|
if (__value) \
|
|
|
|
{ \
|
1999-03-02 08:58:30 +00:00
|
|
|
__value = [__value copy]; \
|
1999-02-13 00:50:41 +00:00
|
|
|
} \
|
|
|
|
if (object) \
|
|
|
|
{ \
|
|
|
|
[object release]; \
|
|
|
|
} \
|
|
|
|
object = __value; \
|
|
|
|
} \
|
|
|
|
})
|
|
|
|
|
1998-11-11 06:09:36 +00:00
|
|
|
/*
|
|
|
|
* DESTROY() is a release operation which also sets the object to be
|
|
|
|
* a nil pointer for tidyness - we can't accidentally use a DESTROYED
|
|
|
|
* object later.
|
|
|
|
*/
|
|
|
|
#define DESTROY(object) ([object release], object = nil)
|
1999-03-02 08:58:30 +00:00
|
|
|
|
|
|
|
#define CREATE_AUTORELEASE_POOL(X) \
|
|
|
|
NSAutoreleasePool *(X) = [NSAutoreleasePool new]
|
|
|
|
|
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 */
|