mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-24 11:20:42 +00:00
CPArray -componentsJoinedByString fixed
Moved objj object toString override to CPObject.j Reviewed by me [#89 state:resolved responsible:tlrobinson]
This commit is contained in:
@@ -656,21 +656,16 @@ import "CPException.j"
|
||||
/*
|
||||
Returns a string formed by concatenating the objects in the
|
||||
receiver, with the specified separator string inserted between each part.
|
||||
If the element is a Cappuccino object, then the <code>description</code>
|
||||
If the element is a Objective-J object, then the <code>description</code>
|
||||
of that object will be used, otherwise the default JavaScript representation will be used.
|
||||
@param aString the separator that will separate each object string
|
||||
@return the string representation of the array
|
||||
*/
|
||||
- (CPString)componentsJoinedByString:(CPString)aString
|
||||
{
|
||||
var index = 0,
|
||||
count = [self count],
|
||||
string = @"";
|
||||
|
||||
for(; index < count; ++i)
|
||||
string += self[index].isa ? [self[index] description] : self[index];
|
||||
|
||||
return string;
|
||||
// Objective-J objects get "description" called on them automatically when coerced to strings
|
||||
// (see "objj_object.prototype.toString" at bottom of CPObject.j)
|
||||
return join(aString);
|
||||
}
|
||||
|
||||
// Creating a description of the array
|
||||
|
||||
@@ -372,12 +372,3 @@ var _CPLogInitPopup = function(logWindow)
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
// override toString on Objective-J objects so we print the actual description of the object instead of [Object object]
|
||||
objj_object.prototype.toString = function()
|
||||
{
|
||||
if (this.isa && class_getInstanceMethod(this.isa, "description") != NULL)
|
||||
return [this description]
|
||||
else
|
||||
return String(this) + " (-description not implemented)";
|
||||
}
|
||||
|
||||
@@ -453,3 +453,13 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// override toString on Objective-J objects so we get the actual description of the object
|
||||
// when coerced to a string, instead of "[Object object]"
|
||||
objj_object.prototype.toString = function()
|
||||
{
|
||||
if (this.isa && class_getInstanceMethod(this.isa, "description") != NULL)
|
||||
return [this description]
|
||||
else
|
||||
return String(this) + " (-description not implemented)";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user