Implement description and toString for class objects.

This commit is contained in:
Tom Robinson
2010-02-01 17:38:13 -08:00
parent cd98bce331
commit e088280a5f
+6 -1
View File
@@ -273,6 +273,11 @@ CPLog(@"Got some class: %@", inst);
return "<" + class_getName(isa) + " 0x" + [CPString stringWithHash:[self UID]] + ">";
}
+ (CPString)description
{
return class_getName(isa);
}
// Sending Messages
/*!
Sends the specified message to the receiver.
@@ -523,7 +528,7 @@ CPLog(@"Got some class: %@", inst);
// 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()
objj_class.prototype.toString = objj_object.prototype.toString = function()
{
if (this.isa && class_getInstanceMethod(this.isa, "description") != NULL)
return [this description]