mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
compatibility, documentation, and optimisation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15420 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3e6dd244a0
commit
35d91cf9d5
9 changed files with 385 additions and 427 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2002-12-31 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSEQ.h: Optimisations for normalising sequences, especially
|
||||
where they contain latin1 characters.
|
||||
* Source/Additions/GCDictionary.m: Update map tables for macosx
|
||||
* Source/NSMapTable.m: Update for macosx compatibility, add some
|
||||
documentation and move stuff from externs.m
|
||||
* Source/NSHashTable.m: Update for macosx compatibility, add some
|
||||
documentation and move stuff from externs.m
|
||||
* Source/externs.m: Remove map and hash table stuff
|
||||
* Headers/gnustep/base/NSMapTable.h: Update for macosx compatibility.
|
||||
* Headers/gnustep/base/NSHashTable.h: Ditto
|
||||
|
||||
2002-12-30 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* SSL/GNUmakefile: Don't compile if base=no
|
||||
|
|
|
@ -41,8 +41,9 @@
|
|||
typedef void* NSHashTable;
|
||||
|
||||
/**
|
||||
* Type for enumerating.
|
||||
* NB. layout *must* correspond to that used by the GSIMap code.
|
||||
* Type for enumerating.<br />
|
||||
* NB. Implementation detail ... in GNUstep the layout <strong>must</strong>
|
||||
* correspond to that used by the GSIMap macros.
|
||||
*/
|
||||
typedef struct { void *map; void *node; size_t bucket; } NSHashEnumerator;
|
||||
|
||||
|
@ -62,143 +63,70 @@ typedef struct _NSHashTableCallBacks
|
|||
|
||||
/** release() ... Releasing function called when a data element is
|
||||
* removed from the table. <br />*/
|
||||
void (*release)(NSHashTable *, const void *);
|
||||
void (*release)(NSHashTable *, void *);
|
||||
|
||||
/** describe() ... Description function. <br />*/
|
||||
NSString *(*describe)(NSHashTable *, const void *);
|
||||
} NSHashTableCallBacks;
|
||||
|
||||
/* For sets of pointer-sized or smaller quantities. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSIntHashCallBacks;
|
||||
|
||||
/* For sets of pointers hashed by address. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks;
|
||||
|
||||
/* For sets of objects without retaining and releasing. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks;
|
||||
|
||||
/* For sets of objects; similar to NSSet. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSObjectHashCallBacks;
|
||||
|
||||
/* For sets of pointers with transfer of ownership upon insertion. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSOwnedPointerHashCallBacks;
|
||||
|
||||
/* For sets of pointers to structs when the first field of the
|
||||
* struct is the size of an int. */
|
||||
GS_EXPORT const NSHashTableCallBacks NSPointerToStructHashCallBacks;
|
||||
|
||||
/** Creating an NSHashTable... **/
|
||||
|
||||
/* Returns a (pointer to) an NSHashTable space for which is allocated
|
||||
* in the default zone. If CAPACITY is small or 0, then the returned
|
||||
* table has a reasonable (but still small) capacity. */
|
||||
GS_EXPORT NSHashTable *
|
||||
NSCreateHashTable(NSHashTableCallBacks callBacks,
|
||||
unsigned int capacity);
|
||||
|
||||
/* Just like 'NSCreateHashTable()', but the returned hash table is created
|
||||
* in the memory zone ZONE, rather than in the default zone. (Of course,
|
||||
* if you send 0 for ZONE, then the hash table will be created in the
|
||||
* default zone.) */
|
||||
GS_EXPORT NSHashTable *
|
||||
NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
|
||||
unsigned int capacity,
|
||||
NSZone *zone);
|
||||
|
||||
/* Returns a hash table, space for which is allocated in ZONE, which
|
||||
* has (newly retained) copies of TABLE's keys and values. As always,
|
||||
* if ZONE is 0, then the returned hash table is allocated in the
|
||||
* default zone. */
|
||||
GS_EXPORT NSHashTable *
|
||||
NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone);
|
||||
|
||||
/** Freeing an NSHashTable... **/
|
||||
|
||||
/* Releases all the keys and values of TABLE (using the callbacks
|
||||
* specified at the time of TABLE's creation), and then proceeds
|
||||
* to deallocate the space allocated for TABLE itself. */
|
||||
GS_EXPORT void
|
||||
NSFreeHashTable(NSHashTable *table);
|
||||
|
||||
/* Releases every element of TABLE, while preserving
|
||||
* TABLE's "capacity". */
|
||||
GS_EXPORT void
|
||||
NSResetHashTable(NSHashTable *table);
|
||||
|
||||
/** Comparing two NSHashTables... **/
|
||||
|
||||
/* Returns 'YES' if and only if every element of TABLE1 is an element
|
||||
* of TABLE2, and vice versa. */
|
||||
GS_EXPORT BOOL
|
||||
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
|
||||
|
||||
/** Getting the number of items in an NSHashTable... **/
|
||||
|
||||
/* Returns the total number of elements in TABLE. */
|
||||
GS_EXPORT unsigned int
|
||||
NSCountHashTable(NSHashTable *table);
|
||||
|
||||
/** Retrieving items from an NSHashTable... **/
|
||||
|
||||
/* Returns the element of TABLE equal to POINTER, if POINTER is a
|
||||
* member of TABLE. If not, then 0 (the only completely
|
||||
* forbidden element) is returned. */
|
||||
GS_EXPORT void *
|
||||
NSHashGet(NSHashTable *table, const void *element);
|
||||
|
||||
/* Returns an NSArray which contains all of the elements of TABLE.
|
||||
* WARNING: Call this function only when the elements of TABLE
|
||||
* are objects. */
|
||||
GS_EXPORT NSArray *
|
||||
NSAllHashTableObjects(NSHashTable *table);
|
||||
|
||||
GS_EXPORT void
|
||||
NSEndHashTableEnumeration(NSHashEnumerator *enumerator);
|
||||
|
||||
/* Returns an NSHashEnumerator structure (a pointer to) which
|
||||
* can be passed repeatedly to the function 'NSNextHashEnumeratorItem()'
|
||||
* to enumerate the elements of TABLE. */
|
||||
GS_EXPORT NSHashEnumerator
|
||||
NSEnumerateHashTable(NSHashTable *table);
|
||||
|
||||
/* Return 0 if ENUMERATOR has completed its enumeration of
|
||||
* its hash table's elements. If not, then the next element is
|
||||
* returned. */
|
||||
GS_EXPORT void *
|
||||
NSNextHashEnumeratorItem(NSHashEnumerator *enumerator);
|
||||
|
||||
/** Adding an item to an NSHashTable... **/
|
||||
|
||||
/* Inserts the item POINTER into the hash table TABLE.
|
||||
* If POINTER is already an element of TABLE, then its previously
|
||||
* incarnation is released from TABLE, and POINTER is put in its place.
|
||||
* Raises an NSInvalidArgumentException if POINTER is 0. */
|
||||
GS_EXPORT void
|
||||
NSHashInsert(NSHashTable *table, const void *element);
|
||||
|
||||
/* Just like 'NSHashInsert()', with one exception: If POINTER is already
|
||||
* in TABLE, then an NSInvalidArgumentException is raised. */
|
||||
GS_EXPORT void
|
||||
NSHashInsertKnownAbsent(NSHashTable *table, const void *element);
|
||||
|
||||
/* If POINTER is already in TABLE, the pre-existing item is returned.
|
||||
* Otherwise, 0 is returned, and this is just like 'NSHashInsert()'. */
|
||||
GS_EXPORT void *
|
||||
NSHashInsertIfAbsent(NSHashTable *table, const void *element);
|
||||
|
||||
/** Removing an item from an NSHashTable... **/
|
||||
|
||||
/* Releases POINTER from TABLE. It is not
|
||||
* an error if POINTER is not already in TABLE. */
|
||||
GS_EXPORT void
|
||||
NSHashRemove(NSHashTable *table, const void *element);
|
||||
|
||||
/** Getting an NSString representation of an NSHashTable... **/
|
||||
|
||||
/* Returns an NSString which describes TABLE. The returned string
|
||||
* is produced by iterating over the elements of TABLE,
|
||||
* appending the string "X;\n", where X is the description of
|
||||
* the element (obtained from the callbacks, of course). */
|
||||
GS_EXPORT NSString *
|
||||
NSStringFromHashTable(NSHashTable *table);
|
||||
|
||||
|
|
|
@ -40,47 +40,83 @@
|
|||
typedef void *NSMapTable;
|
||||
|
||||
/**
|
||||
* Type for enumerating.
|
||||
* NB. layout *must* correspond to that used by the GSIMap code.
|
||||
* Type for enumerating.<br />
|
||||
* NB. Implementation detail ... in GNUstep the layout <strong>must</strong>
|
||||
* correspond to that used by the GSIMap macros.
|
||||
*/
|
||||
typedef struct { void *map; void *node; size_t bucket; } NSMapEnumerator;
|
||||
|
||||
/* Callback functions for a key. */
|
||||
/**
|
||||
* Callback functions for a key.
|
||||
*/
|
||||
typedef struct _NSMapTableKeyCallBacks
|
||||
{
|
||||
/* Hashing function. NOTE: Elements with equal values must
|
||||
* have equal hash function values. */
|
||||
/*
|
||||
* Hashing function. Must not modify the key.<br />
|
||||
* NOTE: Elements with equal values must
|
||||
* have equal hash function values.
|
||||
*/
|
||||
unsigned (*hash)(NSMapTable *, const void *);
|
||||
|
||||
/* Comparison function. */
|
||||
/**
|
||||
* Comparison function. Must not modify either key.
|
||||
*/
|
||||
BOOL (*isEqual)(NSMapTable *, const void *, const void *);
|
||||
|
||||
/* Retaining function called when adding elements to table. */
|
||||
/**
|
||||
* Retaining function called when adding elements to table.<br />
|
||||
* Notionally this must not modify the key (the key may not
|
||||
* actually have a retain count, or the retain count may be stored
|
||||
* externally to the key, but in practice this often actually
|
||||
* changes a counter within the key).
|
||||
*/
|
||||
void (*retain)(NSMapTable *, const void *);
|
||||
|
||||
/* Releasing function called when a data element is
|
||||
* removed from the table. */
|
||||
void (*release)(NSMapTable *, const void *);
|
||||
/**
|
||||
* Releasing function called when a data element is
|
||||
* removed from the table. This may decrease a retain count or may
|
||||
* actually destroy the key.
|
||||
*/
|
||||
void (*release)(NSMapTable *, void *);
|
||||
|
||||
/* Description function. */
|
||||
/**
|
||||
* Description function. Generates a string describing the key
|
||||
* and does not modify the key itsself.
|
||||
*/
|
||||
NSString *(*describe)(NSMapTable *, const void *);
|
||||
|
||||
/* Quantity that is not a key to the map table. */
|
||||
/**
|
||||
* Quantity that is not a key to the map table.
|
||||
*/
|
||||
const void *notAKeyMarker;
|
||||
} NSMapTableKeyCallBacks;
|
||||
|
||||
/* Callback functions for a value. */
|
||||
/**
|
||||
* Callback functions for a value.
|
||||
*/
|
||||
typedef struct _NSMapTableValueCallBacks NSMapTableValueCallBacks;
|
||||
struct _NSMapTableValueCallBacks
|
||||
{
|
||||
/* Retaining function called when adding elements to table. */
|
||||
/**
|
||||
* Retaining function called when adding elements to table.<br />
|
||||
* Notionally this must not modify the element (the element may not
|
||||
* actually have a retain count, or the retain count may be stored
|
||||
* externally to the element, but in practice this often actually
|
||||
* changes a counter within the element).
|
||||
*/
|
||||
void (*retain)(NSMapTable *, const void *);
|
||||
|
||||
/* Releasing function called when a data element is
|
||||
* removed from the table. */
|
||||
void (*release)(NSMapTable *, const void *);
|
||||
/**
|
||||
* Releasing function called when a data element is
|
||||
* removed from the table. This may decrease a retain count or may
|
||||
* actually destroy the element.
|
||||
*/
|
||||
void (*release)(NSMapTable *, void *);
|
||||
|
||||
/* Description function. */
|
||||
/**
|
||||
* Description function. Generates a string describing the element
|
||||
* and does not modify the element itsself.
|
||||
*/
|
||||
NSString *(*describe)(NSMapTable *, const void *);
|
||||
};
|
||||
|
||||
|
@ -88,176 +124,84 @@ struct _NSMapTableValueCallBacks
|
|||
#define NSNotAnIntMapKey ((const void *)0x80000000)
|
||||
#define NSNotAPointerMapKey ((const void *)0xffffffff)
|
||||
|
||||
/* For keys that are pointer-sized or smaller quantities. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSIntMapKeyCallBacks;
|
||||
|
||||
/* For keys that are pointers not freed. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks;
|
||||
|
||||
/* For keys that are pointers not freed, or 0. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks;
|
||||
|
||||
/* For sets of objects without retaining and releasing. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks;
|
||||
|
||||
/* For keys that are objects. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks;
|
||||
|
||||
/* For keys that are pointers with transfer of ownership upon insertion. */
|
||||
GS_EXPORT const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks;
|
||||
|
||||
/* For values that are pointer-sized quantities. */
|
||||
GS_EXPORT const NSMapTableValueCallBacks NSIntMapValueCallBacks;
|
||||
|
||||
/* For values that are pointers not freed. */
|
||||
GS_EXPORT const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks;
|
||||
|
||||
/* For sets of objects without retaining and releasing. */
|
||||
GS_EXPORT const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks;
|
||||
|
||||
/* For values that are objects. */
|
||||
GS_EXPORT const NSMapTableValueCallBacks NSObjectMapValueCallBacks;
|
||||
|
||||
/* For values that are pointers with transfer of ownership upon insertion. */
|
||||
GS_EXPORT const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks;
|
||||
|
||||
/** Creating an NSMapTable... **/
|
||||
|
||||
/* Returns a (pointer to) an NSMapTable space for which is allocated
|
||||
* in the default zone. If CAPACITY is small or 0, then the returned
|
||||
* table has a reasonable capacity. */
|
||||
GS_EXPORT NSMapTable *
|
||||
NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks,
|
||||
NSMapTableValueCallBacks valueCallBacks,
|
||||
unsigned int capacity);
|
||||
|
||||
/* Just like 'NSCreateMapTable()', but the returned map table is created
|
||||
* in the memory zone ZONE, rather than in the default zone. (Of course,
|
||||
* if you send 0 for ZONE, then the map table will be created in the
|
||||
* default zone.) */
|
||||
GS_EXPORT NSMapTable *
|
||||
NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
|
||||
NSMapTableValueCallBacks valueCallBacks,
|
||||
unsigned int capacity,
|
||||
NSZone *zone);
|
||||
|
||||
/* Returns a map table, space for which is allocated in ZONE, which
|
||||
* has (newly retained) copies of TABLE's keys and values. As always,
|
||||
* if ZONE is 0, then the returned map table is allocated in the
|
||||
* default zone. */
|
||||
GS_EXPORT NSMapTable *
|
||||
NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone);
|
||||
|
||||
/** Freeing an NSMapTable... **/
|
||||
|
||||
/* Releases all the keys and values of TABLE (using the key and
|
||||
* value callbacks specified at the time of TABLE's creation),
|
||||
* and then proceeds to deallocate the space allocated for TABLE itself. */
|
||||
GS_EXPORT void
|
||||
NSFreeMapTable(NSMapTable *table);
|
||||
|
||||
/* Releases every key and value of TABLE, while preserving
|
||||
* TABLE's "capacity". */
|
||||
GS_EXPORT void
|
||||
NSResetMapTable(NSMapTable *table);
|
||||
|
||||
/** Comparing two NSMapTables... **/
|
||||
|
||||
/* Returns 'YES' if and only if every key of TABLE1 is a key
|
||||
* of TABLE2, and vice versa. NOTE: This function only cares
|
||||
* about keys, never values. */
|
||||
GS_EXPORT BOOL
|
||||
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2);
|
||||
|
||||
/** Getting the number of items in an NSMapTable... **/
|
||||
|
||||
/* Returns the total number of key/value pairs in TABLE. */
|
||||
GS_EXPORT unsigned int
|
||||
NSCountMapTable(NSMapTable *table);
|
||||
|
||||
/** Retrieving items from an NSMapTable... **/
|
||||
|
||||
/* Returns 'YES' iff TABLE contains a key that is "equal" to KEY.
|
||||
* If so, then ORIGINALKEY is set to that key of TABLE, while
|
||||
* VALUE is set to the value to which it maps in TABLE. */
|
||||
GS_EXPORT BOOL
|
||||
NSMapMember(NSMapTable *table,
|
||||
const void *key,
|
||||
void **originalKey,
|
||||
void **value);
|
||||
|
||||
/* Returns the value to which TABLE maps KEY, if KEY is a
|
||||
* member of TABLE. If not, then 0 (the only completely
|
||||
* forbidden value) is returned. */
|
||||
GS_EXPORT void *
|
||||
NSMapGet(NSMapTable *table, const void *key);
|
||||
|
||||
GS_EXPORT void
|
||||
NSEndMapTableEnumeration(NSMapEnumerator *enumerator);
|
||||
|
||||
/* Returns an NSMapEnumerator structure (a pointer to) which
|
||||
* can be passed repeatedly to the function 'NSNextMapEnumeratorPair()'
|
||||
* to enumerate the key/value pairs of TABLE. */
|
||||
GS_EXPORT NSMapEnumerator
|
||||
NSEnumerateMapTable(NSMapTable *table);
|
||||
|
||||
/* Return 'NO' if ENUMERATOR has completed its enumeration of
|
||||
* its map table's key/value pairs. If not, then 'YES' is
|
||||
* returned and KEY and VALUE are set to the next key and
|
||||
* value (respectively) in ENUMERATOR's table. */
|
||||
GS_EXPORT BOOL
|
||||
NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
||||
void **key,
|
||||
void **value);
|
||||
|
||||
/* Returns an NSArray which contains all of the keys of TABLE.
|
||||
* WARNING: Call this function only when the keys of TABLE
|
||||
* are objects. */
|
||||
GS_EXPORT NSArray *
|
||||
NSAllMapTableKeys(NSMapTable *table);
|
||||
|
||||
/* Returns an NSArray which contains all of the values of TABLE.
|
||||
* WARNING: Call this function only when the values of TABLE
|
||||
* are objects. */
|
||||
GS_EXPORT NSArray *
|
||||
NSAllMapTableValues(NSMapTable *table);
|
||||
|
||||
/** Adding an item to an NSMapTable... **/
|
||||
|
||||
/* Inserts the association KEY -> VALUE into the map table TABLE.
|
||||
* If KEY is already a key of TABLE, then its previously associated
|
||||
* value is released from TABLE, and VALUE is put in its place.
|
||||
* Raises an NSInvalidArgumentException if KEY is the "not a key
|
||||
* marker" for TABLE (as specified in its key callbacks). */
|
||||
GS_EXPORT void
|
||||
NSMapInsert(NSMapTable *table, const void *key, const void *value);
|
||||
|
||||
/* If KEY is already in TABLE, the pre-existing key is returned.
|
||||
* Otherwise, 0 is returned, and this is just like 'NSMapInsert()'. */
|
||||
GS_EXPORT void *
|
||||
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value);
|
||||
|
||||
/* Just like 'NSMapInsert()', with one exception: If KEY is already
|
||||
* in TABLE, then an NSInvalidArgumentException is raised. */
|
||||
GS_EXPORT void
|
||||
NSMapInsertKnownAbsent(NSMapTable *table,
|
||||
const void *key,
|
||||
const void *value);
|
||||
|
||||
/** Removing an item from an NSMapTable... **/
|
||||
|
||||
/* Releases KEY (and its associated value) from TABLE. It is not
|
||||
* an error if KEY is not already in TABLE. */
|
||||
GS_EXPORT void
|
||||
NSMapRemove(NSMapTable *table, const void *key);
|
||||
|
||||
/** Getting an NSString representation of an NSMapTable **/
|
||||
|
||||
/* Returns an NSString which describes TABLE. The returned string
|
||||
* is produced by iterating over the key/value pairs of TABLE,
|
||||
* appending the string "X = Y;\n", where X is the description of
|
||||
* the key, and Y is the description of the value (each obtained
|
||||
* from the respective callbacks, of course). */
|
||||
GS_EXPORT NSString *NSStringFromMapTable (NSMapTable *table);
|
||||
|
||||
#endif /* __NSMapTable_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
|
@ -131,14 +131,14 @@ static const NSMapTableKeyCallBacks GCInfoMapKeyCallBacks = {
|
|||
(unsigned(*)(NSMapTable *, const void *))_GCHashObject,
|
||||
(BOOL(*)(NSMapTable *, const void *, const void *))_GCCompareObjects,
|
||||
(void (*)(NSMapTable *, const void *))_GCRetainObjects,
|
||||
(void (*)(NSMapTable *, const void *))_GCReleaseObjects,
|
||||
(void (*)(NSMapTable *, void *))_GCReleaseObjects,
|
||||
(NSString *(*)(NSMapTable *, const void *))_GCDescribeObjects,
|
||||
(const void *)NULL
|
||||
};
|
||||
|
||||
static const NSMapTableValueCallBacks GCInfoValueCallBacks = {
|
||||
(void (*)(NSMapTable *, const void *))_GCRetainObjects,
|
||||
(void (*)(NSMapTable *, const void *))_GCReleaseObjects,
|
||||
(void (*)(NSMapTable *, void *))_GCReleaseObjects,
|
||||
(NSString *(*)(NSMapTable *, const void *))_GCDescribeObjects
|
||||
};
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ GetDefEncoding()
|
|||
{
|
||||
count = 0;
|
||||
while (str_encoding_table[count].enc
|
||||
&& strcmp(str_encoding_table[count].ename, encoding))
|
||||
&& strcmp(str_encoding_table[count].ename, encoding))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
|
145
Source/GSeq.h
145
Source/GSeq.h
|
@ -32,8 +32,7 @@
|
|||
* The second part of the file contains inline function definitions that
|
||||
* are designed to be modified depending on the defined macros at the
|
||||
* point where they are included. This is meant to be included multiple
|
||||
* times so the same code can be used for NSString, NSGString, and
|
||||
* NSGCString objects.
|
||||
* times so the same code can be used for NSString, and subclasses.
|
||||
*/
|
||||
|
||||
#ifndef __GSeq_h_GNUSTEP_BASE_INCLUDE
|
||||
|
@ -73,86 +72,126 @@ typedef GSeqStruct *GSeq;
|
|||
GSeqStruct SEQ = { BUF, LEN, LEN * MAXDEC, 0 }
|
||||
|
||||
/*
|
||||
* A function to normalize a unicode character sequence.
|
||||
* A function to normalize a unicode character sequence ... produces a
|
||||
* sequence containing composed characters in a well defined order and
|
||||
* with a nul terminator as well as a character count.
|
||||
*/
|
||||
static inline void GSeq_normalize(GSeq seq)
|
||||
{
|
||||
unsigned count = seq->count;
|
||||
unichar *source = seq->chars;
|
||||
|
||||
if (count)
|
||||
{
|
||||
unichar *source = seq->chars;
|
||||
unichar target[count*MAXDEC+1];
|
||||
BOOL notdone = YES;
|
||||
unsigned base = 0;
|
||||
|
||||
while (notdone)
|
||||
/*
|
||||
* Pre-scan ... anything with a code under 0x00C0 is not a decomposable
|
||||
* character, so we don't need to expand it.
|
||||
* If there are no decomposable characters or composed sequences, the
|
||||
* sequence is already normalised and we don't need to make any changes.
|
||||
*/
|
||||
while (base < count)
|
||||
{
|
||||
unichar *spoint = source;
|
||||
unichar *tpoint = target;
|
||||
|
||||
source[count] = (unichar)(0);
|
||||
notdone = NO;
|
||||
do
|
||||
if (source[base] >= 0x00C0)
|
||||
{
|
||||
unichar *dpoint = uni_is_decomp(*spoint);
|
||||
break;
|
||||
}
|
||||
base++;
|
||||
}
|
||||
source[count] = (unichar)(0);
|
||||
if (base < count)
|
||||
{
|
||||
|
||||
if (!dpoint)
|
||||
/*
|
||||
* Now expand decomposable characters into the long format.
|
||||
* Use the 'base' value to avoid re-checking characters which have
|
||||
* already been expanded.
|
||||
*/
|
||||
while (base < count)
|
||||
{
|
||||
unichar *spoint = &source[base];
|
||||
unichar *tpoint = &target[base];
|
||||
unsigned newbase = 0;
|
||||
|
||||
do
|
||||
{
|
||||
*tpoint++ = *spoint;
|
||||
unichar *dpoint = uni_is_decomp(*spoint);
|
||||
|
||||
if (!dpoint)
|
||||
{
|
||||
*tpoint++ = *spoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*dpoint)
|
||||
{
|
||||
*tpoint++ = *dpoint++;
|
||||
}
|
||||
if (newbase <= 0)
|
||||
{
|
||||
newbase = (spoint - source) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (*spoint++);
|
||||
|
||||
count = tpoint - target;
|
||||
memcpy(&source[base], &target[base], 2*(count - base));
|
||||
source[count] = (unichar)(0);
|
||||
if (newbase > 0)
|
||||
{
|
||||
base = newbase;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*dpoint)
|
||||
{
|
||||
*tpoint++ = *dpoint++;
|
||||
}
|
||||
notdone = YES;
|
||||
base = count;
|
||||
}
|
||||
}
|
||||
while (*spoint++);
|
||||
seq->count = count;
|
||||
|
||||
count = tpoint - target;
|
||||
memcpy(source, target, 2*count);
|
||||
}
|
||||
|
||||
seq->count = count;
|
||||
if (count > 1)
|
||||
{
|
||||
notdone = YES;
|
||||
|
||||
while (notdone)
|
||||
/*
|
||||
* Now standardise ordering of all composed character sequences.
|
||||
*/
|
||||
if (count > 1)
|
||||
{
|
||||
unichar *first = seq->chars;
|
||||
unichar *second = first + 1;
|
||||
unsigned i;
|
||||
BOOL notdone = YES;
|
||||
|
||||
notdone = NO;
|
||||
for (i = 1; i < count; i++)
|
||||
while (notdone)
|
||||
{
|
||||
if (uni_cop(*second))
|
||||
unichar *first = seq->chars;
|
||||
unichar *second = first + 1;
|
||||
unsigned i;
|
||||
|
||||
notdone = NO;
|
||||
for (i = 1; i < count; i++)
|
||||
{
|
||||
if (uni_cop(*first) > uni_cop(*second))
|
||||
if (uni_cop(*second))
|
||||
{
|
||||
unichar tmp = *first;
|
||||
|
||||
*first = *second;
|
||||
*second = tmp;
|
||||
notdone = YES;
|
||||
}
|
||||
else if (uni_cop(*first) == uni_cop(*second))
|
||||
{
|
||||
if (*first > *second)
|
||||
if (uni_cop(*first) > uni_cop(*second))
|
||||
{
|
||||
unichar tmp = *first;
|
||||
unichar tmp = *first;
|
||||
|
||||
*first = *second;
|
||||
*second = tmp;
|
||||
notdone = YES;
|
||||
*first = *second;
|
||||
*second = tmp;
|
||||
notdone = YES;
|
||||
}
|
||||
else if (uni_cop(*first) == uni_cop(*second))
|
||||
{
|
||||
if (*first > *second)
|
||||
{
|
||||
unichar tmp = *first;
|
||||
|
||||
*first = *second;
|
||||
*second = tmp;
|
||||
notdone = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
first++;
|
||||
second++;
|
||||
}
|
||||
first++;
|
||||
second++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,9 @@ NSCountHashTable(NSHashTable *table)
|
|||
|
||||
/**
|
||||
* Create a new hash table by calling NSCreateHashTableWithZone() using
|
||||
* NSDefaultMallocZone().
|
||||
* NSDefaultMallocZone().<br />
|
||||
* If capacity is small or 0, then the returned
|
||||
* table has a reasonable (but still small) capacity.
|
||||
*/
|
||||
NSHashTable *
|
||||
NSCreateHashTable(
|
||||
|
@ -261,7 +263,9 @@ NSEnumerateHashTable(NSHashTable *table)
|
|||
}
|
||||
|
||||
/**
|
||||
* Destroy the hash table and relase its contents.
|
||||
* Releases all the keys and values of table (using the callbacks
|
||||
* specified at the time of table's creation), and then proceeds
|
||||
* to deallocate the space allocated for table itself.
|
||||
*/
|
||||
void
|
||||
NSFreeHashTable(NSHashTable *table)
|
||||
|
@ -449,7 +453,7 @@ NSNextHashEnumeratorItem(NSHashEnumerator *enumerator)
|
|||
}
|
||||
|
||||
/**
|
||||
* Empty the hash table, but preserve its capacity.
|
||||
* Empty the hash table (releasing all elements), but preserve its capacity.
|
||||
*/
|
||||
void
|
||||
NSResetHashTable(NSHashTable *table)
|
||||
|
@ -499,3 +503,73 @@ NSStringFromHashTable(NSHashTable *table)
|
|||
return string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* These are to increase readabilty locally. */
|
||||
typedef unsigned int (*NSHT_hash_func_t)(NSHashTable *, const void *);
|
||||
typedef BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *);
|
||||
typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *);
|
||||
typedef void (*NSHT_release_func_t)(NSHashTable *, void *);
|
||||
typedef NSString *(*NSHT_describe_func_t)(NSHashTable *, const void *);
|
||||
|
||||
/** For sets of pointer-sized or smaller quantities. */
|
||||
const NSHashTableCallBacks NSIntHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_int_hash,
|
||||
(NSHT_isEqual_func_t) _NS_int_is_equal,
|
||||
(NSHT_retain_func_t) _NS_int_retain,
|
||||
(NSHT_release_func_t) _NS_int_release,
|
||||
(NSHT_describe_func_t) _NS_int_describe
|
||||
};
|
||||
|
||||
/** For sets of pointers hashed by address. */
|
||||
const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSHT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSHT_describe_func_t) _NS_non_owned_void_p_describe
|
||||
};
|
||||
|
||||
/** For sets of objects without retaining and releasing. */
|
||||
const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_non_retained_id_hash,
|
||||
(NSHT_isEqual_func_t) _NS_non_retained_id_is_equal,
|
||||
(NSHT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSHT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSHT_describe_func_t) _NS_non_retained_id_describe
|
||||
};
|
||||
|
||||
/** For sets of objects; similar to [NSSet]. */
|
||||
const NSHashTableCallBacks NSObjectHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_id_hash,
|
||||
(NSHT_isEqual_func_t) _NS_id_is_equal,
|
||||
(NSHT_retain_func_t) _NS_id_retain,
|
||||
(NSHT_release_func_t) _NS_id_release,
|
||||
(NSHT_describe_func_t) _NS_id_describe
|
||||
};
|
||||
|
||||
/** For sets of pointers with transfer of ownership upon insertion. */
|
||||
const NSHashTableCallBacks NSOwnedPointerHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_owned_void_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_owned_void_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSHT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSHT_describe_func_t) _NS_owned_void_p_describe
|
||||
};
|
||||
|
||||
/** For sets of pointers to structs when the first field of the
|
||||
* struct is the size of an int. */
|
||||
const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_int_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_int_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_int_p_retain,
|
||||
(NSHT_release_func_t) _NS_int_p_release,
|
||||
(NSHT_describe_func_t) _NS_int_p_describe
|
||||
};
|
||||
|
||||
|
|
|
@ -188,7 +188,10 @@ NSCompareMapTables(NSMapTable *table1, NSMapTable *table2)
|
|||
}
|
||||
|
||||
/**
|
||||
* Copy the supplied map table creating the new table in the specified zone.
|
||||
* Copy the supplied map table.<br />
|
||||
* Returns a map table, space for which is allocated in zone, which
|
||||
* has (newly retained) copies of table's keys and values. As always,
|
||||
* if zone is 0, then NSDefaultMallocZone() is used.
|
||||
*/
|
||||
NSMapTable *
|
||||
NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
||||
|
@ -218,7 +221,7 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the number of keys in the table.
|
||||
* Returns the number of key/value pairs in the table.
|
||||
*/
|
||||
unsigned int
|
||||
NSCountMapTable(NSMapTable *table)
|
||||
|
@ -233,7 +236,10 @@ NSCountMapTable(NSMapTable *table)
|
|||
|
||||
/**
|
||||
* Create a new map table by calling NSCreateMapTableWithZone() using
|
||||
* NSDefaultMallocZone().
|
||||
* NSDefaultMallocZone().<br />
|
||||
* Returns a (pointer to) an NSMapTable space for which is allocated
|
||||
* in the default zone. If capacity is small or 0, then the returned
|
||||
* table has a reasonable capacity.
|
||||
*/
|
||||
NSMapTable *
|
||||
NSCreateMapTable(
|
||||
|
@ -248,9 +254,11 @@ NSCreateMapTable(
|
|||
/**
|
||||
* Create a new map table using the supplied callbacks structures.
|
||||
* If any functions in the callback structures are null the default
|
||||
* values are used ... as for non-owned pointers.
|
||||
* values are used ... as for non-owned pointers.<br />
|
||||
* Of course, if you send 0 for zone, then the map table will be
|
||||
* created in NSDefaultMallocZone().<br />
|
||||
* The table will be created with the specified capacity ... ie ready
|
||||
* to hold at lest that many items.
|
||||
* to hold at least that many items.
|
||||
*/
|
||||
NSMapTable *
|
||||
NSCreateMapTableWithZone(
|
||||
|
@ -320,7 +328,10 @@ NSEnumerateMapTable(NSMapTable *table)
|
|||
}
|
||||
|
||||
/**
|
||||
* Destroy the map table and relase its contents.
|
||||
* Destroy the map table and relase its contents.<br />
|
||||
* Releases all the keys and values of table (using the key and
|
||||
* value callbacks specified at the time of table's creation),
|
||||
* and then proceeds to deallocate the space allocated for table itself.
|
||||
*/
|
||||
void
|
||||
NSFreeMapTable(NSMapTable *table)
|
||||
|
@ -367,7 +378,7 @@ NSMapGet(NSMapTable *table, const void *key)
|
|||
* Adds the key and value to table.<br />
|
||||
* If an equal key is already in table, replaces its mapped value
|
||||
* with the new one, without changing the key itsself.<br />
|
||||
* If key is equal to the notAKeyMarker field of the tables
|
||||
* If key is equal to the notAKeyMarker field of the table's
|
||||
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
||||
*/
|
||||
void
|
||||
|
@ -405,7 +416,7 @@ NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
|||
* Adds the key and value to table and returns nul.<br />
|
||||
* If an equal key is already in table, returns the old key
|
||||
* instead of adding the new key-value pair.<br />
|
||||
* If key is equal to the notAKeyMarker field of the tables
|
||||
* If key is equal to the notAKeyMarker field of the table's
|
||||
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
||||
*/
|
||||
void *
|
||||
|
@ -439,7 +450,7 @@ NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
|||
/**
|
||||
* Adds the key and value to table and returns nul.<br />
|
||||
* If an equal key is already in table, raises an NSInvalidArgumentException.
|
||||
* <br />If key is equal to the notAKeyMarker field of the tables
|
||||
* <br />If key is equal to the notAKeyMarker field of the table's
|
||||
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
||||
*/
|
||||
void
|
||||
|
@ -507,7 +518,8 @@ NSMapMember(NSMapTable *table, const void *key,
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove the specified key from the table.
|
||||
* Remove the specified key from the table (if present).<br />
|
||||
* Causes the key and its associated value to be released.
|
||||
*/
|
||||
void
|
||||
NSMapRemove(NSMapTable *table, const void *key)
|
||||
|
@ -523,6 +535,8 @@ NSMapRemove(NSMapTable *table, const void *key)
|
|||
/**
|
||||
* Step through the map table ... return the next key-value pair and
|
||||
* return YES, or hit the end of the table and return NO.<br />
|
||||
* The enumerator parameter is a value supplied by NSEnumerateMapTable()
|
||||
* and must be destroyed using NSEndMapTableEnumeration().<br />
|
||||
* The GNUstep implementation permits either key or value to be a
|
||||
* null pointer, and refrains from attempting to return the appropriate
|
||||
* result in that case.
|
||||
|
@ -567,7 +581,8 @@ NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|||
}
|
||||
|
||||
/**
|
||||
* Empty the map table, but preserve its capacity.
|
||||
* Empty the map table (releasing every key and value),
|
||||
* but preserve its capacity.
|
||||
*/
|
||||
void
|
||||
NSResetMapTable(NSMapTable *table)
|
||||
|
@ -619,4 +634,120 @@ NSStringFromMapTable(NSMapTable *table)
|
|||
return string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* These are to increase readabilty locally. */
|
||||
typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *);
|
||||
typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *);
|
||||
typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *);
|
||||
typedef void (*NSMT_release_func_t)(NSMapTable *, void *);
|
||||
typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *);
|
||||
|
||||
|
||||
/** For keys that are pointer-sized or smaller quantities. */
|
||||
const NSMapTableKeyCallBacks NSIntMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_int_hash,
|
||||
(NSMT_is_equal_func_t) _NS_int_is_equal,
|
||||
(NSMT_retain_func_t) _NS_int_retain,
|
||||
(NSMT_release_func_t) _NS_int_release,
|
||||
(NSMT_describe_func_t) _NS_int_describe,
|
||||
NSNotAnIntMapKey
|
||||
};
|
||||
|
||||
/** For keys that are pointers not freed. */
|
||||
const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
/** For keys that are pointers not freed, or 0. */
|
||||
const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
/** For sets of objects without retaining and releasing. */
|
||||
const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_retained_id_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_retained_id_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSMT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSMT_describe_func_t) _NS_non_retained_id_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
/** For keys that are objects. */
|
||||
const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_id_hash,
|
||||
(NSMT_is_equal_func_t) _NS_id_is_equal,
|
||||
(NSMT_retain_func_t) _NS_id_retain,
|
||||
(NSMT_release_func_t) _NS_id_release,
|
||||
(NSMT_describe_func_t) _NS_id_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
/** For keys that are pointers with transfer of ownership upon insertion. */
|
||||
const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
/** For values that are pointer-sized integer quantities. */
|
||||
const NSMapTableValueCallBacks NSIntMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_int_retain,
|
||||
(NSMT_release_func_t) _NS_int_release,
|
||||
(NSMT_describe_func_t) _NS_int_describe
|
||||
};
|
||||
|
||||
/** For values that are pointers not freed. */
|
||||
const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe
|
||||
};
|
||||
|
||||
/** For sets of objects without retaining and releasing. */
|
||||
const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSMT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSMT_describe_func_t) _NS_non_retained_id_describe
|
||||
};
|
||||
|
||||
/** For values that are objects. */
|
||||
const NSMapTableValueCallBacks NSObjectMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_id_retain,
|
||||
(NSMT_release_func_t) _NS_id_release,
|
||||
(NSMT_describe_func_t) _NS_id_describe
|
||||
};
|
||||
|
||||
/** For values that are pointers with transfer of ownership upon insertion. */
|
||||
const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_owned_void_p_describe
|
||||
};
|
||||
|
||||
|
|
171
Source/externs.m
171
Source/externs.m
|
@ -27,9 +27,6 @@
|
|||
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
#include "NSCallBacks.h"
|
||||
#include <Foundation/NSHashTable.h>
|
||||
|
||||
/* Global lock to be used by classes when operating on any global
|
||||
data that invoke other methods which also access global; thus,
|
||||
|
@ -341,173 +338,5 @@ GSBuildStrings()
|
|||
|
||||
|
||||
|
||||
/* These are to increase readabilty locally. */
|
||||
typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *);
|
||||
typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *);
|
||||
typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *);
|
||||
typedef void (*NSMT_release_func_t)(NSMapTable *, const void *);
|
||||
typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *);
|
||||
|
||||
|
||||
/* Standard MapTable callbacks */
|
||||
const NSMapTableKeyCallBacks NSIntMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_int_hash,
|
||||
(NSMT_is_equal_func_t) _NS_int_is_equal,
|
||||
(NSMT_retain_func_t) _NS_int_retain,
|
||||
(NSMT_release_func_t) _NS_int_release,
|
||||
(NSMT_describe_func_t) _NS_int_describe,
|
||||
NSNotAnIntMapKey
|
||||
};
|
||||
|
||||
const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_non_retained_id_hash,
|
||||
(NSMT_is_equal_func_t) _NS_non_retained_id_is_equal,
|
||||
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSMT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSMT_describe_func_t) _NS_non_retained_id_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_id_hash,
|
||||
(NSMT_is_equal_func_t) _NS_id_is_equal,
|
||||
(NSMT_retain_func_t) _NS_id_retain,
|
||||
(NSMT_release_func_t) _NS_id_release,
|
||||
(NSMT_describe_func_t) _NS_id_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks =
|
||||
{
|
||||
(NSMT_hash_func_t) _NS_owned_void_p_hash,
|
||||
(NSMT_is_equal_func_t) _NS_owned_void_p_is_equal,
|
||||
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_owned_void_p_describe,
|
||||
NSNotAPointerMapKey
|
||||
};
|
||||
|
||||
const NSMapTableValueCallBacks NSIntMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_int_retain,
|
||||
(NSMT_release_func_t) _NS_int_release,
|
||||
(NSMT_describe_func_t) _NS_int_describe
|
||||
};
|
||||
|
||||
const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_non_owned_void_p_describe
|
||||
};
|
||||
|
||||
const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSMT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSMT_describe_func_t) _NS_non_retained_id_describe
|
||||
};
|
||||
|
||||
const NSMapTableValueCallBacks NSObjectMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_id_retain,
|
||||
(NSMT_release_func_t) _NS_id_release,
|
||||
(NSMT_describe_func_t) _NS_id_describe
|
||||
};
|
||||
|
||||
const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
||||
{
|
||||
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSMT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSMT_describe_func_t) _NS_owned_void_p_describe
|
||||
};
|
||||
|
||||
/* These are to increase readabilty locally. */
|
||||
typedef unsigned int (*NSHT_hash_func_t)(NSHashTable *, const void *);
|
||||
typedef BOOL (*NSHT_isEqual_func_t)(NSHashTable *, const void *, const void *);
|
||||
typedef void (*NSHT_retain_func_t)(NSHashTable *, const void *);
|
||||
typedef void (*NSHT_release_func_t)(NSHashTable *, const void *);
|
||||
typedef NSString *(*NSHT_describe_func_t)(NSHashTable *, const void *);
|
||||
|
||||
/**** Function Prototypes ****************************************************/
|
||||
/** Standard NSHashTable callbacks... **/
|
||||
|
||||
const NSHashTableCallBacks NSIntHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_int_hash,
|
||||
(NSHT_isEqual_func_t) _NS_int_is_equal,
|
||||
(NSHT_retain_func_t) _NS_int_retain,
|
||||
(NSHT_release_func_t) _NS_int_release,
|
||||
(NSHT_describe_func_t) _NS_int_describe
|
||||
};
|
||||
|
||||
const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_non_owned_void_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_non_owned_void_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_non_owned_void_p_retain,
|
||||
(NSHT_release_func_t) _NS_non_owned_void_p_release,
|
||||
(NSHT_describe_func_t) _NS_non_owned_void_p_describe
|
||||
};
|
||||
|
||||
const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_non_retained_id_hash,
|
||||
(NSHT_isEqual_func_t) _NS_non_retained_id_is_equal,
|
||||
(NSHT_retain_func_t) _NS_non_retained_id_retain,
|
||||
(NSHT_release_func_t) _NS_non_retained_id_release,
|
||||
(NSHT_describe_func_t) _NS_non_retained_id_describe
|
||||
};
|
||||
|
||||
const NSHashTableCallBacks NSObjectHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_id_hash,
|
||||
(NSHT_isEqual_func_t) _NS_id_is_equal,
|
||||
(NSHT_retain_func_t) _NS_id_retain,
|
||||
(NSHT_release_func_t) _NS_id_release,
|
||||
(NSHT_describe_func_t) _NS_id_describe
|
||||
};
|
||||
|
||||
const NSHashTableCallBacks NSOwnedPointerHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_owned_void_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_owned_void_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_owned_void_p_retain,
|
||||
(NSHT_release_func_t) _NS_owned_void_p_release,
|
||||
(NSHT_describe_func_t) _NS_owned_void_p_describe
|
||||
};
|
||||
|
||||
const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
||||
{
|
||||
(NSHT_hash_func_t) _NS_int_p_hash,
|
||||
(NSHT_isEqual_func_t) _NS_int_p_is_equal,
|
||||
(NSHT_retain_func_t) _NS_int_p_retain,
|
||||
(NSHT_release_func_t) _NS_int_p_release,
|
||||
(NSHT_describe_func_t) _NS_int_p_describe
|
||||
};
|
||||
|
||||
/* For bug in gcc 3.1. See NSByteOrder.h */
|
||||
void _gcc3_1_hack(void){}
|
||||
|
|
Loading…
Reference in a new issue