mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
984e50ff8c
commit
7fffe7ce03
22 changed files with 829 additions and 914 deletions
|
@ -1,4 +1,4 @@
|
|||
/* A fast inline array table implementation without objc method overhead.
|
||||
/* A fast (Inline) array implementation without objc method overhead.
|
||||
* Copyright (C) 1998,1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
@ -32,47 +32,47 @@
|
|||
/* To turn assertions on, comment out the following four lines */
|
||||
#ifndef NS_BLOCK_ASSERTIONS
|
||||
#define NS_BLOCK_ASSERTIONS 1
|
||||
#define FAST_ARRAY_BLOCKED_ASSERTIONS 1
|
||||
#define GSI_ARRAY_BLOCKED_ASSERTIONS 1
|
||||
#endif
|
||||
|
||||
#define FAST_ARRAY_CHECK NSCAssert(array->count <= array->cap && array->old <= array->cap && array->old >= 1, NSInternalInconsistencyException)
|
||||
#define GSI_ARRAY_CHECK NSCAssert(array->count <= array->cap && array->old <= array->cap && array->old >= 1, NSInternalInconsistencyException)
|
||||
|
||||
/*
|
||||
This file should be INCLUDED in files wanting to use the FastArray
|
||||
This file should be INCLUDED in files wanting to use the GSIArray
|
||||
* functions - these are all declared inline for maximum performance.
|
||||
*
|
||||
* The file including this one may predefine some macros to alter
|
||||
* the behaviour (default macros assume the items are NSObjects
|
||||
* that are to be retained in the array) ...
|
||||
*
|
||||
* FAST_ARRAY_RETAIN()
|
||||
* GSI_ARRAY_RETAIN()
|
||||
* Macro to retain an array item
|
||||
*
|
||||
* FAST_ARRAY_RELEASE()
|
||||
* GSI_ARRAY_RELEASE()
|
||||
* Macro to release the item.
|
||||
*
|
||||
* The next two values can be defined in order to let us optimise
|
||||
* even further when either retain or release operations are not needed.
|
||||
*
|
||||
* FAST_ARRAY_NO_RELEASE
|
||||
* GSI_ARRAY_NO_RELEASE
|
||||
* Defined if no release operation is needed for an item
|
||||
* FAST_ARRAY_NO_RETAIN
|
||||
* GSI_ARRAY_NO_RETAIN
|
||||
* Defined if no retain operation is needed for a an item
|
||||
*/
|
||||
#ifndef FAST_ARRAY_RETAIN
|
||||
#define FAST_ARRAY_RETAIN(X) [(X).obj retain]
|
||||
#ifndef GSI_ARRAY_RETAIN
|
||||
#define GSI_ARRAY_RETAIN(X) [(X).obj retain]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_ARRAY_RELEASE
|
||||
#define FAST_ARRAY_RELEASE(X) [(X).obj release]
|
||||
#ifndef GSI_ARRAY_RELEASE
|
||||
#define GSI_ARRAY_RELEASE(X) [(X).obj release]
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If there is no bitmask defined to supply the types that
|
||||
* may be stored in the array, default to permitting all types.
|
||||
*/
|
||||
#ifndef FAST_ARRAY_TYPES
|
||||
#define FAST_ARRAY_TYPES GSUNION_ALL
|
||||
#ifndef GSI_ARRAY_TYPES
|
||||
#define GSI_ARRAY_TYPES GSUNION_ALL
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -81,7 +81,7 @@
|
|||
#ifdef GSUNION
|
||||
#undef GSUNION
|
||||
#endif
|
||||
#define GSUNION FastArrayItem
|
||||
#define GSUNION GSIArrayItem
|
||||
|
||||
/*
|
||||
* Set up the types that will be storable in the union.
|
||||
|
@ -90,12 +90,12 @@
|
|||
#ifdef GSUNION_TYPES
|
||||
#undef GSUNION_TYPES
|
||||
#endif
|
||||
#define GSUNION_TYPES FAST_ARRAY_TYPES
|
||||
#define GSUNION_TYPES GSI_ARRAY_TYPES
|
||||
#ifdef GSUNION_EXTRA
|
||||
#undef GSUNION_EXTRA
|
||||
#endif
|
||||
#ifdef FAST_ARRAY_EXTRA
|
||||
#define GSUNION_EXTRA FAST_ARRAY_EXTRA
|
||||
#ifdef GSI_ARRAY_EXTRA
|
||||
#define GSUNION_EXTRA GSI_ARRAY_EXTRA
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -103,33 +103,33 @@
|
|||
*/
|
||||
#include <base/GSUnion.h>
|
||||
|
||||
struct _FastArray {
|
||||
FastArrayItem *ptr;
|
||||
struct _GSIArray {
|
||||
GSIArrayItem *ptr;
|
||||
unsigned count;
|
||||
unsigned cap;
|
||||
unsigned old;
|
||||
NSZone *zone;
|
||||
};
|
||||
typedef struct _FastArray FastArray_t;
|
||||
typedef struct _FastArray *FastArray;
|
||||
typedef struct _GSIArray GSIArray_t;
|
||||
typedef struct _GSIArray *GSIArray;
|
||||
|
||||
static INLINE unsigned
|
||||
FastArrayCount(FastArray array)
|
||||
GSIArrayCount(GSIArray array)
|
||||
{
|
||||
return array->count;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayGrow(FastArray array)
|
||||
GSIArrayGrow(GSIArray array)
|
||||
{
|
||||
unsigned next;
|
||||
unsigned size;
|
||||
FastArrayItem *tmp;
|
||||
GSIArrayItem *tmp;
|
||||
|
||||
next = array->cap + array->old;
|
||||
size = next*sizeof(FastArrayItem);
|
||||
size = next*sizeof(GSIArrayItem);
|
||||
#if GS_WITH_GC
|
||||
tmp = (FastArrayItem*)GC_REALLOC(size);
|
||||
tmp = (GSIArrayItem*)GC_REALLOC(size);
|
||||
#else
|
||||
tmp = NSZoneRealloc(array->zone, array->ptr, size);
|
||||
#endif
|
||||
|
@ -137,7 +137,7 @@ FastArrayGrow(FastArray array)
|
|||
if (tmp == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"failed to grow FastArray"];
|
||||
format: @"failed to grow GSIArray"];
|
||||
}
|
||||
array->ptr = tmp;
|
||||
array->old = array->cap;
|
||||
|
@ -145,65 +145,65 @@ FastArrayGrow(FastArray array)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayInsertItem(FastArray array, FastArrayItem item, unsigned index)
|
||||
GSIArrayInsertItem(GSIArray array, GSIArrayItem item, unsigned index)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
FAST_ARRAY_RETAIN(item);
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_RETAIN(item);
|
||||
GSI_ARRAY_CHECK;
|
||||
if (array->count == array->cap)
|
||||
{
|
||||
FastArrayGrow(array);
|
||||
GSIArrayGrow(array);
|
||||
}
|
||||
for (i = array->count++; i > index; i--)
|
||||
{
|
||||
array->ptr[i] = array->ptr[i-1];
|
||||
}
|
||||
array->ptr[i] = item;
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayInsertItemNoRetain(FastArray array, FastArrayItem item, unsigned index)
|
||||
GSIArrayInsertItemNoRetain(GSIArray array, GSIArrayItem item, unsigned index)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
if (array->count == array->cap)
|
||||
{
|
||||
FastArrayGrow(array);
|
||||
GSIArrayGrow(array);
|
||||
}
|
||||
for (i = array->count++; i > index; i--)
|
||||
{
|
||||
array->ptr[i] = array->ptr[i-1];
|
||||
}
|
||||
array->ptr[i] = item;
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayAddItem(FastArray array, FastArrayItem item)
|
||||
GSIArrayAddItem(GSIArray array, GSIArrayItem item)
|
||||
{
|
||||
FAST_ARRAY_RETAIN(item);
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_RETAIN(item);
|
||||
GSI_ARRAY_CHECK;
|
||||
if (array->count == array->cap)
|
||||
{
|
||||
FastArrayGrow(array);
|
||||
GSIArrayGrow(array);
|
||||
}
|
||||
array->ptr[array->count++] = item;
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayAddItemNoRetain(FastArray array, FastArrayItem item)
|
||||
GSIArrayAddItemNoRetain(GSIArray array, GSIArrayItem item)
|
||||
{
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
if (array->count == array->cap)
|
||||
{
|
||||
FastArrayGrow(array);
|
||||
GSIArrayGrow(array);
|
||||
}
|
||||
array->ptr[array->count++] = item;
|
||||
FAST_ARRAY_CHECK;
|
||||
GSI_ARRAY_CHECK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -214,8 +214,8 @@ FastArrayAddItemNoRetain(FastArray array, FastArrayItem item)
|
|||
* if it is greater, and NSOrderedSame if it is equal.
|
||||
*/
|
||||
static INLINE unsigned
|
||||
FastArrayInsertionPosition(FastArray array, FastArrayItem item,
|
||||
NSComparisonResult (*sorter)(FastArrayItem, FastArrayItem))
|
||||
GSIArrayInsertionPosition(GSIArray array, GSIArrayItem item,
|
||||
NSComparisonResult (*sorter)(GSIArrayItem, GSIArrayItem))
|
||||
{
|
||||
unsigned upper = array->count;
|
||||
unsigned lower = 0;
|
||||
|
@ -257,8 +257,8 @@ FastArrayInsertionPosition(FastArray array, FastArrayItem item,
|
|||
|
||||
#ifndef NS_BLOCK_ASSERTIONS
|
||||
static INLINE void
|
||||
FastArrayCheckSort(FastArray array,
|
||||
NSComparisonResult (*sorter)(FastArrayItem, FastArrayItem))
|
||||
GSIArrayCheckSort(GSIArray array,
|
||||
NSComparisonResult (*sorter)(GSIArrayItem, GSIArrayItem))
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@ -271,47 +271,47 @@ FastArrayCheckSort(FastArray array,
|
|||
#endif
|
||||
|
||||
static INLINE void
|
||||
FastArrayInsertSorted(FastArray array, FastArrayItem item,
|
||||
NSComparisonResult (*sorter)(FastArrayItem, FastArrayItem))
|
||||
GSIArrayInsertSorted(GSIArray array, GSIArrayItem item,
|
||||
NSComparisonResult (*sorter)(GSIArrayItem, GSIArrayItem))
|
||||
{
|
||||
unsigned index;
|
||||
|
||||
index = FastArrayInsertionPosition(array, item, sorter);
|
||||
FastArrayInsertItem(array, item, index);
|
||||
index = GSIArrayInsertionPosition(array, item, sorter);
|
||||
GSIArrayInsertItem(array, item, index);
|
||||
#ifndef NS_BLOCK_ASSERTIONS
|
||||
FastArrayCheckSort(array, sorter);
|
||||
GSIArrayCheckSort(array, sorter);
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayInsertSortedNoRetain(FastArray array, FastArrayItem item,
|
||||
NSComparisonResult (*sorter)(FastArrayItem, FastArrayItem))
|
||||
GSIArrayInsertSortedNoRetain(GSIArray array, GSIArrayItem item,
|
||||
NSComparisonResult (*sorter)(GSIArrayItem, GSIArrayItem))
|
||||
{
|
||||
unsigned index;
|
||||
|
||||
index = FastArrayInsertionPosition(array, item, sorter);
|
||||
FastArrayInsertItemNoRetain(array, item, index);
|
||||
index = GSIArrayInsertionPosition(array, item, sorter);
|
||||
GSIArrayInsertItemNoRetain(array, item, index);
|
||||
#ifndef NS_BLOCK_ASSERTIONS
|
||||
FastArrayCheckSort(array, sorter);
|
||||
GSIArrayCheckSort(array, sorter);
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayRemoveItemAtIndex(FastArray array, unsigned index)
|
||||
GSIArrayRemoveItemAtIndex(GSIArray array, unsigned index)
|
||||
{
|
||||
FastArrayItem tmp;
|
||||
GSIArrayItem tmp;
|
||||
NSCAssert(index < array->count, NSInvalidArgumentException);
|
||||
tmp = array->ptr[index];
|
||||
while (++index < array->count)
|
||||
array->ptr[index-1] = array->ptr[index];
|
||||
array->count--;
|
||||
FAST_ARRAY_RELEASE(tmp);
|
||||
GSI_ARRAY_RELEASE(tmp);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayRemoveItemAtIndexNoRelease(FastArray array, unsigned index)
|
||||
GSIArrayRemoveItemAtIndexNoRelease(GSIArray array, unsigned index)
|
||||
{
|
||||
FastArrayItem tmp;
|
||||
GSIArrayItem tmp;
|
||||
NSCAssert(index < array->count, NSInvalidArgumentException);
|
||||
tmp = array->ptr[index];
|
||||
while (++index < array->count)
|
||||
|
@ -320,25 +320,25 @@ FastArrayRemoveItemAtIndexNoRelease(FastArray array, unsigned index)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastArraySetItemAtIndex(FastArray array, FastArrayItem item, unsigned index)
|
||||
GSIArraySetItemAtIndex(GSIArray array, GSIArrayItem item, unsigned index)
|
||||
{
|
||||
FastArrayItem tmp;
|
||||
GSIArrayItem tmp;
|
||||
NSCAssert(index < array->count, NSInvalidArgumentException);
|
||||
tmp = array->ptr[index];
|
||||
FAST_ARRAY_RETAIN(item);
|
||||
GSI_ARRAY_RETAIN(item);
|
||||
array->ptr[index] = item;
|
||||
FAST_ARRAY_RELEASE(tmp);
|
||||
GSI_ARRAY_RELEASE(tmp);
|
||||
}
|
||||
|
||||
static INLINE FastArrayItem
|
||||
FastArrayItemAtIndex(FastArray array, unsigned index)
|
||||
static INLINE GSIArrayItem
|
||||
GSIArrayItemAtIndex(GSIArray array, unsigned index)
|
||||
{
|
||||
NSCAssert(index < array->count, NSInvalidArgumentException);
|
||||
return array->ptr[index];
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayClear(FastArray array)
|
||||
GSIArrayClear(GSIArray array)
|
||||
{
|
||||
if (array->ptr)
|
||||
{
|
||||
|
@ -353,26 +353,41 @@ FastArrayClear(FastArray array)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayRemoveAllItems(FastArray array)
|
||||
GSIArrayRemoveItemsFromIndex(GSIArray array, unsigned index)
|
||||
{
|
||||
#ifndef FAST_ARRAY_NO_RELEASE
|
||||
if (index < array->count)
|
||||
{
|
||||
#ifndef GSI_ARRAY_NO_RELEASE
|
||||
while (array->count-- > index)
|
||||
{
|
||||
GSI_ARRAY_RELEASE(array->ptr[array->count]);
|
||||
}
|
||||
#endif
|
||||
array->count = index;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
GSIArrayRemoveAllItems(GSIArray array)
|
||||
{
|
||||
#ifndef GSI_ARRAY_NO_RELEASE
|
||||
while (array->count--)
|
||||
{
|
||||
FAST_ARRAY_RELEASE(array->ptr[array->count]);
|
||||
GSI_ARRAY_RELEASE(array->ptr[array->count]);
|
||||
}
|
||||
#endif
|
||||
array->count = 0;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastArrayEmpty(FastArray array)
|
||||
GSIArrayEmpty(GSIArray array)
|
||||
{
|
||||
FastArrayRemoveAllItems(array);
|
||||
FastArrayClear(array);
|
||||
GSIArrayRemoveAllItems(array);
|
||||
GSIArrayClear(array);
|
||||
}
|
||||
|
||||
static INLINE FastArray
|
||||
FastArrayInitWithZoneAndCapacity(FastArray array, NSZone *zone, size_t capacity)
|
||||
static INLINE GSIArray
|
||||
GSIArrayInitWithZoneAndCapacity(GSIArray array, NSZone *zone, size_t capacity)
|
||||
{
|
||||
unsigned size;
|
||||
|
||||
|
@ -382,23 +397,23 @@ FastArrayInitWithZoneAndCapacity(FastArray array, NSZone *zone, size_t capacity)
|
|||
capacity = 2;
|
||||
array->cap = capacity;
|
||||
array->old = capacity/2;
|
||||
size = capacity*sizeof(FastArrayItem);
|
||||
size = capacity*sizeof(GSIArrayItem);
|
||||
#if GS_WITH_GC
|
||||
/*
|
||||
* If we use a nil zone, objects we point to are subject to GC
|
||||
*/
|
||||
if (zone == 0)
|
||||
array->ptr = (FastArrayItem*)GC_MALLOC_ATOMIC(size);
|
||||
array->ptr = (GSIArrayItem*)GC_MALLOC_ATOMIC(size);
|
||||
else
|
||||
array->ptr = (FastArrayitem)GC_MALLOC(zone, size);
|
||||
array->ptr = (GSIArrayitem)GC_MALLOC(zone, size);
|
||||
#else
|
||||
array->ptr = (FastArrayItem*)NSZoneMalloc(zone, size);
|
||||
array->ptr = (GSIArrayItem*)NSZoneMalloc(zone, size);
|
||||
#endif
|
||||
return array;
|
||||
}
|
||||
|
||||
#ifdef FAST_ARRAY_BLOCKED_ASSERTIONS
|
||||
#ifdef GSI_ARRAY_BLOCKED_ASSERTIONS
|
||||
#undef NS_BLOCK_ASSERTIONS
|
||||
#undef FAST_ARRAY_BLOCKED_ASSERTIONS
|
||||
#undef GSI_ARRAY_BLOCKED_ASSERTIONS
|
||||
#endif
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* A fast map/hash table implementation for NSObjects
|
||||
/* A fast (Inline) map/hash table implementation for NSObjects
|
||||
* Copyright (C) 1998,1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
@ -34,72 +34,72 @@
|
|||
/* To turn assertions on, comment out the following four lines */
|
||||
#ifndef NS_BLOCK_ASSERTIONS
|
||||
#define NS_BLOCK_ASSERTIONS 1
|
||||
#define FAST_MAP_BLOCKED_ASSERTIONS 1
|
||||
#define GSI_MAP_BLOCKED_ASSERTIONS 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This file should be INCLUDED in files wanting to use the FastMap
|
||||
* This file should be INCLUDED in files wanting to use the GSIMap
|
||||
* functions - these are all declared inline for maximum performance.
|
||||
*
|
||||
* The file including this one may predefine some macros to alter
|
||||
* the behaviour
|
||||
*
|
||||
* FAST_MAP_HAS_VALUE
|
||||
* GSI_MAP_HAS_VALUE
|
||||
* If defined as 0, then this becomes a hash table rather than
|
||||
* a map table.
|
||||
*
|
||||
* FAST_MAP_RETAIN_KEY()
|
||||
* GSI_MAP_RETAIN_KEY()
|
||||
* Macro to retain the key item in a map or hash table.
|
||||
*
|
||||
* FAST_MAP_RETAIN_VAL()
|
||||
* GSI_MAP_RETAIN_VAL()
|
||||
* Macro to retain the value item in a map table.
|
||||
*
|
||||
* FAST_MAP_RELEASE_KEY()
|
||||
* GSI_MAP_RELEASE_KEY()
|
||||
* Macro to release the key item in a map or hash table.
|
||||
*
|
||||
* FAST_MAP_RELEASE_VAL()
|
||||
* GSI_MAP_RELEASE_VAL()
|
||||
* Macro to release the value item in a map table.
|
||||
*
|
||||
* FAST_MAP_HASH()
|
||||
* GSI_MAP_HASH()
|
||||
* Macro to get the hash of a key item.
|
||||
*
|
||||
* FAST_MAP_EQUAL()
|
||||
* GSI_MAP_EQUAL()
|
||||
* Macro to compare two key items for equality - produces zero
|
||||
* if the items are not equal.
|
||||
*
|
||||
* FAST_MAP_EXTRA
|
||||
* GSI_MAP_EXTRA
|
||||
* If this value is defined, there is an 'extra' field in each
|
||||
* map table which is a pointer to void. This field can be used
|
||||
* to store additional information for the map.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FAST_MAP_HAS_VALUE
|
||||
#define FAST_MAP_HAS_VALUE 1
|
||||
#ifndef GSI_MAP_HAS_VALUE
|
||||
#define GSI_MAP_HAS_VALUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_RETAIN_KEY
|
||||
#define FAST_MAP_RETAIN_KEY(X) [(X).obj retain]
|
||||
#ifndef GSI_MAP_RETAIN_KEY
|
||||
#define GSI_MAP_RETAIN_KEY(X) [(X).obj retain]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_RELEASE_KEY
|
||||
#define FAST_MAP_RELEASE_KEY(X) [(X).obj release]
|
||||
#ifndef GSI_MAP_RELEASE_KEY
|
||||
#define GSI_MAP_RELEASE_KEY(X) [(X).obj release]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_RETAIN_VAL
|
||||
#define FAST_MAP_RETAIN_VAL(X) [(X).obj retain]
|
||||
#ifndef GSI_MAP_RETAIN_VAL
|
||||
#define GSI_MAP_RETAIN_VAL(X) [(X).obj retain]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_RELEASE_VAL
|
||||
#define FAST_MAP_RELEASE_VAL(X) [(X).obj release]
|
||||
#ifndef GSI_MAP_RELEASE_VAL
|
||||
#define GSI_MAP_RELEASE_VAL(X) [(X).obj release]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_HASH
|
||||
#define FAST_MAP_HASH(X) [(X).obj hash]
|
||||
#ifndef GSI_MAP_HASH
|
||||
#define GSI_MAP_HASH(X) [(X).obj hash]
|
||||
#endif
|
||||
|
||||
#ifndef FAST_MAP_EQUAL
|
||||
#define FAST_MAP_EQUAL(X,Y) [(X).obj isEqual: (Y).obj]
|
||||
#ifndef GSI_MAP_EQUAL
|
||||
#define GSI_MAP_EQUAL(X,Y) [(X).obj isEqual: (Y).obj]
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -107,8 +107,8 @@
|
|||
* If there is no bitmask defined to supply the types that
|
||||
* may be used as keys in the map, default to permitting all types.
|
||||
*/
|
||||
#ifndef FAST_MAP_KTYPES
|
||||
#define FAST_MAP_KTYPES GSUNION_ALL
|
||||
#ifndef GSI_MAP_KTYPES
|
||||
#define GSI_MAP_KTYPES GSUNION_ALL
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -117,7 +117,7 @@
|
|||
#ifdef GSUNION
|
||||
#undef GSUNION
|
||||
#endif
|
||||
#define GSUNION FastMapKey
|
||||
#define GSUNION GSIMapKey
|
||||
|
||||
/*
|
||||
* Set up the types that will be storable in the union.
|
||||
|
@ -126,12 +126,12 @@
|
|||
#ifdef GSUNION_TYPES
|
||||
#undef GSUNION_TYPES
|
||||
#endif
|
||||
#define GSUNION_TYPES FAST_MAP_KTYPES
|
||||
#define GSUNION_TYPES GSI_MAP_KTYPES
|
||||
#ifdef GSUNION_EXTRA
|
||||
#undef GSUNION_EXTRA
|
||||
#endif
|
||||
#ifdef FAST_MAP_KEXTRA
|
||||
#define GSUNION_EXTRA FAST_MAP_KEXTRA
|
||||
#ifdef GSI_MAP_KEXTRA
|
||||
#define GSUNION_EXTRA GSI_MAP_KEXTRA
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -143,8 +143,8 @@
|
|||
* If there is no bitmask defined to supply the types that
|
||||
* may be used as values in the map, default to permitting all types.
|
||||
*/
|
||||
#ifndef FAST_MAP_VTYPES
|
||||
#define FAST_MAP_VTYPES GSUNION_ALL
|
||||
#ifndef GSI_MAP_VTYPES
|
||||
#define GSI_MAP_VTYPES GSUNION_ALL
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -153,7 +153,7 @@
|
|||
#ifdef GSUNION
|
||||
#undef GSUNION
|
||||
#endif
|
||||
#define GSUNION FastMapVal
|
||||
#define GSUNION GSIMapVal
|
||||
|
||||
/*
|
||||
* Set up the types that will be storable in the union.
|
||||
|
@ -162,12 +162,12 @@
|
|||
#ifdef GSUNION_TYPES
|
||||
#undef GSUNION_TYPES
|
||||
#endif
|
||||
#define GSUNION_TYPES FAST_MAP_VTYPES
|
||||
#define GSUNION_TYPES GSI_MAP_VTYPES
|
||||
#ifdef GSUNION_EXTRA
|
||||
#undef GSUNION_EXTRA
|
||||
#endif
|
||||
#ifdef FAST_MAP_VEXTRA
|
||||
#define GSUNION_EXTRA FAST_MAP_VEXTRA
|
||||
#ifdef GSI_MAP_VEXTRA
|
||||
#define GSUNION_EXTRA GSI_MAP_VEXTRA
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -176,70 +176,70 @@
|
|||
#include <base/GSUnion.h>
|
||||
|
||||
|
||||
typedef struct _FastMapTable FastMapTable_t;
|
||||
typedef struct _FastMapBucket FastMapBucket_t;
|
||||
typedef struct _FastMapNode FastMapNode_t;
|
||||
typedef struct _FastMapEnumerator FastMapEnumerator_t;
|
||||
typedef struct _GSIMapTable GSIMapTable_t;
|
||||
typedef struct _GSIMapBucket GSIMapBucket_t;
|
||||
typedef struct _GSIMapNode GSIMapNode_t;
|
||||
typedef struct _GSIMapEnumerator GSIMapEnumerator_t;
|
||||
|
||||
typedef FastMapTable_t *FastMapTable;
|
||||
typedef FastMapBucket_t *FastMapBucket;
|
||||
typedef FastMapNode_t *FastMapNode;
|
||||
typedef FastMapEnumerator_t *FastMapEnumerator;
|
||||
typedef GSIMapTable_t *GSIMapTable;
|
||||
typedef GSIMapBucket_t *GSIMapBucket;
|
||||
typedef GSIMapNode_t *GSIMapNode;
|
||||
typedef GSIMapEnumerator_t *GSIMapEnumerator;
|
||||
|
||||
struct _FastMapNode {
|
||||
FastMapNode nextInBucket; /* Linked list of bucket. */
|
||||
FastMapNode nextInMap; /* For enumerating. */
|
||||
FastMapKey key;
|
||||
#if FAST_MAP_HAS_VALUE
|
||||
FastMapVal value;
|
||||
struct _GSIMapNode {
|
||||
GSIMapNode nextInBucket; /* Linked list of bucket. */
|
||||
GSIMapNode nextInMap; /* For enumerating. */
|
||||
GSIMapKey key;
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
GSIMapVal value;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _FastMapBucket {
|
||||
struct _GSIMapBucket {
|
||||
size_t nodeCount; /* Number of nodes in bucket. */
|
||||
FastMapNode firstNode; /* The linked list of nodes. */
|
||||
GSIMapNode firstNode; /* The linked list of nodes. */
|
||||
};
|
||||
|
||||
struct _FastMapTable {
|
||||
struct _GSIMapTable {
|
||||
NSZone *zone;
|
||||
size_t nodeCount; /* Number of nodes in map. */
|
||||
FastMapNode firstNode; /* List for enumerating. */
|
||||
GSIMapNode firstNode; /* List for enumerating. */
|
||||
size_t bucketCount; /* Number of buckets in map. */
|
||||
FastMapBucket buckets; /* Array of buckets. */
|
||||
FastMapNode freeNodes; /* List of unused nodes. */
|
||||
GSIMapBucket buckets; /* Array of buckets. */
|
||||
GSIMapNode freeNodes; /* List of unused nodes. */
|
||||
size_t chunkCount; /* Number of chunks in array. */
|
||||
FastMapNode *nodeChunks; /* Chunks of allocated memory. */
|
||||
#ifdef FAST_MAP_EXTRA
|
||||
GSIMapNode *nodeChunks; /* Chunks of allocated memory. */
|
||||
#ifdef GSI_MAP_EXTRA
|
||||
void *extra;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _FastMapEnumerator {
|
||||
FastMapTable map; /* the map being enumerated. */
|
||||
FastMapNode node; /* The next node to use. */
|
||||
struct _GSIMapEnumerator {
|
||||
GSIMapTable map; /* the map being enumerated. */
|
||||
GSIMapNode node; /* The next node to use. */
|
||||
};
|
||||
|
||||
static INLINE FastMapBucket
|
||||
FastMapPickBucket(FastMapKey key, FastMapBucket buckets, size_t bucketCount)
|
||||
static INLINE GSIMapBucket
|
||||
GSIMapPickBucket(GSIMapKey key, GSIMapBucket buckets, size_t bucketCount)
|
||||
{
|
||||
return buckets + FAST_MAP_HASH(key) % bucketCount;
|
||||
return buckets + GSI_MAP_HASH(key) % bucketCount;
|
||||
}
|
||||
|
||||
static INLINE FastMapBucket
|
||||
FastMapBucketForKey(FastMapTable map, FastMapKey key)
|
||||
static INLINE GSIMapBucket
|
||||
GSIMapBucketForKey(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
return FastMapPickBucket(key, map->buckets, map->bucketCount);
|
||||
return GSIMapPickBucket(key, map->buckets, map->bucketCount);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapLinkNodeIntoBucket(FastMapBucket bucket, FastMapNode node)
|
||||
GSIMapLinkNodeIntoBucket(GSIMapBucket bucket, GSIMapNode node)
|
||||
{
|
||||
node->nextInBucket = bucket->firstNode;
|
||||
bucket->firstNode = node;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapUnlinkNodeFromBucket(FastMapBucket bucket, FastMapNode node)
|
||||
GSIMapUnlinkNodeFromBucket(GSIMapBucket bucket, GSIMapNode node)
|
||||
{
|
||||
if (node == bucket->firstNode)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ FastMapUnlinkNodeFromBucket(FastMapBucket bucket, FastMapNode node)
|
|||
}
|
||||
else
|
||||
{
|
||||
FastMapNode tmp = bucket->firstNode;
|
||||
GSIMapNode tmp = bucket->firstNode;
|
||||
|
||||
while (tmp->nextInBucket != node)
|
||||
{
|
||||
|
@ -259,14 +259,14 @@ FastMapUnlinkNodeFromBucket(FastMapBucket bucket, FastMapNode node)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapLinkNodeIntoMap(FastMapTable map, FastMapNode node)
|
||||
GSIMapLinkNodeIntoMap(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
node->nextInMap = map->firstNode;
|
||||
map->firstNode = node;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapUnlinkNodeFromMap(FastMapTable map, FastMapNode node)
|
||||
GSIMapUnlinkNodeFromMap(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
if (node == map->firstNode)
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ FastMapUnlinkNodeFromMap(FastMapTable map, FastMapNode node)
|
|||
}
|
||||
else
|
||||
{
|
||||
FastMapNode tmp = map->firstNode;
|
||||
GSIMapNode tmp = map->firstNode;
|
||||
|
||||
while (tmp->nextInMap != node)
|
||||
{
|
||||
|
@ -286,75 +286,75 @@ FastMapUnlinkNodeFromMap(FastMapTable map, FastMapNode node)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapAddNodeToBucket(FastMapBucket bucket, FastMapNode node)
|
||||
GSIMapAddNodeToBucket(GSIMapBucket bucket, GSIMapNode node)
|
||||
{
|
||||
FastMapLinkNodeIntoBucket(bucket, node);
|
||||
GSIMapLinkNodeIntoBucket(bucket, node);
|
||||
bucket->nodeCount += 1;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapAddNodeToMap(FastMapTable map, FastMapNode node)
|
||||
GSIMapAddNodeToMap(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
FastMapBucket bucket;
|
||||
GSIMapBucket bucket;
|
||||
|
||||
bucket = FastMapBucketForKey(map, node->key);
|
||||
FastMapAddNodeToBucket(bucket, node);
|
||||
FastMapLinkNodeIntoMap(map, node);
|
||||
bucket = GSIMapBucketForKey(map, node->key);
|
||||
GSIMapAddNodeToBucket(bucket, node);
|
||||
GSIMapLinkNodeIntoMap(map, node);
|
||||
map->nodeCount++;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapRemoveNodeFromBucket(FastMapBucket bucket, FastMapNode node)
|
||||
GSIMapRemoveNodeFromBucket(GSIMapBucket bucket, GSIMapNode node)
|
||||
{
|
||||
bucket->nodeCount--;
|
||||
FastMapUnlinkNodeFromBucket(bucket, node);
|
||||
GSIMapUnlinkNodeFromBucket(bucket, node);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapRemoveNodeFromMap(FastMapTable map, FastMapBucket bkt, FastMapNode node)
|
||||
GSIMapRemoveNodeFromMap(GSIMapTable map, GSIMapBucket bkt, GSIMapNode node)
|
||||
{
|
||||
map->nodeCount--;
|
||||
FastMapUnlinkNodeFromMap(map, node);
|
||||
FastMapRemoveNodeFromBucket(bkt, node);
|
||||
GSIMapUnlinkNodeFromMap(map, node);
|
||||
GSIMapRemoveNodeFromBucket(bkt, node);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapRemangleBuckets(FastMapTable map,
|
||||
FastMapBucket old_buckets,
|
||||
GSIMapRemangleBuckets(GSIMapTable map,
|
||||
GSIMapBucket old_buckets,
|
||||
size_t old_bucketCount,
|
||||
FastMapBucket new_buckets,
|
||||
GSIMapBucket new_buckets,
|
||||
size_t new_bucketCount)
|
||||
{
|
||||
while (old_bucketCount-- > 0)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
while ((node = old_buckets->firstNode) != 0)
|
||||
{
|
||||
FastMapBucket bkt;
|
||||
GSIMapBucket bkt;
|
||||
|
||||
FastMapRemoveNodeFromBucket(old_buckets, node);
|
||||
bkt = FastMapPickBucket(node->key, new_buckets, new_bucketCount);
|
||||
FastMapAddNodeToBucket(bkt, node);
|
||||
GSIMapRemoveNodeFromBucket(old_buckets, node);
|
||||
bkt = GSIMapPickBucket(node->key, new_buckets, new_bucketCount);
|
||||
GSIMapAddNodeToBucket(bkt, node);
|
||||
}
|
||||
old_buckets++;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapMoreNodes(FastMapTable map)
|
||||
GSIMapMoreNodes(GSIMapTable map)
|
||||
{
|
||||
FastMapNode *newArray;
|
||||
size_t arraySize = (map->chunkCount+1)*sizeof(FastMapNode);
|
||||
GSIMapNode *newArray;
|
||||
size_t arraySize = (map->chunkCount+1)*sizeof(GSIMapNode);
|
||||
|
||||
newArray = (FastMapNode*)NSZoneMalloc(map->zone, arraySize);
|
||||
newArray = (GSIMapNode*)NSZoneMalloc(map->zone, arraySize);
|
||||
if (newArray)
|
||||
{
|
||||
FastMapNode newNodes;
|
||||
GSIMapNode newNodes;
|
||||
size_t chunkCount;
|
||||
size_t chunkSize;
|
||||
|
||||
memcpy(newArray,map->nodeChunks,(map->chunkCount)*sizeof(FastMapNode));
|
||||
memcpy(newArray,map->nodeChunks,(map->chunkCount)*sizeof(GSIMapNode));
|
||||
if (map->nodeChunks != 0)
|
||||
{
|
||||
NSZoneFree(map->zone, map->nodeChunks);
|
||||
|
@ -369,17 +369,17 @@ FastMapMoreNodes(FastMapTable map)
|
|||
{
|
||||
chunkCount = ((map->nodeCount>>2)+1)<<1;
|
||||
}
|
||||
chunkSize = chunkCount * sizeof(FastMapNode_t);
|
||||
chunkSize = chunkCount * sizeof(GSIMapNode_t);
|
||||
#if GS_WITH_GC
|
||||
/*
|
||||
* If we use a nil zone, objects we point to are subject to GC
|
||||
*/
|
||||
if (map->zone == 0)
|
||||
newNodes = (FastMapNode*)GC_MALLOC_ATOMIC(chunkSize);
|
||||
newNodes = (GSIMapNode*)GC_MALLOC_ATOMIC(chunkSize);
|
||||
else
|
||||
newNodes = (FastMapNode*)GC_MALLOC(chunkSize);
|
||||
newNodes = (GSIMapNode*)GC_MALLOC(chunkSize);
|
||||
#else
|
||||
newNodes = (FastMapNode)NSZoneMalloc(map->zone, chunkSize);
|
||||
newNodes = (GSIMapNode)NSZoneMalloc(map->zone, chunkSize);
|
||||
#endif
|
||||
if (newNodes)
|
||||
{
|
||||
|
@ -394,15 +394,15 @@ FastMapMoreNodes(FastMapTable map)
|
|||
}
|
||||
}
|
||||
|
||||
#if FAST_MAP_HAS_VALUE
|
||||
static INLINE FastMapNode
|
||||
FastMapNewNode(FastMapTable map, FastMapKey key, FastMapVal value)
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
static INLINE GSIMapNode
|
||||
GSIMapNewNode(GSIMapTable map, GSIMapKey key, GSIMapVal value)
|
||||
{
|
||||
FastMapNode node = map->freeNodes;
|
||||
GSIMapNode node = map->freeNodes;
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
FastMapMoreNodes(map);
|
||||
GSIMapMoreNodes(map);
|
||||
node = map->freeNodes;
|
||||
if (node == 0)
|
||||
{
|
||||
|
@ -419,14 +419,14 @@ FastMapNewNode(FastMapTable map, FastMapKey key, FastMapVal value)
|
|||
return node;
|
||||
}
|
||||
#else
|
||||
static INLINE FastMapNode
|
||||
FastMapNewNode(FastMapTable map, FastMapKey key)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapNewNode(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
FastMapNode node = map->freeNodes;
|
||||
GSIMapNode node = map->freeNodes;
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
FastMapMoreNodes(map);
|
||||
GSIMapMoreNodes(map);
|
||||
node = map->freeNodes;
|
||||
if (node == 0)
|
||||
{
|
||||
|
@ -443,45 +443,45 @@ FastMapNewNode(FastMapTable map, FastMapKey key)
|
|||
#endif
|
||||
|
||||
static INLINE void
|
||||
FastMapFreeNode(FastMapTable map, FastMapNode node)
|
||||
GSIMapFreeNode(GSIMapTable map, GSIMapNode node)
|
||||
{
|
||||
FAST_MAP_RELEASE_KEY(node->key);
|
||||
#if FAST_MAP_HAS_VALUE
|
||||
FAST_MAP_RELEASE_VAL(node->value);
|
||||
GSI_MAP_RELEASE_KEY(node->key);
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
GSI_MAP_RELEASE_VAL(node->value);
|
||||
#endif
|
||||
node->nextInMap = map->freeNodes;
|
||||
map->freeNodes = node;
|
||||
}
|
||||
|
||||
static INLINE FastMapNode
|
||||
FastMapNodeForKeyInBucket(FastMapBucket bucket, FastMapKey key)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapNodeForKeyInBucket(GSIMapBucket bucket, GSIMapKey key)
|
||||
{
|
||||
FastMapNode node = bucket->firstNode;
|
||||
GSIMapNode node = bucket->firstNode;
|
||||
|
||||
while ((node != 0) && FAST_MAP_EQUAL(node->key, key) == NO)
|
||||
while ((node != 0) && GSI_MAP_EQUAL(node->key, key) == NO)
|
||||
{
|
||||
node = node->nextInBucket;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static INLINE FastMapNode
|
||||
FastMapNodeForKey(FastMapTable map, FastMapKey key)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapNodeForKey(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
FastMapBucket bucket;
|
||||
FastMapNode node;
|
||||
GSIMapBucket bucket;
|
||||
GSIMapNode node;
|
||||
|
||||
if (map->nodeCount == 0)
|
||||
return 0;
|
||||
bucket = FastMapBucketForKey(map, key);
|
||||
node = FastMapNodeForKeyInBucket(bucket, key);
|
||||
bucket = GSIMapBucketForKey(map, key);
|
||||
node = GSIMapNodeForKeyInBucket(bucket, key);
|
||||
return node;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapResize(FastMapTable map, size_t new_capacity)
|
||||
GSIMapResize(GSIMapTable map, size_t new_capacity)
|
||||
{
|
||||
FastMapBucket new_buckets;
|
||||
GSIMapBucket new_buckets;
|
||||
size_t size = 1;
|
||||
size_t old = 1;
|
||||
|
||||
|
@ -504,11 +504,11 @@ FastMapResize(FastMapTable map, size_t new_capacity)
|
|||
/*
|
||||
* Make a new set of buckets for this map
|
||||
*/
|
||||
new_buckets = (FastMapBucket)NSZoneCalloc(map->zone, size,
|
||||
sizeof(FastMapBucket_t));
|
||||
new_buckets = (GSIMapBucket)NSZoneCalloc(map->zone, size,
|
||||
sizeof(GSIMapBucket_t));
|
||||
if (new_buckets != 0)
|
||||
{
|
||||
FastMapRemangleBuckets(map,
|
||||
GSIMapRemangleBuckets(map,
|
||||
map->buckets,
|
||||
map->bucketCount,
|
||||
new_buckets,
|
||||
|
@ -524,7 +524,7 @@ FastMapResize(FastMapTable map, size_t new_capacity)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapRightSizeMap(FastMapTable map, size_t capacity)
|
||||
GSIMapRightSizeMap(GSIMapTable map, size_t capacity)
|
||||
{
|
||||
/* FIXME: Now, this is a guess, based solely on my intuition. If anyone
|
||||
* knows of a better ratio (or other test, for that matter) and can
|
||||
|
@ -533,7 +533,7 @@ FastMapRightSizeMap(FastMapTable map, size_t capacity)
|
|||
|
||||
if (3 * capacity >= 4 * map->bucketCount)
|
||||
{
|
||||
FastMapResize(map, (3 * capacity)/4 + 1);
|
||||
GSIMapResize(map, (3 * capacity)/4 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -556,7 +556,7 @@ FastMapRightSizeMap(FastMapTable map, size_t capacity)
|
|||
* this. */
|
||||
|
||||
/* IMPORTANT WARNING: Enumerators have yet another wonderous property.
|
||||
* Once a node has been returned by `FastMapEnumeratorNextNode()', it may be
|
||||
* Once a node has been returned by `GSIMapEnumeratorNextNode()', it may be
|
||||
* removed from the map without effecting the rest of the current
|
||||
* enumeration. */
|
||||
|
||||
|
@ -565,10 +565,10 @@ FastMapRightSizeMap(FastMapTable map, size_t capacity)
|
|||
* the behaviours outlined above. So be prepared for some serious
|
||||
* breakage when you go fudging around with these things. */
|
||||
|
||||
static INLINE FastMapEnumerator_t
|
||||
FastMapEnumeratorForMap(FastMapTable map)
|
||||
static INLINE GSIMapEnumerator_t
|
||||
GSIMapEnumeratorForMap(GSIMapTable map)
|
||||
{
|
||||
FastMapEnumerator_t enumerator;
|
||||
GSIMapEnumerator_t enumerator;
|
||||
|
||||
enumerator.map = map;
|
||||
enumerator.node = map->firstNode;
|
||||
|
@ -576,10 +576,10 @@ FastMapEnumeratorForMap(FastMapTable map)
|
|||
return enumerator;
|
||||
}
|
||||
|
||||
static INLINE FastMapNode
|
||||
FastMapEnumeratorNextNode(FastMapEnumerator enumerator)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapEnumeratorNextNode(GSIMapEnumerator enumerator)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
node = enumerator->node;
|
||||
|
||||
|
@ -590,102 +590,102 @@ FastMapEnumeratorNextNode(FastMapEnumerator enumerator)
|
|||
return node;
|
||||
}
|
||||
|
||||
#if FAST_MAP_HAS_VALUE
|
||||
static INLINE FastMapNode
|
||||
FastMapAddPairNoRetain(FastMapTable map, FastMapKey key, FastMapVal value)
|
||||
#if GSI_MAP_HAS_VALUE
|
||||
static INLINE GSIMapNode
|
||||
GSIMapAddPairNoRetain(GSIMapTable map, GSIMapKey key, GSIMapVal value)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
node = FastMapNewNode(map, key, value);
|
||||
node = GSIMapNewNode(map, key, value);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
FastMapRightSizeMap(map, map->nodeCount);
|
||||
FastMapAddNodeToMap(map, node);
|
||||
GSIMapRightSizeMap(map, map->nodeCount);
|
||||
GSIMapAddNodeToMap(map, node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static INLINE FastMapNode
|
||||
FastMapAddPair(FastMapTable map, FastMapKey key, FastMapVal value)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapAddPair(GSIMapTable map, GSIMapKey key, GSIMapVal value)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
FAST_MAP_RETAIN_KEY(key);
|
||||
FAST_MAP_RETAIN_VAL(value);
|
||||
node = FastMapNewNode(map, key, value);
|
||||
GSI_MAP_RETAIN_KEY(key);
|
||||
GSI_MAP_RETAIN_VAL(value);
|
||||
node = GSIMapNewNode(map, key, value);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
FastMapRightSizeMap(map, map->nodeCount);
|
||||
FastMapAddNodeToMap(map, node);
|
||||
GSIMapRightSizeMap(map, map->nodeCount);
|
||||
GSIMapAddNodeToMap(map, node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#else
|
||||
static INLINE FastMapNode
|
||||
FastMapAddKeyNoRetain(FastMapTable map, FastMapKey key)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapAddKeyNoRetain(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
node = FastMapNewNode(map, key);
|
||||
node = GSIMapNewNode(map, key);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
FastMapRightSizeMap(map, map->nodeCount);
|
||||
FastMapAddNodeToMap(map, node);
|
||||
GSIMapRightSizeMap(map, map->nodeCount);
|
||||
GSIMapAddNodeToMap(map, node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static INLINE FastMapNode
|
||||
FastMapAddKey(FastMapTable map, FastMapKey key)
|
||||
static INLINE GSIMapNode
|
||||
GSIMapAddKey(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
FastMapNode node;
|
||||
GSIMapNode node;
|
||||
|
||||
FAST_MAP_RETAIN_KEY(key);
|
||||
node = FastMapNewNode(map, key);
|
||||
GSI_MAP_RETAIN_KEY(key);
|
||||
node = GSIMapNewNode(map, key);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
FastMapRightSizeMap(map, map->nodeCount);
|
||||
FastMapAddNodeToMap(map, node);
|
||||
GSIMapRightSizeMap(map, map->nodeCount);
|
||||
GSIMapAddNodeToMap(map, node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
|
||||
static INLINE void
|
||||
FastMapRemoveKey(FastMapTable map, FastMapKey key)
|
||||
GSIMapRemoveKey(GSIMapTable map, GSIMapKey key)
|
||||
{
|
||||
FastMapBucket bucket = FastMapBucketForKey(map, key);
|
||||
GSIMapBucket bucket = GSIMapBucketForKey(map, key);
|
||||
|
||||
if (bucket != 0)
|
||||
{
|
||||
FastMapNode node = FastMapNodeForKeyInBucket(bucket, key);
|
||||
GSIMapNode node = GSIMapNodeForKeyInBucket(bucket, key);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
FastMapRemoveNodeFromMap(map, bucket, node);
|
||||
FastMapFreeNode(map, node);
|
||||
GSIMapRemoveNodeFromMap(map, bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapCleanMap(FastMapTable map)
|
||||
GSIMapCleanMap(GSIMapTable map)
|
||||
{
|
||||
FastMapBucket bucket = map->buckets;
|
||||
GSIMapBucket bucket = map->buckets;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < map->bucketCount; i++)
|
||||
{
|
||||
while (bucket->nodeCount != 0)
|
||||
{
|
||||
FastMapNode node = bucket->firstNode;
|
||||
GSIMapNode node = bucket->firstNode;
|
||||
|
||||
FastMapRemoveNodeFromBucket(bucket, node);
|
||||
FastMapFreeNode(map, node);
|
||||
GSIMapRemoveNodeFromBucket(bucket, node);
|
||||
GSIMapFreeNode(map, node);
|
||||
}
|
||||
bucket++;
|
||||
}
|
||||
|
@ -694,11 +694,11 @@ FastMapCleanMap(FastMapTable map)
|
|||
}
|
||||
|
||||
static INLINE void
|
||||
FastMapEmptyMap(FastMapTable map)
|
||||
GSIMapEmptyMap(GSIMapTable map)
|
||||
{
|
||||
int i;
|
||||
|
||||
FastMapCleanMap(map);
|
||||
GSIMapCleanMap(map);
|
||||
if (map->buckets != 0)
|
||||
{
|
||||
NSZoneFree(map->zone, map->buckets);
|
||||
|
@ -723,8 +723,8 @@ FastMapEmptyMap(FastMapTable map)
|
|||
map->zone = 0;
|
||||
}
|
||||
|
||||
static INLINE FastMapTable
|
||||
FastMapInitWithZoneAndCapacity(FastMapTable map, NSZone *zone, size_t capacity)
|
||||
static INLINE GSIMapTable
|
||||
GSIMapInitWithZoneAndCapacity(GSIMapTable map, NSZone *zone, size_t capacity)
|
||||
{
|
||||
map->zone = zone;
|
||||
map->nodeCount = 0;
|
||||
|
@ -734,12 +734,12 @@ FastMapInitWithZoneAndCapacity(FastMapTable map, NSZone *zone, size_t capacity)
|
|||
map->nodeChunks = 0;
|
||||
map->freeNodes = 0;
|
||||
map->chunkCount = 0;
|
||||
FastMapRightSizeMap(map, capacity);
|
||||
FastMapMoreNodes(map);
|
||||
GSIMapRightSizeMap(map, capacity);
|
||||
GSIMapMoreNodes(map);
|
||||
}
|
||||
|
||||
#ifdef FAST_MAP_BLOCKED_ASSERTIONS
|
||||
#ifdef GSI_MAP_BLOCKED_ASSERTIONS
|
||||
#undef NS_BLOCK_ASSERTIONS
|
||||
#undef FAST_MAP_BLOCKED_ASSERTIONS
|
||||
#undef GSI_MAP_BLOCKED_ASSERTIONS
|
||||
#endif
|
||||
|
|
@ -38,16 +38,16 @@
|
|||
IMP eObjImp; /* Method to encode an id. */
|
||||
IMP eValImp; /* Method to encode others. */
|
||||
#ifndef _IN_NSARCHIVER_M
|
||||
#define FastMapTable void*
|
||||
#define GSIMapTable void*
|
||||
#endif
|
||||
FastMapTable clsMap; /* Class cross references. */
|
||||
FastMapTable cIdMap; /* Conditionally coded. */
|
||||
FastMapTable uIdMap; /* Unconditionally coded. */
|
||||
FastMapTable ptrMap; /* Constant pointers. */
|
||||
FastMapTable namMap; /* Mappings for class names. */
|
||||
FastMapTable repMap; /* Mappings for objects. */
|
||||
GSIMapTable clsMap; /* Class cross references. */
|
||||
GSIMapTable cIdMap; /* Conditionally coded. */
|
||||
GSIMapTable uIdMap; /* Unconditionally coded. */
|
||||
GSIMapTable ptrMap; /* Constant pointers. */
|
||||
GSIMapTable namMap; /* Mappings for class names. */
|
||||
GSIMapTable repMap; /* Mappings for objects. */
|
||||
#ifndef _IN_NSARCHIVER_M
|
||||
#undef FastMapTable
|
||||
#undef GSIMapTable
|
||||
#endif
|
||||
unsigned xRefC; /* Counter for cross-reference. */
|
||||
unsigned xRefO; /* Counter for cross-reference. */
|
||||
|
@ -159,11 +159,11 @@
|
|||
void (*tagImp)(id, SEL, unsigned char*, unsigned*,unsigned*);
|
||||
IMP dValImp; /* Method to decode data with. */
|
||||
#ifndef _IN_NSUNARCHIVER_M
|
||||
#define FastArray void*
|
||||
#define GSIArray void*
|
||||
#endif
|
||||
FastArray clsMap; /* Class crossreference map. */
|
||||
FastArray objMap; /* Object crossreference map. */
|
||||
FastArray ptrMap; /* Pointer crossreference map. */
|
||||
GSIArray clsMap; /* Class crossreference map. */
|
||||
GSIArray objMap; /* Object crossreference map. */
|
||||
GSIArray ptrMap; /* Pointer crossreference map. */
|
||||
#ifndef _IN_NSUNARCHIVER_M
|
||||
#undef GSUnarchiverArray
|
||||
#endif
|
||||
|
|
|
@ -147,4 +147,16 @@ NSStringFromRange(NSRange range);
|
|||
#undef MIN
|
||||
#endif
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
/*
|
||||
* To be used inside a method for making sure that a range does not specify
|
||||
* anything outsize the size of an array/string.
|
||||
*/
|
||||
#define GS_RANGE_CHECK(RANGE, SIZE) \
|
||||
if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
|
||||
[NSException raise: NSRangeException \
|
||||
format: @"in %s, range { %u, %u } extends beyond size (%u)", \
|
||||
sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
|
||||
#endif
|
||||
|
||||
#endif /* __NSRange_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue