mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
|
@ -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…
Add table
Add a link
Reference in a new issue