]> git.saurik.com Git - cycript.git/commitdiff
Fail to auto-@property get a void return.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 17 Oct 2009 02:00:22 +0000 (02:00 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 17 Oct 2009 02:00:22 +0000 (02:00 +0000)
Library.mm

index c9fea30a15e474831526ecbe45423d9f2c19b68f..85638f5aa76f0e3612ce7af5be7365d04f014cd6 100644 (file)
@@ -1720,9 +1720,18 @@ JSValueRef CYFromFFI(JSContextRef context, sig::Type *type, ffi_type *ffi, void
     return value;
 }
 
-static bool CYImplements(id object, Class _class, SEL selector) {
+static bool CYImplements(id object, Class _class, SEL selector, bool devoid) {
+    if (Method method = class_getInstanceMethod(_class, selector)) {
+        if (!devoid)
+            return true;
+        char type[16];
+        method_getReturnType(method, type, sizeof(type));
+        if (type[0] != 'v')
+            return true;
+    }
+
     // XXX: possibly use a more "awesome" check?
-    return class_getInstanceMethod(_class, selector) != NULL;
+    return false;
 }
 
 static bool Instance_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) {
@@ -1751,7 +1760,7 @@ static bool Instance_hasProperty(JSContextRef context, JSObjectRef object, JSStr
         return true;
 
     if (SEL sel = sel_getUid(string))
-        if (CYImplements(self, _class, sel))
+        if (CYImplements(self, _class, sel, true))
             return true;
 
     return false;
@@ -1787,7 +1796,7 @@ static JSValueRef Instance_getProperty(JSContextRef context, JSObjectRef object,
         }
 
         if (SEL sel = sel_getUid(string))
-            if (CYImplements(self, _class, sel))
+            if (CYImplements(self, _class, sel, true))
                 return CYSendMessage(pool, context, self, sel, 0, NULL, false, exception);
 
         return NULL;
@@ -1837,7 +1846,7 @@ static bool Instance_setProperty(JSContextRef context, JSObjectRef object, JSStr
         set[length + 4] = '\0';
 
         if (SEL sel = sel_getUid(set))
-            if (CYImplements(self, _class, sel)) {
+            if (CYImplements(self, _class, sel, false)) {
                 JSValueRef arguments[1] = {value};
                 CYSendMessage(pool, context, self, sel, 1, arguments, false, exception);
             }