]> git.saurik.com Git - cycript.git/commitdiff
Indirecting a function pointer should get Functor.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 20 Jan 2014 10:06:18 +0000 (02:06 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 20 Jan 2014 10:06:18 +0000 (02:06 -0800)
Execute.cpp

index 241ba325ab6199cd7cf9061156cade4e3d3cfa4e..1c8983cc6918130e9cd8fb3c8e12a7e5214587ce 100644 (file)
@@ -823,9 +823,9 @@ static JSValueRef Pointer_getProperty(JSContextRef context, JSObjectRef object,
         return internal->length_ == _not(size_t) ? CYJSUndefined(context) : CYCastJSValue(context, internal->length_);
 
     Type_privateData *typical(internal->type_);
-
     if (typical->type_ == NULL)
         return NULL;
+    sig::Type &type(*typical->type_);
 
     ssize_t offset;
     if (JSStringIsEqualToUTF8CString(property, "$cyi"))
@@ -833,13 +833,16 @@ static JSValueRef Pointer_getProperty(JSContextRef context, JSObjectRef object,
     else if (!CYGetOffset(pool, context, property, offset))
         return NULL;
 
+    if (type.primitive == sig::function_P)
+        return CYMakeFunctor(context, reinterpret_cast<void (*)()>(internal->value_), type.data.signature);
+
     ffi_type *ffi(typical->GetFFI());
 
     uint8_t *base(reinterpret_cast<uint8_t *>(internal->value_));
     base += ffi->size * offset;
 
     JSObjectRef owner(internal->GetOwner() ?: object);
-    return CYFromFFI(context, typical->type_, ffi, base, false, owner);
+    return CYFromFFI(context, &type, ffi, base, false, owner);
 } CYCatch(NULL) }
 
 static bool Pointer_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {