CPArray -componentsJoinedByString fixed

Moved objj object toString override to CPObject.j

Reviewed by me

[#89 state:resolved responsible:tlrobinson]
This commit is contained in:
Tom Robinson
2008-10-05 18:34:06 -07:00
parent bf28b8bbc6
commit ba189afaf5
3 changed files with 14 additions and 18 deletions
+4 -9
View File
@@ -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
-9
View File
@@ -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)";
}
+10
View File
@@ -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)";
}