Inline map and array updates.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4447 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-06-21 08:30:26 +00:00
parent aade319e69
commit e704dbd2b8
22 changed files with 829 additions and 914 deletions

View file

@ -161,8 +161,8 @@ libgnustep-base.def
GNU_HEADERS = \
fast.x \
GSUnion.h \
FastArray.x \
FastMap.x \
GSIArray.h \
GSIMap.h \
Archiver.h \
Array.h \
ArrayPrivate.h \

View file

@ -212,22 +212,24 @@ $(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \
: $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)/GSConfig.h
#
# Files that include FastArray.x will need a rebuild if it is changed.
# Files that include GSIArray.h will need a rebuild if it is changed.
#
$(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \
$(GNUSTEP_OBJ_DIR)/NSRunLoop.o \
$(GNUSTEP_OBJ_DIR)/NSSerializer.o \
$(GNUSTEP_OBJ_DIR)/NSUnarchiver.o \
: include/FastArray.x include/GSUnion.h
: include/GSIArray.h include/GSUnion.h
#
# Files that include FastMap.x will need a rebuild if it is changed.
# Files that include GSIMap.h will need a rebuild if it is changed.
#
$(GNUSTEP_OBJ_DIR)/NSArchiver.o \
$(GNUSTEP_OBJ_DIR)/NSGCountedSet.o \
$(GNUSTEP_OBJ_DIR)/NSGDictionary.o \
$(GNUSTEP_OBJ_DIR)/NSGSet.o \
$(GNUSTEP_OBJ_DIR)/NSNotificationCenter.o \
$(GNUSTEP_OBJ_DIR)/NSSerializer.o \
: include/FastMap.x include/GSUnion.h
: include/GSIMap.h include/GSUnion.h
#
# Files that include fast.x will need a rebuild if it is changed.

View file

@ -26,14 +26,14 @@
/*
* Setup for inline operation of pointer map tables.
*/
#define FAST_MAP_RETAIN_KEY(X) X
#define FAST_MAP_RELEASE_KEY(X)
#define FAST_MAP_RETAIN_VAL(X) X
#define FAST_MAP_RELEASE_VAL(X)
#define FAST_MAP_HASH(X) ((X).uint)
#define FAST_MAP_EQUAL(X,Y) ((X).uint == (Y).uint)
#define GSI_MAP_RETAIN_KEY(X) X
#define GSI_MAP_RELEASE_KEY(X)
#define GSI_MAP_RETAIN_VAL(X) X
#define GSI_MAP_RELEASE_VAL(X)
#define GSI_MAP_HASH(X) ((X).uint)
#define GSI_MAP_EQUAL(X,Y) ((X).uint == (Y).uint)
#include <base/FastMap.x>
#include <base/GSIMap.h>
#define _IN_NSARCHIVER_M
#include <Foundation/NSArchiver.h>
@ -97,18 +97,18 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
/*
* Set up map tables.
*/
clsMap = (FastMapTable)NSZoneMalloc(zone, sizeof(FastMapTable_t)*6);
clsMap = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t)*6);
cIdMap = &clsMap[1];
uIdMap = &clsMap[2];
ptrMap = &clsMap[3];
namMap = &clsMap[4];
repMap = &clsMap[5];
FastMapInitWithZoneAndCapacity(clsMap, zone, 100);
FastMapInitWithZoneAndCapacity(cIdMap, zone, 10);
FastMapInitWithZoneAndCapacity(uIdMap, zone, 200);
FastMapInitWithZoneAndCapacity(ptrMap, zone, 100);
FastMapInitWithZoneAndCapacity(namMap, zone, 1);
FastMapInitWithZoneAndCapacity(repMap, zone, 1);
GSIMapInitWithZoneAndCapacity(clsMap, zone, 100);
GSIMapInitWithZoneAndCapacity(cIdMap, zone, 10);
GSIMapInitWithZoneAndCapacity(uIdMap, zone, 200);
GSIMapInitWithZoneAndCapacity(ptrMap, zone, 100);
GSIMapInitWithZoneAndCapacity(namMap, zone, 1);
GSIMapInitWithZoneAndCapacity(repMap, zone, 1);
}
return self;
}
@ -118,26 +118,26 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
RELEASE(data);
if (clsMap)
{
FastMapEmptyMap(clsMap);
GSIMapEmptyMap(clsMap);
if (cIdMap)
{
FastMapEmptyMap(cIdMap);
GSIMapEmptyMap(cIdMap);
}
if (uIdMap)
{
FastMapEmptyMap(uIdMap);
GSIMapEmptyMap(uIdMap);
}
if (ptrMap)
{
FastMapEmptyMap(ptrMap);
GSIMapEmptyMap(ptrMap);
}
if (namMap)
{
FastMapEmptyMap(namMap);
GSIMapEmptyMap(namMap);
}
if (repMap)
{
FastMapEmptyMap(repMap);
GSIMapEmptyMap(repMap);
}
NSZoneFree(clsMap->zone, (void*)clsMap);
}
@ -316,9 +316,9 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
}
else
{
FastMapNode node;
GSIMapNode node;
node = FastMapNodeForKey(ptrMap, (FastMapKey)*(void**)buf);
node = GSIMapNodeForKey(ptrMap, (GSIMapKey)*(void**)buf);
if (isInPreparatoryPass == YES)
{
/*
@ -327,8 +327,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
*/
if (node == 0)
{
FastMapAddPair(ptrMap,
(FastMapKey)*(void**)buf, (FastMapVal)0);
GSIMapAddPair(ptrMap,
(GSIMapKey)*(void**)buf, (GSIMapVal)0);
type++;
buf = *(char**)buf;
(*eValImp)(self, eValSel, type, buf);
@ -341,8 +341,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
*/
if (node == 0)
{
node = FastMapAddPair(ptrMap,
(FastMapKey)*(void**)buf, (FastMapVal)++xRefP);
node = GSIMapAddPair(ptrMap,
(GSIMapKey)*(void**)buf, (GSIMapVal)++xRefP);
}
else
{
@ -384,10 +384,10 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
else
{
Class c = *(Class*)buf;
FastMapNode node;
GSIMapNode node;
BOOL done = NO;
node = FastMapNodeForKey(clsMap, (FastMapKey)(void*)c);
node = GSIMapNodeForKey(clsMap, (GSIMapKey)(void*)c);
if (node != 0)
{
@ -406,8 +406,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
[NSException raise: NSInternalInconsistencyException
format: @"negative class version"];
}
node = FastMapAddPair(clsMap,
(FastMapKey)(void*)c, (FastMapVal)++xRefC);
node = GSIMapAddPair(clsMap,
(GSIMapKey)(void*)c, (GSIMapVal)++xRefC);
/*
* Encode tag and crossref number.
*/
@ -425,7 +425,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
* [super initWithCoder:ccc]
*/
if (s == c || s == 0 ||
FastMapNodeForKey(clsMap, (FastMapKey)(void*)s) != 0)
GSIMapNodeForKey(clsMap, (GSIMapKey)(void*)s) != 0)
{
done = YES;
}
@ -452,12 +452,12 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
else
{
SEL s = *(SEL*)buf;
FastMapNode node = FastMapNodeForKey(ptrMap, (FastMapKey)(void*)s);
GSIMapNode node = GSIMapNodeForKey(ptrMap, (GSIMapKey)(void*)s);
if (node == 0)
{
node = FastMapAddPair(ptrMap,
(FastMapKey)(void*)s, (FastMapVal)++xRefP);
node = GSIMapAddPair(ptrMap,
(GSIMapKey)(void*)s, (GSIMapVal)++xRefP);
(*xRefImp)(dst, xRefSel, _GSC_SEL, node->value.uint);
/*
* Encode selector.
@ -481,13 +481,13 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
}
else
{
FastMapNode node;
GSIMapNode node;
node = FastMapNodeForKey(ptrMap, (FastMapKey)*(char**)buf);
node = GSIMapNodeForKey(ptrMap, (GSIMapKey)*(char**)buf);
if (node == 0)
{
node = FastMapAddPair(ptrMap,
(FastMapKey)*(char**)buf, (FastMapVal)++xRefP);
node = GSIMapAddPair(ptrMap,
(GSIMapKey)*(char**)buf, (GSIMapVal)++xRefP);
(*xRefImp)(dst, xRefSel, _GSC_CHARPTR, node->value.uint);
(*serImp)(dst, serSel, buf, type, nil);
}
@ -616,7 +616,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
if (isInPreparatoryPass)
{
FastMapNode node;
GSIMapNode node;
/*
* Conditionally encoding 'nil' is a no-op.
@ -630,7 +630,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
* If we have already conditionally encoded this object, we can
* ignore it this time.
*/
node = FastMapNodeForKey(cIdMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(cIdMap, (GSIMapKey)anObject);
if (node != 0)
{
return;
@ -640,13 +640,13 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
* If we have unconditionally encoded this object, we can ignore
* it now.
*/
node = FastMapNodeForKey(uIdMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(uIdMap, (GSIMapKey)anObject);
if (node != 0)
{
return;
}
FastMapAddPair(cIdMap, (FastMapKey)anObject, (FastMapVal)0);
GSIMapAddPair(cIdMap, (GSIMapKey)anObject, (GSIMapVal)0);
}
else if (anObject == nil)
{
@ -654,18 +654,18 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
}
else
{
FastMapNode node;
GSIMapNode node;
if (repMap->nodeCount)
{
node = FastMapNodeForKey(repMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(repMap, (GSIMapKey)anObject);
if (node)
{
anObject = (id)node->value.ptr;
}
}
node = FastMapNodeForKey(cIdMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(cIdMap, (GSIMapKey)anObject);
if (node != 0)
{
(*eObjImp)(self, eObjSel, nil);
@ -721,12 +721,12 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
}
else
{
FastMapNode node;
GSIMapNode node;
/*
* Substitute replacement object if required.
*/
node = FastMapNodeForKey(repMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(repMap, (GSIMapKey)anObject);
if (node)
{
anObject = (id)node->value.ptr;
@ -735,7 +735,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
/*
* See if the object has already been encoded.
*/
node = FastMapNodeForKey(uIdMap, (FastMapKey)anObject);
node = GSIMapNodeForKey(uIdMap, (GSIMapKey)anObject);
if (isInPreparatoryPass)
{
@ -745,8 +745,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
* Remove object from map of conditionally encoded objects
* and add it to the map of unconditionay encoded ones.
*/
FastMapRemoveKey(cIdMap, (FastMapKey)anObject);
FastMapAddPair(uIdMap, (FastMapKey)anObject, (FastMapVal)0);
GSIMapRemoveKey(cIdMap, (GSIMapKey)anObject);
GSIMapAddPair(uIdMap, (GSIMapKey)anObject, (GSIMapVal)0);
[anObject encodeWithCoder: self];
}
return;
@ -759,8 +759,8 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
if (node == 0)
{
node = FastMapAddPair(uIdMap,
(FastMapKey)anObject, (FastMapVal)++xRefO);
node = GSIMapAddPair(uIdMap,
(GSIMapKey)anObject, (GSIMapVal)++xRefO);
}
else
{
@ -773,9 +773,9 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
(*xRefImp)(dst, xRefSel, _GSC_ID, node->value.uint);
if (namMap->nodeCount)
{
FastMapNode node;
GSIMapNode node;
node = FastMapNodeForKey(namMap, (FastMapKey)cls);
node = GSIMapNodeForKey(namMap, (GSIMapKey)cls);
if (node)
{
@ -801,11 +801,11 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
{
if (namMap->nodeCount)
{
FastMapNode node;
GSIMapNode node;
Class c;
c = objc_get_class([trueName cString]);
node = FastMapNodeForKey(namMap, (FastMapKey)c);
node = GSIMapNodeForKey(namMap, (GSIMapKey)c);
if (node)
{
c = (Class)node->value.ptr;
@ -818,7 +818,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
- (void) encodeClassName: (NSString*)trueName
intoClassName: (NSString*)inArchiveName
{
FastMapNode node;
GSIMapNode node;
Class tc;
Class ic;
@ -834,10 +834,10 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
[NSException raise: NSInternalInconsistencyException
format: @"Can't find class '%@'.", inArchiveName];
}
node = FastMapNodeForKey(namMap, (FastMapKey)tc);
node = GSIMapNodeForKey(namMap, (GSIMapKey)tc);
if (node == 0)
{
FastMapAddPair(namMap, (FastMapKey)(void*)tc, (FastMapVal)(void*)ic);
GSIMapAddPair(namMap, (GSIMapKey)(void*)tc, (GSIMapVal)(void*)ic);
}
else
{
@ -848,7 +848,7 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
- (void) replaceObject: (id)object
withObject: (id)newObject
{
FastMapNode node;
GSIMapNode node;
if (object == 0)
{
@ -860,10 +860,10 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
[NSException raise: NSInternalInconsistencyException
format: @"attempt to remap object to nil"];
}
node = FastMapNodeForKey(namMap, (FastMapKey)object);
node = GSIMapNodeForKey(namMap, (GSIMapKey)object);
if (node == 0)
{
FastMapAddPair(namMap, (FastMapKey)object, (FastMapVal)newObject);
GSIMapAddPair(namMap, (GSIMapKey)object, (GSIMapVal)newObject);
}
else
{
@ -888,26 +888,26 @@ static SEL eValSel = @selector(encodeValueOfObjCType:at:);
if (clsMap)
{
FastMapCleanMap(clsMap);
GSIMapCleanMap(clsMap);
if (cIdMap)
{
FastMapCleanMap(cIdMap);
GSIMapCleanMap(cIdMap);
}
if (uIdMap)
{
FastMapCleanMap(uIdMap);
GSIMapCleanMap(uIdMap);
}
if (ptrMap)
{
FastMapCleanMap(ptrMap);
GSIMapCleanMap(ptrMap);
}
if (namMap)
{
FastMapCleanMap(namMap);
GSIMapCleanMap(namMap);
}
if (repMap)
{
FastMapCleanMap(repMap);
GSIMapCleanMap(repMap);
}
}
isEncodingRootObject = NO;

View file

@ -32,6 +32,7 @@
#include <Foundation/NSCoder.h>
#include <Foundation/NSString.h>
#include <Foundation/NSGArray.h>
#include <Foundation/NSRange.h>
#include <limits.h>
#include <Foundation/NSUtilities.h>
#include <Foundation/NSException.h>
@ -361,10 +362,7 @@ static Class NSMutableArray_concrete_class;
{
unsigned i, j = 0, c = [self count], e = aRange.location + aRange.length;
if (aRange.location >= c)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (c - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, c);
for (i = aRange.location; i < e; i++)
aBuffer[j++] = [self objectAtIndex: i];
@ -388,10 +386,7 @@ static Class NSMutableArray_concrete_class;
{
unsigned i, e = aRange.location + aRange.length, c = [self count];
if (aRange.location >= c)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (c - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, c);
for (i = aRange.location; i < e; i++)
if (anObject == [self objectAtIndex: i])
@ -414,10 +409,7 @@ static Class NSMutableArray_concrete_class;
{
unsigned i, e = aRange.location + aRange.length, c = [self count];
if (aRange.location >= c)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (c - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, c);
for (i = aRange.location; i < e; i++)
{
@ -565,10 +557,7 @@ static Class NSMutableArray_concrete_class;
id na;
unsigned c = [self count];
if (aRange.location >= c)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (c - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, c);
if (aRange.length == 0)
return [NSArray array];

View file

@ -52,6 +52,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSRange.h>
@interface GSMutableAttributedStringTracker : NSMutableString
@ -359,11 +360,9 @@ static Class NSMutableAttributedString_concrete_class;
NSString *newSubstring;
NSDictionary *attrs;
NSRange range;
unsigned len = [self length];
if (aRange.location<0 || aRange.length<0 || NSMaxRange(aRange)>[self length])
[NSException raise: NSRangeException
format: @"RangeError in method -attributedSubstringFromRange: "
@"in class NSAttributedString"];
GS_RANGE_CHECK(aRange, len);
newSubstring = [[self string] substringFromRange: aRange];
@ -434,11 +433,7 @@ static Class NSMutableAttributedString_concrete_class;
unsigned int tmpLength;
tmpLength = [self length];
if (aRange.location <= 0 || NSMaxRange(aRange) > tmpLength)
{
[NSException raise: NSRangeException
format: @"RangeError in method -addAttribute: value: range: in class NSMutableAttributedString"];
}
GS_RANGE_CHECK(aRange, tmpLength);
attrDict = [self attributesAtIndex: aRange.location
effectiveRange: &effectiveRange];
@ -512,11 +507,7 @@ static Class NSMutableAttributedString_concrete_class;
unsigned int tmpLength;
tmpLength = [self length];
if (aRange.location <= 0 || NSMaxRange(aRange) > tmpLength)
{
[NSException raise: NSRangeException
format: @"RangeError in method -addAttribute: value: range: in class NSMutableAttributedString"];
}
GS_RANGE_CHECK(aRange, tmpLength);
attrDict = [self attributesAtIndex: aRange.location
effectiveRange: &effectiveRange];

View file

@ -73,6 +73,7 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSRange.h>
#include <string.h> /* for memset() */
#include <unistd.h> /* SEEK_* on SunOS 4 */
@ -413,23 +414,10 @@ failure:
- (void)getBytes: (void*)buffer
range: (NSRange)aRange
{
int size;
unsigned size = [self length];
// Check for 'out of range' errors. This code assumes that the
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
[NSException raise: NSRangeException
format: @"Range: (%u, %u) Size: %d",
aRange.location, aRange.length, size];
}
else
memcpy(buffer, [self bytes] + aRange.location, aRange.length);
return;
GS_RANGE_CHECK(aRange, size);
memcpy(buffer, [self bytes] + aRange.location, aRange.length);
}
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder
@ -442,14 +430,7 @@ failure:
void *buffer;
unsigned l = [self length];
// Check for 'out of range' errors before calling [-getBytes:range:]
// so that we can be sure that we don't get a range exception raised
// after we have allocated memory.
l = [self length];
if (aRange.location > l || aRange.length > l || NSMaxRange(aRange) > l)
[NSException raise: NSRangeException
format: @"Range: (%u, %u) Size: %d",
aRange.location, aRange.length, l];
GS_RANGE_CHECK(aRange, l);
buffer = NSZoneMalloc([self zone], aRange.length);
if (buffer == 0)
@ -1230,45 +1211,17 @@ failure:
- (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)bytes
{
int size;
unsigned size = [self length];
// Check for 'out of range' errors. This code assumes that the
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
// Raise an exception.
[NSException raise : NSRangeException
format : @"Range: (%u, %u) Size: %d",
aRange.location,
aRange.length,
size];
}
GS_RANGE_CHECK(aRange, size);
memcpy([self mutableBytes] + aRange.location, bytes, aRange.length);
}
- (void) resetBytesInRange: (NSRange)aRange
{
int size;
unsigned size = [self length];
// Check for 'out of range' errors. This code assumes that the
// NSRange location and length types will remain unsigned (hence
// the lack of a less-than-zero check).
size = [self length];
if (aRange.location > size ||
aRange.length > size ||
NSMaxRange( aRange ) > size)
{
// Raise an exception.
[NSException raise : NSRangeException
format : @"Range: (%u, %u) Size: %d",
aRange.location,
aRange.length,
size];
}
GS_RANGE_CHECK(aRange, size);
memset((char*)[self bytes] + aRange.location, 0, aRange.length);
}
@ -1692,17 +1645,8 @@ failure:
- (void) getBytes: (void*)buffer
range: (NSRange)aRange
{
if (aRange.location > length || NSMaxRange(aRange) > length)
{
[NSException raise: NSRangeException
format: @"Range: (%u, %u) Size: %d",
aRange.location, aRange.length, length];
}
else
{
memcpy(buffer, bytes + aRange.location, aRange.length);
}
return;
GS_RANGE_CHECK(aRange, length);
memcpy(buffer, bytes + aRange.location, aRange.length);
}
- (unsigned) length
@ -2623,12 +2567,8 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
- (void) replaceBytesInRange: (NSRange)aRange
withBytes: (const void*)moreBytes
{
if (aRange.location > length || NSMaxRange(aRange) > length) {
[NSException raise: NSRangeException
format: @"Range: (%u, %u) Size: %u",
aRange.location, aRange.length, length];
}
memcpy(bytes + aRange.location, moreBytes, aRange.length);
GS_RANGE_CHECK(aRange, length);
memcpy(bytes + aRange.location, moreBytes, aRange.length);
}
- (void) serializeDataAt: (const void*)data

View file

@ -252,10 +252,7 @@
{
unsigned i, j = 0, e = aRange.location + aRange.length;
if (aRange.location >= _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
for (i = aRange.location; i < e; i++)
{

View file

@ -46,6 +46,7 @@
#include <base/preface.h>
#include <Foundation/NSGAttributedString.h>
#include <Foundation/NSException.h>
#include <Foundation/NSRange.h>
#include <base/NSGArray.h>
#include <base/fast.x>
@ -420,12 +421,7 @@ _attributesAtIndexEffectiveRange(
if (!attributes)
attributes = [NSDictionary dictionary];
tmpLength = [textChars length];
if (NSMaxRange(range) > tmpLength)
{
[NSException raise: NSRangeException
format: @"RangeError in method -replaceCharactersInRange: "
@"withString: in class NSMutableAttributedString"];
}
GS_RANGE_CHECK(range, tmpLength);
arraySize = (*cntImp)(infoArray, cntSel);
if (NSMaxRange(range) < tmpLength)
{
@ -508,12 +504,7 @@ _attributesAtIndexEffectiveRange(
if (!aString)
aString = @"";
tmpLength = [textChars length];
if (NSMaxRange(range) > tmpLength)
{
[NSException raise: NSRangeException
format: @"RangeError in method -replaceCharactersInRange: "
@"withString: in class NSMutableAttributedString"];
}
GS_RANGE_CHECK(range, tmpLength);
arraySize = (*cntImp)(infoArray, cntSel);
if (NSMaxRange(range) < tmpLength)
{

View file

@ -31,6 +31,7 @@
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSRange.h>
#include <base/NSGString.h>
#include <base/NSGCString.h>
#include <base/IndexedCollection.h>
@ -343,10 +344,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
{
int len;
if (aRange.location >= _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
if (maxLength < aRange.length)
{
len = maxLength;
@ -403,10 +401,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
{
int e, i;
if (aRange.location >= _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
e = aRange.location + aRange.length;
for (i = aRange.location; i < e; i++)
*buffer++ = chartouni(((unsigned char *)_contents_chars)[i]);
@ -414,10 +409,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
- (NSString*) substringFromRange: (NSRange)aRange
{
if (aRange.location > _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
return [[self class] stringWithCString: _contents_chars + aRange.location
length: aRange.length];
}

View file

@ -31,12 +31,12 @@
#include <Foundation/NSPortCoder.h>
#define FAST_MAP_RETAIN_VAL(X) X
#define FAST_MAP_RELEASE_VAL(X)
#define FAST_MAP_KTYPES GSUNION_OBJ
#define FAST_MAP_VTYPES GSUNION_INT
#define GSI_MAP_RETAIN_VAL(X) X
#define GSI_MAP_RELEASE_VAL(X)
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_INT
#include <base/FastMap.x>
#include <base/GSIMap.h>
@class NSSetNonCore;
@class NSMutableSetNonCore;
@ -44,14 +44,14 @@
@interface NSGCountedSet : NSCountedSet
{
@public
FastMapTable_t map;
GSIMapTable_t map;
}
@end
@interface NSGCountedSetEnumerator : NSEnumerator
{
NSGCountedSet *set;
FastMapNode node;
GSIMapNode node;
}
@end
@ -70,7 +70,7 @@
- nextObject
{
FastMapNode old = node;
GSIMapNode old = node;
if (node == 0)
{
@ -102,14 +102,14 @@
- (void) dealloc
{
FastMapEmptyMap(&map);
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = map.nodeCount;
FastMapNode node = map.firstNode;
GSIMapNode node = map.firstNode;
SEL sel1 = @selector(encodeObject:);
IMP imp1 = [aCoder methodForSelector: sel1];
SEL sel2 = @selector(encodeValueOfObjCType:at:);
@ -138,12 +138,12 @@
(*imp)(aCoder, sel, utype, &count);
FastMapInitWithZoneAndCapacity(&map, [self zone], count);
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
while (count-- > 0)
{
(*imp)(aCoder, sel, otype, &value);
(*imp)(aCoder, sel, utype, &valcnt);
FastMapAddPairNoRetain(&map, (FastMapKey)value, (FastMapVal)valcnt);
GSIMapAddPairNoRetain(&map, (GSIMapKey)value, (GSIMapVal)valcnt);
}
return self;
@ -152,7 +152,7 @@
/* Designated initialiser */
- (id) initWithCapacity: (unsigned)cap
{
FastMapInitWithZoneAndCapacity(&map, [self zone], cap);
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
return self;
}
@ -166,7 +166,7 @@
}
for (i = 0; i < c; i++)
{
FastMapNode node;
GSIMapNode node;
if (objs[i] == nil)
{
@ -174,10 +174,10 @@
[NSException raise: NSInvalidArgumentException
format: @"Tried to init counted set with nil value"];
}
node = FastMapNodeForKey(&map, (FastMapKey)objs[i]);
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
FastMapAddPair(&map,(FastMapKey)objs[i],(FastMapVal)(unsigned)1);
GSIMapAddPair(&map,(GSIMapKey)objs[i],(GSIMapVal)(unsigned)1);
}
else
{
@ -189,7 +189,7 @@
- (void) addObject: (NSObject*)anObject
{
FastMapNode node;
GSIMapNode node;
if (anObject == nil)
{
@ -197,10 +197,10 @@
format: @"Tried to nil value to counted set"];
}
node = FastMapNodeForKey(&map, (FastMapKey)anObject);
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
FastMapAddPair(&map,(FastMapKey)anObject,(FastMapVal)(unsigned)1);
GSIMapAddPair(&map,(GSIMapKey)anObject,(GSIMapVal)(unsigned)1);
}
else
{
@ -217,7 +217,7 @@
{
if (anObject)
{
FastMapNode node = FastMapNodeForKey(&map, (FastMapKey)anObject);
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node)
{
@ -236,7 +236,7 @@
{
if (anObject)
{
FastMapNode node = FastMapNodeForKey(&map, (FastMapKey)anObject);
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node)
{
@ -256,20 +256,20 @@
{
if (anObject)
{
FastMapBucket bucket;
GSIMapBucket bucket;
bucket = FastMapBucketForKey(&map, (FastMapKey)anObject);
bucket = GSIMapBucketForKey(&map, (GSIMapKey)anObject);
if (bucket)
{
FastMapNode node;
GSIMapNode node;
node = FastMapNodeForKeyInBucket(bucket, (FastMapKey)anObject);
node = GSIMapNodeForKeyInBucket(bucket, (GSIMapKey)anObject);
if (node)
{
if (--node->value.uint == 0)
{
FastMapRemoveNodeFromMap(&map, bucket, node);
FastMapFreeNode(&map, node);
GSIMapRemoveNodeFromMap(&map, bucket, node);
GSIMapFreeNode(&map, node);
}
}
}
@ -278,7 +278,7 @@
- (void) removeAllObjects
{
FastMapCleanMap(&map);
GSIMapCleanMap(&map);
}
@end

View file

@ -96,14 +96,14 @@ myEqual(id self, id other)
* The 'Fastmap' stuff provides an inline implementation of a mapping
* table - for maximum performance.
*/
#define FAST_MAP_KTYPES GSUNION_OBJ
#define FAST_MAP_VTYPES GSUNION_OBJ
#define FAST_MAP_HASH(X) myHash(X.obj)
#define FAST_MAP_EQUAL(X,Y) myEqual(X.obj,Y.obj)
#define FAST_MAP_RETAIN_KEY(X) ((id)(X).obj) = \
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_OBJ
#define GSI_MAP_HASH(X) myHash(X.obj)
#define GSI_MAP_EQUAL(X,Y) myEqual(X.obj,Y.obj)
#define GSI_MAP_RETAIN_KEY(X) ((id)(X).obj) = \
[((id)(X).obj) copyWithZone: map->zone]
#include <base/FastMap.x>
#include <base/GSIMap.h>
@class NSDictionaryNonCore;
@class NSMutableDictionaryNonCore;
@ -111,21 +111,21 @@ myEqual(id self, id other)
@interface NSGDictionary : NSDictionary
{
@public
FastMapTable_t map;
GSIMapTable_t map;
}
@end
@interface NSGMutableDictionary : NSMutableDictionary
{
@public
FastMapTable_t map;
GSIMapTable_t map;
}
@end
@interface NSGDictionaryKeyEnumerator : NSEnumerator
{
NSGDictionary *dictionary;
FastMapNode node;
GSIMapNode node;
}
@end
@ -149,14 +149,14 @@ myEqual(id self, id other)
- (void) dealloc
{
FastMapEmptyMap(&map);
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = map.nodeCount;
FastMapNode node = map.firstNode;
GSIMapNode node = map.firstNode;
SEL sel = @selector(encodeObject:);
IMP imp = [aCoder methodForSelector: sel];
@ -186,12 +186,12 @@ myEqual(id self, id other)
[aCoder decodeValueOfObjCType: @encode(unsigned)
at: &count];
FastMapInitWithZoneAndCapacity(&map, fastZone(self), count);
GSIMapInitWithZoneAndCapacity(&map, fastZone(self), count);
while (count-- > 0)
{
(*imp)(aCoder, sel, type, &key);
(*imp)(aCoder, sel, type, &value);
FastMapAddPairNoRetain(&map, (FastMapKey)key, (FastMapVal)value);
GSIMapAddPairNoRetain(&map, (GSIMapKey)key, (GSIMapVal)value);
}
return self;
}
@ -201,10 +201,10 @@ myEqual(id self, id other)
{
int i;
FastMapInitWithZoneAndCapacity(&map, fastZone(self), c);
GSIMapInitWithZoneAndCapacity(&map, fastZone(self), c);
for (i = 0; i < c; i++)
{
FastMapNode node;
GSIMapNode node;
if (keys[i] == nil)
{
@ -219,7 +219,7 @@ myEqual(id self, id other)
format: @"Tried to init dictionary with nil value"];
}
node = FastMapNodeForKey(&map, (FastMapKey)keys[i]);
node = GSIMapNodeForKey(&map, (GSIMapKey)keys[i]);
if (node)
{
[objs[i] retain];
@ -228,7 +228,7 @@ myEqual(id self, id other)
}
else
{
FastMapAddPair(&map, (FastMapKey)keys[i], (FastMapVal)objs[i]);
GSIMapAddPair(&map, (GSIMapKey)keys[i], (GSIMapVal)objs[i]);
}
}
return self;
@ -245,10 +245,10 @@ myEqual(id self, id other)
unsigned c = [other count];
unsigned i;
FastMapInitWithZoneAndCapacity(&map, z, c);
GSIMapInitWithZoneAndCapacity(&map, z, c);
for (i = 0; i < c; i++)
{
FastMapNode node;
GSIMapNode node;
id k = [e nextObject];
id o = [other objectForKey: k];
@ -274,7 +274,7 @@ myEqual(id self, id other)
format: @"Tried to init dictionary with nil value"];
}
node = FastMapNodeForKey(&map, (FastMapKey)k);
node = GSIMapNodeForKey(&map, (GSIMapKey)k);
if (node)
{
[node->value.obj release];
@ -282,7 +282,7 @@ myEqual(id self, id other)
}
else
{
FastMapAddPairNoRetain(&map, (FastMapKey)k, (FastMapVal)o);
GSIMapAddPairNoRetain(&map, (GSIMapKey)k, (GSIMapVal)o);
}
}
return self;
@ -304,7 +304,7 @@ myEqual(id self, id other)
{
if (aKey != nil)
{
FastMapNode node = FastMapNodeForKey(&map, (FastMapKey)aKey);
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)aKey);
if (node)
{
@ -330,13 +330,13 @@ myEqual(id self, id other)
/* Designated initialiser */
- (id) initWithCapacity: (unsigned)cap
{
FastMapInitWithZoneAndCapacity(&map, fastZone(self), cap);
GSIMapInitWithZoneAndCapacity(&map, fastZone(self), cap);
return self;
}
- (void) setObject: (id)anObject forKey: (id)aKey
{
FastMapNode node;
GSIMapNode node;
if (aKey == nil)
{
@ -348,7 +348,7 @@ myEqual(id self, id other)
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil value to dictionary"];
}
node = FastMapNodeForKey(&map, (FastMapKey)aKey);
node = GSIMapNodeForKey(&map, (GSIMapKey)aKey);
if (node)
{
[anObject retain];
@ -357,20 +357,20 @@ myEqual(id self, id other)
}
else
{
FastMapAddPair(&map, (FastMapKey)aKey, (FastMapVal)anObject);
GSIMapAddPair(&map, (GSIMapKey)aKey, (GSIMapVal)anObject);
}
}
- (void) removeAllObjects
{
FastMapCleanMap(&map);
GSIMapCleanMap(&map);
}
- (void) removeObjectForKey: (id)aKey
{
if (aKey)
{
FastMapRemoveKey(&map, (FastMapKey)aKey);
GSIMapRemoveKey(&map, (GSIMapKey)aKey);
}
}
@ -388,7 +388,7 @@ myEqual(id self, id other)
- nextObject
{
FastMapNode old = node;
GSIMapNode old = node;
if (node == 0)
{
@ -410,7 +410,7 @@ myEqual(id self, id other)
- nextObject
{
FastMapNode old = node;
GSIMapNode old = node;
if (node == 0)
{

View file

@ -31,10 +31,10 @@
#include <Foundation/NSString.h>
#include <Foundation/NSPortCoder.h>
#define FAST_MAP_HAS_VALUE 0
#define FAST_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_HAS_VALUE 0
#define GSI_MAP_KTYPES GSUNION_OBJ
#include <base/FastMap.x>
#include <base/GSIMap.h>
@class NSSetNonCore;
@class NSMutableSetNonCore;
@ -42,21 +42,21 @@
@interface NSGSet : NSSet
{
@public
FastMapTable_t map;
GSIMapTable_t map;
}
@end
@interface NSGMutableSet : NSMutableSet
{
@public
FastMapTable_t map;
GSIMapTable_t map;
}
@end
@interface NSGSetEnumerator : NSEnumerator
{
NSGSet *set;
FastMapNode node;
GSIMapNode node;
}
@end
@ -72,7 +72,7 @@
- nextObject
{
FastMapNode old = node;
GSIMapNode old = node;
if (node == 0)
{
@ -108,14 +108,14 @@
- (void) dealloc
{
FastMapEmptyMap(&map);
GSIMapEmptyMap(&map);
[super dealloc];
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
unsigned count = map.nodeCount;
FastMapNode node = map.firstNode;
GSIMapNode node = map.firstNode;
SEL sel = @selector(encodeObject:);
IMP imp = [aCoder methodForSelector: sel];
@ -142,11 +142,11 @@
(*imp)(aCoder, sel, @encode(unsigned), &count);
FastMapInitWithZoneAndCapacity(&map, [self zone], count);
GSIMapInitWithZoneAndCapacity(&map, [self zone], count);
while (count-- > 0)
{
(*imp)(aCoder, sel, type, &value);
FastMapAddKeyNoRetain(&map, (FastMapKey)value);
GSIMapAddKeyNoRetain(&map, (GSIMapKey)value);
}
return self;
@ -157,10 +157,10 @@
{
int i;
FastMapInitWithZoneAndCapacity(&map, [self zone], c);
GSIMapInitWithZoneAndCapacity(&map, [self zone], c);
for (i = 0; i < c; i++)
{
FastMapNode node;
GSIMapNode node;
if (objs[i] == nil)
{
@ -168,10 +168,10 @@
[NSException raise: NSInvalidArgumentException
format: @"Tried to init set with nil value"];
}
node = FastMapNodeForKey(&map, (FastMapKey)objs[i]);
node = GSIMapNodeForKey(&map, (GSIMapKey)objs[i]);
if (node == 0)
{
FastMapAddKey(&map, (FastMapKey)objs[i]);
GSIMapAddKey(&map, (GSIMapKey)objs[i]);
}
}
return self;
@ -181,7 +181,7 @@
{
if (anObject)
{
FastMapNode node = FastMapNodeForKey(&map, (FastMapKey)anObject);
GSIMapNode node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node)
{
@ -212,23 +212,23 @@
/* Designated initialiser */
- (id) initWithCapacity: (unsigned)cap
{
FastMapInitWithZoneAndCapacity(&map, [self zone], cap);
GSIMapInitWithZoneAndCapacity(&map, [self zone], cap);
return self;
}
- (void) addObject: (NSObject*)anObject
{
FastMapNode node;
GSIMapNode node;
if (anObject == nil)
{
[NSException raise: NSInvalidArgumentException
format: @"Tried to add nil to set"];
}
node = FastMapNodeForKey(&map, (FastMapKey)anObject);
node = GSIMapNodeForKey(&map, (GSIMapKey)anObject);
if (node == 0)
{
FastMapAddKey(&map, (FastMapKey)anObject);
GSIMapAddKey(&map, (GSIMapKey)anObject);
}
}
@ -236,13 +236,13 @@
{
if (anObject)
{
FastMapRemoveKey(&map, (FastMapKey)anObject);
GSIMapRemoveKey(&map, (GSIMapKey)anObject);
}
}
- (void) removeAllObjects
{
FastMapCleanMap(&map);
GSIMapCleanMap(&map);
}
@end

View file

@ -38,6 +38,7 @@
#include <Foundation/NSData.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSRange.h>
#include <base/IndexedCollection.h>
#include <base/IndexedCollectionPrivate.h>
#include <Foundation/NSValue.h>
@ -248,10 +249,7 @@
- (void)getCharacters: (unichar*)buffer range: (NSRange)aRange
{
if (aRange.location >= _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
memcpy(buffer, _contents_chars + aRange.location, aRange.length*2);
}
@ -259,10 +257,7 @@
- (NSString*) substringFromRange: (NSRange)aRange
{
if (aRange.location > _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
return [[self class] stringWithCharacters: _contents_chars + aRange.location
length: aRange.length];
}
@ -622,10 +617,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableStringStruct *self,
int offset;
unsigned stringLength;
if (aRange.location > _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
GS_RANGE_CHECK(aRange, _count);
stringLength = (aString == nil) ? 0 : [aString length];
offset = stringLength - aRange.length;

View file

@ -143,20 +143,20 @@ const NSMapTableValueCallBacks ObsMapCallBacks =
* Setup for inline operation on arrays of Observers.
*/
#define FAST_ARRAY_TYPES 0
#define FAST_ARRAY_EXTRA Observation*
#define GSI_ARRAY_TYPES 0
#define GSI_ARRAY_EXTRA Observation*
#define FAST_ARRAY_RELEASE(X) FreeObs(((X).ext))
#define FAST_ARRAY_RETAIN(X) RetainObs(((X).ext))
#define GSI_ARRAY_RELEASE(X) FreeObs(((X).ext))
#define GSI_ARRAY_RETAIN(X) RetainObs(((X).ext))
#include <base/FastArray.x>
#include <base/GSIArray.h>
#define FAST_MAP_RETAIN_VAL(X) X
#define FAST_MAP_RELEASE_VAL(X)
#define FAST_MAP_KTYPES GSUNION_OBJ
#define FAST_MAP_VTYPES GSUNION_PTR
#define GSI_MAP_RETAIN_VAL(X) X
#define GSI_MAP_RELEASE_VAL(X)
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_PTR
#include <base/FastMap.x>
#include <base/GSIMap.h>
#if GS_WITH_GC
/*
@ -213,8 +213,8 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
NSNonOwnedPointerMapValueCallBacks, 0);
observers = NSCreateMapTable(NSNonOwnedPointerOrNullMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);
named = NSZoneMalloc(NSDefaultMallocZone(), sizeof(FastMapTable_t));
FastMapInitWithZoneAndCapacity((FastMapTable)named,NSDefaultMallocZone(),128);
named = NSZoneMalloc(NSDefaultMallocZone(), sizeof(GSIMapTable_t));
GSIMapInitWithZoneAndCapacity((GSIMapTable)named,NSDefaultMallocZone(),128);
_lock = [NSRecursiveLock new];
@ -233,8 +233,8 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
NSMapEnumerator enumerator;
id o;
FastMapTable f = (FastMapTable)named;
FastMapNode n;
GSIMapTable f = (GSIMapTable)named;
GSIMapNode n;
Observation *l;
NSHashTable *h;
NSMapTable *m;
@ -263,7 +263,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
NSFreeMapTable((NSMapTable*)n->value.ptr);
n = n->nextInMap;
}
FastMapEmptyMap(f);
GSIMapEmptyMap(f);
NSZoneFree(f->zone, named);
/*
@ -335,12 +335,12 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
NSMapTable *m;
Observation *list;
FastMapNode n;
GSIMapNode n;
/*
* Locate the map table for this name - create it if not present.
*/
n = FastMapNodeForKey((FastMapTable)named, (FastMapKey)name);
n = GSIMapNodeForKey((GSIMapTable)named, (GSIMapKey)name);
if (n == 0)
{
m = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
@ -351,8 +351,8 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
*/
name = [name copyWithZone: NSDefaultMallocZone()];
o->name = name;
FastMapAddPair((FastMapTable)named, (FastMapKey)name,
(FastMapVal)(void*)m);
GSIMapAddPair((GSIMapTable)named, (GSIMapKey)name,
(GSIMapVal)(void*)m);
RELEASE(name);
}
else
@ -436,12 +436,12 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
NSMapTable *m;
Observation *list;
FastMapNode n;
GSIMapNode n;
/*
* Locate the map table for this name.
*/
n = FastMapNodeForKey((FastMapTable)named, (FastMapKey)o->name);
n = GSIMapNodeForKey((GSIMapTable)named, (GSIMapKey)o->name);
NSAssert(n != 0, NSInternalInconsistencyException);
m = (NSMapTable*)n->value.ptr;
@ -454,7 +454,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
NSMapRemove(m, CHEATGC(o->object));
if (NSCountMapTable(m) == 0)
{
FastMapRemoveKey((FastMapTable)named, (FastMapKey)o->name);
GSIMapRemoveKey((GSIMapTable)named, (GSIMapKey)o->name);
}
}
else
@ -561,7 +561,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
name: (NSString*)name
object: (id)object
{
FastArray a;
GSIArray a;
/*
* If both NAME and OBJECT are nil, this call is the same as
@ -577,18 +577,18 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
[_lock lock];
a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(FastArray_t));
FastArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 128);
a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 128);
if (name)
{
NSMapTable *m;
FastMapNode n;
GSIMapNode n;
/*
* Locate items with specified name (if any).
*/
n = FastMapNodeForKey((FastMapTable)named, (FastMapKey)name);
n = GSIMapNodeForKey((GSIMapTable)named, (GSIMapKey)name);
if (n)
m = (NSMapTable*)n->value.ptr;
else
@ -611,7 +611,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
if (observer == nil || observer == list->observer)
{
FastArrayAddItem(a, (FastArrayItem)list);
GSIArrayAddItem(a, (GSIArrayItem)list);
}
list = list->next;
}
@ -631,7 +631,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
if (observer == nil || observer == list->observer)
{
FastArrayAddItem(a, (FastArrayItem)list);
GSIArrayAddItem(a, (GSIArrayItem)list);
}
list = list->next;
}
@ -643,7 +643,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
Observation *list;
NSMapTable *m;
FastMapNode n;
GSIMapNode n;
/*
* Make a list of items matching specific object with NO names
@ -655,7 +655,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
if (observer == nil || observer == list->observer)
{
FastArrayAddItem(a, (FastArrayItem)list);
GSIArrayAddItem(a, (GSIArrayItem)list);
}
list = list->next;
}
@ -664,7 +664,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
/*
* Add items for ALL names.
*/
n = ((FastMapTable)named)->firstNode;
n = ((GSIMapTable)named)->firstNode;
while (n != 0)
{
m = (NSMapTable*)n->value.ptr;
@ -676,7 +676,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
if (observer == nil || observer == list->observer)
{
FastArrayAddItem(a, (FastArrayItem)list);
GSIArrayAddItem(a, (GSIArrayItem)list);
}
list = list->next;
}
@ -684,17 +684,17 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
}
}
if (FastArrayCount(a) > 0)
if (GSIArrayCount(a) > 0)
{
id lastObs = nil;
NSHashTable *h = 0;
unsigned count = FastArrayCount(a);
unsigned count = GSIArrayCount(a);
unsigned i;
Observation *o;
for (i = 0; i < count; i++)
{
o = FastArrayItemAtIndex(a, i).ext;
o = GSIArrayItemAtIndex(a, i).ext;
(*remImp)(self, remSel, o);
if (h == 0 || lastObs != o->observer)
{
@ -709,7 +709,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
}
}
FastArrayEmpty(a);
GSIArrayEmpty(a);
NSZoneFree(a->zone, (void*)a);
[_lock unlock];
@ -728,7 +728,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
NSString *n_name;
id n_object;
Observation *o;
FastArray a;
GSIArray a;
unsigned count;
unsigned i;
@ -745,8 +745,8 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
[_lock lock];
a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(FastArray_t));
FastArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 16);
a = NSZoneMalloc(NSDefaultMallocZone(), sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(a, NSDefaultMallocZone(), 16);
NS_DURING
{
@ -756,15 +756,15 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
*/
for (o = wildcard; o != ENDOBS; o = o->next)
{
FastArrayAddItem(a, (FastArrayItem)o);
GSIArrayAddItem(a, (GSIArrayItem)o);
}
count = FastArrayCount(a);
count = GSIArrayCount(a);
while (count-- > 0)
{
o = FastArrayItemAtIndex(a, count).ext;
o = GSIArrayItemAtIndex(a, count).ext;
if (o->next != 0)
(*o->method)(o->observer, o->selector, notification);
FastArrayRemoveItemAtIndex(a, count);
GSIArrayRemoveItemAtIndex(a, count);
}
/*
@ -778,16 +778,16 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
while (o != ENDOBS)
{
FastArrayAddItem(a, (FastArrayItem)o);
GSIArrayAddItem(a, (GSIArrayItem)o);
o = o->next;
}
count = FastArrayCount(a);
count = GSIArrayCount(a);
while (count-- > 0)
{
o = FastArrayItemAtIndex(a, count).ext;
o = GSIArrayItemAtIndex(a, count).ext;
if (o->next != 0)
(*o->method)(o->observer, o->selector, notification);
FastArrayRemoveItemAtIndex(a, count);
GSIArrayRemoveItemAtIndex(a, count);
}
}
}
@ -800,9 +800,9 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
if (n_name)
{
NSMapTable *m;
FastMapNode n;
GSIMapNode n;
n = FastMapNodeForKey((FastMapTable)named, (FastMapKey)n_name);
n = GSIMapNodeForKey((GSIMapTable)named, (GSIMapKey)n_name);
if (n)
m = (NSMapTable*)n->value.ptr;
else
@ -817,16 +817,16 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
while (o != ENDOBS)
{
FastArrayAddItem(a, (FastArrayItem)o);
GSIArrayAddItem(a, (GSIArrayItem)o);
o = o->next;
}
count = FastArrayCount(a);
count = GSIArrayCount(a);
while (count-- > 0)
{
o = FastArrayItemAtIndex(a, count).ext;
o = GSIArrayItemAtIndex(a, count).ext;
if (o->next != 0)
(*o->method)(o->observer, o->selector, notification);
FastArrayRemoveItemAtIndex(a, count);
GSIArrayRemoveItemAtIndex(a, count);
}
}
@ -840,17 +840,17 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
{
while (o != ENDOBS)
{
FastArrayAddItem(a, (FastArrayItem)o);
GSIArrayAddItem(a, (GSIArrayItem)o);
o = o->next;
}
count = FastArrayCount(a);
count = GSIArrayCount(a);
while (count-- > 0)
{
o = FastArrayItemAtIndex(a, count).ext;
o = GSIArrayItemAtIndex(a, count).ext;
if (o->next != 0)
(*o->method)(o->observer, o->selector,
notification);
FastArrayRemoveItemAtIndex(a, count);
GSIArrayRemoveItemAtIndex(a, count);
}
}
}
@ -862,7 +862,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
/*
* If we had a problem - release memory and unlock before going on.
*/
FastArrayEmpty(a);
GSIArrayEmpty(a);
NSZoneFree(a->zone, (void*)a);
[_lock unlock];
@ -870,7 +870,7 @@ static void (*remImp)(NSNotificationCenter*, SEL, Observation*) = 0;
}
NS_ENDHANDLER
FastArrayEmpty(a);
GSIArrayEmpty(a);
NSZoneFree(a->zone, (void*)a);
[_lock unlock];
}

View file

@ -155,19 +155,19 @@ static inline BOOL timerInvalidated(NSTimer* timer)
* Setup for inline operation of arrays.
*/
#define FAST_ARRAY_TYPES GSUNION_OBJ
#define GSI_ARRAY_TYPES GSUNION_OBJ
#if GS_WITH_GC == 0
#define FAST_ARRAY_RELEASE(X) [(X).obj release]
#define FAST_ARRAY_RETAIN(X) [(X).obj retain]
#define GSI_ARRAY_RELEASE(X) [(X).obj release]
#define GSI_ARRAY_RETAIN(X) [(X).obj retain]
#else
#define FAST_ARRAY_RELEASE(X)
#define FAST_ARRAY_RETAIN(X) (X).obj
#define GSI_ARRAY_RELEASE(X)
#define GSI_ARRAY_RETAIN(X) (X).obj
#endif
#include <base/FastArray.x>
#include <base/GSIArray.h>
static NSComparisonResult aSort(FastArrayItem i0, FastArrayItem i1)
static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
{
return [((RunLoopWatcher *)(i0.obj))->_date
compare: ((RunLoopWatcher *)(i1.obj))->_date];
@ -401,7 +401,7 @@ static NSComparisonResult aSort(FastArrayItem i0, FastArrayItem i1)
limit-date order. */
- (void) _addWatcher: (RunLoopWatcher*) item forMode: (NSString*)mode
{
FastArray watchers;
GSIArray watchers;
id obj;
watchers = NSMapGet(_mode_2_watchers, mode);
@ -409,8 +409,8 @@ static NSComparisonResult aSort(FastArrayItem i0, FastArrayItem i1)
{
NSZone *z = [self zone];
watchers = NSZoneMalloc(z, sizeof(FastArray_t));
FastArrayInitWithZoneAndCapacity(watchers, z, 8);
watchers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(watchers, z, 8);
NSMapInsert(_mode_2_watchers, mode, watchers);
}
@ -440,7 +440,7 @@ static NSComparisonResult aSort(FastArrayItem i0, FastArrayItem i1)
}
else
item->_date = RETAIN(theFuture);
FastArrayInsertSorted(watchers, (FastArrayItem)item, aSort);
GSIArrayInsertSorted(watchers, (GSIArrayItem)item, aSort);
}
- (void) _checkPerformers
@ -671,15 +671,15 @@ const NSMapTableValueCallBacks WatcherMapValueCallBacks =
#endif
static void*
aRetain(void* t, FastArray a)
aRetain(void* t, GSIArray a)
{
return t;
}
static void
aRelease(void* t, FastArray a)
aRelease(void* t, GSIArray a)
{
FastArrayEmpty(a);
GSIArrayEmpty(a);
NSZoneFree(a->zone, (void*)a);
}
@ -766,18 +766,18 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
- (void) addTimer: timer
forMode: (NSString*)mode
{
FastArray timers;
GSIArray timers;
timers = NSMapGet(_mode_2_timers, mode);
if (!timers)
{
NSZone *z = [self zone];
timers = NSZoneMalloc(z, sizeof(FastArray_t));
FastArrayInitWithZoneAndCapacity(timers, z, 8);
timers = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity(timers, z, 8);
NSMapInsert(_mode_2_timers, mode, timers);
}
FastArrayInsertSorted(timers, (FastArrayItem)timer, aSort);
GSIArrayInsertSorted(timers, (GSIArrayItem)timer, aSort);
}
@ -788,8 +788,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
{
id saved_mode;
NSDate *when;
FastArray timers;
FastArray watchers;
GSIArray timers;
GSIArray watchers;
NSTimer *min_timer = nil;
RunLoopWatcher *min_watcher = nil;
@ -799,12 +799,12 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
timers = NSMapGet(_mode_2_timers, mode);
if (timers)
{
while (FastArrayCount(timers) != 0)
while (GSIArrayCount(timers) != 0)
{
min_timer = FastArrayItemAtIndex(timers, 0).obj;
min_timer = GSIArrayItemAtIndex(timers, 0).obj;
if (timerInvalidated(min_timer) == YES)
{
FastArrayRemoveItemAtIndex(timers, 0);
GSIArrayRemoveItemAtIndex(timers, 0);
min_timer = nil;
continue;
}
@ -814,13 +814,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
break;
}
FastArrayRemoveItemAtIndexNoRelease(timers, 0);
GSIArrayRemoveItemAtIndexNoRelease(timers, 0);
/* Firing will also increment its fireDate, if it is repeating. */
[min_timer fire];
if (timerInvalidated(min_timer) == NO)
{
FastArrayInsertSortedNoRetain(timers,
(FastArrayItem)min_timer, aSort);
GSIArrayInsertSortedNoRetain(timers,
(GSIArrayItem)min_timer, aSort);
}
else
{
@ -836,13 +836,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
watchers = NSMapGet(_mode_2_watchers, mode);
if (watchers)
{
while (FastArrayCount(watchers) != 0)
while (GSIArrayCount(watchers) != 0)
{
min_watcher = FastArrayItemAtIndex(watchers, 0).obj;
min_watcher = GSIArrayItemAtIndex(watchers, 0).obj;
if (min_watcher->_invalidated == YES)
{
FastArrayRemoveItemAtIndex(watchers, 0);
GSIArrayRemoveItemAtIndex(watchers, 0);
min_watcher = nil;
continue;
}
@ -861,7 +861,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
* timeouts - inform it and give it a chance to set a
* revised limit date.
*/
FastArrayRemoveItemAtIndexNoRelease(watchers, 0);
GSIArrayRemoveItemAtIndexNoRelease(watchers, 0);
obj = min_watcher->receiver;
if ([obj respondsToSelector:
@selector(timedOutEvent:type:forMode:)])
@ -888,8 +888,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
* re-insert it into the queue in the correct place.
*/
ASSIGN(min_watcher->_date, nxt);
FastArrayInsertSortedNoRetain(watchers,
(FastArrayItem)min_watcher, aSort);
GSIArrayInsertSortedNoRetain(watchers,
(GSIArrayItem)min_watcher, aSort);
}
else
{
@ -944,7 +944,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
FastArray watchers;
GSIArray watchers;
if (mode == nil)
{
@ -954,13 +954,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
watchers = NSMapGet(_mode_2_watchers, mode);
if (watchers)
{
unsigned i = FastArrayCount(watchers);
unsigned i = GSIArrayCount(watchers);
while (i-- > 0)
{
RunLoopWatcher *info;
info = FastArrayItemAtIndex(watchers, i).obj;
info = GSIArrayItemAtIndex(watchers, i).obj;
if (info->type == type && info->data == data)
{
return info;
@ -974,7 +974,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
type: (RunLoopEventType)type
forMode: (NSString*)mode
{
FastArray watchers;
GSIArray watchers;
if (mode == nil)
{
@ -984,17 +984,17 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
watchers = NSMapGet(_mode_2_watchers, mode);
if (watchers)
{
unsigned i = FastArrayCount(watchers);
unsigned i = GSIArrayCount(watchers);
while (i-- > 0)
{
RunLoopWatcher *info;
info = FastArrayItemAtIndex(watchers, i).obj;
info = GSIArrayItemAtIndex(watchers, i).obj;
if (info->type == type && info->data == data)
{
info->_invalidated = YES;
FastArrayRemoveItemAtIndex(watchers, i);
GSIArrayRemoveItemAtIndex(watchers, i);
}
}
}
@ -1078,19 +1078,19 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
/* Do the pre-listening set-up for the file descriptors of this mode. */
{
FastArray watchers;
GSIArray watchers;
watchers = NSMapGet(_mode_2_watchers, mode);
if (watchers) {
int i;
for (i = FastArrayCount(watchers); i > 0; i--) {
for (i = GSIArrayCount(watchers); i > 0; i--) {
RunLoopWatcher *info;
int fd;
info = FastArrayItemAtIndex(watchers, i-1).obj;
info = GSIArrayItemAtIndex(watchers, i-1).obj;
if (info->_invalidated == YES) {
FastArrayRemoveItemAtIndex(watchers, i-1);
GSIArrayRemoveItemAtIndex(watchers, i-1);
continue;
}
switch (info->type) {

View file

@ -46,23 +46,23 @@
/*
* Setup for inline operation of string map tables.
*/
#define FAST_MAP_RETAIN_KEY(X) X
#define FAST_MAP_RELEASE_KEY(X)
#define FAST_MAP_RETAIN_VAL(X) X
#define FAST_MAP_RELEASE_VAL(X)
#define FAST_MAP_HASH(X) [(X).obj hash]
#define FAST_MAP_EQUAL(X,Y) [(X).obj isEqualToString: (Y).obj]
#define GSI_MAP_RETAIN_KEY(X) X
#define GSI_MAP_RELEASE_KEY(X)
#define GSI_MAP_RETAIN_VAL(X) X
#define GSI_MAP_RELEASE_VAL(X)
#define GSI_MAP_HASH(X) [(X).obj hash]
#define GSI_MAP_EQUAL(X,Y) [(X).obj isEqualToString: (Y).obj]
#include <base/FastMap.x>
#include <base/GSIMap.h>
/*
* Setup for inline operation of string arrays.
*/
#define FAST_ARRAY_RETAIN(X) X
#define FAST_ARRAY_RELEASE(X)
#define FAST_ARRAY_TYPES GSUNION_OBJ
#define GSI_ARRAY_RETAIN(X) X
#define GSI_ARRAY_RELEASE(X)
#define GSI_ARRAY_TYPES GSUNION_OBJ
#include <base/FastArray.x>
#include <base/GSIArray.h>
/*
* Define constants for data types and variables to hold them.
@ -112,7 +112,7 @@ typedef struct {
void (*serImp)(); // Serialize integer.
void (*setImp)(); // Set length of data.
unsigned count; // String counter.
FastMapTable_t map; // For uniquing.
GSIMapTable_t map; // For uniquing.
BOOL shouldUnique; // Do we do uniquing?
} _NSSerializerInfo;
@ -137,7 +137,7 @@ initSerializerInfo(_NSSerializerInfo* info, NSMutableData *d, BOOL u)
(*info->appImp)(d, appSel, &info->shouldUnique, 1);
if (u)
{
FastMapInitWithZoneAndCapacity(&info->map, NSDefaultMallocZone(), 16);
GSIMapInitWithZoneAndCapacity(&info->map, NSDefaultMallocZone(), 16);
info->count = 0;
}
}
@ -146,7 +146,7 @@ static void
endSerializerInfo(_NSSerializerInfo* info)
{
if (info->shouldUnique)
FastMapEmptyMap(&info->map);
GSIMapEmptyMap(&info->map);
}
static id
@ -163,10 +163,10 @@ serializeToInfo(id object, _NSSerializerInfo* info)
if (c == _fastCls._NSGCString || c == _fastCls._NSGMutableCString ||
c == _fastCls._NXConstantString)
{
FastMapNode node;
GSIMapNode node;
if (info->shouldUnique)
node = FastMapNodeForKey(&info->map, (FastMapKey)object);
node = GSIMapNodeForKey(&info->map, (GSIMapKey)object);
else
node = 0;
if (node == 0)
@ -181,8 +181,8 @@ serializeToInfo(id object, _NSSerializerInfo* info)
(*info->setImp)(info->data, setSel, dlen + slen);
[object getCString: (*info->datImp)(info->data, datSel) + dlen];
if (info->shouldUnique)
FastMapAddPair(&info->map,
(FastMapKey)object, (FastMapVal)info->count++);
GSIMapAddPair(&info->map,
(GSIMapKey)object, (GSIMapVal)info->count++);
}
else
{
@ -192,10 +192,10 @@ serializeToInfo(id object, _NSSerializerInfo* info)
}
else if (fastClassIsKindOfClass(c, _fastCls._NSString))
{
FastMapNode node;
GSIMapNode node;
if (info->shouldUnique)
node = FastMapNodeForKey(&info->map, (FastMapKey)object);
node = GSIMapNodeForKey(&info->map, (GSIMapKey)object);
else
node = 0;
if (node == 0)
@ -210,8 +210,8 @@ serializeToInfo(id object, _NSSerializerInfo* info)
(*info->setImp)(info->data, setSel, dlen + slen*sizeof(unichar));
[object getCharacters: (*info->datImp)(info->data, datSel) + dlen];
if (info->shouldUnique)
FastMapAddPair(&info->map,
(FastMapKey)object, (FastMapVal)info->count++);
GSIMapAddPair(&info->map,
(GSIMapKey)object, (GSIMapVal)info->count++);
}
else
{
@ -371,7 +371,7 @@ typedef struct {
BOOL didUnique;
void (*debImp)();
unsigned int (*deiImp)();
FastArray_t array;
GSIArray_t array;
} _NSDeserializerInfo;
static SEL debSel = @selector(deserializeBytes:length:atCursor:);
@ -401,14 +401,14 @@ initDeserializerInfo(_NSDeserializerInfo* info, NSData *d, unsigned *c, BOOL m)
info->deiImp = (unsigned int (*)())[d methodForSelector: deiSel];
(*info->debImp)(d, debSel, &info->didUnique, 1, c);
if (info->didUnique)
FastArrayInitWithZoneAndCapacity(&info->array, NSDefaultMallocZone(), 16);
GSIArrayInitWithZoneAndCapacity(&info->array, NSDefaultMallocZone(), 16);
}
static void
endDeserializerInfo(_NSDeserializerInfo* info)
{
if (info->didUnique)
FastArrayEmpty(&info->array);
GSIArrayEmpty(&info->array);
}
static id
@ -424,7 +424,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
{
case ST_XREF:
{
return [FastArrayItemAtIndex(&info->array, size).obj retain];
return [GSIArrayItemAtIndex(&info->array, size).obj retain];
}
case ST_CSTRING:
@ -461,7 +461,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
* later reference.
*/
if (info->didUnique)
FastArrayAddItem(&info->array, (FastArrayItem)s);
GSIArrayAddItem(&info->array, (GSIArrayItem)s);
return s;
}
@ -499,7 +499,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
* later reference.
*/
if (info->didUnique)
FastArrayAddItem(&info->array, (FastArrayItem)s);
GSIArrayAddItem(&info->array, (GSIArrayItem)s);
return s;
}

View file

@ -52,6 +52,7 @@
#include <Foundation/NSFileManager.h>
#include <Foundation/NSPortCoder.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSRange.h>
#include <base/IndexedCollection.h>
#include <Foundation/NSData.h>
@ -306,7 +307,7 @@ handle_printf_atsign (FILE *stream,
}
+ (NSString*) stringWithCharacters: (const unichar*)chars
length: (unsigned int)length
length: (unsigned)length
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithCharacters: chars length: length]);
@ -319,7 +320,7 @@ handle_printf_atsign (FILE *stream,
}
+ (NSString*) stringWithCString: (const char*)byteString
length: (unsigned int)length
length: (unsigned)length
{
return AUTORELEASE([[NSString_c_concrete_class allocWithZone:
NSDefaultMallocZone()] initWithCString: byteString length: length]);
@ -358,7 +359,7 @@ handle_printf_atsign (FILE *stream,
/* This is the designated initializer for Unicode Strings. */
- (id) initWithCharactersNoCopy: (unichar*)chars
length: (unsigned int)length
length: (unsigned)length
fromZone: (NSZone*)zone
{
[self subclassResponsibility: _cmd];
@ -366,7 +367,7 @@ handle_printf_atsign (FILE *stream,
}
- (id) initWithCharactersNoCopy: (unichar*)chars
length: (unsigned int)length
length: (unsigned)length
freeWhenDone: (BOOL)flag
{
if (flag)
@ -381,7 +382,7 @@ handle_printf_atsign (FILE *stream,
}
- (id) initWithCharacters: (const unichar*)chars
length: (unsigned int)length
length: (unsigned)length
{
NSZone *z = [self zone];
unichar *s = NSZoneMalloc(z, sizeof(unichar)*length);
@ -393,7 +394,7 @@ handle_printf_atsign (FILE *stream,
}
- (id) initWithCStringNoCopy: (char*)byteString
length: (unsigned int)length
length: (unsigned)length
freeWhenDone: (BOOL)flag
{
if (flag)
@ -408,14 +409,14 @@ handle_printf_atsign (FILE *stream,
/* This is the designated initializer for CStrings. */
- (id) initWithCStringNoCopy: (char*)byteString
length: (unsigned int)length
length: (unsigned)length
fromZone: (NSZone*)zone
{
[self subclassResponsibility: _cmd];
return self;
}
- (id) initWithCString: (const char*)byteString length: (unsigned int)length
- (id) initWithCString: (const char*)byteString length: (unsigned)length
{
NSZone *z = [self zone];
char *s = NSZoneMalloc(z, length);
@ -619,7 +620,7 @@ handle_printf_atsign (FILE *stream,
NSStringEncoding enc;
id d = [NSData dataWithContentsOfFile: path];
const unsigned char *test=[d bytes];
unsigned int len = [d length];
unsigned len = [d length];
if (d == nil) return nil;
if (test && (((test[0]==0xFF) && (test[1]==0xFE)) || ((test[1]==0xFF) && (test[0]==0xFE))))
@ -637,7 +638,7 @@ handle_printf_atsign (FILE *stream,
// Getting a String's Length
- (unsigned int) length
- (unsigned) length
{
[self subclassResponsibility: _cmd];
return 0;
@ -645,7 +646,7 @@ handle_printf_atsign (FILE *stream,
// Accessing Characters
- (unichar) characterAtIndex: (unsigned int)index
- (unichar) characterAtIndex: (unsigned)index
{
[self subclassResponsibility: _cmd];
return (unichar)0;
@ -665,10 +666,7 @@ handle_printf_atsign (FILE *stream,
unsigned l = [self length];
unsigned i;
if (aRange.location >= l)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (l - aRange.location))
[NSException raise:NSRangeException format:@"Invalid location+length"];
GS_RANGE_CHECK(aRange, l);
for (i = 0; i < aRange.length; i++)
{
@ -721,7 +719,7 @@ handle_printf_atsign (FILE *stream,
current = NSMakeRange (search.location,
found.location - search.location);
[array addObject: [self substringFromRange: current]];
[array addObject: [self substringWithRange: current]];
search = NSMakeRange (found.location + found.length,
complete.length - found.location - found.length);
@ -730,27 +728,36 @@ handle_printf_atsign (FILE *stream,
range: search];
}
// Add the last search string range
[array addObject: [self substringFromRange: search]];
[array addObject: [self substringWithRange: search]];
// FIXME: Need to make mutable array into non-mutable array?
return array;
}
- (NSString*) substringFromIndex: (unsigned int)index
- (NSString*) substringFromIndex: (unsigned)index
{
return [self substringFromRange: ((NSRange){index, [self length]-index})];
return [self substringWithRange: ((NSRange){index, [self length]-index})];
}
- (NSString*) substringToIndex: (unsigned)index
{
return [self substringWithRange: ((NSRange){0,index})];;
}
- (NSString*) substringFromRange: (NSRange)aRange
{
NSZone *z;
unichar *buf;
id ret;
return [self substringWithRange: aRange];
}
- (NSString*) substringWithRange: (NSRange)aRange
{
NSZone *z;
unichar *buf;
id ret;
unsigned len = [self length];
GS_RANGE_CHECK(aRange, len);
if (aRange.location > [self length])
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > ([self length] - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
if (aRange.length == 0)
return @"";
z = fastZone(self);
@ -761,16 +768,6 @@ handle_printf_atsign (FILE *stream,
return AUTORELEASE(ret);
}
- (NSString*) substringWithRange: (NSRange)aRange
{
return [self substringFromRange: aRange];
}
- (NSString*) substringToIndex: (unsigned int)index
{
return [self substringFromRange: ((NSRange){0,index})];;
}
// Finding Ranges of Characters and Substrings
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
@ -782,7 +779,7 @@ handle_printf_atsign (FILE *stream,
}
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
options: (unsigned int)mask
options: (unsigned)mask
{
NSRange all = NSMakeRange(0, [self length]);
return [self rangeOfCharacterFromSet: aSet
@ -792,7 +789,7 @@ handle_printf_atsign (FILE *stream,
/* xxx FIXME */
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
options: (unsigned int)mask
options: (unsigned)mask
range: (NSRange)aRange
{
int i, start, stop, step;
@ -801,10 +798,7 @@ handle_printf_atsign (FILE *stream,
BOOL (*mImp)(id, SEL, unichar);
i = [self length];
if (aRange.location > i)
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > (i - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
GS_RANGE_CHECK(aRange, i);
if ((mask & NSBackwardsSearch) == NSBackwardsSearch)
{
@ -843,7 +837,7 @@ handle_printf_atsign (FILE *stream,
}
- (NSRange) rangeOfString: (NSString*)string
options: (unsigned int)mask
options: (unsigned)mask
{
NSRange all = NSMakeRange(0, [self length]);
return [self rangeOfString: string
@ -852,7 +846,7 @@ handle_printf_atsign (FILE *stream,
}
- (NSRange) rangeOfString: (NSString *) aString
options: (unsigned int) mask
options: (unsigned) mask
range: (NSRange) aRange
{
if (aString == nil)
@ -862,7 +856,7 @@ handle_printf_atsign (FILE *stream,
// Determining Composed Character Sequences
- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (unsigned int)anIndex
- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (unsigned)anIndex
{
unsigned start;
unsigned end;
@ -888,7 +882,7 @@ handle_printf_atsign (FILE *stream,
}
- (NSComparisonResult) compare: (NSString*)aString
options: (unsigned int)mask
options: (unsigned)mask
{
return [self compare: aString options: mask
range: ((NSRange){0, [self length]})];
@ -896,7 +890,7 @@ handle_printf_atsign (FILE *stream,
// xxx Should implement full POSIX.2 collate
- (NSComparisonResult) compare: (NSString*)aString
options: (unsigned int)mask
options: (unsigned)mask
range: (NSRange)aRange
{
if (aString == nil)
@ -945,7 +939,7 @@ handle_printf_atsign (FILE *stream,
return NO;
}
- (unsigned int) hash
- (unsigned) hash
{
unsigned ret = 0;
@ -985,7 +979,7 @@ handle_printf_atsign (FILE *stream,
// Getting a Shared Prefix
- (NSString*) commonPrefixWithString: (NSString*)aString
options: (unsigned int)mask
options: (unsigned)mask
{
if (mask & NSLiteralSearch)
{
@ -1077,7 +1071,7 @@ handle_printf_atsign (FILE *stream,
oRange = (*orImp)(aString, ranSel, oIndex);
if ((sRange.length < 2) || (oRange.length < 2))
return [self substringFromRange: NSMakeRange(0, sIndex)];
return [self substringWithRange: NSMakeRange(0, sIndex)];
else
{
GSEQ_MAKE(sBuf, sSeq, sRange.length);
@ -1107,21 +1101,21 @@ handle_printf_atsign (FILE *stream,
oIndex += oRange.length;
}
else
return [self substringFromRange: NSMakeRange(0,sIndex)];
return [self substringWithRange: NSMakeRange(0,sIndex)];
}
else
return [self substringFromRange: NSMakeRange(0,sIndex)];
return [self substringWithRange: NSMakeRange(0,sIndex)];
}
}
}
return [self substringFromRange: NSMakeRange(0, sIndex)];
return [self substringWithRange: NSMakeRange(0, sIndex)];
}
}
- (NSRange) lineRangeForRange: (NSRange)aRange
{
unsigned int startIndex;
unsigned int lineEndIndex;
unsigned startIndex;
unsigned lineEndIndex;
[self getLineStart: &startIndex
end: &lineEndIndex
@ -1130,114 +1124,117 @@ handle_printf_atsign (FILE *stream,
return NSMakeRange(startIndex, lineEndIndex - startIndex);
}
- (void)getLineStart: (unsigned int *)startIndex
end: (unsigned int *)lineEndIndex
contentsEnd: (unsigned int *)contentsEndIndex
forRange: (NSRange)aRange
- (void)getLineStart: (unsigned *)startIndex
end: (unsigned *)lineEndIndex
contentsEnd: (unsigned *)contentsEndIndex
forRange: (NSRange)aRange
{
unichar thischar;
BOOL done;
unsigned int start, end, len;
if (aRange.location > [self length])
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > ([self length] - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
unichar thischar;
BOOL done;
unsigned start, end, len;
len = [self length];
start=aRange.location;
GS_RANGE_CHECK(aRange, len);
start = aRange.location;
if (startIndex)
if (start==0)
*startIndex=0;
else
{
start--;
while (start>0)
{
BOOL done = NO;
thischar = [self characterAtIndex: start];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
done = YES;
break;
default:
start--;
break;
};
if (done)
break;
start--;
while (start > 0)
{
BOOL done = NO;
thischar = [self characterAtIndex: start];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
done = YES;
break;
default:
start--;
break;
};
if (done)
break;
};
if (start == 0)
{
thischar = [self characterAtIndex: start];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
start++;
break;
default:
break;
};
}
else
start++;
*startIndex = start;
};
if (start == 0)
{
thischar = [self characterAtIndex: start];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
start++;
break;
default:
break;
};
}
else
start++;
*startIndex=start;
};
if (lineEndIndex || contentsEndIndex)
{
end=aRange.location+aRange.length;
while (end<len)
{
BOOL done = NO;
thischar = [self characterAtIndex: end];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
done = YES;
break;
default:
break;
};
end++;
if (done)
break;
};
if (end<len)
{
if ([self characterAtIndex: end]==(unichar)0x000D)
if ([self characterAtIndex: end+1]==(unichar)0x000A)
*lineEndIndex = end+1;
else *lineEndIndex = end;
else *lineEndIndex = end;
end=aRange.location+aRange.length;
while (end<len)
{
BOOL done = NO;
thischar = [self characterAtIndex: end];
switch(thischar)
{
case (unichar)0x000A:
case (unichar)0x000D:
case (unichar)0x2028:
case (unichar)0x2029:
done = YES;
break;
default:
break;
};
end++;
if (done)
break;
};
if (end<len)
{
if ([self characterAtIndex: end]==(unichar)0x000D)
{
if ([self characterAtIndex: end+1]==(unichar)0x000A)
*lineEndIndex = end+1;
else
*lineEndIndex = end;
}
else
*lineEndIndex = end;
}
else
*lineEndIndex = end;
}
else
*lineEndIndex = end;
};
if (contentsEndIndex)
{
if (end<len)
{
*contentsEndIndex= end-1;
if (end<len)
{
*contentsEndIndex= end-1;
}
else
{
/* xxx OPENSTEP documentation does not say what to do if last
line is not terminated. Assume this */
*contentsEndIndex= end;
}
}
else
/* xxx OPENSTEP documentation does not say what to do if last
line is not terminated. Assume this */
*contentsEndIndex= end;
};
}
// Changing Case
@ -1330,7 +1327,7 @@ handle_printf_atsign (FILE *stream,
return NULL;
}
- (unsigned int) cStringLength
- (unsigned) cStringLength
{
[self subclassResponsibility: _cmd];
return 0;
@ -1344,7 +1341,7 @@ handle_printf_atsign (FILE *stream,
}
- (void) getCString: (char*)buffer
maxLength: (unsigned int)maxLength
maxLength: (unsigned)maxLength
{
[self getCString: buffer maxLength: maxLength
range: ((NSRange){0, [self length]})
@ -1353,17 +1350,14 @@ handle_printf_atsign (FILE *stream,
// xxx FIXME adjust range for composite sequence
- (void) getCString: (char*)buffer
maxLength: (unsigned int)maxLength
maxLength: (unsigned)maxLength
range: (NSRange)aRange
remainingRange: (NSRange*)leftoverRange
{
int len, count;
len = [self cStringLength];
if (aRange.location > len)
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > (len - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
GS_RANGE_CHECK(aRange, len);
if (maxLength < aRange.length)
{
@ -1548,7 +1542,7 @@ handle_printf_atsign (FILE *stream,
// Manipulating File System Paths
- (unsigned int) completePathIntoString: (NSString**)outputName
- (unsigned) completePathIntoString: (NSString**)outputName
caseSensitive: (BOOL)flag
matchesIntoArray: (NSArray**)outputArray
filterTypes: (NSArray*)filterTypes
@ -1608,7 +1602,7 @@ handle_printf_atsign (FILE *stream,
return [self cString];
}
- (BOOL)getFileSystemRepresentation: (char*)buffer maxLength: (unsigned int)size
- (BOOL)getFileSystemRepresentation: (char*)buffer maxLength: (unsigned)size
{
const char* ptr = [self cString];
if (strlen(ptr) > size)
@ -1785,7 +1779,7 @@ handle_printf_atsign (FILE *stream,
else
/* It is actually of the form `~username' */
uname_len = [self length] - 1;
uname = [self substringFromRange: ((NSRange){1, uname_len})];
uname = [self substringWithRange: ((NSRange){1, uname_len})];
homedir = NSHomeDirectoryForUser (uname);
}
else
@ -2286,7 +2280,7 @@ handle_printf_atsign (FILE *stream,
}
+ (NSString*) stringWithCString: (const char*)byteString
length: (unsigned int)length
length: (unsigned)length
{
return AUTORELEASE([[NSMutableString_c_concrete_class allocWithZone:
NSDefaultMallocZone()] initWithCString: byteString length: length]);

View file

@ -30,11 +30,11 @@
/*
* Setup for inline operation of arrays.
*/
#define FAST_ARRAY_RETAIN(X) X
#define FAST_ARRAY_RELEASE(X)
#define FAST_ARRAY_TYPES GSUNION_OBJ|GSUNION_SEL|GSUNION_STR
#define GSI_ARRAY_RETAIN(X) X
#define GSI_ARRAY_RELEASE(X)
#define GSI_ARRAY_TYPES GSUNION_OBJ|GSUNION_SEL|GSUNION_STR
#include <base/FastArray.x>
#include <base/GSIArray.h>
#define _IN_NSUNARCHIVER_M
#include <Foundation/NSArchiver.h>
@ -344,9 +344,9 @@ mapClassName(NSUnarchiverObjectInfo *info)
{
NSZone *z = clsMap->zone;
FastArrayClear(clsMap);
FastArrayClear(objMap);
FastArrayClear(ptrMap);
GSIArrayClear(clsMap);
GSIArrayClear(objMap);
GSIArrayClear(ptrMap);
NSZoneFree(z, (void*)clsMap);
}
[super dealloc];
@ -497,13 +497,13 @@ mapClassName(NSUnarchiverObjectInfo *info)
{
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(objMap))
if (xref >= GSIArrayCount(objMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"object crossref missing - %d",
xref];
}
obj = FastArrayItemAtIndex(objMap, xref).obj;
obj = GSIArrayItemAtIndex(objMap, xref).obj;
/*
* If it's a cross-reference, we need to retain it in
* order to give the appearance that it's actually a
@ -516,7 +516,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
Class c;
id rep;
if (xref != FastArrayCount(objMap))
if (xref != GSIArrayCount(objMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra object crossref - %d",
@ -525,20 +525,20 @@ mapClassName(NSUnarchiverObjectInfo *info)
(*dValImp)(self, dValSel, @encode(Class), &c);
obj = [c allocWithZone: zone];
FastArrayAddItem(objMap, (FastArrayItem)obj);
GSIArrayAddItem(objMap, (GSIArrayItem)obj);
rep = [obj initWithCoder: self];
if (rep != obj)
{
obj = rep;
FastArraySetItemAtIndex(objMap, (FastArrayItem)obj, xref);
GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref);
}
rep = [obj awakeAfterUsingCoder: self];
if (rep != obj)
{
obj = rep;
FastArraySetItemAtIndex(objMap, (FastArrayItem)obj, xref);
GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref);
}
}
}
@ -563,12 +563,12 @@ mapClassName(NSUnarchiverObjectInfo *info)
}
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(clsMap))
if (xref >= GSIArrayCount(clsMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"class crossref missing - %d", xref];
}
classInfo = (NSUnarchiverObjectInfo*)FastArrayItemAtIndex(clsMap, xref).obj;
classInfo = (NSUnarchiverObjectInfo*)GSIArrayItemAtIndex(clsMap, xref).obj;
*(Class*)address = mapClassObject(classInfo);
return;
}
@ -577,7 +577,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
unsigned cver;
NSString *className;
if (xref != FastArrayCount(clsMap))
if (xref != GSIArrayCount(clsMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra class crossref - %d", xref];
@ -599,7 +599,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
RELEASE(classInfo);
}
classInfo->version = cver;
FastArrayAddItem(clsMap, (FastArrayItem)classInfo);
GSIArrayAddItem(clsMap, (GSIArrayItem)classInfo);
*(Class*)address = mapClassObject(classInfo);
/*
* Point the address to a dummy location and read the
@ -631,22 +631,22 @@ mapClassName(NSUnarchiverObjectInfo *info)
}
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(ptrMap))
if (xref >= GSIArrayCount(ptrMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"sel crossref missing - %d", xref];
}
sel = FastArrayItemAtIndex(ptrMap, xref).sel;
sel = GSIArrayItemAtIndex(ptrMap, xref).sel;
}
else
{
if (xref != FastArrayCount(ptrMap))
if (xref != GSIArrayCount(ptrMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra sel crossref - %d", xref];
}
(*desImp)(src, desSel, &sel, @encode(SEL), &cursor, nil);
FastArrayAddItem(ptrMap, (FastArrayItem)sel);
GSIArrayAddItem(ptrMap, (GSIArrayItem)sel);
}
*(SEL*)address = sel;
return;
@ -708,19 +708,19 @@ mapClassName(NSUnarchiverObjectInfo *info)
}
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(ptrMap))
if (xref >= GSIArrayCount(ptrMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"ptr crossref missing - %d", xref];
}
*(void**)address = FastArrayItemAtIndex(ptrMap, xref).ptr;
*(void**)address = GSIArrayItemAtIndex(ptrMap, xref).ptr;
}
else
{
unsigned size;
NSData *dat;
if (FastArrayCount(ptrMap) != xref)
if (GSIArrayCount(ptrMap) != xref)
{
[NSException raise: NSInternalInconsistencyException
format: @"extra ptr crossref - %d", xref];
@ -732,7 +732,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
*/
size = objc_sizeof_type(++type);
*(void**)address = _fastMallocBuffer(size);
FastArrayAddItem(ptrMap, (FastArrayItem)*(void**)address);
GSIArrayAddItem(ptrMap, (GSIArrayItem)*(void**)address);
/*
* Decode value and add memory to map for crossrefs.
@ -757,24 +757,24 @@ mapClassName(NSUnarchiverObjectInfo *info)
}
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(ptrMap))
if (xref >= GSIArrayCount(ptrMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"string crossref missing - %d", xref];
}
*(char**)address = FastArrayItemAtIndex(ptrMap, xref).str;
*(char**)address = GSIArrayItemAtIndex(ptrMap, xref).str;
}
else
{
int length;
if (xref != FastArrayCount(ptrMap))
if (xref != GSIArrayCount(ptrMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra string crossref - %d", xref];
}
(*desImp)(src, desSel, address, @encode(char*), &cursor, nil);
FastArrayAddItem(ptrMap, (FastArrayItem)*(void**)address);
GSIArrayAddItem(ptrMap, (GSIArrayItem)*(void**)address);
}
return;
}
@ -1003,13 +1003,13 @@ mapClassName(NSUnarchiverObjectInfo *info)
if (info & _GSC_XREF)
{
if (xref >= FastArrayCount(objMap))
if (xref >= GSIArrayCount(objMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"object crossref missing - %d",
xref];
}
obj = FastArrayItemAtIndex(objMap, xref).obj;
obj = GSIArrayItemAtIndex(objMap, xref).obj;
/*
* If it's a cross-reference, we don't need to autorelease it
* since we didn't create it.
@ -1021,7 +1021,7 @@ mapClassName(NSUnarchiverObjectInfo *info)
Class c;
id rep;
if (xref != FastArrayCount(objMap))
if (xref != GSIArrayCount(objMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra object crossref - %d",
@ -1030,20 +1030,20 @@ mapClassName(NSUnarchiverObjectInfo *info)
(*dValImp)(self, dValSel, @encode(Class), &c);
obj = [c allocWithZone: zone];
FastArrayAddItem(objMap, (FastArrayItem)obj);
GSIArrayAddItem(objMap, (GSIArrayItem)obj);
rep = [obj initWithCoder: self];
if (rep != obj)
{
obj = rep;
FastArraySetItemAtIndex(objMap, (FastArrayItem)obj, xref);
GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref);
}
rep = [obj awakeAfterUsingCoder: self];
if (rep != obj)
{
obj = rep;
FastArraySetItemAtIndex(objMap, (FastArrayItem)obj, xref);
GSIArraySetItemAtIndex(objMap, (GSIArrayItem)obj, xref);
}
/*
* A newly allocated object needs to be autoreleased.
@ -1153,11 +1153,11 @@ mapClassName(NSUnarchiverObjectInfo *info)
if (replacement == anObject)
return;
for (i = FastArrayCount(objMap) - 1; i > 0; i--)
for (i = GSIArrayCount(objMap) - 1; i > 0; i--)
{
if (FastArrayItemAtIndex(objMap, i).obj == anObject)
if (GSIArrayItemAtIndex(objMap, i).obj == anObject)
{
FastArraySetItemAtIndex(objMap, (FastArrayItem)replacement, i);
GSIArraySetItemAtIndex(objMap, (GSIArrayItem)replacement, i);
return;
}
}
@ -1237,17 +1237,17 @@ mapClassName(NSUnarchiverObjectInfo *info)
/*
* Allocate and initialise arrays to build crossref maps in.
*/
clsMap = NSZoneMalloc(zone, sizeof(FastArray_t)*3);
FastArrayInitWithZoneAndCapacity(clsMap, zone, sizeC);
FastArrayAddItem(clsMap, (FastArrayItem)0);
clsMap = NSZoneMalloc(zone, sizeof(GSIArray_t)*3);
GSIArrayInitWithZoneAndCapacity(clsMap, zone, sizeC);
GSIArrayAddItem(clsMap, (GSIArrayItem)0);
objMap = &clsMap[1];
FastArrayInitWithZoneAndCapacity(objMap, zone, sizeO);
FastArrayAddItem(objMap, (FastArrayItem)0);
GSIArrayInitWithZoneAndCapacity(objMap, zone, sizeO);
GSIArrayAddItem(objMap, (GSIArrayItem)0);
ptrMap = &clsMap[2];
FastArrayInitWithZoneAndCapacity(ptrMap, zone, sizeP);
FastArrayAddItem(ptrMap, (FastArrayItem)0);
GSIArrayInitWithZoneAndCapacity(ptrMap, zone, sizeP);
GSIArrayAddItem(ptrMap, (GSIArrayItem)0);
}
else
{