mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Overhaul for new collection class scheme to improve distributed
objects and NeXT-compatibility. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@966 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1c319c7279
commit
1809abb47f
2 changed files with 17 additions and 50 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <objects/IndexedCollection.h>
|
#include <objects/IndexedCollection.h>
|
||||||
#include <objects/IndexedCollectionPrivate.h>
|
#include <objects/IndexedCollectionPrivate.h>
|
||||||
#include <objects/MallocAddress.h>
|
#include <objects/MallocAddress.h>
|
||||||
|
#include <Foundation/NSValue.h>
|
||||||
/* memcpy(), strlen(), strcmp() are gcc builtin's */
|
/* memcpy(), strlen(), strcmp() are gcc builtin's */
|
||||||
|
|
||||||
@implementation NSGCString
|
@implementation NSGCString
|
||||||
|
@ -43,11 +44,15 @@
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) _collectionReleaseContents
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _collectionDealloc
|
||||||
{
|
{
|
||||||
if (_free_contents)
|
if (_free_contents)
|
||||||
OBJC_FREE(_contents_chars);
|
OBJC_FREE(_contents_chars);
|
||||||
[super dealloc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Class) classForConnectedCoder: aRmc
|
- (Class) classForConnectedCoder: aRmc
|
||||||
|
@ -124,12 +129,10 @@
|
||||||
|
|
||||||
// FOR IndexedCollection SUPPORT;
|
// FOR IndexedCollection SUPPORT;
|
||||||
|
|
||||||
- (elt) elementAtIndex: (unsigned)index
|
- objectAtIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
elt ret_elt;
|
|
||||||
CHECK_INDEX_RANGE_ERROR(index, _count);
|
CHECK_INDEX_RANGE_ERROR(index, _count);
|
||||||
ret_elt.char_u = _contents_chars[index];
|
return [NSNumber numberWithChar: _contents_chars[index]];
|
||||||
return ret_elt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -246,11 +249,10 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
|
|
||||||
/* xxx This should be made to return void, but we need to change
|
/* xxx This should be made to return void, but we need to change
|
||||||
IndexedCollecting and its conformers */
|
IndexedCollecting and its conformers */
|
||||||
- removeRange: (IndexRange)range
|
- (void) removeRange: (IndexRange)range
|
||||||
{
|
{
|
||||||
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self,
|
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self,
|
||||||
range.location, range.length);
|
range.location, range.length);
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) encodeWithCoder: aCoder
|
- (void) encodeWithCoder: aCoder
|
||||||
|
@ -292,7 +294,10 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
return _contents_chars[index];
|
return _contents_chars[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
- insertElement: (elt)newElement atIndex: (unsigned)index
|
|
||||||
|
// FOR IndexedCollection and OrderedCollection SUPPORT;
|
||||||
|
|
||||||
|
- (void) insertObject: newObject atIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
CHECK_INDEX_RANGE_ERROR(index, _count+1);
|
CHECK_INDEX_RANGE_ERROR(index, _count+1);
|
||||||
// one for the next char, one for the '\0';
|
// one for the next char, one for the '\0';
|
||||||
|
@ -302,28 +307,15 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
OBJC_REALLOC(_contents_chars, char, _capacity);
|
OBJC_REALLOC(_contents_chars, char, _capacity);
|
||||||
}
|
}
|
||||||
stringIncrementCountAndMakeHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
stringIncrementCountAndMakeHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
||||||
_contents_chars[index] = newElement.char_u;
|
_contents_chars[index] = [newObject charValue];
|
||||||
_contents_chars[_count] = '\0';
|
_contents_chars[_count] = '\0';
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (elt) removeElementAtIndex: (unsigned)index
|
- (void) removeObjectAtIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
elt ret;
|
|
||||||
|
|
||||||
CHECK_INDEX_RANGE_ERROR(index, _count);
|
CHECK_INDEX_RANGE_ERROR(index, _count);
|
||||||
ret = _contents_chars[index];
|
|
||||||
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
||||||
_contents_chars[_count] = '\0';
|
_contents_chars[_count] = '\0';
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (elt) elementAtIndex: (unsigned)index
|
|
||||||
{
|
|
||||||
elt ret_elt;
|
|
||||||
CHECK_INDEX_RANGE_ERROR(index, _count);
|
|
||||||
ret_elt.char_u = _contents_chars[index];
|
|
||||||
return ret_elt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -75,19 +75,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This override in mutable string classes */
|
/* This override in mutable string classes */
|
||||||
- empty
|
- (void) empty
|
||||||
{
|
{
|
||||||
[self subclassResponsibility:_cmd];
|
[self subclassResponsibility:_cmd];
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Override the designated initializer of superclass */
|
|
||||||
- initWithType: (const char *)contentEncoding
|
|
||||||
{
|
|
||||||
if (strcmp(contentEncoding, @encode(char)))
|
|
||||||
[self error:"invalid args to String initializer"];
|
|
||||||
[super initWithType:contentEncoding];
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCString: (const char*)aCharPtr length: (unsigned)aLength
|
- initWithCString: (const char*)aCharPtr length: (unsigned)aLength
|
||||||
|
@ -286,21 +276,6 @@
|
||||||
|
|
||||||
// TESTING;
|
// TESTING;
|
||||||
|
|
||||||
- (const char *) contentsDescription
|
|
||||||
{
|
|
||||||
return @encode(char);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (const char *) contentType
|
|
||||||
{
|
|
||||||
return @encode(char);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int(*)(elt,elt)) comparisonFunction
|
|
||||||
{
|
|
||||||
return elt_compare_chars;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (unsigned) hash
|
- (unsigned) hash
|
||||||
{
|
{
|
||||||
return elt_hash_string([self cString]);
|
return elt_hash_string([self cString]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue