2002-11-19 05:37:42 +00:00
|
|
|
|
/* Implementation of garbage collecting array classes.
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
|
Inspired by gc classes of Ovidiu Predescu and Mircea Oancea
|
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2002-11-19 05:37:42 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
2002-11-19 05:37:42 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2002-11-19 05:37:42 +00:00
|
|
|
|
License along with this library; if not, write to the Free
|
2024-11-07 13:37:59 +00:00
|
|
|
|
Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2010-02-19 08:12:46 +00:00
|
|
|
|
#import "common.h"
|
2003-02-03 04:15:27 +00:00
|
|
|
|
#ifndef NeXT_Foundation_LIBRARY
|
2010-02-14 10:48:10 +00:00
|
|
|
|
#import "Foundation/NSException.h"
|
|
|
|
|
#import "Foundation/NSRange.h"
|
2003-02-03 04:15:27 +00:00
|
|
|
|
#endif
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
2010-02-14 10:48:10 +00:00
|
|
|
|
#import "GNUstepBase/GSObjCRuntime.h"
|
|
|
|
|
#import "GNUstepBase/GCObject.h"
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
@implementation GCArray
|
|
|
|
|
|
|
|
|
|
static Class gcClass = 0;
|
|
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (gcClass == 0)
|
|
|
|
|
{
|
|
|
|
|
gcClass = [GCObject class];
|
2002-11-27 12:52:29 +00:00
|
|
|
|
GSObjCAddClassBehavior(self, gcClass);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (Class) classForCoder
|
|
|
|
|
{
|
|
|
|
|
return [GCArray class];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
|
|
|
|
{
|
2004-12-13 04:53:01 +00:00
|
|
|
|
GCArray *result;
|
|
|
|
|
id *objects;
|
2010-03-08 07:06:47 +00:00
|
|
|
|
NSUInteger i, c = [self count];
|
2004-12-13 04:53:01 +00:00
|
|
|
|
|
2002-11-19 05:37:42 +00:00
|
|
|
|
if (NSShouldRetainWithZone(self, zone))
|
|
|
|
|
{
|
|
|
|
|
return [self retain];
|
|
|
|
|
}
|
2004-12-13 04:53:01 +00:00
|
|
|
|
|
|
|
|
|
objects = NSZoneMalloc(zone, c * sizeof(id));
|
|
|
|
|
/* FIXME: Check if malloc return 0 */
|
|
|
|
|
[self getObjects: objects];
|
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
|
{
|
|
|
|
|
objects[i] = [objects[i] copy];
|
|
|
|
|
}
|
|
|
|
|
result = [[GCArray allocWithZone: zone] initWithObjects: objects count: c];
|
|
|
|
|
NSZoneFree(zone, objects);
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
2004-12-13 04:53:01 +00:00
|
|
|
|
return result;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (NSUInteger) count
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
return _count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger c = _count;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
[GCObject gcObjectWillBeDeallocated: (GCObject*)self];
|
|
|
|
|
if ([GCObject gcIsCollecting])
|
|
|
|
|
{
|
|
|
|
|
while (c-- > 0)
|
|
|
|
|
{
|
|
|
|
|
if (_isGCObject[c] == NO)
|
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
DESTROY(_contents[c]);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (c-- > 0)
|
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
DESTROY(_contents[c]);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSZoneFree([self zone], _contents);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) gcDecrementRefCountOfContainedObjects
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger c = _count;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
gc.flags.visited = 0;
|
|
|
|
|
while (c-- > 0)
|
|
|
|
|
{
|
|
|
|
|
if (_isGCObject[c])
|
|
|
|
|
{
|
|
|
|
|
[_contents[c] gcDecrementRefCount];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) gcIncrementRefCountOfContainedObjects
|
|
|
|
|
{
|
|
|
|
|
if (gc.flags.visited == 1)
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger c = _count;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
gc.flags.visited = 1;
|
|
|
|
|
while (c-- > 0)
|
|
|
|
|
{
|
|
|
|
|
if (_isGCObject[c])
|
|
|
|
|
{
|
|
|
|
|
[_contents[c] gcIncrementRefCount];
|
|
|
|
|
[_contents[c] gcIncrementRefCountOfContainedObjects];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 12:02:04 +00:00
|
|
|
|
- (id) initWithObjects: (const id[])objects count: (NSUInteger)count
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
_contents = NSZoneMalloc([self zone], count * (sizeof(id) + sizeof(BOOL)));
|
|
|
|
|
_isGCObject = (BOOL*)&_contents[count];
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_count = 0;
|
|
|
|
|
while (_count < count)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
_contents[_count] = RETAIN(objects[_count]);
|
2002-11-26 09:15:11 +00:00
|
|
|
|
if (_contents[_count] == nil)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2010-02-25 18:49:31 +00:00
|
|
|
|
DESTROY(self);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Nil object to be added in array"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_isGCObject[_count] = [objects[_count] isKindOfClass: gcClass];
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_count++;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithArray: (NSArray*)anotherArray
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger count = [anotherArray count];
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
_contents = NSZoneMalloc([self zone], count * (sizeof(id) + sizeof(BOOL)));
|
|
|
|
|
_isGCObject = (BOOL*)&_contents[count];
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_count = 0;
|
|
|
|
|
while (_count < count)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
_contents[_count] = RETAIN([anotherArray objectAtIndex: _count]);
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_isGCObject[_count] = [_contents[_count] isKindOfClass: gcClass];
|
|
|
|
|
_count++;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We use the same initial instance variable layout as a GCObject and
|
|
|
|
|
* ue the <em>behavior</em> mechanism to inherit methods from that class
|
|
|
|
|
* to implement a form of multiple inheritance. We need to implement
|
|
|
|
|
* this method to make this apparent at runtime.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) isKindOfClass: (Class)c
|
|
|
|
|
{
|
|
|
|
|
if (c == gcClass)
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
return [super isKindOfClass: c];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) mutableCopyWithZone: (NSZone*)zone
|
|
|
|
|
{
|
2004-12-13 04:53:01 +00:00
|
|
|
|
return [[GCMutableArray allocWithZone: zone] initWithArray: self];
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (id) objectAtIndex: (NSUInteger)index
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (index >= _count)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSRangeException
|
2013-07-02 15:46:26 +00:00
|
|
|
|
format: @"[%@-%@]: index: %"PRIuPTR,
|
2002-11-19 05:37:42 +00:00
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd), index];
|
|
|
|
|
}
|
|
|
|
|
return _contents[index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation GCMutableArray
|
|
|
|
|
|
|
|
|
|
+ (void)initialize
|
|
|
|
|
{
|
|
|
|
|
static BOOL beenHere = NO;
|
|
|
|
|
|
|
|
|
|
if (beenHere == NO)
|
|
|
|
|
{
|
|
|
|
|
beenHere = YES;
|
2002-11-27 12:52:29 +00:00
|
|
|
|
GSObjCAddClassBehavior(self, [GCArray class]);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) addObject: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
[self insertObject: anObject atIndex: _count];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (Class) classForCoder
|
|
|
|
|
{
|
|
|
|
|
return [GCMutableArray class];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
|
|
|
|
{
|
2004-12-13 04:53:01 +00:00
|
|
|
|
GCArray *result;
|
|
|
|
|
id *objects;
|
2010-03-08 07:06:47 +00:00
|
|
|
|
NSUInteger i, c = [self count];
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
2004-12-13 04:53:01 +00:00
|
|
|
|
objects = NSZoneMalloc(zone, c * sizeof(id));
|
|
|
|
|
/* FIXME: Check if malloc return 0 */
|
|
|
|
|
[self getObjects: objects];
|
|
|
|
|
for (i = 0; i < c; i++)
|
|
|
|
|
{
|
|
|
|
|
objects[i] = [objects[i] copy];
|
|
|
|
|
}
|
|
|
|
|
result = [[GCArray allocWithZone: zone] initWithObjects: objects count: c];
|
|
|
|
|
NSZoneFree(zone, objects);
|
2005-02-22 11:22:44 +00:00
|
|
|
|
|
2004-12-13 04:53:01 +00:00
|
|
|
|
return result;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
return [self initWithCapacity: 1];
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-26 09:15:11 +00:00
|
|
|
|
- (id) initWithArray: (NSArray*)anotherArray
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger count = [anotherArray count];
|
2002-11-26 09:15:11 +00:00
|
|
|
|
|
|
|
|
|
self = [self initWithCapacity: count];
|
|
|
|
|
if (self != nil)
|
|
|
|
|
{
|
|
|
|
|
while (_count < count)
|
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
_contents[_count] = RETAIN([anotherArray objectAtIndex: _count]);
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_isGCObject[_count] = [_contents[_count] isKindOfClass: gcClass];
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (id) initWithCapacity: (NSUInteger)aNumItems
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (aNumItems < 1)
|
|
|
|
|
{
|
|
|
|
|
aNumItems = 1;
|
|
|
|
|
}
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_contents = NSZoneMalloc([self zone],
|
|
|
|
|
aNumItems * (sizeof(id) + sizeof(BOOL)));
|
2002-11-19 05:37:42 +00:00
|
|
|
|
_isGCObject = (BOOL*)&_contents[aNumItems];
|
|
|
|
|
_maxCount = aNumItems;
|
|
|
|
|
_count = 0;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 12:02:04 +00:00
|
|
|
|
- (id) initWithObjects: (const id [])objects count: (NSUInteger)count
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
self = [self initWithCapacity: count];
|
|
|
|
|
if (self != nil)
|
|
|
|
|
{
|
2002-11-26 09:15:11 +00:00
|
|
|
|
while (_count < count)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
_contents[_count] = RETAIN(objects[_count]);
|
2002-11-26 09:15:11 +00:00
|
|
|
|
if (_contents[_count] == nil)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2010-02-25 18:49:31 +00:00
|
|
|
|
DESTROY(self);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Nil object to be added in array"];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_isGCObject[_count] = [objects[_count] isKindOfClass: gcClass];
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
2002-11-26 09:15:11 +00:00
|
|
|
|
_count++;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (void) insertObject: (id)anObject atIndex: (NSUInteger)index
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger i;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
if (anObject == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"[%@-%@]: nil argument",
|
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
|
|
|
|
}
|
|
|
|
|
if (index > _count)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSRangeException
|
2013-07-02 15:46:26 +00:00
|
|
|
|
format: @"[%@-%@]: bad index %"PRIuPTR,
|
2002-11-19 05:37:42 +00:00
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd), index];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_count == _maxCount)
|
|
|
|
|
{
|
2010-03-08 07:06:47 +00:00
|
|
|
|
NSUInteger old = _maxCount;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
BOOL *optr;
|
|
|
|
|
|
|
|
|
|
if (_maxCount > 0)
|
|
|
|
|
{
|
|
|
|
|
_maxCount += (_maxCount >> 1) ? (_maxCount >> 1) : 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_maxCount = 1;
|
|
|
|
|
}
|
|
|
|
|
_contents = (id*)NSZoneRealloc([self zone], _contents,
|
|
|
|
|
_maxCount * (sizeof(id) + sizeof(BOOL)));
|
|
|
|
|
optr = (BOOL*)&_contents[old];
|
|
|
|
|
_isGCObject = (BOOL*)&_contents[_maxCount];
|
|
|
|
|
memmove(_isGCObject, optr, sizeof(BOOL)*old);
|
|
|
|
|
}
|
2005-02-22 11:22:44 +00:00
|
|
|
|
for (i = _count; i > index; i--)
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
_contents[i] = _contents[i - 1];
|
|
|
|
|
_isGCObject[i] = _isGCObject[i - 1];
|
|
|
|
|
}
|
2003-04-01 04:27:18 +00:00
|
|
|
|
_contents[index] = RETAIN(anObject);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
_isGCObject[index] = [anObject isKindOfClass: gcClass];
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) mutableCopyWithZone: (NSZone*)zone
|
|
|
|
|
{
|
2004-12-13 04:53:01 +00:00
|
|
|
|
return [[GCMutableArray allocWithZone: zone] initWithArray: self];
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) removeAllObjects
|
|
|
|
|
{
|
|
|
|
|
[self removeObjectsInRange: NSMakeRange(0, _count)];
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (void) removeObjectAtIndex: (NSUInteger)index
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
[self removeObjectsInRange: NSMakeRange(index, 1)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) removeObjectsInRange: (NSRange)range
|
|
|
|
|
{
|
2009-02-23 20:42:32 +00:00
|
|
|
|
NSUInteger i;
|
2002-11-19 05:37:42 +00:00
|
|
|
|
|
|
|
|
|
if (NSMaxRange(range) > _count)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSRangeException
|
|
|
|
|
format: @"[%@-%@]: bad range %@",
|
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
|
|
|
|
|
NSStringFromRange(range)];
|
|
|
|
|
}
|
|
|
|
|
if (range.length == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (i = range.location; i < NSMaxRange(range); i++)
|
|
|
|
|
{
|
2003-04-01 04:27:18 +00:00
|
|
|
|
RELEASE(_contents[i]);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
for (i = NSMaxRange(range); i < _count; i++, range.location++)
|
|
|
|
|
{
|
|
|
|
|
_contents[range.location] = _contents[i];
|
|
|
|
|
_isGCObject[range.location] = _isGCObject[i];
|
|
|
|
|
}
|
|
|
|
|
_count -= range.length;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
|
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
|
2002-11-19 05:37:42 +00:00
|
|
|
|
{
|
|
|
|
|
if (anObject == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"[%@-%@]: nil argument",
|
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
|
|
|
|
}
|
|
|
|
|
if (index >= _count)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSRangeException
|
2013-07-02 15:46:26 +00:00
|
|
|
|
format: @"[%@-%@]: bad index %"PRIuPTR,
|
2002-11-19 05:37:42 +00:00
|
|
|
|
NSStringFromClass([self class]), NSStringFromSelector(_cmd), index];
|
|
|
|
|
}
|
2003-04-01 04:27:18 +00:00
|
|
|
|
ASSIGN(_contents[index], anObject);
|
2002-11-19 05:37:42 +00:00
|
|
|
|
_isGCObject[index] = [anObject isKindOfClass: gcClass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|