From 001fffa87bb3c27c24c9c7a7fa12e57d1a02f2f9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 20 Jan 2014 02:06:18 -0800 Subject: [PATCH] Indirecting a function pointer should get Functor. --- Execute.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index 241ba32..1c8983c 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -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(internal->value_), type.data.signature); + ffi_type *ffi(typical->GetFFI()); uint8_t *base(reinterpret_cast(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 { -- 2.45.2