]> git.saurik.com Git - cycript.git/commitdiff
Do not use isKindOfClass: to check for NSBlock.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 26 Jan 2014 16:36:38 +0000 (08:36 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 26 Jan 2014 16:36:38 +0000 (08:36 -0800)
ObjectiveC/Library.mm

index 33ccaf0dade7df56081a8be618f57617c62fa3b5..43e592b9c64e2fb5d6494b5ce9eb64074f8530fd 100644 (file)
@@ -394,8 +394,15 @@ JSObjectRef Super::Make(JSContextRef context, id object, Class _class) {
     return value;
 } }
 
+bool CYIsKindOfClass(id object, Class _class) {
+    for (Class isa(object_getClass(object)); isa != NULL; isa = class_getSuperclass(isa))
+        if (isa == _class)
+            return true;
+    return false;
+}
+
 JSObjectRef Instance::Make(JSContextRef context, id object, Flags flags) {
-    JSObjectRef value(JSObjectMake(context, [object isKindOfClass:NSBlock_] ? FunctionInstance_ : Instance_, new Instance(object, flags)));
+    JSObjectRef value(JSObjectMake(context, CYIsKindOfClass(object, NSBlock_) ? FunctionInstance_ : Instance_, new Instance(object, flags)));
     JSObjectSetPrototype(context, value, CYGetClassPrototype(context, object_getClass(object)));
     return value;
 }