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
|
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>
|
|
|
|
#include <base/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;
|
|
|
|
|
|
|
|
@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;
|
2000-03-17 13:13:08 +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
|
|
|
}
|
|
|
|
|
2000-07-04 11:05:46 +00:00
|
|
|
#if GS_WITH_GC
|
|
|
|
+ (BOOL) requiresTypedMemory;
|
|
|
|
#endif
|
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
|
|
|
|
2000-07-04 11:05:46 +00:00
|
|
|
+ (id) setVersion: (int)aVersion;
|
1998-09-28 20:38:02 +00:00
|
|
|
+ (int) version;
|
|
|
|
|
1994-11-08 16:44:01 +00:00
|
|
|
@end
|
|
|
|
|
2001-04-10 03:27:01 +00:00
|
|
|
GS_EXPORT NSObject *
|
|
|
|
NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
|
|
|
|
GS_EXPORT void
|
|
|
|
NSDeallocateObject(NSObject *anObject);
|
|
|
|
GS_EXPORT NSObject *
|
|
|
|
NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone);
|
|
|
|
|
|
|
|
GS_EXPORT BOOL
|
|
|
|
NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone);
|
|
|
|
GS_EXPORT unsigned
|
|
|
|
NSExtraRefCount(id anObject);
|
|
|
|
GS_EXPORT void
|
|
|
|
NSIncrementExtraRefCount(id anObject);
|
|
|
|
GS_EXPORT BOOL
|
|
|
|
NSDecrementExtraRefCountWasZero(id anObject);
|
1995-03-12 15:50:58 +00:00
|
|
|
|
|
|
|
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. */
|
2001-07-30 19:36:39 +00:00
|
|
|
GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
1998-11-02 10:23:56 +00:00
|
|
|
|
1998-12-18 17:05:44 +00:00
|
|
|
/*
|
2000-03-17 13:13:08 +00:00
|
|
|
* The GNUDescriptionDestination protocol declares methods used to
|
|
|
|
* append a property-list description string to some output destination
|
1998-12-18 17:05:44 +00:00
|
|
|
* 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
|
2000-03-17 13:13:08 +00:00
|
|
|
- (void) appendFormat: (NSString*)str, ...;
|
1998-12-18 17:05:44 +00:00
|
|
|
- (void) appendString: (NSString*)str;
|
|
|
|
@end
|
|
|
|
|
1995-03-12 19:34:43 +00:00
|
|
|
@interface NSObject (GNU)
|
2000-03-17 13:13:08 +00:00
|
|
|
- (int) compare: (id)anObject;
|
|
|
|
/*
|
|
|
|
* Default description methods -
|
|
|
|
* [descriptionWithLocale:] calls [description]
|
|
|
|
* [descriptionWithLocale:indent:] calls [descriptionWithLocale:]
|
|
|
|
* [descriptionWithLocale:indent:to:] calls [descriptionWithLocale:indent:]
|
|
|
|
* So - to have working descriptions, it is only necessary to implement the
|
|
|
|
* [description] method, and to have efficient property-list generation, it
|
|
|
|
* is necessary to override [descriptionWithLocale:indent:to:]
|
|
|
|
*/
|
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)aLocale;
|
|
|
|
+ (NSString*) descriptionWithLocale: (NSDictionary*)aLocale;
|
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)aLocale
|
|
|
|
indent: (unsigned)level;
|
|
|
|
+ (NSString*) descriptionWithLocale: (NSDictionary*)aLocale
|
|
|
|
indent: (unsigned)level;
|
1998-12-18 17:05:44 +00:00
|
|
|
- (void) descriptionWithLocale: (NSDictionary*)aLocale
|
2000-03-17 13:13:08 +00:00
|
|
|
indent: (unsigned)level
|
1998-12-18 17:05:44 +00:00
|
|
|
to: (id<GNUDescriptionDestination>)output;
|
2000-03-17 13:13:08 +00:00
|
|
|
+ (void) descriptionWithLocale: (NSDictionary*)aLocale
|
1998-12-18 17:05:44 +00:00
|
|
|
indent: (unsigned)level
|
|
|
|
to: (id<GNUDescriptionDestination>)output;
|
2000-03-17 13:13:08 +00:00
|
|
|
- (Class) transmuteClassTo: (Class)aClassObject;
|
1999-12-15 17:31:01 +00:00
|
|
|
- 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;
|
1999-12-15 17:31:01 +00:00
|
|
|
/*
|
|
|
|
* If the 'deallocActivationsActive' flag is set, the _dealloc method will be
|
|
|
|
* called during the final release of an object, and the dealloc method will
|
|
|
|
* then be called only if _dealloc returns YES.
|
|
|
|
* You can override the _dealloc implementation to perform some action before
|
|
|
|
* an object is deallocated (or disable deallocation by returning NO).
|
|
|
|
* The default implementation simply returns YES.
|
|
|
|
*/
|
|
|
|
- (BOOL) deallocNotificationsActive;
|
|
|
|
- (void) setDeallocNotificationsActive: (BOOL)flag;
|
|
|
|
- (BOOL) _dealloc;
|
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
|
|
|
|
|
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-04-21 20:16:25 +00:00
|
|
|
/*
|
|
|
|
* Basic retain, release, and autorelease operations.
|
|
|
|
*/
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef RETAIN
|
1998-11-11 06:09:36 +00:00
|
|
|
#define RETAIN(object) [object retain]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef RELEASE
|
1998-11-11 06:09:36 +00:00
|
|
|
#define RELEASE(object) [object release]
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef 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
|
|
|
|
1999-04-21 20:16:25 +00:00
|
|
|
/*
|
|
|
|
* Tested retain, release, and autorelease operations - only invoke the
|
|
|
|
* objective-c method if the receiver is not nil.
|
|
|
|
*/
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef TEST_RETAIN
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_RETAIN(object) (object != nil ? [object retain] : nil)
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_RELEASE
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_RELEASE(object) ({ if (object) [object release]; })
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TEST_AUTORELEASE
|
1999-04-21 20:16:25 +00:00
|
|
|
#define TEST_AUTORELEASE(object) ({ if (object) [object autorelease]; })
|
1999-05-21 08:35:50 +00:00
|
|
|
#endif
|
1999-04-21 20:16:25 +00:00
|
|
|
|
1998-11-11 06:09:36 +00:00
|
|
|
/*
|
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.
|
|
|
|
*/
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef ASSIGN
|
1998-11-11 06:09:36 +00:00
|
|
|
#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
|
|
|
object = __value; \
|
|
|
|
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
|
|
|
} \
|
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
|
|
|
|
1999-02-13 00:50:41 +00:00
|
|
|
/*
|
|
|
|
* ASSIGNCOPY(object,value) assignes a copy of the value to the object with
|
|
|
|
* and release operations.
|
|
|
|
*/
|
1999-05-21 08:35:50 +00:00
|
|
|
#ifndef ASSIGNCOPY
|
1999-02-13 00:50:41 +00:00
|
|
|
#define ASSIGNCOPY(object,value) ({\
|
1999-06-18 10:28:11 +00:00
|
|
|
id __value = (value); \
|
|
|
|
if (__value != (id)object) \
|
1999-02-13 00:50:41 +00:00
|
|
|
{ \
|
|
|
|
if (__value) \
|
|
|
|
{ \
|
1999-03-02 08:58:30 +00:00
|
|
|
__value = [__value copy]; \
|
1999-02-13 00:50:41 +00:00
|
|
|
} \
|
|
|
|
if (object) \
|
|
|
|
{ \
|
1999-06-18 10:28:11 +00:00
|
|
|
[(id)object release]; \
|
1999-02-13 00:50:41 +00:00
|
|
|
} \
|
1999-06-18 10:28:11 +00:00
|
|
|
(id)object = __value; \
|
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
|
|
|
|
1998-11-11 06:09:36 +00:00
|
|
|
/*
|
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-05-21 08:35:50 +00:00
|
|
|
#ifndef DESTROY
|
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
|
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
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Similar, but allows reuse of variables. Be sure to use DESTROY()
|
|
|
|
* so the object variable stays nil.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RECREATE_AUTORELEASE_POOL
|
|
|
|
#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 */
|