* Source/GSArray.m:

(-[GSMutableArray _raiseRangeExceptionWithIndex:from:]):
        Declare private method obtained through behavior additions.
        (-[GSArray _raiseRangeExceptionWithIndex:from:]): Use
        'unsigned' in favor of 'int' for index and count.  Move
        private method to the top of implementation context to avoid
        warnings.
        (-[GSMutableArray insertObject:atIndex:]): Use 'unsigned' in
        favor of 'int' for index.
        (-[GSMutableArray replaceObjectAtIndex:withObject:]): Correct
        selector name and parameter of method call.
        (-[GSMutableArray sortUsingFunction:context:]): Correct
        prototype.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17963 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2003-10-24 09:27:09 +00:00
parent 034969baa0
commit 20704de08d
2 changed files with 41 additions and 24 deletions

View file

@ -1,3 +1,17 @@
2003-10-24 David Ayers <d.ayers@inode.at>
* Source/GSArray.m:
(-[GSMutableArray _raiseRangeExceptionWithIndex:from:]): Declare
private method obtained through behavior additions.
(-[GSArray _raiseRangeExceptionWithIndex:from:]): Use 'unsigned' in
favor of 'int' for index and count. Move private method to the
top of implementation context to avoid warnings.
(-[GSMutableArray insertObject:atIndex:]): Use 'unsigned' in favor
of 'int' for index.
(-[GSMutableArray replaceObjectAtIndex:withObject:]): Correct
selector name and parameter of method call.
(-[GSMutableArray sortUsingFunction:context:]): Correct prototype.
Fri Oct 24 07:55:00 2003 Stefan Urbanek <stefanu@altair.des.elf.stuba.sk>
* Source/GSArray.m: make exception messages more informative.

View file

@ -64,6 +64,10 @@ static Class GSInlineArrayClass;
}
@end
@interface GSMutableArray (GSArrayBehavior)
- (void) _raiseRangeExceptionWithIndex: (unsigned)index from: (SEL)sel;
@end
@interface GSPlaceholderArray : NSArray
{
}
@ -71,6 +75,26 @@ static Class GSInlineArrayClass;
@implementation GSArray
- (void) _raiseRangeExceptionWithIndex: (unsigned)index from: (SEL)sel
{
NSDictionary *info;
NSException *exception;
NSString *reason;
info = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInt: index], @"Index",
[NSNumber numberWithUnsignedInt: _count], @"Count",
self, @"Array", nil, nil];
reason = [NSString stringWithFormat: @"Index %d is out of range %d (in '%@')",
index, _count, NSStringFromSelector(sel)];
exception = [NSException exceptionWithName: NSRangeException
reason: reason
userInfo: info];
[exception raise];
}
+ (void) initialize
{
if (self == [GSArray class])
@ -315,27 +339,6 @@ static Class GSInlineArrayClass;
aBuffer[j++] = _contents_array[i];
}
}
- (void) _raiseRangeExceptionWithIndex: (int)index from: (SEL)sel
{
NSDictionary *info;
NSException *exception;
NSString *reason;
info = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: index], @"Index",
[NSNumber numberWithInt: _count], @"Count",
self, @"Array", nil, nil];
reason = [NSString stringWithFormat: @"Index %d is out of range %d (in '%@')",
index, _count, NSStringFromSelector(sel)];
exception = [NSException exceptionWithName: NSRangeException
reason: reason
userInfo: info];
[exception raise];
}
@end
@implementation GSInlineArray
@ -510,7 +513,7 @@ static Class GSInlineArrayClass;
NSDictionary *info;
info = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: index], @"Index",
[NSNumber numberWithUnsignedInt: index], @"Index",
self, @"Array", nil, nil];
exception = [NSException exceptionWithName: NSInvalidArgumentException
@ -681,7 +684,7 @@ static Class GSInlineArrayClass;
if (index >= _count)
{
[self _raiseRangeExceptionForIndex: index];
[self _raiseRangeExceptionWithIndex: index from: _cmd];
}
/*
* Swap objects in order so that there is always a valid object in the
@ -693,7 +696,7 @@ static Class GSInlineArrayClass;
RELEASE(obj);
}
- (void) sortUsingFunction: (int(*)(id,id,void*))compare
- (void) sortUsingFunction: (NSComparisonResult(*)(id,id,void*))compare
context: (void*)context
{
/* Shell sort algorithm taken from SortingInAction - a NeXT example */