From: Jay Freeman (saurik) Date: Thu, 5 Jun 2014 09:25:19 +0000 (-0700) Subject: Do not rely on -[description] to describe classes. X-Git-Tag: v0.9.502~11 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/179d115012d6dc6a897e1a6ccac70248c9e65081?hp=98735bfe852adb9e5421e5c04bb2e0119af443bd Do not rely on -[description] to describe classes. --- diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index bb7acf3..52df126 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -308,8 +308,6 @@ static Class NSCFBoolean_; static Class NSCFType_; static Class NSGenericDeallocHandler_; static Class NSZombie_; - -static std::set banned_; #else static Class NSBoolNumber_; #endif @@ -481,7 +479,13 @@ NSString *CYCastNSCYON(id value, bool objective, std::set &objects) { Class _class(object_getClass(value)); SEL sel(@selector(cy$toCYON:inSet:)); - if (objc_method *toCYON = class_getInstanceMethod(_class, sel)) + if (class_isMetaClass(_class)) { + const char *name(class_getName(value)); + if (class_isMetaClass(value)) + string = [NSString stringWithFormat:@"object_getClass(%s)", name]; + else + string = [NSString stringWithUTF8String:name]; + } else if (objc_method *toCYON = class_getInstanceMethod(_class, sel)) string = reinterpret_cast &)>(method_getImplementation(toCYON))(value, sel, objective, objects); else if (objc_method *methodSignatureForSelector = class_getInstanceMethod(_class, @selector(methodSignatureForSelector:))) { if (reinterpret_cast(method_getImplementation(methodSignatureForSelector))(value, @selector(methodSignatureForSelector:), sel) != nil) @@ -490,13 +494,8 @@ NSString *CYCastNSCYON(id value, bool objective, std::set &objects) { } else fail: { if (false); #ifdef __APPLE__ - else if (value == NSZombie_) - string = @"_NSZombie_"; else if (_class == NSZombie_) string = [NSString stringWithFormat:@"<_NSZombie_: %p>", value]; - // XXX: frowny /in/ the pants - else if (banned_.find(value) != banned_.end()) - string = nil; #endif else string = [NSString stringWithFormat:@"%@", value]; @@ -2867,12 +2866,6 @@ void CYObjectiveC_Initialize() { /*XXX*/ JSContextRef context(NULL); CYPoolTry { NSCFType_ = objc_getClass("NSCFType"); NSZombie_ = objc_getClass("_NSZombie_"); - - banned_.insert(Object_); - banned_.insert(objc_getClass("__NSAtom")); - banned_.insert(objc_getClass("__NSGenericDeallocHandler")); - banned_.insert(objc_getClass("NSMessageBuilder")); - banned_.insert(objc_getClass("__NSMessageBuilder")); #else NSBoolNumber_ = objc_getClass("NSBoolNumber"); #endif