mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-10 02:40:59 +00:00
Merge branch 'master' of git://github.com/280north/cappuccino
This commit is contained in:
commit
011c033478
3 files changed
+30
-25
No files matched your search
@@ -2,6 +2,13 @@
|
||||
@import "CPMutableArray.j"
|
||||
|
||||
|
||||
var indexOf = Array.prototype.indexOf,
|
||||
join = Array.prototype.join,
|
||||
pop = Array.prototype.pop,
|
||||
push = Array.prototype.push,
|
||||
slice = Array.prototype.slice,
|
||||
splice = Array.prototype.splice;
|
||||
|
||||
@implementation _CPJavaScriptArray : CPMutableArray
|
||||
{
|
||||
}
|
||||
@@ -28,13 +35,13 @@
|
||||
|
||||
- (id)initWithArray:(CPArray)anArray
|
||||
{
|
||||
return anArray.slice(0);
|
||||
return slice.call(anArray, 0);
|
||||
}
|
||||
|
||||
- (id)initWithArray:(CPArray)anArray copyItems:(BOOL)shouldCopyItems
|
||||
{
|
||||
if (!shouldCopyItems)
|
||||
return anArray.slice(0);
|
||||
return slice.call(anArray, 0);
|
||||
|
||||
self = [super init];
|
||||
|
||||
@@ -76,19 +83,19 @@
|
||||
if (arguments[index] === nil)
|
||||
break;
|
||||
|
||||
return Array.prototype.slice.call(arguments, 2, index);
|
||||
return slice.call(arguments, 2, index);
|
||||
}
|
||||
|
||||
- (id)initWithObjects:(CPArray)objects count:(CPUInteger)aCount
|
||||
{
|
||||
if (objects.isa === _CPJavaScriptArray)
|
||||
return objects.slice(0);
|
||||
return slice.call(objects, 0);
|
||||
|
||||
var array = [],
|
||||
index = 0;
|
||||
|
||||
for (; index < aCount; ++index)
|
||||
array.push([objects objectAtIndex:index]);
|
||||
push.call(array, [objects objectAtIndex:index]);
|
||||
|
||||
return array;
|
||||
}
|
||||
@@ -106,11 +113,6 @@
|
||||
return self[anIndex];
|
||||
}
|
||||
|
||||
- (CPUInteger)indexOfObject:(id)anObject
|
||||
{
|
||||
return [self indexOfObject:anObject inRange:nil];
|
||||
}
|
||||
|
||||
- (CPUInteger)indexOfObject:(id)anObject inRange:(CPRange)aRange
|
||||
{
|
||||
// Only use isEqual: if our object is a CPObject.
|
||||
@@ -129,15 +131,10 @@
|
||||
return [self indexOfObjectIdenticalTo:anObject inRange:aRange];
|
||||
}
|
||||
|
||||
- (CPUInteger)indexOfObjectIdenticalTo:(id)anObject
|
||||
{
|
||||
return [self indexOfObjectIdenticalTo:anObject inRange:nil];
|
||||
}
|
||||
|
||||
- (CPUInteger)indexOfObjectIdenticalTo:(id)anObject inRange:(CPRange)aRange
|
||||
{
|
||||
if (self.indexOf)
|
||||
return self.indexOf(anObject);
|
||||
if (indexOf && !aRange)
|
||||
return indexOf.call(self, anObject);
|
||||
|
||||
var index = aRange ? aRange.location : 0,
|
||||
count = aRange ? CPMaxRange(aRange) : self.length;
|
||||
@@ -179,32 +176,32 @@
|
||||
if (aRange.location < 0 || CPMaxRange(aRange) > self.length)
|
||||
[CPException raise:CPRangeException reason:"subarrayWithRange: aRange out of bounds"];
|
||||
|
||||
return self.slice(aRange.location, CPMaxRange(aRange));
|
||||
return slice.call(self, aRange.location, CPMaxRange(aRange));
|
||||
}
|
||||
|
||||
- (CPString)componentsJoinedByString:(CPString)aString
|
||||
{
|
||||
return self.join(aString);
|
||||
return join.call(self, aString);
|
||||
}
|
||||
|
||||
- (void)insertObject:(id)anObject atIndex:(CPUInteger)anIndex
|
||||
{
|
||||
self.splice(anIndex, 0, anObject);
|
||||
splice.call(self, anIndex, 0, anObject);
|
||||
}
|
||||
|
||||
- (void)removeObjectAtIndex:(CPUInteger)anIndex
|
||||
{
|
||||
self.splice(anIndex, 1);
|
||||
splice.call(self, anIndex, 1);
|
||||
}
|
||||
|
||||
- (void)addObject:(id)anObject
|
||||
{
|
||||
self.push(anObject);
|
||||
push.call(self, anObject);
|
||||
}
|
||||
|
||||
- (void)removeLastObject
|
||||
{
|
||||
self.pop();
|
||||
pop.call(self);
|
||||
}
|
||||
|
||||
- (void)replaceObjectAtIndex:(int)anIndex withObject:(id)anObject
|
||||
@@ -214,7 +211,7 @@
|
||||
|
||||
- (void)copy
|
||||
{
|
||||
return self.slice(0);
|
||||
return slice.call(self, 0);
|
||||
}
|
||||
|
||||
- (Class)classForCoder
|
||||
|
||||
@@ -316,7 +316,7 @@
|
||||
objectEnumerator = [self objectEnumerator];
|
||||
|
||||
while ((object = [objectEnumerator nextObject]) !== nil)
|
||||
if (![self containsObject:object])
|
||||
if (![aSet containsObject:object])
|
||||
return NO;
|
||||
|
||||
return YES;
|
||||
|
||||
@@ -196,6 +196,14 @@
|
||||
[self assertFalse:[set containsObject:nil]];
|
||||
}
|
||||
|
||||
- (void)testIsSubsetOfSet
|
||||
{
|
||||
var set = [CPSet setWithArray:[1, 2, 3, 4, 5]];
|
||||
[self assertTrue:[[CPSet setWithArray:[1, 2, 3]] isSubsetOfSet:set]];
|
||||
[self assertFalse:[[CPSet setWithArray:[1, 2, 3, 100]] isSubsetOfSet:set]];
|
||||
[self assertTrue:[[CPSet new] isSubsetOfSet:set]];
|
||||
}
|
||||
|
||||
- (void)testDescription
|
||||
{
|
||||
var set = [CPSet new];
|
||||
|
||||
Reference in new issue
Block a user