mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Rename all objects_* to o_*.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1445 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e819b08f9c
commit
2361a6f94f
46 changed files with 3626 additions and 3626 deletions
|
@ -49,7 +49,7 @@ grow_released_arrays()
|
|||
}
|
||||
|
||||
void
|
||||
objc_release_stack_objects_to_frame_address(void *frame_address)
|
||||
objc_release_stack_o_to_frame_address(void *frame_address)
|
||||
{
|
||||
assert(released_objects);
|
||||
/* xxx This assumes stack grows up */
|
||||
|
@ -66,7 +66,7 @@ void
|
|||
objc_release_stack_objects()
|
||||
{
|
||||
assert(released_objects);
|
||||
objc_release_stack_objects_to_frame_address(__builtin_frame_address(1));
|
||||
objc_release_stack_o_to_frame_address(__builtin_frame_address(1));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -94,7 +94,7 @@ objc_stack_release_object(id anObj)
|
|||
s = __builtin_frame_address(3);
|
||||
|
||||
/* Do the pending releases of other objects */
|
||||
objc_release_stack_objects_to_frame_address(s);
|
||||
objc_release_stack_o_to_frame_address(s);
|
||||
|
||||
/* Queue this object for later release */
|
||||
objc_stack_release_object_with_address(anObj, s);
|
||||
|
|
|
@ -211,8 +211,8 @@
|
|||
{
|
||||
#if 0
|
||||
if (!fref_stack)
|
||||
fref_stack = objects_list_of_void_p ();
|
||||
objects_list_append_element (fref_stack, NSCreateMap (...));
|
||||
fref_stack = o_list_of_void_p ();
|
||||
o_list_append_element (fref_stack, NSCreateMap (...));
|
||||
#endif
|
||||
if (!address_2_fref)
|
||||
address_2_fref = NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
|
||||
|
|
|
@ -56,7 +56,7 @@ enum {
|
|||
#define DEFAULT_MEMORY_STREAM_SIZE 64
|
||||
|
||||
extern int
|
||||
objects_vscanf (void *stream,
|
||||
o_vscanf (void *stream,
|
||||
int (*inchar_func)(void*),
|
||||
void (*unchar_func)(void*,int),
|
||||
const char *format, va_list argptr);
|
||||
|
@ -238,7 +238,7 @@ void unchar_func(void *s, int c)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
ret = objects_vscanf(self, inchar_func, unchar_func,
|
||||
ret = o_vscanf(self, inchar_func, unchar_func,
|
||||
[format cStringNoCopy], ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
|
|
|
@ -100,7 +100,7 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
/** Macros... **/
|
||||
|
||||
#define NSHT_CALLBACKS(T) \
|
||||
(*((NSHashTableCallBacks *)(objects_hash_extra((objects_hash_t *)(T)))))
|
||||
(*((NSHashTableCallBacks *)(o_hash_extra((o_hash_t *)(T)))))
|
||||
|
||||
#define NSHT_DESCRIBE(T, P) \
|
||||
(NSHT_CALLBACKS((T))).describe((T), (P))
|
||||
|
@ -148,14 +148,14 @@ _NSHT_describe(const void *element, const void *table)
|
|||
}
|
||||
|
||||
/* These are wrappers for getting at the real callbacks. */
|
||||
objects_callbacks_t _NSHT_callbacks =
|
||||
o_callbacks_t _NSHT_callbacks =
|
||||
{
|
||||
(objects_hash_func_t) _NSHT_hash,
|
||||
(objects_compare_func_t) _NSHT_compare,
|
||||
(objects_is_equal_func_t) _NSHT_is_equal,
|
||||
(objects_retain_func_t) _NSHT_retain,
|
||||
(objects_release_func_t) _NSHT_release,
|
||||
(objects_describe_func_t) _NSHT_describe,
|
||||
(o_hash_func_t) _NSHT_hash,
|
||||
(o_compare_func_t) _NSHT_compare,
|
||||
(o_is_equal_func_t) _NSHT_is_equal,
|
||||
(o_retain_func_t) _NSHT_retain,
|
||||
(o_release_func_t) _NSHT_release,
|
||||
(o_describe_func_t) _NSHT_describe,
|
||||
0 /* Note that OpenStep decrees that '0' is the (only) forbidden value. */
|
||||
};
|
||||
|
||||
|
@ -169,7 +169,7 @@ _NSHT_extra_retain (const NSHashTableCallBacks *callBacks, NSHashTable *table)
|
|||
NSHashTableCallBacks *newCallBacks;
|
||||
|
||||
/* Set aside space for our new callbacks in the right zone. */
|
||||
newCallBacks = (NSHashTableCallBacks *)NSZoneMalloc(objects_hash_zone(table),
|
||||
newCallBacks = (NSHashTableCallBacks *)NSZoneMalloc(o_hash_zone(table),
|
||||
sizeof(NSHashTableCallBacks));
|
||||
|
||||
/* FIXME: Check for an invalid pointer? */
|
||||
|
@ -185,7 +185,7 @@ void
|
|||
_NSHT_extra_release(NSHashTableCallBacks *callBacks, NSHashTable *table)
|
||||
{
|
||||
if (callBacks != 0)
|
||||
NSZoneFree(objects_hash_zone(table), callBacks);
|
||||
NSZoneFree(o_hash_zone(table), callBacks);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -200,14 +200,14 @@ _NSHT_extra_describe(NSHashTableCallBacks *callBacks, NSHashTable *table)
|
|||
/* The idea here is that these callbacks ensure that the
|
||||
* NSHashTableCallbacks which are associated with a given NSHashTable
|
||||
* remain so associated throughout the life of the table and its copies. */
|
||||
objects_callbacks_t _NSHT_extra_callbacks =
|
||||
o_callbacks_t _NSHT_extra_callbacks =
|
||||
{
|
||||
(objects_hash_func_t) objects_non_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_non_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_non_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) _NSHT_extra_retain,
|
||||
(objects_release_func_t) _NSHT_extra_release,
|
||||
(objects_describe_func_t) _NSHT_extra_describe,
|
||||
(o_hash_func_t) o_non_owned_void_p_hash,
|
||||
(o_compare_func_t) o_non_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_non_owned_void_p_is_equal,
|
||||
(o_retain_func_t) _NSHT_extra_retain,
|
||||
(o_release_func_t) _NSHT_extra_release,
|
||||
(o_describe_func_t) _NSHT_extra_describe,
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -224,17 +224,17 @@ NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
|
|||
|
||||
/* Build the core table. See the above for the definitions of
|
||||
* the funny callbacks. */
|
||||
table = objects_hash_with_zone_with_callbacks(zone, _NSHT_callbacks);
|
||||
table = o_hash_with_zone_with_callbacks(zone, _NSHT_callbacks);
|
||||
|
||||
/* Check to make sure our allocation has succeeded. */
|
||||
if (table != 0)
|
||||
{
|
||||
/* Resize TABLE to CAPACITY. */
|
||||
objects_hash_resize(table, capacity);
|
||||
o_hash_resize(table, capacity);
|
||||
|
||||
/* Add CALLBACKS to TABLE. This takes care of everything for us. */
|
||||
objects_hash_set_extra_callbacks(table, _NSHT_extra_callbacks);
|
||||
objects_hash_set_extra(table, &callBacks);
|
||||
o_hash_set_extra_callbacks(table, _NSHT_extra_callbacks);
|
||||
o_hash_set_extra(table, &callBacks);
|
||||
}
|
||||
|
||||
/* Yah-hoo, kid! */
|
||||
|
@ -255,7 +255,7 @@ NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone)
|
|||
{
|
||||
/* Due to the wonders of modern structure technology,
|
||||
* everything we care about is automagically and safely destroyed. */
|
||||
return objects_hash_copy_with_zone(table, zone);
|
||||
return o_hash_copy_with_zone(table, zone);
|
||||
}
|
||||
|
||||
/** Destroying **/
|
||||
|
@ -265,7 +265,7 @@ NSFreeHashTable(NSHashTable *table)
|
|||
{
|
||||
/* Due to the wonders of modern technology,
|
||||
* everything we care about is automagically and safely destroyed. */
|
||||
objects_hash_dealloc(table);
|
||||
o_hash_dealloc(table);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ NSFreeHashTable(NSHashTable *table)
|
|||
void
|
||||
NSResetHashTable(NSHashTable *table)
|
||||
{
|
||||
objects_hash_empty(table);
|
||||
o_hash_empty(table);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ NSResetHashTable(NSHashTable *table)
|
|||
BOOL
|
||||
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2)
|
||||
{
|
||||
return (objects_hash_is_equal_to_hash(table1, table2) ? YES : NO);
|
||||
return (o_hash_is_equal_to_hash(table1, table2) ? YES : NO);
|
||||
}
|
||||
|
||||
/** Counting **/
|
||||
|
@ -291,7 +291,7 @@ NSCompareHashTables(NSHashTable *table1, NSHashTable *table2)
|
|||
unsigned int
|
||||
NSCountHashTable(NSHashTable *table)
|
||||
{
|
||||
return (unsigned int) objects_hash_count(table);
|
||||
return (unsigned int) o_hash_count(table);
|
||||
}
|
||||
|
||||
/** Retrieving **/
|
||||
|
@ -300,7 +300,7 @@ void *
|
|||
NSHashGet(NSHashTable *table, const void *pointer)
|
||||
{
|
||||
/* Just make the call. You know the number. */
|
||||
return (void *) objects_hash_element(table, pointer);
|
||||
return (void *) o_hash_element(table, pointer);
|
||||
}
|
||||
|
||||
NSArray *
|
||||
|
@ -331,7 +331,7 @@ NSAllHashTableObjects (NSHashTable *table)
|
|||
NSHashEnumerator
|
||||
NSEnumerateHashTable(NSHashTable *table)
|
||||
{
|
||||
return objects_hash_enumerator_for_hash(table);
|
||||
return o_hash_enumerator_for_hash(table);
|
||||
}
|
||||
|
||||
void *
|
||||
|
@ -340,7 +340,7 @@ NSNextHashEnumeratorItem(NSHashEnumerator *enumerator)
|
|||
const void *element;
|
||||
|
||||
/* Grab the next element. */
|
||||
objects_hash_enumerator_next_element(enumerator, &element);
|
||||
o_hash_enumerator_next_element(enumerator, &element);
|
||||
|
||||
/* Return ELEMENT. */
|
||||
return (void *) element;
|
||||
|
@ -352,7 +352,7 @@ void
|
|||
NSHashInsert(NSHashTable *table, const void *pointer)
|
||||
{
|
||||
/* Place POINTER in TABLE. */
|
||||
objects_hash_add_element(table, pointer);
|
||||
o_hash_add_element(table, pointer);
|
||||
|
||||
/* OpenStep doesn't care for any return value, so... */
|
||||
return;
|
||||
|
@ -361,7 +361,7 @@ NSHashInsert(NSHashTable *table, const void *pointer)
|
|||
void
|
||||
NSHashInsertKnownAbsent(NSHashTable *table, const void *element)
|
||||
{
|
||||
if (objects_hash_contains_element(table, element))
|
||||
if (o_hash_contains_element(table, element))
|
||||
{
|
||||
/* FIXME: I should make this give the user/programmer more
|
||||
* information. Not difficult to do, just something for a later
|
||||
|
@ -372,7 +372,7 @@ NSHashInsertKnownAbsent(NSHashTable *table, const void *element)
|
|||
}
|
||||
else
|
||||
{
|
||||
objects_hash_add_element_known_absent(table, element);
|
||||
o_hash_add_element_known_absent(table, element);
|
||||
}
|
||||
|
||||
/* OpenStep doesn't care for any return value, so... */
|
||||
|
@ -385,7 +385,7 @@ NSHashInsertIfAbsent(NSHashTable *table, const void *element)
|
|||
const void *old_element;
|
||||
|
||||
/* Place ELEMENT in TABLE. */
|
||||
old_element = objects_hash_add_element_if_absent(table, element);
|
||||
old_element = o_hash_add_element_if_absent(table, element);
|
||||
|
||||
/* Return the version of ELEMENT in TABLE now. */
|
||||
return (void *) old_element;
|
||||
|
@ -397,7 +397,7 @@ void
|
|||
NSHashRemove(NSHashTable *table, const void *element)
|
||||
{
|
||||
/* Remove ELEMENT from TABLE. */
|
||||
objects_hash_remove_element(table, element);
|
||||
o_hash_remove_element(table, element);
|
||||
|
||||
/* OpenStep doesn't care about return values here, so... */
|
||||
return;
|
||||
|
|
|
@ -145,7 +145,7 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
/** Macros... **/
|
||||
|
||||
#define NSMT_EXTRA(T) \
|
||||
((_NSMT_extra_t *)(objects_map_extra((objects_map_t *)(T))))
|
||||
((_NSMT_extra_t *)(o_map_extra((o_map_t *)(T))))
|
||||
|
||||
#define NSMT_KEY_CALLBACKS(T) \
|
||||
((NSMT_EXTRA((T)))->keyCallBacks)
|
||||
|
@ -228,35 +228,35 @@ _NSMT_value_describe(const void *element, const void *table)
|
|||
}
|
||||
|
||||
/* These are wrappers for getting at the real callbacks. */
|
||||
objects_callbacks_t _NSMT_key_callbacks =
|
||||
o_callbacks_t _NSMT_key_callbacks =
|
||||
{
|
||||
(objects_hash_func_t) _NSMT_key_hash,
|
||||
(objects_compare_func_t) _NSMT_key_compare,
|
||||
(objects_is_equal_func_t) _NSMT_key_is_equal,
|
||||
(objects_retain_func_t) _NSMT_key_retain,
|
||||
(objects_release_func_t) _NSMT_key_release,
|
||||
(objects_describe_func_t) _NSMT_key_describe,
|
||||
(o_hash_func_t) _NSMT_key_hash,
|
||||
(o_compare_func_t) _NSMT_key_compare,
|
||||
(o_is_equal_func_t) _NSMT_key_is_equal,
|
||||
(o_retain_func_t) _NSMT_key_retain,
|
||||
(o_release_func_t) _NSMT_key_release,
|
||||
(o_describe_func_t) _NSMT_key_describe,
|
||||
0 /* This gets changed...See just below. */
|
||||
};
|
||||
|
||||
static inline objects_callbacks_t
|
||||
static inline o_callbacks_t
|
||||
_NSMT_callbacks_for_key_callbacks(NSMapTableKeyCallBacks keyCallBacks)
|
||||
{
|
||||
objects_callbacks_t cbs = _NSMT_key_callbacks;
|
||||
o_callbacks_t cbs = _NSMT_key_callbacks;
|
||||
|
||||
cbs.not_an_item_marker = keyCallBacks.notAKeyMarker;
|
||||
|
||||
return cbs;
|
||||
}
|
||||
|
||||
objects_callbacks_t _NSMT_value_callbacks =
|
||||
o_callbacks_t _NSMT_value_callbacks =
|
||||
{
|
||||
(objects_hash_func_t) objects_non_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_non_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_non_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) _NSMT_value_retain,
|
||||
(objects_release_func_t) _NSMT_value_release,
|
||||
(objects_describe_func_t) _NSMT_value_describe,
|
||||
(o_hash_func_t) o_non_owned_void_p_hash,
|
||||
(o_compare_func_t) o_non_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_non_owned_void_p_is_equal,
|
||||
(o_retain_func_t) _NSMT_value_retain,
|
||||
(o_release_func_t) _NSMT_value_release,
|
||||
(o_describe_func_t) _NSMT_value_describe,
|
||||
0 /* Not needed, really, for OpenStep...And so, ignored here. */
|
||||
};
|
||||
|
||||
|
@ -270,7 +270,7 @@ _NSMT_extra_retain(_NSMT_extra_t *extra, NSMapTable *table)
|
|||
_NSMT_extra_t *new_extra;
|
||||
|
||||
/* Set aside space for our new callbacks in the right zone. */
|
||||
new_extra = (_NSMT_extra_t *)NSZoneMalloc(objects_map_zone(table),
|
||||
new_extra = (_NSMT_extra_t *)NSZoneMalloc(o_map_zone(table),
|
||||
sizeof(_NSMT_extra_t));
|
||||
|
||||
/* Copy the old callbacks into NEW_EXTRA. */
|
||||
|
@ -284,7 +284,7 @@ void
|
|||
_NSMT_extra_release(void *extra, NSMapTable *table)
|
||||
{
|
||||
if (extra != 0)
|
||||
NSZoneFree(objects_map_zone(table), extra);
|
||||
NSZoneFree(o_map_zone(table), extra);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -299,14 +299,14 @@ _NSMT_extra_describe(const void *extra, NSMapTable *table)
|
|||
/* The basic idea here is that these callbacks ensure that the
|
||||
* NSMapTable...Callbacks which are associated with a given NSMapTable
|
||||
* remain so throughout the life of the table and its copies. */
|
||||
objects_callbacks_t _NSMT_extra_callbacks =
|
||||
o_callbacks_t _NSMT_extra_callbacks =
|
||||
{
|
||||
(objects_hash_func_t) objects_non_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_non_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_non_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) _NSMT_extra_retain,
|
||||
(objects_release_func_t)_NSMT_extra_release,
|
||||
(objects_describe_func_t)_NSMT_extra_describe,
|
||||
(o_hash_func_t) o_non_owned_void_p_hash,
|
||||
(o_compare_func_t) o_non_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_non_owned_void_p_is_equal,
|
||||
(o_retain_func_t) _NSMT_extra_retain,
|
||||
(o_release_func_t)_NSMT_extra_release,
|
||||
(o_describe_func_t)_NSMT_extra_describe,
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -321,18 +321,18 @@ NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
|
|||
NSZone *zone)
|
||||
{
|
||||
NSMapTable *table;
|
||||
objects_callbacks_t key_callbacks, value_callbacks;
|
||||
o_callbacks_t key_callbacks, value_callbacks;
|
||||
|
||||
/* Transform the callbacks we were given. */
|
||||
key_callbacks = _NSMT_callbacks_for_key_callbacks(keyCallBacks);
|
||||
value_callbacks = _NSMT_value_callbacks;
|
||||
|
||||
/* Create a map table. */
|
||||
table = objects_map_with_zone_with_callbacks(zone, key_callbacks,
|
||||
table = o_map_with_zone_with_callbacks(zone, key_callbacks,
|
||||
value_callbacks);
|
||||
|
||||
/* Adjust the capacity of TABLE. */
|
||||
objects_map_resize(table, capacity);
|
||||
o_map_resize(table, capacity);
|
||||
|
||||
if (table != 0)
|
||||
{
|
||||
|
@ -343,12 +343,12 @@ NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
|
|||
extra.valueCallBacks = valueCallBacks;
|
||||
|
||||
/* These callbacks are defined above. */
|
||||
objects_map_set_extra_callbacks(table, _NSMT_extra_callbacks);
|
||||
o_map_set_extra_callbacks(table, _NSMT_extra_callbacks);
|
||||
|
||||
/* We send a pointer because that's all the room we have.
|
||||
* The callbacks make a copy of these extras, so we needn't
|
||||
* worry about the way they disappear real soon now. */
|
||||
objects_map_set_extra(table, &extra);
|
||||
o_map_set_extra(table, &extra);
|
||||
}
|
||||
|
||||
return table;
|
||||
|
@ -368,7 +368,7 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
{
|
||||
NSMapTable *new_table;
|
||||
|
||||
new_table = objects_map_copy_with_zone(table, zone);
|
||||
new_table = o_map_copy_with_zone(table, zone);
|
||||
|
||||
return new_table;
|
||||
}
|
||||
|
@ -378,14 +378,14 @@ NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
|||
void
|
||||
NSFreeMapTable(NSMapTable *table)
|
||||
{
|
||||
objects_map_dealloc(table);
|
||||
o_map_dealloc(table);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
NSResetMapTable(NSMapTable *table)
|
||||
{
|
||||
objects_map_empty(table);
|
||||
o_map_empty(table);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ NSResetMapTable(NSMapTable *table)
|
|||
BOOL
|
||||
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2)
|
||||
{
|
||||
return objects_map_is_equal_to_map(table1, table2) ? YES : NO;
|
||||
return o_map_is_equal_to_map(table1, table2) ? YES : NO;
|
||||
}
|
||||
|
||||
/** Getting the number of items in an NSMapTable **/
|
||||
|
@ -402,7 +402,7 @@ NSCompareMapTables(NSMapTable *table1, NSMapTable *table2)
|
|||
unsigned int
|
||||
NSCountMapTable(NSMapTable *table)
|
||||
{
|
||||
return (unsigned int) objects_map_count(table);
|
||||
return (unsigned int) o_map_count(table);
|
||||
}
|
||||
|
||||
/** Retrieving items from an NSMapTable **/
|
||||
|
@ -414,7 +414,7 @@ NSMapMember(NSMapTable *table, const void *key,
|
|||
int i;
|
||||
|
||||
/* Check for K in TABLE. */
|
||||
i = objects_map_key_and_value_at_key(table, (const void **)originalKey,
|
||||
i = o_map_key_and_value_at_key(table, (const void **)originalKey,
|
||||
(const void **)value, key);
|
||||
|
||||
/* Indicate our state of success. */
|
||||
|
@ -424,13 +424,13 @@ NSMapMember(NSMapTable *table, const void *key,
|
|||
void *
|
||||
NSMapGet(NSMapTable *table, const void *key)
|
||||
{
|
||||
return (void *) objects_map_value_at_key(table, key);
|
||||
return (void *) o_map_value_at_key(table, key);
|
||||
}
|
||||
|
||||
NSMapEnumerator
|
||||
NSEnumerateMapTable(NSMapTable *table)
|
||||
{
|
||||
return objects_map_enumerator_for_map(table);
|
||||
return o_map_enumerator_for_map(table);
|
||||
}
|
||||
|
||||
BOOL
|
||||
|
@ -440,7 +440,7 @@ NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|||
int i;
|
||||
|
||||
/* Get the next pair. */
|
||||
i = objects_map_enumerator_next_key_and_value(enumerator,
|
||||
i = o_map_enumerator_next_key_and_value(enumerator,
|
||||
(const void **)key,
|
||||
(const void **)value);
|
||||
|
||||
|
@ -494,7 +494,7 @@ void
|
|||
NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
/* Put KEY -> VALUE into TABLE. */
|
||||
objects_map_at_key_put_value(table, key, value);
|
||||
o_map_at_key_put_value(table, key, value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -502,12 +502,12 @@ NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
|||
void *
|
||||
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
if (objects_map_contains_key (table, key))
|
||||
return (void *) objects_map_key_at_key(table, key);
|
||||
if (o_map_contains_key (table, key))
|
||||
return (void *) o_map_key_at_key(table, key);
|
||||
else
|
||||
{
|
||||
/* Put KEY -> VALUE into TABLE. */
|
||||
objects_map_at_key_put_value_known_absent (table, key, value);
|
||||
o_map_at_key_put_value_known_absent (table, key, value);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ void
|
|||
NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
||||
{
|
||||
/* Is the key already in the table? */
|
||||
if (objects_map_contains_key(table, key))
|
||||
if (o_map_contains_key(table, key))
|
||||
{
|
||||
/* FIXME: I should make this give the user/programmer more
|
||||
* information. Not difficult to do, just something for a later
|
||||
|
@ -529,7 +529,7 @@ NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
|||
else
|
||||
{
|
||||
/* Well, we know it's not there, so... */
|
||||
objects_map_at_key_put_value_known_absent (table, key, value);
|
||||
o_map_at_key_put_value_known_absent (table, key, value);
|
||||
}
|
||||
|
||||
/* Yah-hoo! */
|
||||
|
@ -541,7 +541,7 @@ NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
|||
void
|
||||
NSMapRemove(NSMapTable *table, const void *key)
|
||||
{
|
||||
objects_map_remove_key (table, key);
|
||||
o_map_remove_key (table, key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ enum {
|
|||
};
|
||||
|
||||
extern int
|
||||
objects_vscanf (void *stream,
|
||||
o_vscanf (void *stream,
|
||||
int (*inchar_func)(void*),
|
||||
void (*unchar_func)(void*,int),
|
||||
const char *format, va_list argptr);
|
||||
|
@ -198,7 +198,7 @@ stdio_unchar_func(void *s, int c)
|
|||
#endif
|
||||
|
||||
va_start(ap, format);
|
||||
ret = objects_vscanf(fp, stdio_inchar_func, stdio_unchar_func,
|
||||
ret = o_vscanf(fp, stdio_inchar_func, stdio_unchar_func,
|
||||
[format cStringNoCopy], ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
|
|
406
Source/array.m
406
Source/array.m
|
@ -34,32 +34,32 @@
|
|||
/** Background functions **/
|
||||
|
||||
static inline size_t
|
||||
_objects_array_fold_index(size_t index, size_t slot_count)
|
||||
_o_array_fold_index(size_t index, size_t slot_count)
|
||||
{
|
||||
return (slot_count ? (index % slot_count) : 0);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
_objects_array_internal_index(objects_array_t *array, size_t index)
|
||||
_o_array_internal_index(o_array_t *array, size_t index)
|
||||
{
|
||||
return _objects_array_fold_index (index, array->slot_count);
|
||||
return _o_array_fold_index (index, array->slot_count);
|
||||
}
|
||||
|
||||
static inline objects_array_slot_t *
|
||||
_objects_array_slot_for_index(objects_array_t *array, size_t index)
|
||||
static inline o_array_slot_t *
|
||||
_o_array_slot_for_index(o_array_t *array, size_t index)
|
||||
{
|
||||
return (array->slots + _objects_array_internal_index (array, index));
|
||||
return (array->slots + _o_array_internal_index (array, index));
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_bucket_for_index (objects_array_t *array, size_t index)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_bucket_for_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_slot_t *slot;
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_slot_t *slot;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* First, we translate the index into a bucket index to find our
|
||||
* candidate for the bucket. */
|
||||
slot = _objects_array_slot_for_index (array, index);
|
||||
slot = _o_array_slot_for_index (array, index);
|
||||
bucket = *slot;
|
||||
|
||||
/* But we need to check to see whether this is really the bucket we
|
||||
|
@ -73,16 +73,16 @@ _objects_array_bucket_for_index (objects_array_t *array, size_t index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_new_bucket (objects_array_t *array, size_t index, const void *element)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_new_bucket (o_array_t *array, size_t index, const void *element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = (objects_array_bucket_t *) NSZoneMalloc(objects_array_zone(array),
|
||||
sizeof(objects_array_bucket_t));
|
||||
bucket = (o_array_bucket_t *) NSZoneMalloc(o_array_zone(array),
|
||||
sizeof(o_array_bucket_t));
|
||||
if (bucket != 0)
|
||||
{
|
||||
objects_retain(objects_array_element_callbacks(array), element, array);
|
||||
o_retain(o_array_element_callbacks(array), element, array);
|
||||
bucket->index = index;
|
||||
bucket->element = element;
|
||||
}
|
||||
|
@ -90,44 +90,44 @@ _objects_array_new_bucket (objects_array_t *array, size_t index, const void *ele
|
|||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_free_bucket(objects_array_t *array,
|
||||
objects_array_bucket_t *bucket)
|
||||
_o_array_free_bucket(o_array_t *array,
|
||||
o_array_bucket_t *bucket)
|
||||
{
|
||||
if (bucket != 0)
|
||||
{
|
||||
objects_release(objects_array_element_callbacks (array),
|
||||
o_release(o_array_element_callbacks (array),
|
||||
(void *)(bucket->element),
|
||||
array);
|
||||
NSZoneFree(objects_array_zone(array), bucket);
|
||||
NSZoneFree(o_array_zone(array), bucket);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static inline objects_array_slot_t *
|
||||
_objects_array_new_slots(objects_array_t *array, size_t slot_count)
|
||||
static inline o_array_slot_t *
|
||||
_o_array_new_slots(o_array_t *array, size_t slot_count)
|
||||
{
|
||||
return (objects_array_slot_t *) NSZoneCalloc(objects_array_zone(array),
|
||||
return (o_array_slot_t *) NSZoneCalloc(o_array_zone(array),
|
||||
slot_count,
|
||||
sizeof(objects_array_slot_t));
|
||||
sizeof(o_array_slot_t));
|
||||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_free_slots(objects_array_t *array,
|
||||
objects_array_slot_t *slots)
|
||||
_o_array_free_slots(o_array_t *array,
|
||||
o_array_slot_t *slots)
|
||||
{
|
||||
if (slots != 0)
|
||||
NSZoneFree(objects_array_zone(array), slots);
|
||||
NSZoneFree(o_array_zone(array), slots);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_empty_slot (objects_array_t *array, objects_array_slot_t * slot)
|
||||
_o_array_empty_slot (o_array_t *array, o_array_slot_t * slot)
|
||||
{
|
||||
if (*slot != 0)
|
||||
{
|
||||
/* Get rid of the bucket. */
|
||||
_objects_array_free_bucket (array, *slot);
|
||||
_o_array_free_bucket (array, *slot);
|
||||
|
||||
/* Mark the slot as empty. */
|
||||
*slot = 0;
|
||||
|
@ -141,18 +141,18 @@ _objects_array_empty_slot (objects_array_t *array, objects_array_slot_t * slot)
|
|||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_insert_bucket(objects_array_t *array,
|
||||
objects_array_bucket_t * bucket)
|
||||
_o_array_insert_bucket(o_array_t *array,
|
||||
o_array_bucket_t * bucket)
|
||||
{
|
||||
objects_array_slot_t *slot;
|
||||
o_array_slot_t *slot;
|
||||
|
||||
slot = _objects_array_slot_for_index (array, bucket->index);
|
||||
slot = _o_array_slot_for_index (array, bucket->index);
|
||||
|
||||
/* We're adding a bucket, so the current set of sorted slots is now
|
||||
* invalidated. */
|
||||
if (array->sorted_slots != 0)
|
||||
{
|
||||
_objects_array_free_slots (array, array->sorted_slots);
|
||||
_o_array_free_slots (array, array->sorted_slots);
|
||||
array->sorted_slots = 0;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
/* There's a bucket there, and it has the same index as `bucket'.
|
||||
* So we get rid of the old one, and put the new one in its
|
||||
* place. */
|
||||
_objects_array_free_bucket (array, *slot);
|
||||
_o_array_free_bucket (array, *slot);
|
||||
*slot = bucket;
|
||||
return;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
* better place... */
|
||||
|
||||
size_t new_slot_count;
|
||||
objects_array_slot_t *new_slots; /* This guy holds the buckets while we
|
||||
o_array_slot_t *new_slots; /* This guy holds the buckets while we
|
||||
* muck about with them. */
|
||||
size_t d; /* Just a counter */
|
||||
|
||||
|
@ -196,14 +196,14 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
do
|
||||
{
|
||||
/* First we make a new pile of slots for the buckets. */
|
||||
new_slots = _objects_array_new_slots (array, new_slot_count);
|
||||
new_slots = _o_array_new_slots (array, new_slot_count);
|
||||
|
||||
if (new_slots == 0)
|
||||
/* FIXME: Make this a *little* more friendly. */
|
||||
abort();
|
||||
|
||||
/* Then we put the new bucket in the pile. */
|
||||
new_slots[_objects_array_fold_index (bucket->index,
|
||||
new_slots[_o_array_fold_index (bucket->index,
|
||||
new_slot_count)] = bucket;
|
||||
|
||||
/* Now loop and try to place the others. Upon collision
|
||||
|
@ -215,7 +215,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
{
|
||||
size_t i;
|
||||
|
||||
i = _objects_array_fold_index (array->slots[d]->index,
|
||||
i = _o_array_fold_index (array->slots[d]->index,
|
||||
new_slot_count);
|
||||
|
||||
if (new_slots[i] == 0)
|
||||
|
@ -227,7 +227,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
/* A collision. Clean up and try again. */
|
||||
|
||||
/* Free the current set of new buckets. */
|
||||
_objects_array_free_slots (array, new_slots);
|
||||
_o_array_free_slots (array, new_slots);
|
||||
|
||||
/* Bump up the number of new buckets. */
|
||||
++new_slot_count;
|
||||
|
@ -241,7 +241,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
while (d < array->slot_count);
|
||||
|
||||
if (array->slots != 0)
|
||||
_objects_array_free_slots (array, array->slots);
|
||||
_o_array_free_slots (array, array->slots);
|
||||
|
||||
array->slots = new_slots;
|
||||
array->slot_count = new_slot_count;
|
||||
|
@ -252,8 +252,8 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
}
|
||||
|
||||
static inline int
|
||||
_objects_array_compare_slots (const objects_array_slot_t *slot1,
|
||||
const objects_array_slot_t *slot2)
|
||||
_o_array_compare_slots (const o_array_slot_t *slot1,
|
||||
const o_array_slot_t *slot2)
|
||||
{
|
||||
if (slot1 == slot2)
|
||||
return 0;
|
||||
|
@ -273,9 +273,9 @@ _objects_array_compare_slots (const objects_array_slot_t *slot1,
|
|||
typedef int (*qsort_compare_func_t) (const void *, const void *);
|
||||
|
||||
static inline void
|
||||
_objects_array_make_sorted_slots (objects_array_t *array)
|
||||
_o_array_make_sorted_slots (o_array_t *array)
|
||||
{
|
||||
objects_array_slot_t *new_slots;
|
||||
o_array_slot_t *new_slots;
|
||||
|
||||
/* If there're already some sorted slots, then they're valid, and
|
||||
* we're done. */
|
||||
|
@ -283,15 +283,15 @@ _objects_array_make_sorted_slots (objects_array_t *array)
|
|||
return;
|
||||
|
||||
/* Make some new slots. */
|
||||
new_slots = _objects_array_new_slots (array, array->slot_count);
|
||||
new_slots = _o_array_new_slots (array, array->slot_count);
|
||||
|
||||
/* Copy the pointers to buckets into the new slots. */
|
||||
memcpy (new_slots, array->slots, (array->slot_count
|
||||
* sizeof (objects_array_slot_t)));
|
||||
* sizeof (o_array_slot_t)));
|
||||
|
||||
/* Sort the new slots. */
|
||||
qsort (new_slots, array->slot_count, sizeof (objects_array_slot_t),
|
||||
(qsort_compare_func_t) _objects_array_compare_slots);
|
||||
qsort (new_slots, array->slot_count, sizeof (o_array_slot_t),
|
||||
(qsort_compare_func_t) _o_array_compare_slots);
|
||||
|
||||
/* Put the newly sorted slots in the `sorted_slots' element of the
|
||||
* array structure. */
|
||||
|
@ -300,8 +300,8 @@ _objects_array_make_sorted_slots (objects_array_t *array)
|
|||
return;
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_enumerator_next_bucket (o_array_enumerator_t *enumerator)
|
||||
{
|
||||
if (enumerator->is_sorted)
|
||||
{
|
||||
|
@ -312,7 +312,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
|
||||
if (enumerator->index < enumerator->array->element_count)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = enumerator->array->sorted_slots[enumerator->index];
|
||||
++(enumerator->index);
|
||||
|
@ -328,7 +328,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
|
||||
if (enumerator->index > 0)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
--(enumerator->index);
|
||||
bucket = enumerator->array->sorted_slots[enumerator->index];
|
||||
|
@ -340,7 +340,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
}
|
||||
else
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
if (enumerator->array->slots == 0)
|
||||
return 0;
|
||||
|
@ -360,118 +360,118 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
/** Statistics **/
|
||||
|
||||
size_t
|
||||
objects_array_count(objects_array_t *array)
|
||||
o_array_count(o_array_t *array)
|
||||
{
|
||||
return array->element_count;
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_array_capacity (objects_array_t *array)
|
||||
o_array_capacity (o_array_t *array)
|
||||
{
|
||||
return array->slot_count;
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_check(objects_array_t *array)
|
||||
o_array_check(o_array_t *array)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_is_empty(objects_array_t *array)
|
||||
o_array_is_empty(o_array_t *array)
|
||||
{
|
||||
return objects_array_count (array) != 0;
|
||||
return o_array_count (array) != 0;
|
||||
}
|
||||
|
||||
/** Emptying **/
|
||||
|
||||
void
|
||||
objects_array_empty(objects_array_t *array)
|
||||
o_array_empty(o_array_t *array)
|
||||
{
|
||||
size_t c;
|
||||
|
||||
/* Just empty each slot out, one by one. */
|
||||
for (c = 0; c < array->slot_count; ++c)
|
||||
_objects_array_empty_slot (array, array->slots + c);
|
||||
_o_array_empty_slot (array, array->slots + c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Creating **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_alloc_with_zone(NSZone *zone)
|
||||
o_array_t *
|
||||
o_array_alloc_with_zone(NSZone *zone)
|
||||
{
|
||||
objects_array_t *array;
|
||||
o_array_t *array;
|
||||
|
||||
/* Get a new array. */
|
||||
array = _objects_array_alloc_with_zone(zone);
|
||||
array = _o_array_alloc_with_zone(zone);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_alloc(void)
|
||||
o_array_t *
|
||||
o_array_alloc(void)
|
||||
{
|
||||
return objects_array_alloc_with_zone(0);
|
||||
return o_array_alloc_with_zone(0);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_zone(NSZone *zone)
|
||||
o_array_t *
|
||||
o_array_with_zone(NSZone *zone)
|
||||
{
|
||||
return objects_array_init(objects_array_alloc_with_zone(zone));
|
||||
return o_array_init(o_array_alloc_with_zone(zone));
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_zone_with_callbacks(NSZone *zone,
|
||||
objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_with_zone_with_callbacks(NSZone *zone,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_array_init_with_callbacks(objects_array_alloc_with_zone(zone),
|
||||
return o_array_init_with_callbacks(o_array_alloc_with_zone(zone),
|
||||
callbacks);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_callbacks(objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_with_callbacks(o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_array_init_with_callbacks(objects_array_alloc(), callbacks);
|
||||
return o_array_init_with_callbacks(o_array_alloc(), callbacks);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_char_p(void)
|
||||
o_array_t *
|
||||
o_array_of_char_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_char_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_char_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_non_owned_void_p(void)
|
||||
o_array_t *
|
||||
o_array_of_non_owned_void_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_non_owned_void_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_non_owned_void_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_owned_void_p(void)
|
||||
o_array_t *
|
||||
o_array_of_owned_void_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_owned_void_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_owned_void_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_int(void)
|
||||
o_array_t *
|
||||
o_array_of_int(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_int);
|
||||
return o_array_with_callbacks(o_callbacks_for_int);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_id(void)
|
||||
o_array_t *
|
||||
o_array_of_id(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_id);
|
||||
return o_array_with_callbacks(o_callbacks_for_id);
|
||||
}
|
||||
|
||||
/** Initializing **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init_with_callbacks(objects_array_t *array,
|
||||
objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_init_with_callbacks(o_array_t *array,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
if (array != 0)
|
||||
{
|
||||
|
@ -479,14 +479,14 @@ objects_array_init_with_callbacks(objects_array_t *array,
|
|||
size_t capacity = 15;
|
||||
|
||||
/* Record the element callbacks. */
|
||||
array->callbacks = objects_callbacks_standardize(callbacks);
|
||||
array->callbacks = o_callbacks_standardize(callbacks);
|
||||
|
||||
/* Initialize ARRAY's information. */
|
||||
array->element_count = 0;
|
||||
array->slot_count = capacity + 1;
|
||||
|
||||
/* Make some new slots. */
|
||||
array->slots = _objects_array_new_slots(array, capacity + 1);
|
||||
array->slots = _o_array_new_slots(array, capacity + 1);
|
||||
|
||||
/* Get the sorted slots ready for later use. */
|
||||
array->sorted_slots = 0;
|
||||
|
@ -495,33 +495,33 @@ objects_array_init_with_callbacks(objects_array_t *array,
|
|||
return array;
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init (objects_array_t *array)
|
||||
o_array_t *
|
||||
o_array_init (o_array_t *array)
|
||||
{
|
||||
return objects_array_init_with_callbacks (array,
|
||||
objects_callbacks_standard());
|
||||
return o_array_init_with_callbacks (array,
|
||||
o_callbacks_standard());
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init_from_array (objects_array_t *array, objects_array_t *old_array)
|
||||
o_array_t *
|
||||
o_array_init_from_array (o_array_t *array, o_array_t *old_array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
size_t index;
|
||||
const void *element;
|
||||
|
||||
/* Initialize ARRAY in the usual way. */
|
||||
objects_array_init_with_callbacks (array,
|
||||
objects_array_element_callbacks (old_array));
|
||||
o_array_init_with_callbacks (array,
|
||||
o_array_element_callbacks (old_array));
|
||||
|
||||
/* Get an enumerator for OLD_ARRAY. */
|
||||
enumerator = objects_array_enumerator (old_array);
|
||||
enumerator = o_array_enumerator (old_array);
|
||||
|
||||
/* Step through OLD_ARRAY's elements, putting them at the proper
|
||||
* index in ARRAY. */
|
||||
while (objects_array_enumerator_next_index_and_element (&enumerator,
|
||||
while (o_array_enumerator_next_index_and_element (&enumerator,
|
||||
&index, &element))
|
||||
{
|
||||
objects_array_at_index_put_element (array, index, element);
|
||||
o_array_at_index_put_element (array, index, element);
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -530,20 +530,20 @@ objects_array_init_from_array (objects_array_t *array, objects_array_t *old_arra
|
|||
/** Destroying **/
|
||||
|
||||
void
|
||||
objects_array_dealloc(objects_array_t *array)
|
||||
o_array_dealloc(o_array_t *array)
|
||||
{
|
||||
if (array != 0)
|
||||
{
|
||||
/* Empty out ARRAY. */
|
||||
objects_array_empty (array);
|
||||
o_array_empty (array);
|
||||
|
||||
/* Free up its slots. */
|
||||
_objects_array_free_slots (array, array->slots);
|
||||
_o_array_free_slots (array, array->slots);
|
||||
|
||||
/* FIXME: What about ARRAY's sorted slots? */
|
||||
|
||||
/* Free up ARRAY itself. */
|
||||
_objects_array_dealloc (array);
|
||||
_o_array_dealloc (array);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -552,29 +552,29 @@ objects_array_dealloc(objects_array_t *array)
|
|||
/** Searching **/
|
||||
|
||||
const void *
|
||||
objects_array_element_at_index (objects_array_t *array, size_t index)
|
||||
o_array_element_at_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_bucket_t *bucket = _objects_array_bucket_for_index (array, index);
|
||||
o_array_bucket_t *bucket = _o_array_bucket_for_index (array, index);
|
||||
|
||||
if (bucket != 0)
|
||||
return bucket->element;
|
||||
else
|
||||
/* If `bucket' is 0, then the requested index is unused. */
|
||||
/* There's no bucket, so... */
|
||||
return objects_array_not_an_element_marker (array);
|
||||
return o_array_not_an_element_marker (array);
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_array_index_of_element (objects_array_t *array, const void *element)
|
||||
o_array_index_of_element (o_array_t *array, const void *element)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < array->slot_count; ++i)
|
||||
{
|
||||
objects_array_bucket_t *bucket = array->slots[i];
|
||||
o_array_bucket_t *bucket = array->slots[i];
|
||||
|
||||
if (bucket != 0)
|
||||
if (objects_is_equal (objects_array_element_callbacks (array),
|
||||
if (o_is_equal (o_array_element_callbacks (array),
|
||||
bucket->element,
|
||||
element,
|
||||
array))
|
||||
|
@ -585,82 +585,82 @@ objects_array_index_of_element (objects_array_t *array, const void *element)
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_contains_element (objects_array_t *array, const void *element)
|
||||
o_array_contains_element (o_array_t *array, const void *element)
|
||||
{
|
||||
/* Note that this search is quite inefficient. */
|
||||
return objects_array_index_of_element (array, element) < (array->slot_count);
|
||||
return o_array_index_of_element (array, element) < (array->slot_count);
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements (objects_array_t *array)
|
||||
o_array_all_elements (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_enumerator(array);
|
||||
enumerator = o_array_enumerator(array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker(array);
|
||||
elements[i] = o_array_not_an_element_marker(array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements_ascending (objects_array_t *array)
|
||||
o_array_all_elements_ascending (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_ascending_enumerator (array);
|
||||
enumerator = o_array_ascending_enumerator (array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker (array);
|
||||
elements[i] = o_array_not_an_element_marker (array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements_descending (objects_array_t *array)
|
||||
o_array_all_elements_descending (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_descending_enumerator (array);
|
||||
enumerator = o_array_descending_enumerator (array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker (array);
|
||||
elements[i] = o_array_not_an_element_marker (array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
|
@ -669,36 +669,36 @@ objects_array_all_elements_descending (objects_array_t *array)
|
|||
/** Removing **/
|
||||
|
||||
void
|
||||
objects_array_remove_element_at_index (objects_array_t *array, size_t index)
|
||||
o_array_remove_element_at_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* Get the bucket that might be there. */
|
||||
bucket = _objects_array_bucket_for_index (array, index);
|
||||
bucket = _o_array_bucket_for_index (array, index);
|
||||
|
||||
/* If there's a bucket at the index, then we empty its slot out. */
|
||||
if (bucket != 0)
|
||||
_objects_array_empty_slot (array, _objects_array_slot_for_index (array, index));
|
||||
_o_array_empty_slot (array, _o_array_slot_for_index (array, index));
|
||||
|
||||
/* Finally, we return. */
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_array_remove_element_known_present (objects_array_t *array,
|
||||
o_array_remove_element_known_present (o_array_t *array,
|
||||
const void *element)
|
||||
{
|
||||
objects_array_remove_element_at_index (array,
|
||||
objects_array_index_of_element (array,
|
||||
o_array_remove_element_at_index (array,
|
||||
o_array_index_of_element (array,
|
||||
element));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_array_remove_element (objects_array_t *array, const void *element)
|
||||
o_array_remove_element (o_array_t *array, const void *element)
|
||||
{
|
||||
if (objects_array_contains_element (array, element))
|
||||
objects_array_remove_element_known_present (array, element);
|
||||
if (o_array_contains_element (array, element))
|
||||
o_array_remove_element_known_present (array, element);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -706,62 +706,62 @@ objects_array_remove_element (objects_array_t *array, const void *element)
|
|||
/** Adding **/
|
||||
|
||||
const void *
|
||||
objects_array_at_index_put_element (objects_array_t *array,
|
||||
o_array_at_index_put_element (o_array_t *array,
|
||||
size_t index,
|
||||
const void *element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* Clean out anything that's already there. */
|
||||
objects_array_remove_element_at_index (array, index);
|
||||
o_array_remove_element_at_index (array, index);
|
||||
|
||||
/* Make a bucket for our information. */
|
||||
bucket = _objects_array_new_bucket (array, index, element);
|
||||
bucket = _o_array_new_bucket (array, index, element);
|
||||
|
||||
/* Put our bucket in the array. */
|
||||
_objects_array_insert_bucket (array, bucket);
|
||||
_o_array_insert_bucket (array, bucket);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
/** Enumerating **/
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_ascending_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_ascending_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 1;
|
||||
enumerator.is_ascending = 1;
|
||||
enumerator.index = 0;
|
||||
|
||||
_objects_array_make_sorted_slots (array);
|
||||
_o_array_make_sorted_slots (array);
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_descending_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_descending_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 1;
|
||||
enumerator.is_ascending = 0;
|
||||
/* The `+ 1' is so that we have `0' as a known ending condition.
|
||||
* See `_objects_array_enumerator_next_bucket()'. */
|
||||
* See `_o_array_enumerator_next_bucket()'. */
|
||||
enumerator.index = array->element_count + 1;
|
||||
|
||||
_objects_array_make_sorted_slots (array);
|
||||
_o_array_make_sorted_slots (array);
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 0;
|
||||
|
@ -772,13 +772,13 @@ objects_array_enumerator (objects_array_t *array)
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_index_and_element (o_array_enumerator_t * enumerator,
|
||||
size_t * index,
|
||||
const void **element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = _objects_array_enumerator_next_bucket (enumerator);
|
||||
bucket = _o_array_enumerator_next_bucket (enumerator);
|
||||
|
||||
if (bucket != 0)
|
||||
{
|
||||
|
@ -791,7 +791,7 @@ objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * en
|
|||
else
|
||||
{
|
||||
if (element != 0)
|
||||
*element = objects_array_not_an_element_marker (enumerator->array);
|
||||
*element = o_array_not_an_element_marker (enumerator->array);
|
||||
if (index != 0)
|
||||
*index = 0;
|
||||
return 0;
|
||||
|
@ -799,19 +799,19 @@ objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * en
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_element (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_element (o_array_enumerator_t * enumerator,
|
||||
const void **element)
|
||||
{
|
||||
return objects_array_enumerator_next_index_and_element (enumerator,
|
||||
return o_array_enumerator_next_index_and_element (enumerator,
|
||||
0,
|
||||
element);
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_index (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_index (o_array_enumerator_t * enumerator,
|
||||
size_t * index)
|
||||
{
|
||||
return objects_array_enumerator_next_index_and_element (enumerator,
|
||||
return o_array_enumerator_next_index_and_element (enumerator,
|
||||
index,
|
||||
0);
|
||||
}
|
||||
|
@ -819,14 +819,14 @@ objects_array_enumerator_next_index (objects_array_enumerator_t * enumerator,
|
|||
/** Comparing **/
|
||||
|
||||
int
|
||||
objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array2)
|
||||
o_array_is_equal_to_array (o_array_t *array1, o_array_t *array2)
|
||||
{
|
||||
size_t a, b;
|
||||
const void *m, *n;
|
||||
objects_array_enumerator_t e, f;
|
||||
o_array_enumerator_t e, f;
|
||||
|
||||
a = objects_array_count (array1);
|
||||
b = objects_array_count (array2);
|
||||
a = o_array_count (array1);
|
||||
b = o_array_count (array2);
|
||||
|
||||
if (a < b)
|
||||
return (b - a);
|
||||
|
@ -834,11 +834,11 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
return (a - b);
|
||||
|
||||
/* Get ascending enumerators for each of the two arrays. */
|
||||
e = objects_array_ascending_enumerator (array1);
|
||||
e = objects_array_ascending_enumerator (array1);
|
||||
e = o_array_ascending_enumerator (array1);
|
||||
e = o_array_ascending_enumerator (array1);
|
||||
|
||||
while (objects_array_enumerator_next_index_and_element (&e, &a, &m)
|
||||
&& objects_array_enumerator_next_index_and_element (&f, &b, &n))
|
||||
while (o_array_enumerator_next_index_and_element (&e, &a, &m)
|
||||
&& o_array_enumerator_next_index_and_element (&f, &b, &n))
|
||||
{
|
||||
int c, d;
|
||||
|
||||
|
@ -847,11 +847,11 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
if (a > b)
|
||||
return (a - b);
|
||||
|
||||
c = objects_compare (objects_array_element_callbacks (array1), m, n, array1);
|
||||
c = o_compare (o_array_element_callbacks (array1), m, n, array1);
|
||||
if (c != 0)
|
||||
return c;
|
||||
|
||||
d = objects_compare (objects_array_element_callbacks (array2), n, m, array2);
|
||||
d = o_compare (o_array_element_callbacks (array2), n, m, array2);
|
||||
if (d != 0)
|
||||
return d;
|
||||
}
|
||||
|
@ -861,8 +861,8 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
|
||||
/** Mapping **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_map_elements(objects_array_t *array,
|
||||
o_array_t *
|
||||
o_array_map_elements(o_array_t *array,
|
||||
const void *(*fcn) (const void *, const void *),
|
||||
const void *user_data)
|
||||
{
|
||||
|
@ -872,38 +872,38 @@ objects_array_map_elements(objects_array_t *array,
|
|||
|
||||
/** Miscellaneous **/
|
||||
|
||||
objects_hash_t *
|
||||
objects_hash_init_from_array (objects_hash_t * hash, objects_array_t *array)
|
||||
o_hash_t *
|
||||
o_hash_init_from_array (o_hash_t * hash, o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
/* NOTE: If ARRAY contains multiple elements of the same equivalence
|
||||
* class, it is indeterminate which will end up in HASH. This
|
||||
* shouldn't matter, though. */
|
||||
enumerator = objects_array_enumerator (array);
|
||||
enumerator = o_array_enumerator (array);
|
||||
|
||||
/* Just walk through ARRAY's elements and add them to HASH. */
|
||||
while (objects_array_enumerator_next_element (&enumerator, &element))
|
||||
objects_hash_add_element (hash, element);
|
||||
while (o_array_enumerator_next_element (&enumerator, &element))
|
||||
o_hash_add_element (hash, element);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
// objects_chash_t *
|
||||
// objects_chash_init_from_array (objects_chash_t * chash, objects_array_t *array)
|
||||
// o_chash_t *
|
||||
// o_chash_init_from_array (o_chash_t * chash, o_array_t *array)
|
||||
// {
|
||||
// objects_array_enumerator_t enumerator;
|
||||
// o_array_enumerator_t enumerator;
|
||||
// const void *element;
|
||||
//
|
||||
// /* NOTE: If ARRAY contains multiple elements of the same equivalence
|
||||
// * class, it is indeterminate which will end up in CHASH. This
|
||||
// * shouldn't matter, though. */
|
||||
// enumerator = objects_array_enumerator (array);
|
||||
// enumerator = o_array_enumerator (array);
|
||||
//
|
||||
// /* Just walk through ARRAY's elements and add them to CHASH. */
|
||||
// while (objects_array_enumerator_next_element (&enumerator, &element))
|
||||
// objects_chash_add_element (chash, element);
|
||||
// while (o_array_enumerator_next_element (&enumerator, &element))
|
||||
// o_chash_add_element (chash, element);
|
||||
//
|
||||
// return chash;
|
||||
// }
|
||||
|
|
466
Source/data.m
466
Source/data.m
File diff suppressed because it is too large
Load diff
566
Source/hash.m
566
Source/hash.m
File diff suppressed because it is too large
Load diff
428
Source/list.m
428
Source/list.m
|
@ -34,7 +34,7 @@
|
|||
/** Background functions **/
|
||||
|
||||
static inline void
|
||||
_objects_list_remove_node_from_its_list (objects_list_node_t * node)
|
||||
_o_list_remove_node_from_its_list (o_list_node_t * node)
|
||||
{
|
||||
if (node->list->first_node == node)
|
||||
node->list->first_node = node->next_in_list;
|
||||
|
@ -51,19 +51,19 @@ _objects_list_remove_node_from_its_list (objects_list_node_t * node)
|
|||
return;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_new_node (objects_list_t *list, const void *element)
|
||||
static inline o_list_node_t *
|
||||
_o_list_new_node (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = NSZoneMalloc(objects_list_zone(list), sizeof(objects_list_node_t));
|
||||
node = NSZoneMalloc(o_list_zone(list), sizeof(o_list_node_t));
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
node->list = list;
|
||||
node->next_in_list = 0;
|
||||
node->prev_in_list = 0;
|
||||
objects_retain (objects_list_element_callbacks (list), element, list);
|
||||
o_retain (o_list_element_callbacks (list), element, list);
|
||||
node->element = element;
|
||||
}
|
||||
|
||||
|
@ -71,19 +71,19 @@ _objects_list_new_node (objects_list_t *list, const void *element)
|
|||
}
|
||||
|
||||
void
|
||||
_objects_list_free_node (objects_list_t *list, objects_list_node_t * node)
|
||||
_o_list_free_node (o_list_t *list, o_list_node_t * node)
|
||||
{
|
||||
objects_release (objects_list_element_callbacks (node->list),
|
||||
o_release (o_list_element_callbacks (node->list),
|
||||
(void*)node->element,
|
||||
node->list);
|
||||
NSZoneFree(objects_list_zone(list), node);
|
||||
NSZoneFree(o_list_zone(list), node);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_nth_node (objects_list_t *list, long int n)
|
||||
static inline o_list_node_t *
|
||||
_o_list_nth_node (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
|
@ -111,12 +111,12 @@ _objects_list_nth_node (objects_list_t *list, long int n)
|
|||
return node;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_nth_node_for_element (objects_list_t *list,
|
||||
static inline o_list_node_t *
|
||||
_o_list_nth_node_for_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
|
||||
while (node != 0 && n != 0)
|
||||
{
|
||||
if (objects_is_equal (objects_list_element_callbacks (list), element, node->element, list))
|
||||
if (o_is_equal (o_list_element_callbacks (list), element, node->element, list))
|
||||
++n;
|
||||
if (n != 0)
|
||||
node = node->prev_in_list;
|
||||
|
@ -138,7 +138,7 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
|
||||
while (node != 0 && n != 0)
|
||||
{
|
||||
if (objects_is_equal (objects_list_element_callbacks (list), element, node->element, list))
|
||||
if (o_is_equal (o_list_element_callbacks (list), element, node->element, list))
|
||||
--n;
|
||||
if (n != 0)
|
||||
node = node->next_in_list;
|
||||
|
@ -148,10 +148,10 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
return node;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_enumerator_next_node (objects_list_enumerator_t *enumerator)
|
||||
static inline o_list_node_t *
|
||||
_o_list_enumerator_next_node (o_list_enumerator_t *enumerator)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
/* Remember ENUMERATOR's current node. */
|
||||
node = enumerator->node;
|
||||
|
@ -173,56 +173,56 @@ _objects_list_enumerator_next_node (objects_list_enumerator_t *enumerator)
|
|||
/** Gathering statistics **/
|
||||
|
||||
size_t
|
||||
objects_list_count (objects_list_t *list)
|
||||
o_list_count (o_list_t *list)
|
||||
{
|
||||
return list->element_count;
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_list_capacity (objects_list_t *list)
|
||||
o_list_capacity (o_list_t *list)
|
||||
{
|
||||
return list->element_count;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_check (objects_list_t *list)
|
||||
o_list_check (o_list_t *list)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_contains_element (objects_list_t *list, const void *element)
|
||||
o_list_contains_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *member;
|
||||
|
||||
objects_list_enumerator (list);
|
||||
o_list_enumerator (list);
|
||||
|
||||
while (objects_list_enumerator_next_element (&enumerator, &member))
|
||||
if (objects_compare (objects_list_element_callbacks (list), element, member, list))
|
||||
while (o_list_enumerator_next_element (&enumerator, &member))
|
||||
if (o_compare (o_list_element_callbacks (list), element, member, list))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_is_empty (objects_list_t *list)
|
||||
o_list_is_empty (o_list_t *list)
|
||||
{
|
||||
return objects_list_count (list) == 0;
|
||||
return o_list_count (list) == 0;
|
||||
}
|
||||
|
||||
/** Enumerating **/
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_enumerator (o_list_t *list)
|
||||
{
|
||||
return objects_list_forward_enumerator (list);
|
||||
return o_list_forward_enumerator (list);
|
||||
}
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_forward_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_forward_enumerator (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
|
||||
/* Make sure ENUMERATOR knows its list. */
|
||||
enumerator.list = list;
|
||||
|
@ -236,10 +236,10 @@ objects_list_forward_enumerator (objects_list_t *list)
|
|||
return enumerator;
|
||||
}
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_reverse_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_reverse_enumerator (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
|
||||
/* Make sure ENUMERATOR knows its list. */
|
||||
enumerator.list = list;
|
||||
|
@ -254,14 +254,14 @@ objects_list_reverse_enumerator (objects_list_t *list)
|
|||
}
|
||||
|
||||
int
|
||||
objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
||||
o_list_enumerator_next_element (o_list_enumerator_t *enumerator,
|
||||
const void **element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
/* Try and get the next node in the enumeration represented by
|
||||
* ENUMERATOR. */
|
||||
node = _objects_list_enumerator_next_node (enumerator);
|
||||
node = _o_list_enumerator_next_node (enumerator);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
|||
{
|
||||
/* If NODE isn't real, then we return the ``bogus'' indicator. */
|
||||
if (element != 0)
|
||||
*element = objects_list_not_an_element_marker (enumerator->list);
|
||||
*element = o_list_not_an_element_marker (enumerator->list);
|
||||
|
||||
/* Indicate that the enumeration is over. */
|
||||
return 0;
|
||||
|
@ -286,63 +286,63 @@ objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
|||
/** Searching **/
|
||||
|
||||
const void *
|
||||
objects_list_element (objects_list_t *list, const void *element)
|
||||
o_list_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, 0, element);
|
||||
node = _o_list_nth_node_for_element (list, 0, element);
|
||||
|
||||
if (node != 0)
|
||||
return node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_nth_element (objects_list_t *list, long int n)
|
||||
o_list_nth_element (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
return node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_first_element (objects_list_t *list)
|
||||
o_list_first_element (o_list_t *list)
|
||||
{
|
||||
if (list->first_node != 0)
|
||||
return list->first_node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_last_element (objects_list_t *list)
|
||||
o_list_last_element (o_list_t *list)
|
||||
{
|
||||
if (list->last_node != 0)
|
||||
return list->last_node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
/** Obtaining elements **/
|
||||
|
||||
const void **
|
||||
objects_list_all_elements (objects_list_t *list)
|
||||
o_list_all_elements (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void **array;
|
||||
size_t i;
|
||||
|
||||
array = NSZoneCalloc(objects_list_zone(list),
|
||||
objects_list_count(list) + 1,
|
||||
array = NSZoneCalloc(o_list_zone(list),
|
||||
o_list_count(list) + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
for (i = 0; objects_list_enumerator_next_element (&enumerator, array + i); ++i);
|
||||
for (i = 0; o_list_enumerator_next_element (&enumerator, array + i); ++i);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
@ -350,38 +350,38 @@ objects_list_all_elements (objects_list_t *list)
|
|||
/** Adding elements **/
|
||||
|
||||
const void *
|
||||
objects_list_append_element (objects_list_t *list, const void *element)
|
||||
o_list_append_element (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element (list, -1, element);
|
||||
return o_list_at_index_insert_element (list, -1, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_append_element_if_absent (objects_list_t *list, const void *element)
|
||||
o_list_append_element_if_absent (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element_if_absent (list, -1, element);
|
||||
return o_list_at_index_insert_element_if_absent (list, -1, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_prepend_element (objects_list_t *list, const void *element)
|
||||
o_list_prepend_element (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element (list, 0, element);
|
||||
return o_list_at_index_insert_element (list, 0, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_prepend_element_if_absent (objects_list_t *list, const void *element)
|
||||
o_list_prepend_element_if_absent (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element_if_absent (list, 0, element);
|
||||
return o_list_at_index_insert_element_if_absent (list, 0, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_at_index_insert_element(objects_list_t *list,
|
||||
o_list_at_index_insert_element(o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *anode, *bnode, *new_node, *node;
|
||||
o_list_node_t *anode, *bnode, *new_node, *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
new_node = _objects_list_new_node (list, element);
|
||||
node = _o_list_nth_node (list, n);
|
||||
new_node = _o_list_new_node (list, element);
|
||||
|
||||
if (new_node == 0)
|
||||
/* FIXME: Make this a *little* more graceful, for goodness' sake! */
|
||||
|
@ -437,87 +437,87 @@ objects_list_at_index_insert_element(objects_list_t *list,
|
|||
}
|
||||
|
||||
const void *
|
||||
objects_list_at_index_insert_element_if_absent (objects_list_t *list,
|
||||
o_list_at_index_insert_element_if_absent (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
if (!objects_list_contains_element (list, element))
|
||||
return objects_list_at_index_insert_element (list, n, element);
|
||||
if (!o_list_contains_element (list, element))
|
||||
return o_list_at_index_insert_element (list, n, element);
|
||||
else
|
||||
return objects_list_element (list, element);
|
||||
return o_list_element (list, element);
|
||||
}
|
||||
|
||||
/** Removing elements **/
|
||||
|
||||
void
|
||||
objects_list_remove_nth_occurrance_of_element (objects_list_t *list,
|
||||
o_list_remove_nth_occurrance_of_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, n, element);
|
||||
node = _o_list_nth_node_for_element (list, n, element);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_element (objects_list_t *list, const void *element)
|
||||
o_list_remove_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_remove_nth_occurrance_of_element (list, 0, element);
|
||||
o_list_remove_nth_occurrance_of_element (list, 0, element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_nth_element (objects_list_t *list, long int n)
|
||||
o_list_remove_nth_element (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_first_element (objects_list_t *list)
|
||||
o_list_remove_first_element (o_list_t *list)
|
||||
{
|
||||
objects_list_remove_nth_element (list, 0);
|
||||
o_list_remove_nth_element (list, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_last_element (objects_list_t *list)
|
||||
o_list_remove_last_element (o_list_t *list)
|
||||
{
|
||||
objects_list_remove_nth_element (list, -1);
|
||||
o_list_remove_nth_element (list, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Emptying **/
|
||||
|
||||
void
|
||||
objects_list_empty (objects_list_t *list)
|
||||
o_list_empty (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
objects_list_node_t *node;
|
||||
o_list_enumerator_t enumerator;
|
||||
o_list_node_t *node;
|
||||
|
||||
enumerator = objects_list_enumerator (list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
while ((node = _objects_list_enumerator_next_node (&enumerator)) != 0)
|
||||
while ((node = _o_list_enumerator_next_node (&enumerator)) != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -526,19 +526,19 @@ objects_list_empty (objects_list_t *list)
|
|||
/** Replacing **/
|
||||
|
||||
void
|
||||
objects_list_replace_nth_occurrance_of_element (objects_list_t *list,
|
||||
o_list_replace_nth_occurrance_of_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *old_element,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, n, old_element);
|
||||
node = _o_list_nth_node_for_element (list, n, old_element);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
objects_retain (objects_list_element_callbacks (list), new_element, list);
|
||||
objects_release (objects_list_element_callbacks (list),
|
||||
o_retain (o_list_element_callbacks (list), new_element, list);
|
||||
o_release (o_list_element_callbacks (list),
|
||||
(void*)node->element,
|
||||
list);
|
||||
node->element = new_element;
|
||||
|
@ -548,27 +548,27 @@ objects_list_replace_nth_occurrance_of_element (objects_list_t *list,
|
|||
}
|
||||
|
||||
void
|
||||
objects_list_replace_element (objects_list_t *list,
|
||||
o_list_replace_element (o_list_t *list,
|
||||
const void *old_element,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_occurrance_of_element (list, 0, old_element, new_element);
|
||||
o_list_replace_nth_occurrance_of_element (list, 0, old_element, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_replace_nth_element (objects_list_t *list,
|
||||
o_list_replace_nth_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
objects_retain (objects_list_element_callbacks (list), new_element, list);
|
||||
objects_release (objects_list_element_callbacks (list),
|
||||
o_retain (o_list_element_callbacks (list), new_element, list);
|
||||
o_release (o_list_element_callbacks (list),
|
||||
(void*)node->element,
|
||||
list);
|
||||
node->element = new_element;
|
||||
|
@ -578,105 +578,105 @@ objects_list_replace_nth_element (objects_list_t *list,
|
|||
}
|
||||
|
||||
void
|
||||
objects_list_replace_first_element (objects_list_t *list,
|
||||
o_list_replace_first_element (o_list_t *list,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_element (list, 0, new_element);
|
||||
o_list_replace_nth_element (list, 0, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_replace_last_element (objects_list_t *list,
|
||||
o_list_replace_last_element (o_list_t *list,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_element (list, -1, new_element);
|
||||
o_list_replace_nth_element (list, -1, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Creating **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_alloc_with_zone (NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_alloc_with_zone (NSZone *zone)
|
||||
{
|
||||
objects_list_t *list;
|
||||
o_list_t *list;
|
||||
|
||||
list = _objects_list_alloc_with_zone(zone);
|
||||
list = _o_list_alloc_with_zone(zone);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_alloc (void)
|
||||
o_list_t *
|
||||
o_list_alloc (void)
|
||||
{
|
||||
return objects_list_alloc_with_zone (0);
|
||||
return o_list_alloc_with_zone (0);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list (void)
|
||||
o_list_t *
|
||||
o_list (void)
|
||||
{
|
||||
return objects_list_init (objects_list_alloc ());
|
||||
return o_list_init (o_list_alloc ());
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_zone (NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_with_zone (NSZone *zone)
|
||||
{
|
||||
return objects_list_init (objects_list_alloc_with_zone(zone));
|
||||
return o_list_init (o_list_alloc_with_zone(zone));
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_zone_with_callbacks (NSZone *zone,
|
||||
objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_with_zone_with_callbacks (NSZone *zone,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_list_init_with_callbacks(objects_list_alloc_with_zone(zone),
|
||||
return o_list_init_with_callbacks(o_list_alloc_with_zone(zone),
|
||||
callbacks);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_callbacks (objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_with_callbacks (o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_list_init_with_callbacks (objects_list_alloc (), callbacks);
|
||||
return o_list_init_with_callbacks (o_list_alloc (), callbacks);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_char_p (void)
|
||||
o_list_t *
|
||||
o_list_of_char_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_char_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_char_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_int (void)
|
||||
o_list_t *
|
||||
o_list_of_int (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_int);
|
||||
return o_list_with_callbacks (o_callbacks_for_int);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_non_owned_void_p (void)
|
||||
o_list_t *
|
||||
o_list_of_non_owned_void_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_non_owned_void_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_non_owned_void_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_owned_void_p (void)
|
||||
o_list_t *
|
||||
o_list_of_owned_void_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_owned_void_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_owned_void_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_id (void)
|
||||
o_list_t *
|
||||
o_list_of_id (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_id);
|
||||
return o_list_with_callbacks (o_callbacks_for_id);
|
||||
}
|
||||
|
||||
/** Initializing **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init (objects_list_t *list)
|
||||
o_list_t *
|
||||
o_list_init (o_list_t *list)
|
||||
{
|
||||
return objects_list_init_with_callbacks (list, objects_callbacks_standard());
|
||||
return o_list_init_with_callbacks (list, o_callbacks_standard());
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init_with_callbacks (objects_list_t *list, objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_init_with_callbacks (o_list_t *list, o_callbacks_t callbacks)
|
||||
{
|
||||
if (list != 0)
|
||||
{
|
||||
|
@ -690,15 +690,15 @@ objects_list_init_with_callbacks (objects_list_t *list, objects_callbacks_t call
|
|||
return list;
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
||||
o_list_t *
|
||||
o_list_init_from_list (o_list_t *list, o_list_t *old_list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
if (list != 0)
|
||||
{
|
||||
list->callbacks = objects_list_element_callbacks (old_list);
|
||||
list->callbacks = o_list_element_callbacks (old_list);
|
||||
list->element_count = 0;
|
||||
list->node_count = 0;
|
||||
list->first_node = 0;
|
||||
|
@ -707,12 +707,12 @@ objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
|||
if (old_list != 0)
|
||||
{
|
||||
/* Get a forward enumerator for OLD_LIST. */
|
||||
enumerator = objects_list_forward_enumerator (old_list);
|
||||
enumerator = o_list_forward_enumerator (old_list);
|
||||
|
||||
/* Walk from the beginning to the end of OLD_LIST, and add each
|
||||
* element to the end of LIST. */
|
||||
while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
objects_list_at_index_insert_element (list, -1, element);
|
||||
while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
o_list_at_index_insert_element (list, -1, element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,13 +722,13 @@ objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
|||
/** Destroying **/
|
||||
|
||||
void
|
||||
objects_list_dealloc (objects_list_t *list)
|
||||
o_list_dealloc (o_list_t *list)
|
||||
{
|
||||
/* Empty LIST out. */
|
||||
objects_list_empty (list);
|
||||
o_list_empty (list);
|
||||
|
||||
/* Get rid of LIST. */
|
||||
_objects_list_dealloc (list);
|
||||
_o_list_dealloc (list);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ objects_list_dealloc (objects_list_t *list)
|
|||
/** Comparing **/
|
||||
|
||||
int
|
||||
objects_list_is_equal_to_list(objects_list_t *list, objects_list_t *other_list)
|
||||
o_list_is_equal_to_list(o_list_t *list, o_list_t *other_list)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return 0;
|
||||
|
@ -744,81 +744,81 @@ objects_list_is_equal_to_list(objects_list_t *list, objects_list_t *other_list)
|
|||
|
||||
/** Concatenating **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_append_list (objects_list_t *base_list, objects_list_t *suffix_list)
|
||||
o_list_t *
|
||||
o_list_append_list (o_list_t *base_list, o_list_t *suffix_list)
|
||||
{
|
||||
return objects_list_at_index_insert_list (base_list, -1, suffix_list);
|
||||
return o_list_at_index_insert_list (base_list, -1, suffix_list);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_prepend_list (objects_list_t *base_list, objects_list_t *prefix_list)
|
||||
o_list_t *
|
||||
o_list_prepend_list (o_list_t *base_list, o_list_t *prefix_list)
|
||||
{
|
||||
return objects_list_at_index_insert_list (base_list, 0, prefix_list);
|
||||
return o_list_at_index_insert_list (base_list, 0, prefix_list);
|
||||
}
|
||||
|
||||
/* FIXME: I was lazy when I wrote this next one. It can easily be
|
||||
* sped up. Do it. */
|
||||
objects_list_t *
|
||||
objects_list_at_index_insert_list(objects_list_t *base_list,
|
||||
o_list_t *
|
||||
o_list_at_index_insert_list(o_list_t *base_list,
|
||||
long int n,
|
||||
objects_list_t *infix_list)
|
||||
o_list_t *infix_list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
if (n < 0)
|
||||
enumerator = objects_list_forward_enumerator(infix_list);
|
||||
enumerator = o_list_forward_enumerator(infix_list);
|
||||
else /* (n >= 0) */
|
||||
enumerator = objects_list_reverse_enumerator(infix_list);
|
||||
enumerator = o_list_reverse_enumerator(infix_list);
|
||||
|
||||
while (objects_list_enumerator_next_element(&enumerator, &element))
|
||||
objects_list_at_index_insert_element(base_list, n, element);
|
||||
while (o_list_enumerator_next_element(&enumerator, &element))
|
||||
o_list_at_index_insert_element(base_list, n, element);
|
||||
|
||||
return base_list;
|
||||
}
|
||||
|
||||
/** Copying **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_copy (objects_list_t *old_list)
|
||||
o_list_t *
|
||||
o_list_copy (o_list_t *old_list)
|
||||
{
|
||||
return objects_list_copy_with_zone (old_list, 0);
|
||||
return o_list_copy_with_zone (old_list, 0);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_copy_with_zone (objects_list_t *old_list, NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_copy_with_zone (o_list_t *old_list, NSZone *zone)
|
||||
{
|
||||
objects_list_t *list;
|
||||
o_list_t *list;
|
||||
|
||||
/* Allocate a new (low-level) copy of OLD_LIST. */
|
||||
list = _objects_list_copy_with_zone(old_list, zone);
|
||||
list = _o_list_copy_with_zone(old_list, zone);
|
||||
|
||||
/* Fill it in. */
|
||||
return objects_list_init_from_list (list, old_list);
|
||||
return o_list_init_from_list (list, old_list);
|
||||
}
|
||||
|
||||
/** Mapping **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_map_elements(objects_list_t *list,
|
||||
o_list_t *
|
||||
o_list_map_elements(o_list_t *list,
|
||||
const void *(*fcn)(const void *, void *),
|
||||
void *user_data)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
objects_list_node_t *node;
|
||||
objects_callbacks_t callbacks;
|
||||
o_list_enumerator_t enumerator;
|
||||
o_list_node_t *node;
|
||||
o_callbacks_t callbacks;
|
||||
|
||||
callbacks = objects_list_element_callbacks(list);
|
||||
enumerator = objects_list_enumerator (list);
|
||||
callbacks = o_list_element_callbacks(list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
while ((node = _objects_list_enumerator_next_node (&enumerator)) != 0)
|
||||
while ((node = _o_list_enumerator_next_node (&enumerator)) != 0)
|
||||
{
|
||||
const void *element;
|
||||
|
||||
element = (*fcn)(node->element, user_data);
|
||||
|
||||
objects_retain (callbacks, element, list);
|
||||
objects_release (callbacks, (void *)(node->element), list);
|
||||
o_retain (callbacks, element, list);
|
||||
o_release (callbacks, (void *)(node->element), list);
|
||||
|
||||
node->element = element;
|
||||
}
|
||||
|
@ -828,16 +828,16 @@ objects_list_map_elements(objects_list_t *list,
|
|||
|
||||
/** Creating other collections from lists **/
|
||||
|
||||
objects_hash_t *
|
||||
objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
||||
o_hash_t *
|
||||
o_hash_init_from_list (o_hash_t * hash, o_list_t *list)
|
||||
{
|
||||
if (hash != 0)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
/* Make a note of the callbacks for HASH. */
|
||||
hash->callbacks = objects_list_element_callbacks (list);
|
||||
hash->callbacks = o_list_element_callbacks (list);
|
||||
|
||||
/* Zero out the various counts. */
|
||||
hash->node_count = 0;
|
||||
|
@ -849,33 +849,33 @@ objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
|||
hash->buckets = 0;
|
||||
|
||||
/* Resize HASH to the given CAPACITY. */
|
||||
objects_hash_resize (hash, objects_list_capacity (list));
|
||||
o_hash_resize (hash, o_list_capacity (list));
|
||||
|
||||
/* Get an element enumerator for LIST. */
|
||||
enumerator = objects_list_enumerator (list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
/* Add LIST's elements to HASH, one at a time. Note that if LIST
|
||||
* contains multiple elements from the same equivalence class, it
|
||||
* is indeterminate which will end up in HASH. But this shouldn't
|
||||
* be a problem. */
|
||||
while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
objects_hash_add_element (hash, element);
|
||||
while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
o_hash_add_element (hash, element);
|
||||
}
|
||||
|
||||
/* Return the newly initialized HASH. */
|
||||
return hash;
|
||||
}
|
||||
|
||||
// objects_chash_t *
|
||||
// objects_chash_init_from_list (objects_chash_t * chash, objects_list_t *list)
|
||||
// o_chash_t *
|
||||
// o_chash_init_from_list (o_chash_t * chash, o_list_t *list)
|
||||
// {
|
||||
// if (chash != 0)
|
||||
// {
|
||||
// objects_list_enumerator_t enumerator;
|
||||
// o_list_enumerator_t enumerator;
|
||||
// const void *element;
|
||||
//
|
||||
// /* Make a note of the callbacks for CHASH. */
|
||||
// chash->callbacks = objects_list_element_callbacks (list);
|
||||
// chash->callbacks = o_list_element_callbacks (list);
|
||||
//
|
||||
// /* Zero out the various counts. */
|
||||
// chash->node_count = 0;
|
||||
|
@ -887,17 +887,17 @@ objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
|||
// chash->buckets = 0;
|
||||
//
|
||||
// /* Resize CHASH to the given CAPACITY. */
|
||||
// objects_chash_resize (chash, objects_list_capacity (list));
|
||||
// o_chash_resize (chash, o_list_capacity (list));
|
||||
//
|
||||
// /* Get an element enumerator for LIST. */
|
||||
// enumerator = objects_list_enumerator (list);
|
||||
// enumerator = o_list_enumerator (list);
|
||||
//
|
||||
// /* Add LIST's elements to CHASH, one at a time. Note that if LIST
|
||||
// * contains multiple elements from the same equivalence class, it
|
||||
// * is indeterminate which will end up in CHASH. But this shouldn't
|
||||
// * be a problem. */
|
||||
// while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
// objects_chash_add_element (chash, element);
|
||||
// while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
// o_chash_add_element (chash, element);
|
||||
// }
|
||||
//
|
||||
// /* Return the newly initialized CHASH. */
|
||||
|
|
716
Source/map.m
716
Source/map.m
File diff suppressed because it is too large
Load diff
|
@ -28,35 +28,35 @@
|
|||
|
||||
/**** Type, Constant, and Macro Definitions **********************************/
|
||||
|
||||
size_t ___objects_number_allocated = 0;
|
||||
size_t ___objects_number_deallocated = 0;
|
||||
size_t ___objects_number_serialized = 0;
|
||||
size_t ___o_number_allocated = 0;
|
||||
size_t ___o_number_deallocated = 0;
|
||||
size_t ___o_number_serialized = 0;
|
||||
|
||||
/**** Function Implementations ***********************************************/
|
||||
|
||||
/* Returns the number of Libobjects structures allocated. */
|
||||
size_t
|
||||
_objects_number_allocated(void)
|
||||
_o_number_allocated(void)
|
||||
{
|
||||
return ___objects_number_allocated;
|
||||
return ___o_number_allocated;
|
||||
}
|
||||
|
||||
/* Returns the number of Libobjects structures deallocated. */
|
||||
size_t
|
||||
_objects_number_deallocated(void)
|
||||
_o_number_deallocated(void)
|
||||
{
|
||||
return ___objects_number_deallocated;
|
||||
return ___o_number_deallocated;
|
||||
}
|
||||
|
||||
/* Returns the next serial number to be handed out. */
|
||||
size_t
|
||||
_objects_number_serialized(void)
|
||||
_o_number_serialized(void)
|
||||
{
|
||||
return ___objects_number_serialized;
|
||||
return ___o_number_serialized;
|
||||
}
|
||||
|
||||
size_t
|
||||
_objects_next_power_of_two(size_t bound)
|
||||
_o_next_power_of_two(size_t bound)
|
||||
{
|
||||
size_t start = 1;
|
||||
while ((start <= bound) && (start <<= 1));
|
||||
|
|
406
Source/o_array.m
406
Source/o_array.m
|
@ -34,32 +34,32 @@
|
|||
/** Background functions **/
|
||||
|
||||
static inline size_t
|
||||
_objects_array_fold_index(size_t index, size_t slot_count)
|
||||
_o_array_fold_index(size_t index, size_t slot_count)
|
||||
{
|
||||
return (slot_count ? (index % slot_count) : 0);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
_objects_array_internal_index(objects_array_t *array, size_t index)
|
||||
_o_array_internal_index(o_array_t *array, size_t index)
|
||||
{
|
||||
return _objects_array_fold_index (index, array->slot_count);
|
||||
return _o_array_fold_index (index, array->slot_count);
|
||||
}
|
||||
|
||||
static inline objects_array_slot_t *
|
||||
_objects_array_slot_for_index(objects_array_t *array, size_t index)
|
||||
static inline o_array_slot_t *
|
||||
_o_array_slot_for_index(o_array_t *array, size_t index)
|
||||
{
|
||||
return (array->slots + _objects_array_internal_index (array, index));
|
||||
return (array->slots + _o_array_internal_index (array, index));
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_bucket_for_index (objects_array_t *array, size_t index)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_bucket_for_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_slot_t *slot;
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_slot_t *slot;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* First, we translate the index into a bucket index to find our
|
||||
* candidate for the bucket. */
|
||||
slot = _objects_array_slot_for_index (array, index);
|
||||
slot = _o_array_slot_for_index (array, index);
|
||||
bucket = *slot;
|
||||
|
||||
/* But we need to check to see whether this is really the bucket we
|
||||
|
@ -73,16 +73,16 @@ _objects_array_bucket_for_index (objects_array_t *array, size_t index)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_new_bucket (objects_array_t *array, size_t index, const void *element)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_new_bucket (o_array_t *array, size_t index, const void *element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = (objects_array_bucket_t *) NSZoneMalloc(objects_array_zone(array),
|
||||
sizeof(objects_array_bucket_t));
|
||||
bucket = (o_array_bucket_t *) NSZoneMalloc(o_array_zone(array),
|
||||
sizeof(o_array_bucket_t));
|
||||
if (bucket != 0)
|
||||
{
|
||||
objects_retain(objects_array_element_callbacks(array), element, array);
|
||||
o_retain(o_array_element_callbacks(array), element, array);
|
||||
bucket->index = index;
|
||||
bucket->element = element;
|
||||
}
|
||||
|
@ -90,44 +90,44 @@ _objects_array_new_bucket (objects_array_t *array, size_t index, const void *ele
|
|||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_free_bucket(objects_array_t *array,
|
||||
objects_array_bucket_t *bucket)
|
||||
_o_array_free_bucket(o_array_t *array,
|
||||
o_array_bucket_t *bucket)
|
||||
{
|
||||
if (bucket != 0)
|
||||
{
|
||||
objects_release(objects_array_element_callbacks (array),
|
||||
o_release(o_array_element_callbacks (array),
|
||||
(void *)(bucket->element),
|
||||
array);
|
||||
NSZoneFree(objects_array_zone(array), bucket);
|
||||
NSZoneFree(o_array_zone(array), bucket);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static inline objects_array_slot_t *
|
||||
_objects_array_new_slots(objects_array_t *array, size_t slot_count)
|
||||
static inline o_array_slot_t *
|
||||
_o_array_new_slots(o_array_t *array, size_t slot_count)
|
||||
{
|
||||
return (objects_array_slot_t *) NSZoneCalloc(objects_array_zone(array),
|
||||
return (o_array_slot_t *) NSZoneCalloc(o_array_zone(array),
|
||||
slot_count,
|
||||
sizeof(objects_array_slot_t));
|
||||
sizeof(o_array_slot_t));
|
||||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_free_slots(objects_array_t *array,
|
||||
objects_array_slot_t *slots)
|
||||
_o_array_free_slots(o_array_t *array,
|
||||
o_array_slot_t *slots)
|
||||
{
|
||||
if (slots != 0)
|
||||
NSZoneFree(objects_array_zone(array), slots);
|
||||
NSZoneFree(o_array_zone(array), slots);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_empty_slot (objects_array_t *array, objects_array_slot_t * slot)
|
||||
_o_array_empty_slot (o_array_t *array, o_array_slot_t * slot)
|
||||
{
|
||||
if (*slot != 0)
|
||||
{
|
||||
/* Get rid of the bucket. */
|
||||
_objects_array_free_bucket (array, *slot);
|
||||
_o_array_free_bucket (array, *slot);
|
||||
|
||||
/* Mark the slot as empty. */
|
||||
*slot = 0;
|
||||
|
@ -141,18 +141,18 @@ _objects_array_empty_slot (objects_array_t *array, objects_array_slot_t * slot)
|
|||
}
|
||||
|
||||
static inline void
|
||||
_objects_array_insert_bucket(objects_array_t *array,
|
||||
objects_array_bucket_t * bucket)
|
||||
_o_array_insert_bucket(o_array_t *array,
|
||||
o_array_bucket_t * bucket)
|
||||
{
|
||||
objects_array_slot_t *slot;
|
||||
o_array_slot_t *slot;
|
||||
|
||||
slot = _objects_array_slot_for_index (array, bucket->index);
|
||||
slot = _o_array_slot_for_index (array, bucket->index);
|
||||
|
||||
/* We're adding a bucket, so the current set of sorted slots is now
|
||||
* invalidated. */
|
||||
if (array->sorted_slots != 0)
|
||||
{
|
||||
_objects_array_free_slots (array, array->sorted_slots);
|
||||
_o_array_free_slots (array, array->sorted_slots);
|
||||
array->sorted_slots = 0;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
/* There's a bucket there, and it has the same index as `bucket'.
|
||||
* So we get rid of the old one, and put the new one in its
|
||||
* place. */
|
||||
_objects_array_free_bucket (array, *slot);
|
||||
_o_array_free_bucket (array, *slot);
|
||||
*slot = bucket;
|
||||
return;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
* better place... */
|
||||
|
||||
size_t new_slot_count;
|
||||
objects_array_slot_t *new_slots; /* This guy holds the buckets while we
|
||||
o_array_slot_t *new_slots; /* This guy holds the buckets while we
|
||||
* muck about with them. */
|
||||
size_t d; /* Just a counter */
|
||||
|
||||
|
@ -196,14 +196,14 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
do
|
||||
{
|
||||
/* First we make a new pile of slots for the buckets. */
|
||||
new_slots = _objects_array_new_slots (array, new_slot_count);
|
||||
new_slots = _o_array_new_slots (array, new_slot_count);
|
||||
|
||||
if (new_slots == 0)
|
||||
/* FIXME: Make this a *little* more friendly. */
|
||||
abort();
|
||||
|
||||
/* Then we put the new bucket in the pile. */
|
||||
new_slots[_objects_array_fold_index (bucket->index,
|
||||
new_slots[_o_array_fold_index (bucket->index,
|
||||
new_slot_count)] = bucket;
|
||||
|
||||
/* Now loop and try to place the others. Upon collision
|
||||
|
@ -215,7 +215,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
{
|
||||
size_t i;
|
||||
|
||||
i = _objects_array_fold_index (array->slots[d]->index,
|
||||
i = _o_array_fold_index (array->slots[d]->index,
|
||||
new_slot_count);
|
||||
|
||||
if (new_slots[i] == 0)
|
||||
|
@ -227,7 +227,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
/* A collision. Clean up and try again. */
|
||||
|
||||
/* Free the current set of new buckets. */
|
||||
_objects_array_free_slots (array, new_slots);
|
||||
_o_array_free_slots (array, new_slots);
|
||||
|
||||
/* Bump up the number of new buckets. */
|
||||
++new_slot_count;
|
||||
|
@ -241,7 +241,7 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
while (d < array->slot_count);
|
||||
|
||||
if (array->slots != 0)
|
||||
_objects_array_free_slots (array, array->slots);
|
||||
_o_array_free_slots (array, array->slots);
|
||||
|
||||
array->slots = new_slots;
|
||||
array->slot_count = new_slot_count;
|
||||
|
@ -252,8 +252,8 @@ _objects_array_insert_bucket(objects_array_t *array,
|
|||
}
|
||||
|
||||
static inline int
|
||||
_objects_array_compare_slots (const objects_array_slot_t *slot1,
|
||||
const objects_array_slot_t *slot2)
|
||||
_o_array_compare_slots (const o_array_slot_t *slot1,
|
||||
const o_array_slot_t *slot2)
|
||||
{
|
||||
if (slot1 == slot2)
|
||||
return 0;
|
||||
|
@ -273,9 +273,9 @@ _objects_array_compare_slots (const objects_array_slot_t *slot1,
|
|||
typedef int (*qsort_compare_func_t) (const void *, const void *);
|
||||
|
||||
static inline void
|
||||
_objects_array_make_sorted_slots (objects_array_t *array)
|
||||
_o_array_make_sorted_slots (o_array_t *array)
|
||||
{
|
||||
objects_array_slot_t *new_slots;
|
||||
o_array_slot_t *new_slots;
|
||||
|
||||
/* If there're already some sorted slots, then they're valid, and
|
||||
* we're done. */
|
||||
|
@ -283,15 +283,15 @@ _objects_array_make_sorted_slots (objects_array_t *array)
|
|||
return;
|
||||
|
||||
/* Make some new slots. */
|
||||
new_slots = _objects_array_new_slots (array, array->slot_count);
|
||||
new_slots = _o_array_new_slots (array, array->slot_count);
|
||||
|
||||
/* Copy the pointers to buckets into the new slots. */
|
||||
memcpy (new_slots, array->slots, (array->slot_count
|
||||
* sizeof (objects_array_slot_t)));
|
||||
* sizeof (o_array_slot_t)));
|
||||
|
||||
/* Sort the new slots. */
|
||||
qsort (new_slots, array->slot_count, sizeof (objects_array_slot_t),
|
||||
(qsort_compare_func_t) _objects_array_compare_slots);
|
||||
qsort (new_slots, array->slot_count, sizeof (o_array_slot_t),
|
||||
(qsort_compare_func_t) _o_array_compare_slots);
|
||||
|
||||
/* Put the newly sorted slots in the `sorted_slots' element of the
|
||||
* array structure. */
|
||||
|
@ -300,8 +300,8 @@ _objects_array_make_sorted_slots (objects_array_t *array)
|
|||
return;
|
||||
}
|
||||
|
||||
static inline objects_array_bucket_t *
|
||||
_objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
||||
static inline o_array_bucket_t *
|
||||
_o_array_enumerator_next_bucket (o_array_enumerator_t *enumerator)
|
||||
{
|
||||
if (enumerator->is_sorted)
|
||||
{
|
||||
|
@ -312,7 +312,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
|
||||
if (enumerator->index < enumerator->array->element_count)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = enumerator->array->sorted_slots[enumerator->index];
|
||||
++(enumerator->index);
|
||||
|
@ -328,7 +328,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
|
||||
if (enumerator->index > 0)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
--(enumerator->index);
|
||||
bucket = enumerator->array->sorted_slots[enumerator->index];
|
||||
|
@ -340,7 +340,7 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
}
|
||||
else
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
if (enumerator->array->slots == 0)
|
||||
return 0;
|
||||
|
@ -360,118 +360,118 @@ _objects_array_enumerator_next_bucket (objects_array_enumerator_t *enumerator)
|
|||
/** Statistics **/
|
||||
|
||||
size_t
|
||||
objects_array_count(objects_array_t *array)
|
||||
o_array_count(o_array_t *array)
|
||||
{
|
||||
return array->element_count;
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_array_capacity (objects_array_t *array)
|
||||
o_array_capacity (o_array_t *array)
|
||||
{
|
||||
return array->slot_count;
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_check(objects_array_t *array)
|
||||
o_array_check(o_array_t *array)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_is_empty(objects_array_t *array)
|
||||
o_array_is_empty(o_array_t *array)
|
||||
{
|
||||
return objects_array_count (array) != 0;
|
||||
return o_array_count (array) != 0;
|
||||
}
|
||||
|
||||
/** Emptying **/
|
||||
|
||||
void
|
||||
objects_array_empty(objects_array_t *array)
|
||||
o_array_empty(o_array_t *array)
|
||||
{
|
||||
size_t c;
|
||||
|
||||
/* Just empty each slot out, one by one. */
|
||||
for (c = 0; c < array->slot_count; ++c)
|
||||
_objects_array_empty_slot (array, array->slots + c);
|
||||
_o_array_empty_slot (array, array->slots + c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Creating **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_alloc_with_zone(NSZone *zone)
|
||||
o_array_t *
|
||||
o_array_alloc_with_zone(NSZone *zone)
|
||||
{
|
||||
objects_array_t *array;
|
||||
o_array_t *array;
|
||||
|
||||
/* Get a new array. */
|
||||
array = _objects_array_alloc_with_zone(zone);
|
||||
array = _o_array_alloc_with_zone(zone);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_alloc(void)
|
||||
o_array_t *
|
||||
o_array_alloc(void)
|
||||
{
|
||||
return objects_array_alloc_with_zone(0);
|
||||
return o_array_alloc_with_zone(0);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_zone(NSZone *zone)
|
||||
o_array_t *
|
||||
o_array_with_zone(NSZone *zone)
|
||||
{
|
||||
return objects_array_init(objects_array_alloc_with_zone(zone));
|
||||
return o_array_init(o_array_alloc_with_zone(zone));
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_zone_with_callbacks(NSZone *zone,
|
||||
objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_with_zone_with_callbacks(NSZone *zone,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_array_init_with_callbacks(objects_array_alloc_with_zone(zone),
|
||||
return o_array_init_with_callbacks(o_array_alloc_with_zone(zone),
|
||||
callbacks);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_with_callbacks(objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_with_callbacks(o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_array_init_with_callbacks(objects_array_alloc(), callbacks);
|
||||
return o_array_init_with_callbacks(o_array_alloc(), callbacks);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_char_p(void)
|
||||
o_array_t *
|
||||
o_array_of_char_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_char_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_char_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_non_owned_void_p(void)
|
||||
o_array_t *
|
||||
o_array_of_non_owned_void_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_non_owned_void_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_non_owned_void_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_owned_void_p(void)
|
||||
o_array_t *
|
||||
o_array_of_owned_void_p(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_owned_void_p);
|
||||
return o_array_with_callbacks(o_callbacks_for_owned_void_p);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_int(void)
|
||||
o_array_t *
|
||||
o_array_of_int(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_int);
|
||||
return o_array_with_callbacks(o_callbacks_for_int);
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_of_id(void)
|
||||
o_array_t *
|
||||
o_array_of_id(void)
|
||||
{
|
||||
return objects_array_with_callbacks(objects_callbacks_for_id);
|
||||
return o_array_with_callbacks(o_callbacks_for_id);
|
||||
}
|
||||
|
||||
/** Initializing **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init_with_callbacks(objects_array_t *array,
|
||||
objects_callbacks_t callbacks)
|
||||
o_array_t *
|
||||
o_array_init_with_callbacks(o_array_t *array,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
if (array != 0)
|
||||
{
|
||||
|
@ -479,14 +479,14 @@ objects_array_init_with_callbacks(objects_array_t *array,
|
|||
size_t capacity = 15;
|
||||
|
||||
/* Record the element callbacks. */
|
||||
array->callbacks = objects_callbacks_standardize(callbacks);
|
||||
array->callbacks = o_callbacks_standardize(callbacks);
|
||||
|
||||
/* Initialize ARRAY's information. */
|
||||
array->element_count = 0;
|
||||
array->slot_count = capacity + 1;
|
||||
|
||||
/* Make some new slots. */
|
||||
array->slots = _objects_array_new_slots(array, capacity + 1);
|
||||
array->slots = _o_array_new_slots(array, capacity + 1);
|
||||
|
||||
/* Get the sorted slots ready for later use. */
|
||||
array->sorted_slots = 0;
|
||||
|
@ -495,33 +495,33 @@ objects_array_init_with_callbacks(objects_array_t *array,
|
|||
return array;
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init (objects_array_t *array)
|
||||
o_array_t *
|
||||
o_array_init (o_array_t *array)
|
||||
{
|
||||
return objects_array_init_with_callbacks (array,
|
||||
objects_callbacks_standard());
|
||||
return o_array_init_with_callbacks (array,
|
||||
o_callbacks_standard());
|
||||
}
|
||||
|
||||
objects_array_t *
|
||||
objects_array_init_from_array (objects_array_t *array, objects_array_t *old_array)
|
||||
o_array_t *
|
||||
o_array_init_from_array (o_array_t *array, o_array_t *old_array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
size_t index;
|
||||
const void *element;
|
||||
|
||||
/* Initialize ARRAY in the usual way. */
|
||||
objects_array_init_with_callbacks (array,
|
||||
objects_array_element_callbacks (old_array));
|
||||
o_array_init_with_callbacks (array,
|
||||
o_array_element_callbacks (old_array));
|
||||
|
||||
/* Get an enumerator for OLD_ARRAY. */
|
||||
enumerator = objects_array_enumerator (old_array);
|
||||
enumerator = o_array_enumerator (old_array);
|
||||
|
||||
/* Step through OLD_ARRAY's elements, putting them at the proper
|
||||
* index in ARRAY. */
|
||||
while (objects_array_enumerator_next_index_and_element (&enumerator,
|
||||
while (o_array_enumerator_next_index_and_element (&enumerator,
|
||||
&index, &element))
|
||||
{
|
||||
objects_array_at_index_put_element (array, index, element);
|
||||
o_array_at_index_put_element (array, index, element);
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -530,20 +530,20 @@ objects_array_init_from_array (objects_array_t *array, objects_array_t *old_arra
|
|||
/** Destroying **/
|
||||
|
||||
void
|
||||
objects_array_dealloc(objects_array_t *array)
|
||||
o_array_dealloc(o_array_t *array)
|
||||
{
|
||||
if (array != 0)
|
||||
{
|
||||
/* Empty out ARRAY. */
|
||||
objects_array_empty (array);
|
||||
o_array_empty (array);
|
||||
|
||||
/* Free up its slots. */
|
||||
_objects_array_free_slots (array, array->slots);
|
||||
_o_array_free_slots (array, array->slots);
|
||||
|
||||
/* FIXME: What about ARRAY's sorted slots? */
|
||||
|
||||
/* Free up ARRAY itself. */
|
||||
_objects_array_dealloc (array);
|
||||
_o_array_dealloc (array);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -552,29 +552,29 @@ objects_array_dealloc(objects_array_t *array)
|
|||
/** Searching **/
|
||||
|
||||
const void *
|
||||
objects_array_element_at_index (objects_array_t *array, size_t index)
|
||||
o_array_element_at_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_bucket_t *bucket = _objects_array_bucket_for_index (array, index);
|
||||
o_array_bucket_t *bucket = _o_array_bucket_for_index (array, index);
|
||||
|
||||
if (bucket != 0)
|
||||
return bucket->element;
|
||||
else
|
||||
/* If `bucket' is 0, then the requested index is unused. */
|
||||
/* There's no bucket, so... */
|
||||
return objects_array_not_an_element_marker (array);
|
||||
return o_array_not_an_element_marker (array);
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_array_index_of_element (objects_array_t *array, const void *element)
|
||||
o_array_index_of_element (o_array_t *array, const void *element)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < array->slot_count; ++i)
|
||||
{
|
||||
objects_array_bucket_t *bucket = array->slots[i];
|
||||
o_array_bucket_t *bucket = array->slots[i];
|
||||
|
||||
if (bucket != 0)
|
||||
if (objects_is_equal (objects_array_element_callbacks (array),
|
||||
if (o_is_equal (o_array_element_callbacks (array),
|
||||
bucket->element,
|
||||
element,
|
||||
array))
|
||||
|
@ -585,82 +585,82 @@ objects_array_index_of_element (objects_array_t *array, const void *element)
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_contains_element (objects_array_t *array, const void *element)
|
||||
o_array_contains_element (o_array_t *array, const void *element)
|
||||
{
|
||||
/* Note that this search is quite inefficient. */
|
||||
return objects_array_index_of_element (array, element) < (array->slot_count);
|
||||
return o_array_index_of_element (array, element) < (array->slot_count);
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements (objects_array_t *array)
|
||||
o_array_all_elements (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_enumerator(array);
|
||||
enumerator = o_array_enumerator(array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker(array);
|
||||
elements[i] = o_array_not_an_element_marker(array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements_ascending (objects_array_t *array)
|
||||
o_array_all_elements_ascending (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_ascending_enumerator (array);
|
||||
enumerator = o_array_ascending_enumerator (array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker (array);
|
||||
elements[i] = o_array_not_an_element_marker (array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
}
|
||||
|
||||
const void **
|
||||
objects_array_all_elements_descending (objects_array_t *array)
|
||||
o_array_all_elements_descending (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void **elements;
|
||||
size_t count, i;
|
||||
|
||||
count = objects_array_count (array);
|
||||
count = o_array_count (array);
|
||||
|
||||
/* Set aside space to hold the elements. */
|
||||
elements = (const void **)NSZoneCalloc(objects_array_zone(array),
|
||||
elements = (const void **)NSZoneCalloc(o_array_zone(array),
|
||||
count + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
enumerator = objects_array_descending_enumerator (array);
|
||||
enumerator = o_array_descending_enumerator (array);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
objects_array_enumerator_next_element (&enumerator, elements + i);
|
||||
o_array_enumerator_next_element (&enumerator, elements + i);
|
||||
|
||||
elements[i] = objects_array_not_an_element_marker (array);
|
||||
elements[i] = o_array_not_an_element_marker (array);
|
||||
|
||||
/* We're done, so heave it back. */
|
||||
return elements;
|
||||
|
@ -669,36 +669,36 @@ objects_array_all_elements_descending (objects_array_t *array)
|
|||
/** Removing **/
|
||||
|
||||
void
|
||||
objects_array_remove_element_at_index (objects_array_t *array, size_t index)
|
||||
o_array_remove_element_at_index (o_array_t *array, size_t index)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* Get the bucket that might be there. */
|
||||
bucket = _objects_array_bucket_for_index (array, index);
|
||||
bucket = _o_array_bucket_for_index (array, index);
|
||||
|
||||
/* If there's a bucket at the index, then we empty its slot out. */
|
||||
if (bucket != 0)
|
||||
_objects_array_empty_slot (array, _objects_array_slot_for_index (array, index));
|
||||
_o_array_empty_slot (array, _o_array_slot_for_index (array, index));
|
||||
|
||||
/* Finally, we return. */
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_array_remove_element_known_present (objects_array_t *array,
|
||||
o_array_remove_element_known_present (o_array_t *array,
|
||||
const void *element)
|
||||
{
|
||||
objects_array_remove_element_at_index (array,
|
||||
objects_array_index_of_element (array,
|
||||
o_array_remove_element_at_index (array,
|
||||
o_array_index_of_element (array,
|
||||
element));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_array_remove_element (objects_array_t *array, const void *element)
|
||||
o_array_remove_element (o_array_t *array, const void *element)
|
||||
{
|
||||
if (objects_array_contains_element (array, element))
|
||||
objects_array_remove_element_known_present (array, element);
|
||||
if (o_array_contains_element (array, element))
|
||||
o_array_remove_element_known_present (array, element);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -706,62 +706,62 @@ objects_array_remove_element (objects_array_t *array, const void *element)
|
|||
/** Adding **/
|
||||
|
||||
const void *
|
||||
objects_array_at_index_put_element (objects_array_t *array,
|
||||
o_array_at_index_put_element (o_array_t *array,
|
||||
size_t index,
|
||||
const void *element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
/* Clean out anything that's already there. */
|
||||
objects_array_remove_element_at_index (array, index);
|
||||
o_array_remove_element_at_index (array, index);
|
||||
|
||||
/* Make a bucket for our information. */
|
||||
bucket = _objects_array_new_bucket (array, index, element);
|
||||
bucket = _o_array_new_bucket (array, index, element);
|
||||
|
||||
/* Put our bucket in the array. */
|
||||
_objects_array_insert_bucket (array, bucket);
|
||||
_o_array_insert_bucket (array, bucket);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
/** Enumerating **/
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_ascending_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_ascending_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 1;
|
||||
enumerator.is_ascending = 1;
|
||||
enumerator.index = 0;
|
||||
|
||||
_objects_array_make_sorted_slots (array);
|
||||
_o_array_make_sorted_slots (array);
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_descending_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_descending_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 1;
|
||||
enumerator.is_ascending = 0;
|
||||
/* The `+ 1' is so that we have `0' as a known ending condition.
|
||||
* See `_objects_array_enumerator_next_bucket()'. */
|
||||
* See `_o_array_enumerator_next_bucket()'. */
|
||||
enumerator.index = array->element_count + 1;
|
||||
|
||||
_objects_array_make_sorted_slots (array);
|
||||
_o_array_make_sorted_slots (array);
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
objects_array_enumerator_t
|
||||
objects_array_enumerator (objects_array_t *array)
|
||||
o_array_enumerator_t
|
||||
o_array_enumerator (o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
|
||||
enumerator.array = array;
|
||||
enumerator.is_sorted = 0;
|
||||
|
@ -772,13 +772,13 @@ objects_array_enumerator (objects_array_t *array)
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_index_and_element (o_array_enumerator_t * enumerator,
|
||||
size_t * index,
|
||||
const void **element)
|
||||
{
|
||||
objects_array_bucket_t *bucket;
|
||||
o_array_bucket_t *bucket;
|
||||
|
||||
bucket = _objects_array_enumerator_next_bucket (enumerator);
|
||||
bucket = _o_array_enumerator_next_bucket (enumerator);
|
||||
|
||||
if (bucket != 0)
|
||||
{
|
||||
|
@ -791,7 +791,7 @@ objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * en
|
|||
else
|
||||
{
|
||||
if (element != 0)
|
||||
*element = objects_array_not_an_element_marker (enumerator->array);
|
||||
*element = o_array_not_an_element_marker (enumerator->array);
|
||||
if (index != 0)
|
||||
*index = 0;
|
||||
return 0;
|
||||
|
@ -799,19 +799,19 @@ objects_array_enumerator_next_index_and_element (objects_array_enumerator_t * en
|
|||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_element (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_element (o_array_enumerator_t * enumerator,
|
||||
const void **element)
|
||||
{
|
||||
return objects_array_enumerator_next_index_and_element (enumerator,
|
||||
return o_array_enumerator_next_index_and_element (enumerator,
|
||||
0,
|
||||
element);
|
||||
}
|
||||
|
||||
int
|
||||
objects_array_enumerator_next_index (objects_array_enumerator_t * enumerator,
|
||||
o_array_enumerator_next_index (o_array_enumerator_t * enumerator,
|
||||
size_t * index)
|
||||
{
|
||||
return objects_array_enumerator_next_index_and_element (enumerator,
|
||||
return o_array_enumerator_next_index_and_element (enumerator,
|
||||
index,
|
||||
0);
|
||||
}
|
||||
|
@ -819,14 +819,14 @@ objects_array_enumerator_next_index (objects_array_enumerator_t * enumerator,
|
|||
/** Comparing **/
|
||||
|
||||
int
|
||||
objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array2)
|
||||
o_array_is_equal_to_array (o_array_t *array1, o_array_t *array2)
|
||||
{
|
||||
size_t a, b;
|
||||
const void *m, *n;
|
||||
objects_array_enumerator_t e, f;
|
||||
o_array_enumerator_t e, f;
|
||||
|
||||
a = objects_array_count (array1);
|
||||
b = objects_array_count (array2);
|
||||
a = o_array_count (array1);
|
||||
b = o_array_count (array2);
|
||||
|
||||
if (a < b)
|
||||
return (b - a);
|
||||
|
@ -834,11 +834,11 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
return (a - b);
|
||||
|
||||
/* Get ascending enumerators for each of the two arrays. */
|
||||
e = objects_array_ascending_enumerator (array1);
|
||||
e = objects_array_ascending_enumerator (array1);
|
||||
e = o_array_ascending_enumerator (array1);
|
||||
e = o_array_ascending_enumerator (array1);
|
||||
|
||||
while (objects_array_enumerator_next_index_and_element (&e, &a, &m)
|
||||
&& objects_array_enumerator_next_index_and_element (&f, &b, &n))
|
||||
while (o_array_enumerator_next_index_and_element (&e, &a, &m)
|
||||
&& o_array_enumerator_next_index_and_element (&f, &b, &n))
|
||||
{
|
||||
int c, d;
|
||||
|
||||
|
@ -847,11 +847,11 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
if (a > b)
|
||||
return (a - b);
|
||||
|
||||
c = objects_compare (objects_array_element_callbacks (array1), m, n, array1);
|
||||
c = o_compare (o_array_element_callbacks (array1), m, n, array1);
|
||||
if (c != 0)
|
||||
return c;
|
||||
|
||||
d = objects_compare (objects_array_element_callbacks (array2), n, m, array2);
|
||||
d = o_compare (o_array_element_callbacks (array2), n, m, array2);
|
||||
if (d != 0)
|
||||
return d;
|
||||
}
|
||||
|
@ -861,8 +861,8 @@ objects_array_is_equal_to_array (objects_array_t *array1, objects_array_t *array
|
|||
|
||||
/** Mapping **/
|
||||
|
||||
objects_array_t *
|
||||
objects_array_map_elements(objects_array_t *array,
|
||||
o_array_t *
|
||||
o_array_map_elements(o_array_t *array,
|
||||
const void *(*fcn) (const void *, const void *),
|
||||
const void *user_data)
|
||||
{
|
||||
|
@ -872,38 +872,38 @@ objects_array_map_elements(objects_array_t *array,
|
|||
|
||||
/** Miscellaneous **/
|
||||
|
||||
objects_hash_t *
|
||||
objects_hash_init_from_array (objects_hash_t * hash, objects_array_t *array)
|
||||
o_hash_t *
|
||||
o_hash_init_from_array (o_hash_t * hash, o_array_t *array)
|
||||
{
|
||||
objects_array_enumerator_t enumerator;
|
||||
o_array_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
/* NOTE: If ARRAY contains multiple elements of the same equivalence
|
||||
* class, it is indeterminate which will end up in HASH. This
|
||||
* shouldn't matter, though. */
|
||||
enumerator = objects_array_enumerator (array);
|
||||
enumerator = o_array_enumerator (array);
|
||||
|
||||
/* Just walk through ARRAY's elements and add them to HASH. */
|
||||
while (objects_array_enumerator_next_element (&enumerator, &element))
|
||||
objects_hash_add_element (hash, element);
|
||||
while (o_array_enumerator_next_element (&enumerator, &element))
|
||||
o_hash_add_element (hash, element);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
// objects_chash_t *
|
||||
// objects_chash_init_from_array (objects_chash_t * chash, objects_array_t *array)
|
||||
// o_chash_t *
|
||||
// o_chash_init_from_array (o_chash_t * chash, o_array_t *array)
|
||||
// {
|
||||
// objects_array_enumerator_t enumerator;
|
||||
// o_array_enumerator_t enumerator;
|
||||
// const void *element;
|
||||
//
|
||||
// /* NOTE: If ARRAY contains multiple elements of the same equivalence
|
||||
// * class, it is indeterminate which will end up in CHASH. This
|
||||
// * shouldn't matter, though. */
|
||||
// enumerator = objects_array_enumerator (array);
|
||||
// enumerator = o_array_enumerator (array);
|
||||
//
|
||||
// /* Just walk through ARRAY's elements and add them to CHASH. */
|
||||
// while (objects_array_enumerator_next_element (&enumerator, &element))
|
||||
// objects_chash_add_element (chash, element);
|
||||
// while (o_array_enumerator_next_element (&enumerator, &element))
|
||||
// o_chash_add_element (chash, element);
|
||||
//
|
||||
// return chash;
|
||||
// }
|
||||
|
|
|
@ -30,14 +30,14 @@
|
|||
/**** Type, Constant, and Macro Definitions **********************************/
|
||||
|
||||
/* WARNING: Don't change this unless you know what you're getting into! */
|
||||
static objects_callbacks_t ___objects_callbacks_standard =
|
||||
static o_callbacks_t ___o_callbacks_standard =
|
||||
{
|
||||
(objects_hash_func_t) objects_non_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_non_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_non_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) objects_non_owned_void_p_retain,
|
||||
(objects_release_func_t) objects_non_owned_void_p_release,
|
||||
(objects_describe_func_t) objects_non_owned_void_p_describe,
|
||||
(o_hash_func_t) o_non_owned_void_p_hash,
|
||||
(o_compare_func_t) o_non_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_non_owned_void_p_is_equal,
|
||||
(o_retain_func_t) o_non_owned_void_p_retain,
|
||||
(o_release_func_t) o_non_owned_void_p_release,
|
||||
(o_describe_func_t) o_non_owned_void_p_describe,
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -45,31 +45,31 @@ static objects_callbacks_t ___objects_callbacks_standard =
|
|||
|
||||
/** Getting the standard callbacks... **/
|
||||
|
||||
objects_callbacks_t
|
||||
objects_callbacks_standard(void)
|
||||
o_callbacks_t
|
||||
o_callbacks_standard(void)
|
||||
{
|
||||
return ___objects_callbacks_standard;
|
||||
return ___o_callbacks_standard;
|
||||
}
|
||||
|
||||
/** Standardizing callbacks... **/
|
||||
|
||||
objects_callbacks_t
|
||||
objects_callbacks_standardize(objects_callbacks_t callbacks)
|
||||
o_callbacks_t
|
||||
o_callbacks_standardize(o_callbacks_t callbacks)
|
||||
{
|
||||
if (callbacks.hash == 0)
|
||||
callbacks.hash = objects_callbacks_standard().hash;
|
||||
callbacks.hash = o_callbacks_standard().hash;
|
||||
|
||||
if (callbacks.compare == 0 && callbacks.is_equal == 0)
|
||||
{
|
||||
callbacks.compare = objects_callbacks_standard().compare;
|
||||
callbacks.is_equal = objects_callbacks_standard().is_equal;
|
||||
callbacks.compare = o_callbacks_standard().compare;
|
||||
callbacks.is_equal = o_callbacks_standard().is_equal;
|
||||
}
|
||||
|
||||
if (callbacks.retain == 0)
|
||||
callbacks.retain = objects_callbacks_standard().retain;
|
||||
callbacks.retain = o_callbacks_standard().retain;
|
||||
|
||||
if (callbacks.release == 0)
|
||||
callbacks.release = objects_callbacks_standard().release;
|
||||
callbacks.release = o_callbacks_standard().release;
|
||||
|
||||
return callbacks;
|
||||
}
|
||||
|
@ -77,18 +77,18 @@ objects_callbacks_standardize(objects_callbacks_t callbacks)
|
|||
/** Using callbacks... **/
|
||||
|
||||
size_t
|
||||
objects_hash(objects_callbacks_t callbacks,
|
||||
o_hash(o_callbacks_t callbacks,
|
||||
const void *thing,
|
||||
void *user_data)
|
||||
{
|
||||
if (callbacks.hash != 0)
|
||||
return callbacks.hash(thing, user_data);
|
||||
else
|
||||
return objects_callbacks_standard().hash(thing, user_data);
|
||||
return o_callbacks_standard().hash(thing, user_data);
|
||||
}
|
||||
|
||||
int
|
||||
objects_compare(objects_callbacks_t callbacks,
|
||||
o_compare(o_callbacks_t callbacks,
|
||||
const void *thing1,
|
||||
const void *thing2,
|
||||
void *user_data)
|
||||
|
@ -98,11 +98,11 @@ objects_compare(objects_callbacks_t callbacks,
|
|||
else if (callbacks.is_equal != 0)
|
||||
return !(callbacks.is_equal(thing1, thing2, user_data));
|
||||
else
|
||||
return objects_callbacks_standard().compare(thing1, thing2, user_data);
|
||||
return o_callbacks_standard().compare(thing1, thing2, user_data);
|
||||
}
|
||||
|
||||
int
|
||||
objects_is_equal(objects_callbacks_t callbacks,
|
||||
o_is_equal(o_callbacks_t callbacks,
|
||||
const void *thing1,
|
||||
const void *thing2,
|
||||
void *user_data)
|
||||
|
@ -112,40 +112,40 @@ objects_is_equal(objects_callbacks_t callbacks,
|
|||
else if (callbacks.compare != 0)
|
||||
return !(callbacks.compare(thing1, thing2, user_data));
|
||||
else
|
||||
return objects_callbacks_standard().is_equal(thing1, thing2, user_data);
|
||||
return o_callbacks_standard().is_equal(thing1, thing2, user_data);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_retain(objects_callbacks_t callbacks,
|
||||
o_retain(o_callbacks_t callbacks,
|
||||
const void *thing,
|
||||
void *user_data)
|
||||
{
|
||||
if (callbacks.retain != 0)
|
||||
return callbacks.retain(thing, user_data);
|
||||
else
|
||||
return objects_callbacks_standard().retain(thing, user_data);
|
||||
return o_callbacks_standard().retain(thing, user_data);
|
||||
}
|
||||
|
||||
void
|
||||
objects_release(objects_callbacks_t callbacks,
|
||||
o_release(o_callbacks_t callbacks,
|
||||
void *thing,
|
||||
void *user_data)
|
||||
{
|
||||
if (callbacks.release != 0)
|
||||
callbacks.release (thing, user_data);
|
||||
else
|
||||
objects_callbacks_standard().release(thing, user_data);
|
||||
o_callbacks_standard().release(thing, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_describe(objects_callbacks_t callbacks,
|
||||
o_describe(o_callbacks_t callbacks,
|
||||
const void *thing,
|
||||
void *user_data)
|
||||
{
|
||||
if (callbacks.release != 0)
|
||||
return callbacks.describe(thing, user_data);
|
||||
else
|
||||
return objects_callbacks_standard().describe(thing, user_data);
|
||||
return o_callbacks_standard().describe(thing, user_data);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,23 +33,23 @@
|
|||
/* FIXME: Is this right?!? */
|
||||
#define _OBJECTS_NOT_A_CHAR_P_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_a_char_p_marker = _OBJECTS_NOT_A_CHAR_P_MARKER;
|
||||
const void *o_not_a_char_p_marker = _OBJECTS_NOT_A_CHAR_P_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_char_p =
|
||||
o_callbacks_t o_callbacks_for_char_p =
|
||||
{
|
||||
(objects_hash_func_t) objects_char_p_hash,
|
||||
(objects_compare_func_t) objects_char_p_compare,
|
||||
(objects_is_equal_func_t) objects_char_p_is_equal,
|
||||
(objects_retain_func_t) objects_char_p_retain,
|
||||
(objects_release_func_t) objects_char_p_release,
|
||||
(objects_describe_func_t) objects_char_p_describe,
|
||||
(o_hash_func_t) o_char_p_hash,
|
||||
(o_compare_func_t) o_char_p_compare,
|
||||
(o_is_equal_func_t) o_char_p_is_equal,
|
||||
(o_retain_func_t) o_char_p_retain,
|
||||
(o_release_func_t) o_char_p_release,
|
||||
(o_describe_func_t) o_char_p_describe,
|
||||
_OBJECTS_NOT_A_CHAR_P_MARKER
|
||||
};
|
||||
|
||||
/**** Function Implementations ***********************************************/
|
||||
|
||||
size_t
|
||||
objects_char_p_hash(const char *cptr)
|
||||
o_char_p_hash(const char *cptr)
|
||||
{
|
||||
register const char *s = cptr;
|
||||
register size_t h = 0;
|
||||
|
@ -62,7 +62,7 @@ objects_char_p_hash(const char *cptr)
|
|||
}
|
||||
|
||||
int
|
||||
objects_char_p_compare(const char *cptr, const char *dptr)
|
||||
o_char_p_compare(const char *cptr, const char *dptr)
|
||||
{
|
||||
register const char *s = (char *) cptr;
|
||||
register const char *t = (char *) dptr;
|
||||
|
@ -90,7 +90,7 @@ objects_char_p_compare(const char *cptr, const char *dptr)
|
|||
* internationalization here. CPTR and DPTR are taken to be C strings
|
||||
* in the default (seven or) eight bit character encoding. */
|
||||
int
|
||||
objects_char_p_is_equal(const char *cptr, const char *dptr)
|
||||
o_char_p_is_equal(const char *cptr, const char *dptr)
|
||||
{
|
||||
register const char *s = cptr;
|
||||
register const char *t = dptr;
|
||||
|
@ -113,19 +113,19 @@ objects_char_p_is_equal(const char *cptr, const char *dptr)
|
|||
}
|
||||
|
||||
const void *
|
||||
objects_char_p_retain(const char *cptr)
|
||||
o_char_p_retain(const char *cptr)
|
||||
{
|
||||
return (const void *)cptr;
|
||||
}
|
||||
|
||||
void
|
||||
objects_char_p_release(char *cptr)
|
||||
o_char_p_release(char *cptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_char_p_describe(const char *cptr)
|
||||
o_char_p_describe(const char *cptr)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return nil;
|
||||
|
|
|
@ -34,16 +34,16 @@
|
|||
/* FIXME: Is this right?!? */
|
||||
#define _OBJECTS_NOT_AN_ID_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_an_id_marker = _OBJECTS_NOT_AN_ID_MARKER;
|
||||
const void *o_not_an_id_marker = _OBJECTS_NOT_AN_ID_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_id =
|
||||
o_callbacks_t o_callbacks_for_id =
|
||||
{
|
||||
(objects_hash_func_t) objects_id_hash,
|
||||
(objects_compare_func_t) objects_id_compare,
|
||||
(objects_is_equal_func_t) objects_id_is_equal,
|
||||
(objects_retain_func_t) objects_id_retain,
|
||||
(objects_release_func_t) objects_id_release,
|
||||
(objects_describe_func_t) objects_id_describe,
|
||||
(o_hash_func_t) o_id_hash,
|
||||
(o_compare_func_t) o_id_compare,
|
||||
(o_is_equal_func_t) o_id_is_equal,
|
||||
(o_retain_func_t) o_id_retain,
|
||||
(o_release_func_t) o_id_release,
|
||||
(o_describe_func_t) o_id_describe,
|
||||
_OBJECTS_NOT_AN_ID_MARKER
|
||||
};
|
||||
|
||||
|
@ -57,38 +57,38 @@ objects_callbacks_t objects_callbacks_for_id =
|
|||
* that there was already a built-in call to do this sort of thing. */
|
||||
|
||||
size_t
|
||||
objects_id_hash(id obj)
|
||||
o_id_hash(id obj)
|
||||
{
|
||||
return (size_t)[obj hash];
|
||||
}
|
||||
|
||||
int
|
||||
objects_id_compare(id obj, id jbo)
|
||||
o_id_compare(id obj, id jbo)
|
||||
{
|
||||
return (int)[obj compare:jbo];
|
||||
}
|
||||
|
||||
int
|
||||
objects_id_is_equal(id obj, id jbo)
|
||||
o_id_is_equal(id obj, id jbo)
|
||||
{
|
||||
return (int)[obj isEqual:jbo];
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_id_retain(id obj)
|
||||
o_id_retain(id obj)
|
||||
{
|
||||
return (const void *)[obj retain];
|
||||
}
|
||||
|
||||
void
|
||||
objects_id_release(id obj)
|
||||
o_id_release(id obj)
|
||||
{
|
||||
[obj release];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_id_describe(id obj)
|
||||
o_id_describe(id obj)
|
||||
{
|
||||
return [obj description];
|
||||
}
|
||||
|
|
|
@ -33,16 +33,16 @@
|
|||
/* FIXME: This isn't right. Fix it. */
|
||||
#define _OBJECTS_NOT_AN_INT_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_an_int_marker = _OBJECTS_NOT_AN_INT_MARKER;
|
||||
const void *o_not_an_int_marker = _OBJECTS_NOT_AN_INT_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_int =
|
||||
o_callbacks_t o_callbacks_for_int =
|
||||
{
|
||||
(objects_hash_func_t) objects_int_hash,
|
||||
(objects_compare_func_t) objects_int_compare,
|
||||
(objects_is_equal_func_t) objects_int_is_equal,
|
||||
(objects_retain_func_t) objects_int_retain,
|
||||
(objects_release_func_t) objects_int_release,
|
||||
(objects_describe_func_t) objects_int_describe,
|
||||
(o_hash_func_t) o_int_hash,
|
||||
(o_compare_func_t) o_int_compare,
|
||||
(o_is_equal_func_t) o_int_is_equal,
|
||||
(o_retain_func_t) o_int_retain,
|
||||
(o_release_func_t) o_int_release,
|
||||
(o_describe_func_t) o_int_describe,
|
||||
_OBJECTS_NOT_AN_INT_MARKER
|
||||
};
|
||||
|
||||
|
@ -53,37 +53,37 @@ objects_callbacks_t objects_callbacks_for_int =
|
|||
* but what can I do? */
|
||||
|
||||
size_t
|
||||
objects_int_hash(int i)
|
||||
o_int_hash(int i)
|
||||
{
|
||||
return (size_t)i;
|
||||
}
|
||||
|
||||
int
|
||||
objects_int_compare(int i, int j)
|
||||
o_int_compare(int i, int j)
|
||||
{
|
||||
return i - j;
|
||||
}
|
||||
|
||||
int
|
||||
objects_int_is_equal(int i, int j)
|
||||
o_int_is_equal(int i, int j)
|
||||
{
|
||||
return i == j;
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_int_retain(int i)
|
||||
o_int_retain(int i)
|
||||
{
|
||||
return (const void *)i;
|
||||
}
|
||||
|
||||
void
|
||||
objects_int_release(int i)
|
||||
o_int_release(int i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_int_describe(int i)
|
||||
o_int_describe(int i)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return nil;
|
||||
|
|
|
@ -33,29 +33,29 @@
|
|||
/* FIXME: Is this right?!? */
|
||||
#define _OBJECTS_NOT_AN_INT_P_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_an_int_p_marker = _OBJECTS_NOT_AN_INT_P_MARKER;
|
||||
const void *o_not_an_int_p_marker = _OBJECTS_NOT_AN_INT_P_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_int_p =
|
||||
o_callbacks_t o_callbacks_for_int_p =
|
||||
{
|
||||
(objects_hash_func_t) objects_int_p_hash,
|
||||
(objects_compare_func_t) objects_int_p_compare,
|
||||
(objects_is_equal_func_t) objects_int_p_is_equal,
|
||||
(objects_retain_func_t) objects_int_p_retain,
|
||||
(objects_release_func_t) objects_int_p_release,
|
||||
(objects_describe_func_t) objects_int_p_describe,
|
||||
(o_hash_func_t) o_int_p_hash,
|
||||
(o_compare_func_t) o_int_p_compare,
|
||||
(o_is_equal_func_t) o_int_p_is_equal,
|
||||
(o_retain_func_t) o_int_p_retain,
|
||||
(o_release_func_t) o_int_p_release,
|
||||
(o_describe_func_t) o_int_p_describe,
|
||||
_OBJECTS_NOT_AN_INT_P_MARKER
|
||||
};
|
||||
|
||||
/**** Function Implementations ***********************************************/
|
||||
|
||||
size_t
|
||||
objects_int_p_hash(const int *iptr)
|
||||
o_int_p_hash(const int *iptr)
|
||||
{
|
||||
return (size_t)(iptr) / 4;
|
||||
}
|
||||
|
||||
int
|
||||
objects_int_p_compare(const int *iptr, const int *jptr)
|
||||
o_int_p_compare(const int *iptr, const int *jptr)
|
||||
{
|
||||
if (iptr < jptr)
|
||||
return -1;
|
||||
|
@ -66,26 +66,26 @@ objects_int_p_compare(const int *iptr, const int *jptr)
|
|||
}
|
||||
|
||||
int
|
||||
objects_int_p_is_equal(const int *iptr, const int *jptr)
|
||||
o_int_p_is_equal(const int *iptr, const int *jptr)
|
||||
{
|
||||
/* FIXME: Is this right? If not, what else could it be? */
|
||||
return iptr == jptr;
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_int_p_retain(const int *iptr)
|
||||
o_int_p_retain(const int *iptr)
|
||||
{
|
||||
return (const void *)iptr;
|
||||
}
|
||||
|
||||
void
|
||||
objects_int_p_release(int *iptr)
|
||||
o_int_p_release(int *iptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_int_p_describe(const int *iptr)
|
||||
o_int_p_describe(const int *iptr)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return nil;
|
||||
|
|
|
@ -33,38 +33,38 @@
|
|||
/* FIXME: Is this right?!? */
|
||||
#define _OBJECTS_NOT_A_VOID_P_MARKER (const void *)(-1)
|
||||
|
||||
const void *objects_not_a_void_p_marker = _OBJECTS_NOT_A_VOID_P_MARKER;
|
||||
const void *o_not_a_void_p_marker = _OBJECTS_NOT_A_VOID_P_MARKER;
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_non_owned_void_p =
|
||||
o_callbacks_t o_callbacks_for_non_owned_void_p =
|
||||
{
|
||||
(objects_hash_func_t) objects_non_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_non_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_non_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) objects_non_owned_void_p_retain,
|
||||
(objects_release_func_t) objects_non_owned_void_p_release,
|
||||
(o_hash_func_t) o_non_owned_void_p_hash,
|
||||
(o_compare_func_t) o_non_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_non_owned_void_p_is_equal,
|
||||
(o_retain_func_t) o_non_owned_void_p_retain,
|
||||
(o_release_func_t) o_non_owned_void_p_release,
|
||||
_OBJECTS_NOT_A_VOID_P_MARKER
|
||||
};
|
||||
|
||||
objects_callbacks_t objects_callbacks_for_owned_void_p =
|
||||
o_callbacks_t o_callbacks_for_owned_void_p =
|
||||
{
|
||||
(objects_hash_func_t) objects_owned_void_p_hash,
|
||||
(objects_compare_func_t) objects_owned_void_p_compare,
|
||||
(objects_is_equal_func_t) objects_owned_void_p_is_equal,
|
||||
(objects_retain_func_t) objects_owned_void_p_retain,
|
||||
(objects_release_func_t) objects_owned_void_p_release,
|
||||
(o_hash_func_t) o_owned_void_p_hash,
|
||||
(o_compare_func_t) o_owned_void_p_compare,
|
||||
(o_is_equal_func_t) o_owned_void_p_is_equal,
|
||||
(o_retain_func_t) o_owned_void_p_retain,
|
||||
(o_release_func_t) o_owned_void_p_release,
|
||||
_OBJECTS_NOT_A_VOID_P_MARKER
|
||||
};
|
||||
|
||||
/**** Function Implementations ***********************************************/
|
||||
|
||||
size_t
|
||||
objects_non_owned_void_p_hash(register const void *cptr)
|
||||
o_non_owned_void_p_hash(register const void *cptr)
|
||||
{
|
||||
return ((size_t) cptr)/4;
|
||||
}
|
||||
|
||||
int
|
||||
objects_non_owned_void_p_compare(register const void *cptr,
|
||||
o_non_owned_void_p_compare(register const void *cptr,
|
||||
register const void *dptr)
|
||||
{
|
||||
if (cptr == dptr)
|
||||
|
@ -76,34 +76,34 @@ objects_non_owned_void_p_compare(register const void *cptr,
|
|||
}
|
||||
|
||||
int
|
||||
objects_non_owned_void_p_is_equal(register const void *cptr,
|
||||
o_non_owned_void_p_is_equal(register const void *cptr,
|
||||
register const void *dptr)
|
||||
{
|
||||
return (cptr == dptr);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_non_owned_void_p_retain(const void *cptr)
|
||||
o_non_owned_void_p_retain(const void *cptr)
|
||||
{
|
||||
return cptr;
|
||||
}
|
||||
|
||||
void
|
||||
objects_non_owned_void_p_release(void *cptr)
|
||||
o_non_owned_void_p_release(void *cptr)
|
||||
{
|
||||
/* We don't own CPTR, so we don't release it. */
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_non_owned_void_p_describe(const void *cptr)
|
||||
o_non_owned_void_p_describe(const void *cptr)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return nil;
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_owned_void_p_hash(register const void *cptr)
|
||||
o_owned_void_p_hash(register const void *cptr)
|
||||
{
|
||||
/* We divide by 4 because many machines align
|
||||
* memory on word boundaries. */
|
||||
|
@ -111,7 +111,7 @@ objects_owned_void_p_hash(register const void *cptr)
|
|||
}
|
||||
|
||||
int
|
||||
objects_owned_void_p_compare(register const void *cptr,
|
||||
o_owned_void_p_compare(register const void *cptr,
|
||||
register const void *dptr)
|
||||
{
|
||||
if (cptr == dptr)
|
||||
|
@ -123,27 +123,27 @@ objects_owned_void_p_compare(register const void *cptr,
|
|||
}
|
||||
|
||||
int
|
||||
objects_owned_void_p_is_equal(register const void *cptr,
|
||||
o_owned_void_p_is_equal(register const void *cptr,
|
||||
register const void *dptr)
|
||||
{
|
||||
return (cptr == dptr);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_owned_void_p_retain(const void *cptr)
|
||||
o_owned_void_p_retain(const void *cptr)
|
||||
{
|
||||
return cptr;
|
||||
}
|
||||
|
||||
void
|
||||
objects_owned_void_p_release(void *cptr)
|
||||
o_owned_void_p_release(void *cptr)
|
||||
{
|
||||
free((void *)cptr);
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *
|
||||
objects_owned_void_p_describe(const void *obj)
|
||||
o_owned_void_p_describe(const void *obj)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return nil;
|
||||
|
|
566
Source/o_hash.m
566
Source/o_hash.m
File diff suppressed because it is too large
Load diff
428
Source/o_list.m
428
Source/o_list.m
|
@ -34,7 +34,7 @@
|
|||
/** Background functions **/
|
||||
|
||||
static inline void
|
||||
_objects_list_remove_node_from_its_list (objects_list_node_t * node)
|
||||
_o_list_remove_node_from_its_list (o_list_node_t * node)
|
||||
{
|
||||
if (node->list->first_node == node)
|
||||
node->list->first_node = node->next_in_list;
|
||||
|
@ -51,19 +51,19 @@ _objects_list_remove_node_from_its_list (objects_list_node_t * node)
|
|||
return;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_new_node (objects_list_t *list, const void *element)
|
||||
static inline o_list_node_t *
|
||||
_o_list_new_node (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = NSZoneMalloc(objects_list_zone(list), sizeof(objects_list_node_t));
|
||||
node = NSZoneMalloc(o_list_zone(list), sizeof(o_list_node_t));
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
node->list = list;
|
||||
node->next_in_list = 0;
|
||||
node->prev_in_list = 0;
|
||||
objects_retain (objects_list_element_callbacks (list), element, list);
|
||||
o_retain (o_list_element_callbacks (list), element, list);
|
||||
node->element = element;
|
||||
}
|
||||
|
||||
|
@ -71,19 +71,19 @@ _objects_list_new_node (objects_list_t *list, const void *element)
|
|||
}
|
||||
|
||||
void
|
||||
_objects_list_free_node (objects_list_t *list, objects_list_node_t * node)
|
||||
_o_list_free_node (o_list_t *list, o_list_node_t * node)
|
||||
{
|
||||
objects_release (objects_list_element_callbacks (node->list),
|
||||
o_release (o_list_element_callbacks (node->list),
|
||||
(void*)node->element,
|
||||
node->list);
|
||||
NSZoneFree(objects_list_zone(list), node);
|
||||
NSZoneFree(o_list_zone(list), node);
|
||||
return;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_nth_node (objects_list_t *list, long int n)
|
||||
static inline o_list_node_t *
|
||||
_o_list_nth_node (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
|
@ -111,12 +111,12 @@ _objects_list_nth_node (objects_list_t *list, long int n)
|
|||
return node;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_nth_node_for_element (objects_list_t *list,
|
||||
static inline o_list_node_t *
|
||||
_o_list_nth_node_for_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
|
||||
while (node != 0 && n != 0)
|
||||
{
|
||||
if (objects_is_equal (objects_list_element_callbacks (list), element, node->element, list))
|
||||
if (o_is_equal (o_list_element_callbacks (list), element, node->element, list))
|
||||
++n;
|
||||
if (n != 0)
|
||||
node = node->prev_in_list;
|
||||
|
@ -138,7 +138,7 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
|
||||
while (node != 0 && n != 0)
|
||||
{
|
||||
if (objects_is_equal (objects_list_element_callbacks (list), element, node->element, list))
|
||||
if (o_is_equal (o_list_element_callbacks (list), element, node->element, list))
|
||||
--n;
|
||||
if (n != 0)
|
||||
node = node->next_in_list;
|
||||
|
@ -148,10 +148,10 @@ _objects_list_nth_node_for_element (objects_list_t *list,
|
|||
return node;
|
||||
}
|
||||
|
||||
static inline objects_list_node_t *
|
||||
_objects_list_enumerator_next_node (objects_list_enumerator_t *enumerator)
|
||||
static inline o_list_node_t *
|
||||
_o_list_enumerator_next_node (o_list_enumerator_t *enumerator)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
/* Remember ENUMERATOR's current node. */
|
||||
node = enumerator->node;
|
||||
|
@ -173,56 +173,56 @@ _objects_list_enumerator_next_node (objects_list_enumerator_t *enumerator)
|
|||
/** Gathering statistics **/
|
||||
|
||||
size_t
|
||||
objects_list_count (objects_list_t *list)
|
||||
o_list_count (o_list_t *list)
|
||||
{
|
||||
return list->element_count;
|
||||
}
|
||||
|
||||
size_t
|
||||
objects_list_capacity (objects_list_t *list)
|
||||
o_list_capacity (o_list_t *list)
|
||||
{
|
||||
return list->element_count;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_check (objects_list_t *list)
|
||||
o_list_check (o_list_t *list)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_contains_element (objects_list_t *list, const void *element)
|
||||
o_list_contains_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *member;
|
||||
|
||||
objects_list_enumerator (list);
|
||||
o_list_enumerator (list);
|
||||
|
||||
while (objects_list_enumerator_next_element (&enumerator, &member))
|
||||
if (objects_compare (objects_list_element_callbacks (list), element, member, list))
|
||||
while (o_list_enumerator_next_element (&enumerator, &member))
|
||||
if (o_compare (o_list_element_callbacks (list), element, member, list))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
objects_list_is_empty (objects_list_t *list)
|
||||
o_list_is_empty (o_list_t *list)
|
||||
{
|
||||
return objects_list_count (list) == 0;
|
||||
return o_list_count (list) == 0;
|
||||
}
|
||||
|
||||
/** Enumerating **/
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_enumerator (o_list_t *list)
|
||||
{
|
||||
return objects_list_forward_enumerator (list);
|
||||
return o_list_forward_enumerator (list);
|
||||
}
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_forward_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_forward_enumerator (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
|
||||
/* Make sure ENUMERATOR knows its list. */
|
||||
enumerator.list = list;
|
||||
|
@ -236,10 +236,10 @@ objects_list_forward_enumerator (objects_list_t *list)
|
|||
return enumerator;
|
||||
}
|
||||
|
||||
objects_list_enumerator_t
|
||||
objects_list_reverse_enumerator (objects_list_t *list)
|
||||
o_list_enumerator_t
|
||||
o_list_reverse_enumerator (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
|
||||
/* Make sure ENUMERATOR knows its list. */
|
||||
enumerator.list = list;
|
||||
|
@ -254,14 +254,14 @@ objects_list_reverse_enumerator (objects_list_t *list)
|
|||
}
|
||||
|
||||
int
|
||||
objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
||||
o_list_enumerator_next_element (o_list_enumerator_t *enumerator,
|
||||
const void **element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
/* Try and get the next node in the enumeration represented by
|
||||
* ENUMERATOR. */
|
||||
node = _objects_list_enumerator_next_node (enumerator);
|
||||
node = _o_list_enumerator_next_node (enumerator);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
|||
{
|
||||
/* If NODE isn't real, then we return the ``bogus'' indicator. */
|
||||
if (element != 0)
|
||||
*element = objects_list_not_an_element_marker (enumerator->list);
|
||||
*element = o_list_not_an_element_marker (enumerator->list);
|
||||
|
||||
/* Indicate that the enumeration is over. */
|
||||
return 0;
|
||||
|
@ -286,63 +286,63 @@ objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator,
|
|||
/** Searching **/
|
||||
|
||||
const void *
|
||||
objects_list_element (objects_list_t *list, const void *element)
|
||||
o_list_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, 0, element);
|
||||
node = _o_list_nth_node_for_element (list, 0, element);
|
||||
|
||||
if (node != 0)
|
||||
return node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_nth_element (objects_list_t *list, long int n)
|
||||
o_list_nth_element (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
return node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_first_element (objects_list_t *list)
|
||||
o_list_first_element (o_list_t *list)
|
||||
{
|
||||
if (list->first_node != 0)
|
||||
return list->first_node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_last_element (objects_list_t *list)
|
||||
o_list_last_element (o_list_t *list)
|
||||
{
|
||||
if (list->last_node != 0)
|
||||
return list->last_node->element;
|
||||
else
|
||||
return objects_list_not_an_element_marker (list);
|
||||
return o_list_not_an_element_marker (list);
|
||||
}
|
||||
|
||||
/** Obtaining elements **/
|
||||
|
||||
const void **
|
||||
objects_list_all_elements (objects_list_t *list)
|
||||
o_list_all_elements (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void **array;
|
||||
size_t i;
|
||||
|
||||
array = NSZoneCalloc(objects_list_zone(list),
|
||||
objects_list_count(list) + 1,
|
||||
array = NSZoneCalloc(o_list_zone(list),
|
||||
o_list_count(list) + 1,
|
||||
sizeof(const void *));
|
||||
|
||||
for (i = 0; objects_list_enumerator_next_element (&enumerator, array + i); ++i);
|
||||
for (i = 0; o_list_enumerator_next_element (&enumerator, array + i); ++i);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
@ -350,38 +350,38 @@ objects_list_all_elements (objects_list_t *list)
|
|||
/** Adding elements **/
|
||||
|
||||
const void *
|
||||
objects_list_append_element (objects_list_t *list, const void *element)
|
||||
o_list_append_element (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element (list, -1, element);
|
||||
return o_list_at_index_insert_element (list, -1, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_append_element_if_absent (objects_list_t *list, const void *element)
|
||||
o_list_append_element_if_absent (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element_if_absent (list, -1, element);
|
||||
return o_list_at_index_insert_element_if_absent (list, -1, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_prepend_element (objects_list_t *list, const void *element)
|
||||
o_list_prepend_element (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element (list, 0, element);
|
||||
return o_list_at_index_insert_element (list, 0, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_prepend_element_if_absent (objects_list_t *list, const void *element)
|
||||
o_list_prepend_element_if_absent (o_list_t *list, const void *element)
|
||||
{
|
||||
return objects_list_at_index_insert_element_if_absent (list, 0, element);
|
||||
return o_list_at_index_insert_element_if_absent (list, 0, element);
|
||||
}
|
||||
|
||||
const void *
|
||||
objects_list_at_index_insert_element(objects_list_t *list,
|
||||
o_list_at_index_insert_element(o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *anode, *bnode, *new_node, *node;
|
||||
o_list_node_t *anode, *bnode, *new_node, *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
new_node = _objects_list_new_node (list, element);
|
||||
node = _o_list_nth_node (list, n);
|
||||
new_node = _o_list_new_node (list, element);
|
||||
|
||||
if (new_node == 0)
|
||||
/* FIXME: Make this a *little* more graceful, for goodness' sake! */
|
||||
|
@ -437,87 +437,87 @@ objects_list_at_index_insert_element(objects_list_t *list,
|
|||
}
|
||||
|
||||
const void *
|
||||
objects_list_at_index_insert_element_if_absent (objects_list_t *list,
|
||||
o_list_at_index_insert_element_if_absent (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
if (!objects_list_contains_element (list, element))
|
||||
return objects_list_at_index_insert_element (list, n, element);
|
||||
if (!o_list_contains_element (list, element))
|
||||
return o_list_at_index_insert_element (list, n, element);
|
||||
else
|
||||
return objects_list_element (list, element);
|
||||
return o_list_element (list, element);
|
||||
}
|
||||
|
||||
/** Removing elements **/
|
||||
|
||||
void
|
||||
objects_list_remove_nth_occurrance_of_element (objects_list_t *list,
|
||||
o_list_remove_nth_occurrance_of_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, n, element);
|
||||
node = _o_list_nth_node_for_element (list, n, element);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_element (objects_list_t *list, const void *element)
|
||||
o_list_remove_element (o_list_t *list, const void *element)
|
||||
{
|
||||
objects_list_remove_nth_occurrance_of_element (list, 0, element);
|
||||
o_list_remove_nth_occurrance_of_element (list, 0, element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_nth_element (objects_list_t *list, long int n)
|
||||
o_list_remove_nth_element (o_list_t *list, long int n)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_first_element (objects_list_t *list)
|
||||
o_list_remove_first_element (o_list_t *list)
|
||||
{
|
||||
objects_list_remove_nth_element (list, 0);
|
||||
o_list_remove_nth_element (list, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_remove_last_element (objects_list_t *list)
|
||||
o_list_remove_last_element (o_list_t *list)
|
||||
{
|
||||
objects_list_remove_nth_element (list, -1);
|
||||
o_list_remove_nth_element (list, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Emptying **/
|
||||
|
||||
void
|
||||
objects_list_empty (objects_list_t *list)
|
||||
o_list_empty (o_list_t *list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
objects_list_node_t *node;
|
||||
o_list_enumerator_t enumerator;
|
||||
o_list_node_t *node;
|
||||
|
||||
enumerator = objects_list_enumerator (list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
while ((node = _objects_list_enumerator_next_node (&enumerator)) != 0)
|
||||
while ((node = _o_list_enumerator_next_node (&enumerator)) != 0)
|
||||
{
|
||||
_objects_list_remove_node_from_its_list (node);
|
||||
_objects_list_free_node (list, node);
|
||||
_o_list_remove_node_from_its_list (node);
|
||||
_o_list_free_node (list, node);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -526,19 +526,19 @@ objects_list_empty (objects_list_t *list)
|
|||
/** Replacing **/
|
||||
|
||||
void
|
||||
objects_list_replace_nth_occurrance_of_element (objects_list_t *list,
|
||||
o_list_replace_nth_occurrance_of_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *old_element,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node_for_element (list, n, old_element);
|
||||
node = _o_list_nth_node_for_element (list, n, old_element);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
objects_retain (objects_list_element_callbacks (list), new_element, list);
|
||||
objects_release (objects_list_element_callbacks (list),
|
||||
o_retain (o_list_element_callbacks (list), new_element, list);
|
||||
o_release (o_list_element_callbacks (list),
|
||||
(void*)node->element,
|
||||
list);
|
||||
node->element = new_element;
|
||||
|
@ -548,27 +548,27 @@ objects_list_replace_nth_occurrance_of_element (objects_list_t *list,
|
|||
}
|
||||
|
||||
void
|
||||
objects_list_replace_element (objects_list_t *list,
|
||||
o_list_replace_element (o_list_t *list,
|
||||
const void *old_element,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_occurrance_of_element (list, 0, old_element, new_element);
|
||||
o_list_replace_nth_occurrance_of_element (list, 0, old_element, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_replace_nth_element (objects_list_t *list,
|
||||
o_list_replace_nth_element (o_list_t *list,
|
||||
long int n,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_node_t *node;
|
||||
o_list_node_t *node;
|
||||
|
||||
node = _objects_list_nth_node (list, n);
|
||||
node = _o_list_nth_node (list, n);
|
||||
|
||||
if (node != 0)
|
||||
{
|
||||
objects_retain (objects_list_element_callbacks (list), new_element, list);
|
||||
objects_release (objects_list_element_callbacks (list),
|
||||
o_retain (o_list_element_callbacks (list), new_element, list);
|
||||
o_release (o_list_element_callbacks (list),
|
||||
(void*)node->element,
|
||||
list);
|
||||
node->element = new_element;
|
||||
|
@ -578,105 +578,105 @@ objects_list_replace_nth_element (objects_list_t *list,
|
|||
}
|
||||
|
||||
void
|
||||
objects_list_replace_first_element (objects_list_t *list,
|
||||
o_list_replace_first_element (o_list_t *list,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_element (list, 0, new_element);
|
||||
o_list_replace_nth_element (list, 0, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
objects_list_replace_last_element (objects_list_t *list,
|
||||
o_list_replace_last_element (o_list_t *list,
|
||||
const void *new_element)
|
||||
{
|
||||
objects_list_replace_nth_element (list, -1, new_element);
|
||||
o_list_replace_nth_element (list, -1, new_element);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Creating **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_alloc_with_zone (NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_alloc_with_zone (NSZone *zone)
|
||||
{
|
||||
objects_list_t *list;
|
||||
o_list_t *list;
|
||||
|
||||
list = _objects_list_alloc_with_zone(zone);
|
||||
list = _o_list_alloc_with_zone(zone);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_alloc (void)
|
||||
o_list_t *
|
||||
o_list_alloc (void)
|
||||
{
|
||||
return objects_list_alloc_with_zone (0);
|
||||
return o_list_alloc_with_zone (0);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list (void)
|
||||
o_list_t *
|
||||
o_list (void)
|
||||
{
|
||||
return objects_list_init (objects_list_alloc ());
|
||||
return o_list_init (o_list_alloc ());
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_zone (NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_with_zone (NSZone *zone)
|
||||
{
|
||||
return objects_list_init (objects_list_alloc_with_zone(zone));
|
||||
return o_list_init (o_list_alloc_with_zone(zone));
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_zone_with_callbacks (NSZone *zone,
|
||||
objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_with_zone_with_callbacks (NSZone *zone,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_list_init_with_callbacks(objects_list_alloc_with_zone(zone),
|
||||
return o_list_init_with_callbacks(o_list_alloc_with_zone(zone),
|
||||
callbacks);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_with_callbacks (objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_with_callbacks (o_callbacks_t callbacks)
|
||||
{
|
||||
return objects_list_init_with_callbacks (objects_list_alloc (), callbacks);
|
||||
return o_list_init_with_callbacks (o_list_alloc (), callbacks);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_char_p (void)
|
||||
o_list_t *
|
||||
o_list_of_char_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_char_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_char_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_int (void)
|
||||
o_list_t *
|
||||
o_list_of_int (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_int);
|
||||
return o_list_with_callbacks (o_callbacks_for_int);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_non_owned_void_p (void)
|
||||
o_list_t *
|
||||
o_list_of_non_owned_void_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_non_owned_void_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_non_owned_void_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_owned_void_p (void)
|
||||
o_list_t *
|
||||
o_list_of_owned_void_p (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_owned_void_p);
|
||||
return o_list_with_callbacks (o_callbacks_for_owned_void_p);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_of_id (void)
|
||||
o_list_t *
|
||||
o_list_of_id (void)
|
||||
{
|
||||
return objects_list_with_callbacks (objects_callbacks_for_id);
|
||||
return o_list_with_callbacks (o_callbacks_for_id);
|
||||
}
|
||||
|
||||
/** Initializing **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init (objects_list_t *list)
|
||||
o_list_t *
|
||||
o_list_init (o_list_t *list)
|
||||
{
|
||||
return objects_list_init_with_callbacks (list, objects_callbacks_standard());
|
||||
return o_list_init_with_callbacks (list, o_callbacks_standard());
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init_with_callbacks (objects_list_t *list, objects_callbacks_t callbacks)
|
||||
o_list_t *
|
||||
o_list_init_with_callbacks (o_list_t *list, o_callbacks_t callbacks)
|
||||
{
|
||||
if (list != 0)
|
||||
{
|
||||
|
@ -690,15 +690,15 @@ objects_list_init_with_callbacks (objects_list_t *list, objects_callbacks_t call
|
|||
return list;
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
||||
o_list_t *
|
||||
o_list_init_from_list (o_list_t *list, o_list_t *old_list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
if (list != 0)
|
||||
{
|
||||
list->callbacks = objects_list_element_callbacks (old_list);
|
||||
list->callbacks = o_list_element_callbacks (old_list);
|
||||
list->element_count = 0;
|
||||
list->node_count = 0;
|
||||
list->first_node = 0;
|
||||
|
@ -707,12 +707,12 @@ objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
|||
if (old_list != 0)
|
||||
{
|
||||
/* Get a forward enumerator for OLD_LIST. */
|
||||
enumerator = objects_list_forward_enumerator (old_list);
|
||||
enumerator = o_list_forward_enumerator (old_list);
|
||||
|
||||
/* Walk from the beginning to the end of OLD_LIST, and add each
|
||||
* element to the end of LIST. */
|
||||
while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
objects_list_at_index_insert_element (list, -1, element);
|
||||
while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
o_list_at_index_insert_element (list, -1, element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -722,13 +722,13 @@ objects_list_init_from_list (objects_list_t *list, objects_list_t *old_list)
|
|||
/** Destroying **/
|
||||
|
||||
void
|
||||
objects_list_dealloc (objects_list_t *list)
|
||||
o_list_dealloc (o_list_t *list)
|
||||
{
|
||||
/* Empty LIST out. */
|
||||
objects_list_empty (list);
|
||||
o_list_empty (list);
|
||||
|
||||
/* Get rid of LIST. */
|
||||
_objects_list_dealloc (list);
|
||||
_o_list_dealloc (list);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ objects_list_dealloc (objects_list_t *list)
|
|||
/** Comparing **/
|
||||
|
||||
int
|
||||
objects_list_is_equal_to_list(objects_list_t *list, objects_list_t *other_list)
|
||||
o_list_is_equal_to_list(o_list_t *list, o_list_t *other_list)
|
||||
{
|
||||
/* FIXME: Code this. */
|
||||
return 0;
|
||||
|
@ -744,81 +744,81 @@ objects_list_is_equal_to_list(objects_list_t *list, objects_list_t *other_list)
|
|||
|
||||
/** Concatenating **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_append_list (objects_list_t *base_list, objects_list_t *suffix_list)
|
||||
o_list_t *
|
||||
o_list_append_list (o_list_t *base_list, o_list_t *suffix_list)
|
||||
{
|
||||
return objects_list_at_index_insert_list (base_list, -1, suffix_list);
|
||||
return o_list_at_index_insert_list (base_list, -1, suffix_list);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_prepend_list (objects_list_t *base_list, objects_list_t *prefix_list)
|
||||
o_list_t *
|
||||
o_list_prepend_list (o_list_t *base_list, o_list_t *prefix_list)
|
||||
{
|
||||
return objects_list_at_index_insert_list (base_list, 0, prefix_list);
|
||||
return o_list_at_index_insert_list (base_list, 0, prefix_list);
|
||||
}
|
||||
|
||||
/* FIXME: I was lazy when I wrote this next one. It can easily be
|
||||
* sped up. Do it. */
|
||||
objects_list_t *
|
||||
objects_list_at_index_insert_list(objects_list_t *base_list,
|
||||
o_list_t *
|
||||
o_list_at_index_insert_list(o_list_t *base_list,
|
||||
long int n,
|
||||
objects_list_t *infix_list)
|
||||
o_list_t *infix_list)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
if (n < 0)
|
||||
enumerator = objects_list_forward_enumerator(infix_list);
|
||||
enumerator = o_list_forward_enumerator(infix_list);
|
||||
else /* (n >= 0) */
|
||||
enumerator = objects_list_reverse_enumerator(infix_list);
|
||||
enumerator = o_list_reverse_enumerator(infix_list);
|
||||
|
||||
while (objects_list_enumerator_next_element(&enumerator, &element))
|
||||
objects_list_at_index_insert_element(base_list, n, element);
|
||||
while (o_list_enumerator_next_element(&enumerator, &element))
|
||||
o_list_at_index_insert_element(base_list, n, element);
|
||||
|
||||
return base_list;
|
||||
}
|
||||
|
||||
/** Copying **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_copy (objects_list_t *old_list)
|
||||
o_list_t *
|
||||
o_list_copy (o_list_t *old_list)
|
||||
{
|
||||
return objects_list_copy_with_zone (old_list, 0);
|
||||
return o_list_copy_with_zone (old_list, 0);
|
||||
}
|
||||
|
||||
objects_list_t *
|
||||
objects_list_copy_with_zone (objects_list_t *old_list, NSZone *zone)
|
||||
o_list_t *
|
||||
o_list_copy_with_zone (o_list_t *old_list, NSZone *zone)
|
||||
{
|
||||
objects_list_t *list;
|
||||
o_list_t *list;
|
||||
|
||||
/* Allocate a new (low-level) copy of OLD_LIST. */
|
||||
list = _objects_list_copy_with_zone(old_list, zone);
|
||||
list = _o_list_copy_with_zone(old_list, zone);
|
||||
|
||||
/* Fill it in. */
|
||||
return objects_list_init_from_list (list, old_list);
|
||||
return o_list_init_from_list (list, old_list);
|
||||
}
|
||||
|
||||
/** Mapping **/
|
||||
|
||||
objects_list_t *
|
||||
objects_list_map_elements(objects_list_t *list,
|
||||
o_list_t *
|
||||
o_list_map_elements(o_list_t *list,
|
||||
const void *(*fcn)(const void *, void *),
|
||||
void *user_data)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
objects_list_node_t *node;
|
||||
objects_callbacks_t callbacks;
|
||||
o_list_enumerator_t enumerator;
|
||||
o_list_node_t *node;
|
||||
o_callbacks_t callbacks;
|
||||
|
||||
callbacks = objects_list_element_callbacks(list);
|
||||
enumerator = objects_list_enumerator (list);
|
||||
callbacks = o_list_element_callbacks(list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
while ((node = _objects_list_enumerator_next_node (&enumerator)) != 0)
|
||||
while ((node = _o_list_enumerator_next_node (&enumerator)) != 0)
|
||||
{
|
||||
const void *element;
|
||||
|
||||
element = (*fcn)(node->element, user_data);
|
||||
|
||||
objects_retain (callbacks, element, list);
|
||||
objects_release (callbacks, (void *)(node->element), list);
|
||||
o_retain (callbacks, element, list);
|
||||
o_release (callbacks, (void *)(node->element), list);
|
||||
|
||||
node->element = element;
|
||||
}
|
||||
|
@ -828,16 +828,16 @@ objects_list_map_elements(objects_list_t *list,
|
|||
|
||||
/** Creating other collections from lists **/
|
||||
|
||||
objects_hash_t *
|
||||
objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
||||
o_hash_t *
|
||||
o_hash_init_from_list (o_hash_t * hash, o_list_t *list)
|
||||
{
|
||||
if (hash != 0)
|
||||
{
|
||||
objects_list_enumerator_t enumerator;
|
||||
o_list_enumerator_t enumerator;
|
||||
const void *element;
|
||||
|
||||
/* Make a note of the callbacks for HASH. */
|
||||
hash->callbacks = objects_list_element_callbacks (list);
|
||||
hash->callbacks = o_list_element_callbacks (list);
|
||||
|
||||
/* Zero out the various counts. */
|
||||
hash->node_count = 0;
|
||||
|
@ -849,33 +849,33 @@ objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
|||
hash->buckets = 0;
|
||||
|
||||
/* Resize HASH to the given CAPACITY. */
|
||||
objects_hash_resize (hash, objects_list_capacity (list));
|
||||
o_hash_resize (hash, o_list_capacity (list));
|
||||
|
||||
/* Get an element enumerator for LIST. */
|
||||
enumerator = objects_list_enumerator (list);
|
||||
enumerator = o_list_enumerator (list);
|
||||
|
||||
/* Add LIST's elements to HASH, one at a time. Note that if LIST
|
||||
* contains multiple elements from the same equivalence class, it
|
||||
* is indeterminate which will end up in HASH. But this shouldn't
|
||||
* be a problem. */
|
||||
while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
objects_hash_add_element (hash, element);
|
||||
while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
o_hash_add_element (hash, element);
|
||||
}
|
||||
|
||||
/* Return the newly initialized HASH. */
|
||||
return hash;
|
||||
}
|
||||
|
||||
// objects_chash_t *
|
||||
// objects_chash_init_from_list (objects_chash_t * chash, objects_list_t *list)
|
||||
// o_chash_t *
|
||||
// o_chash_init_from_list (o_chash_t * chash, o_list_t *list)
|
||||
// {
|
||||
// if (chash != 0)
|
||||
// {
|
||||
// objects_list_enumerator_t enumerator;
|
||||
// o_list_enumerator_t enumerator;
|
||||
// const void *element;
|
||||
//
|
||||
// /* Make a note of the callbacks for CHASH. */
|
||||
// chash->callbacks = objects_list_element_callbacks (list);
|
||||
// chash->callbacks = o_list_element_callbacks (list);
|
||||
//
|
||||
// /* Zero out the various counts. */
|
||||
// chash->node_count = 0;
|
||||
|
@ -887,17 +887,17 @@ objects_hash_init_from_list (objects_hash_t * hash, objects_list_t *list)
|
|||
// chash->buckets = 0;
|
||||
//
|
||||
// /* Resize CHASH to the given CAPACITY. */
|
||||
// objects_chash_resize (chash, objects_list_capacity (list));
|
||||
// o_chash_resize (chash, o_list_capacity (list));
|
||||
//
|
||||
// /* Get an element enumerator for LIST. */
|
||||
// enumerator = objects_list_enumerator (list);
|
||||
// enumerator = o_list_enumerator (list);
|
||||
//
|
||||
// /* Add LIST's elements to CHASH, one at a time. Note that if LIST
|
||||
// * contains multiple elements from the same equivalence class, it
|
||||
// * is indeterminate which will end up in CHASH. But this shouldn't
|
||||
// * be a problem. */
|
||||
// while (objects_list_enumerator_next_element (&enumerator, &element))
|
||||
// objects_chash_add_element (chash, element);
|
||||
// while (o_list_enumerator_next_element (&enumerator, &element))
|
||||
// o_chash_add_element (chash, element);
|
||||
// }
|
||||
//
|
||||
// /* Return the newly initialized CHASH. */
|
||||
|
|
716
Source/o_map.m
716
Source/o_map.m
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
/* Implementation of objects_vprintf for GNU Objective C Class Library
|
||||
/* Implementation of o_vprintf for GNU Objective C Class Library
|
||||
|
||||
Reworked by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
@ -96,7 +96,7 @@ Cambridge, MA 02139, USA. */
|
|||
|
||||
|
||||
int
|
||||
objects_vprintf(void *stream,
|
||||
o_vprintf(void *stream,
|
||||
int (*write_func)(void*, char*, int len),
|
||||
const char *format, va_list args)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Implementation of objects_vscanf for GNU Objective C Class Library
|
||||
/* Implementation of o_vscanf for GNU Objective C Class Library
|
||||
|
||||
Reworked by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Date: July 1994
|
||||
|
@ -89,7 +89,7 @@ extern long strtol(const char *str, char** ptr, int base);
|
|||
FORMAT, using the argument list in ARGPTR.
|
||||
Return the number of assignments made, or -1 for an input error. */
|
||||
int
|
||||
objects_vscanf (void *stream,
|
||||
o_vscanf (void *stream,
|
||||
int (*inchar_func)(void*),
|
||||
void (*unchar_func)(void*,int),
|
||||
const char *format, va_list argptr)
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
/* Returns XX's magic number. */
|
||||
inline int
|
||||
objects_@XX@_magic_number(objects_@XX@_t *xx)
|
||||
o_@XX@_magic_number(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->magic_number;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ objects_@XX@_magic_number(objects_@XX@_t *xx)
|
|||
|
||||
/* Returns the zone used to create and maintain XX. */
|
||||
inline NSZone *
|
||||
objects_@XX@_zone(objects_@XX@_t *xx)
|
||||
o_@XX@_zone(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->zone;
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ objects_@XX@_zone(objects_@XX@_t *xx)
|
|||
|
||||
/* Returns the name that was given to XX. */
|
||||
inline NSString *
|
||||
objects_@XX@_name(objects_@XX@_t *xx)
|
||||
o_@XX@_name(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->name;
|
||||
}
|
||||
|
||||
/* Gives XX a name. */
|
||||
inline void
|
||||
objects_@XX@_set_name(objects_@XX@_t *xx, NSString *name)
|
||||
o_@XX@_set_name(o_@XX@_t *xx, NSString *name)
|
||||
{
|
||||
[name retain];
|
||||
[xx->name release];
|
||||
|
@ -74,7 +74,7 @@ objects_@XX@_set_name(objects_@XX@_t *xx, NSString *name)
|
|||
|
||||
/* Takes away XX's name. */
|
||||
inline void
|
||||
objects_@XX@_unset_name(objects_@XX@_t *xx)
|
||||
o_@XX@_unset_name(o_@XX@_t *xx)
|
||||
{
|
||||
[xx->name release];
|
||||
xx->name = nil;
|
||||
|
@ -86,7 +86,7 @@ objects_@XX@_unset_name(objects_@XX@_t *xx)
|
|||
/* Returns the (process-wide) unique serial number given to the
|
||||
* structure XX. See <gnustep/base/numbers.h> for more info. */
|
||||
inline size_t
|
||||
objects_@XX@_serial_number(objects_@XX@_t *xx)
|
||||
o_@XX@_serial_number(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->serial_number;
|
||||
}
|
||||
|
@ -94,12 +94,12 @@ objects_@XX@_serial_number(objects_@XX@_t *xx)
|
|||
/* Gives XX a new (process-wide) unique number. Numbers are not
|
||||
* reused. See <gnustep/base/numbers.h> for more info. */
|
||||
inline size_t
|
||||
_objects_@XX@_set_serial_number(objects_@XX@_t *xx)
|
||||
_o_@XX@_set_serial_number(o_@XX@_t *xx)
|
||||
{
|
||||
size_t old_number;
|
||||
|
||||
old_number = xx->serial_number;
|
||||
xx->serial_number = (___objects_number_serialized)++;
|
||||
xx->serial_number = (___o_number_serialized)++;
|
||||
|
||||
return old_number;
|
||||
}
|
||||
|
@ -107,13 +107,13 @@ _objects_@XX@_set_serial_number(objects_@XX@_t *xx)
|
|||
/** Extras **/
|
||||
|
||||
/* Sets the callbacks associated with XX's ``extra''. NOTE: This must
|
||||
* be done before calling `objects_@XX@_set_extra()', as these callbacks
|
||||
* be done before calling `o_@XX@_set_extra()', as these callbacks
|
||||
* are used in that routine. */
|
||||
inline objects_callbacks_t
|
||||
objects_@XX@_set_extra_callbacks(objects_@XX@_t *xx,
|
||||
objects_callbacks_t callbacks)
|
||||
inline o_callbacks_t
|
||||
o_@XX@_set_extra_callbacks(o_@XX@_t *xx,
|
||||
o_callbacks_t callbacks)
|
||||
{
|
||||
objects_callbacks_t old_callbacks;
|
||||
o_callbacks_t old_callbacks;
|
||||
|
||||
/* Remember the old callbacks for later. */
|
||||
old_callbacks = xx->extra_callbacks;
|
||||
|
@ -122,7 +122,7 @@ objects_@XX@_set_extra_callbacks(objects_@XX@_t *xx,
|
|||
xx->extra_callbacks = callbacks;
|
||||
|
||||
/* Release the old contents. */
|
||||
objects_release(old_callbacks, (void *)(xx->extra), xx);
|
||||
o_release(old_callbacks, (void *)(xx->extra), xx);
|
||||
|
||||
/* Set the contents to something noticible. */
|
||||
xx->extra = (xx->extra_callbacks).not_an_item_marker;
|
||||
|
@ -131,8 +131,8 @@ objects_@XX@_set_extra_callbacks(objects_@XX@_t *xx,
|
|||
}
|
||||
|
||||
/* Returns the callbacks associated with XX's ``extra''. */
|
||||
inline objects_callbacks_t
|
||||
objects_@XX@_extra_callbacks(objects_@XX@_t *xx)
|
||||
inline o_callbacks_t
|
||||
o_@XX@_extra_callbacks(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->extra_callbacks;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ objects_@XX@_extra_callbacks(objects_@XX@_t *xx)
|
|||
* structure carries around with it. Its use is
|
||||
* implementation-dependent. */
|
||||
inline const void *
|
||||
objects_@XX@_extra(objects_@XX@_t *xx)
|
||||
o_@XX@_extra(o_@XX@_t *xx)
|
||||
{
|
||||
return xx->extra;
|
||||
}
|
||||
|
@ -149,24 +149,24 @@ objects_@XX@_extra(objects_@XX@_t *xx)
|
|||
/* Sets XX's ``extra'', a little extra space that each structure
|
||||
* carries around with it. Its use is implementation-dependent. */
|
||||
inline const void *
|
||||
objects_@XX@_set_extra(objects_@XX@_t *xx, const void *extra)
|
||||
o_@XX@_set_extra(o_@XX@_t *xx, const void *extra)
|
||||
{
|
||||
const void *old_extra;
|
||||
|
||||
/* Out with the old, and in with the new. */
|
||||
old_extra = xx->extra;
|
||||
xx->extra = objects_retain(xx->extra_callbacks, extra, xx);
|
||||
objects_release(xx->extra_callbacks, (void *)old_extra, xx);
|
||||
xx->extra = o_retain(xx->extra_callbacks, extra, xx);
|
||||
o_release(xx->extra_callbacks, (void *)old_extra, xx);
|
||||
|
||||
return old_extra;
|
||||
}
|
||||
|
||||
/* Resets XX's ``extra''. */
|
||||
inline void
|
||||
objects_@XX@_unset_extra (objects_@XX@_t *xx)
|
||||
o_@XX@_unset_extra (o_@XX@_t *xx)
|
||||
{
|
||||
/* Release XX's extra. */
|
||||
objects_release(xx->extra_callbacks, (void *)(xx->extra), xx);
|
||||
o_release(xx->extra_callbacks, (void *)(xx->extra), xx);
|
||||
|
||||
/* Reset XX's extra. */
|
||||
xx->extra = (xx->extra_callbacks).not_an_item_marker;
|
||||
|
@ -177,26 +177,26 @@ objects_@XX@_unset_extra (objects_@XX@_t *xx)
|
|||
/** Low-level Creation and Destruction **/
|
||||
|
||||
/* Handles the universal, low-level allocation of structures. */
|
||||
inline objects_@XX@_t *
|
||||
_objects_@XX@_alloc_with_zone(NSZone *zone)
|
||||
inline o_@XX@_t *
|
||||
_o_@XX@_alloc_with_zone(NSZone *zone)
|
||||
{
|
||||
objects_@XX@_t *xx;
|
||||
o_@XX@_t *xx;
|
||||
|
||||
/* Try to allocate some space for XX. */
|
||||
xx = (objects_@XX@_t *) NSZoneMalloc(zone, sizeof(objects_@XX@_t));
|
||||
xx = (o_@XX@_t *) NSZoneMalloc(zone, sizeof(o_@XX@_t));
|
||||
|
||||
/* The `objects_malloc()' was successful. */
|
||||
/* The `o_malloc()' was successful. */
|
||||
if (xx != 0)
|
||||
{
|
||||
_objects_@XX@_set_serial_number(xx);
|
||||
_o_@XX@_set_serial_number(xx);
|
||||
xx->magic_number = _OBJECTS_MAGIC_@XX@;
|
||||
xx->name = 0;
|
||||
xx->zone = zone;
|
||||
xx->extra_callbacks = objects_callbacks_for_non_owned_void_p;
|
||||
xx->extra_callbacks = o_callbacks_for_non_owned_void_p;
|
||||
xx->extra = 0;
|
||||
|
||||
/* Increment the counter of allocated structures. */
|
||||
++(___objects_number_allocated);
|
||||
++(___o_number_allocated);
|
||||
}
|
||||
|
||||
return xx;
|
||||
|
@ -204,58 +204,58 @@ _objects_@XX@_alloc_with_zone(NSZone *zone)
|
|||
|
||||
/* Handles the universal, low-level deallocation of @XX@ structures. */
|
||||
inline void
|
||||
_objects_@XX@_dealloc(objects_@XX@_t *xx)
|
||||
_o_@XX@_dealloc(o_@XX@_t *xx)
|
||||
{
|
||||
/* Make sure XX is valid. */
|
||||
if (xx != 0)
|
||||
{
|
||||
/* Free up any space we needed to keep track of XX's name. */
|
||||
if (xx->name != 0)
|
||||
NSZoneFree(objects_@XX@_zone(xx), (char *)(xx->name));
|
||||
NSZoneFree(o_@XX@_zone(xx), (char *)(xx->name));
|
||||
|
||||
/* Release XX's extra. */
|
||||
objects_@XX@_unset_extra(xx);
|
||||
o_@XX@_unset_extra(xx);
|
||||
|
||||
/* Free up XX itself. */
|
||||
NSZoneFree(objects_@XX@_zone(xx), xx);
|
||||
NSZoneFree(o_@XX@_zone(xx), xx);
|
||||
|
||||
/* Increment the counter of deallocated structures. */
|
||||
++(___objects_number_deallocated);
|
||||
++(___o_number_deallocated);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Handles the low-level copying of structures. */
|
||||
inline objects_@XX@_t *
|
||||
_objects_@XX@_copy_with_zone(objects_@XX@_t *xx, NSZone *zone)
|
||||
inline o_@XX@_t *
|
||||
_o_@XX@_copy_with_zone(o_@XX@_t *xx, NSZone *zone)
|
||||
{
|
||||
objects_@XX@_t *new;
|
||||
o_@XX@_t *new;
|
||||
|
||||
/* Create a new structure. */
|
||||
new = _objects_@XX@_alloc_with_zone(zone);
|
||||
new = _o_@XX@_alloc_with_zone(zone);
|
||||
|
||||
if (new != 0)
|
||||
{
|
||||
/* Copy over XX's name. */
|
||||
objects_@XX@_set_name(new, objects_@XX@_name(xx));
|
||||
o_@XX@_set_name(new, o_@XX@_name(xx));
|
||||
|
||||
/* Copy over XX's extras. */
|
||||
objects_@XX@_set_extra_callbacks(new, objects_@XX@_extra_callbacks(xx));
|
||||
objects_@XX@_set_extra(new, objects_@XX@_extra(xx));
|
||||
o_@XX@_set_extra_callbacks(new, o_@XX@_extra_callbacks(xx));
|
||||
o_@XX@_set_extra(new, o_@XX@_extra(xx));
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
inline NSString *
|
||||
_objects_@XX@_description(objects_@XX@_t *xx)
|
||||
_o_@XX@_description(o_@XX@_t *xx)
|
||||
{
|
||||
return [NSString stringWithFormat:@"magic_number = %#x;\nserial_number = %d;\nname = %@;\nextra = %@;\nzone = %@;\n",
|
||||
objects_@XX@_magic_number(xx),
|
||||
objects_@XX@_serial_number(xx),
|
||||
objects_@XX@_name(xx),
|
||||
objects_describe(objects_@XX@_extra_callbacks(xx),
|
||||
objects_@XX@_extra(xx), xx),
|
||||
NSZoneName(objects_@XX@_zone(xx))];
|
||||
o_@XX@_magic_number(xx),
|
||||
o_@XX@_serial_number(xx),
|
||||
o_@XX@_name(xx),
|
||||
o_describe(o_@XX@_extra_callbacks(xx),
|
||||
o_@XX@_extra(xx), xx),
|
||||
NSZoneName(o_@XX@_zone(xx))];
|
||||
}
|
||||
|
|
|
@ -38,29 +38,29 @@
|
|||
/** Callbacks **/
|
||||
|
||||
/* Returns the callbacks associated with YY's keys. */
|
||||
objects_callbacks_t
|
||||
objects_@YY@_key_callbacks(objects_@YY@_t * yy)
|
||||
o_callbacks_t
|
||||
o_@YY@_key_callbacks(o_@YY@_t * yy)
|
||||
{
|
||||
return yy->key_callbacks;
|
||||
}
|
||||
|
||||
/* Returns the ``bogus'' marker associated with YY's keys. */
|
||||
const void *
|
||||
objects_@YY@_not_a_key_marker(objects_@YY@_t *yy)
|
||||
o_@YY@_not_a_key_marker(o_@YY@_t *yy)
|
||||
{
|
||||
return (yy->key_callbacks).not_an_item_marker;
|
||||
}
|
||||
|
||||
/* Returns the callbacks associated with YY's values. */
|
||||
objects_callbacks_t
|
||||
objects_@YY@_value_callbacks(objects_@YY@_t *yy)
|
||||
o_callbacks_t
|
||||
o_@YY@_value_callbacks(o_@YY@_t *yy)
|
||||
{
|
||||
return yy->value_callbacks;
|
||||
}
|
||||
|
||||
/* Returns the ``bogus'' marker associated with YY's values. */
|
||||
const void *
|
||||
objects_@YY@_not_a_value_marker(objects_@YY@_t *yy)
|
||||
o_@YY@_not_a_value_marker(o_@YY@_t *yy)
|
||||
{
|
||||
return (yy->value_callbacks).not_an_item_marker;
|
||||
}
|
||||
|
@ -70,15 +70,15 @@ objects_@YY@_not_a_value_marker(objects_@YY@_t *yy)
|
|||
/** Callbacks **/
|
||||
|
||||
/* Returns the callbacks associated with YY's elements. */
|
||||
objects_callbacks_t
|
||||
objects_@YY@_element_callbacks(objects_@YY@_t *yy)
|
||||
o_callbacks_t
|
||||
o_@YY@_element_callbacks(o_@YY@_t *yy)
|
||||
{
|
||||
return yy->callbacks;
|
||||
}
|
||||
|
||||
/* Returns the ``bogus'' marker associated with YY's elements. */
|
||||
const void *
|
||||
objects_@YY@_not_an_element_marker(objects_@YY@_t *yy)
|
||||
o_@YY@_not_an_element_marker(o_@YY@_t *yy)
|
||||
{
|
||||
return (yy->callbacks).not_an_item_marker;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <gnustep/base/preface.h>
|
||||
|
||||
const char gnustep_base_version[] = STRINGIFY (GNUSTEP_BASE_VERSION);
|
||||
const char objects_gcc_version[] = STRINGIFY (GNUSTEP_BASE_GCC_VERSION);
|
||||
const char o_gcc_version[] = STRINGIFY (GNUSTEP_BASE_GCC_VERSION);
|
||||
|
||||
#if NeXT_cc
|
||||
const char objects_NeXT_cc_version[] = STRINGIFY (NX_CURRENT_COMPILER_RELEASE);
|
||||
const char o_NeXT_cc_version[] = STRINGIFY (NX_CURRENT_COMPILER_RELEASE);
|
||||
#endif /* NeXT_cc */
|
||||
|
|
|
@ -74,7 +74,7 @@ extern double strtod(const char *str, char **ptr);
|
|||
FORMAT, using the argument list in ARG.
|
||||
Return the number of assignments made, or -1 for an input error. */
|
||||
int
|
||||
objects_vfscanf (FILE *s, const char *format, va_list argptr)
|
||||
o_vfscanf (FILE *s, const char *format, va_list argptr)
|
||||
{
|
||||
va_list arg = (va_list) argptr;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue