]> git.saurik.com Git - cycript.git/blobdiff - Execute.cpp
Avoid guessing when converting Functor to Pointer.
[cycript.git] / Execute.cpp
index 930fa1ab70d355fe895ae690a56fcff92288b362..81bd6ec35885585941bd86711163ff46db769725 100644 (file)
@@ -758,7 +758,7 @@ void Primitive<char>::PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi,
 }
 
 void Void::PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const {
-    _assert(false);
+    _assert(JSValueIsUndefined(context, value));
 }
 
 void Unknown::PoolFFI(CYPool *pool, JSContextRef context, ffi_type *ffi, void *data, JSValueRef value) const {
@@ -958,8 +958,7 @@ void CYExecuteClosure(ffi_cif *cif, void *result, void **arguments, void *arg) {
         values[index] = internal->signature_.elements[1 + index].type->FromFFI(context, internal->cif_.arg_types[index], arguments[index]);
 
     JSValueRef value(internal->adapter_(context, count, values, internal->function_));
-    if (internal->cif_.rtype != &ffi_type_void)
-        internal->signature_.elements[0].type->PoolFFI(NULL, context, internal->cif_.rtype, result, value);
+    internal->signature_.elements[0].type->PoolFFI(NULL, context, internal->cif_.rtype, result, value);
 }
 
 static JSValueRef FunctionAdapter_(JSContextRef context, size_t count, JSValueRef values[], JSObjectRef function) {
@@ -1990,9 +1989,10 @@ static JSStaticValue Struct_staticValues[2] = {
     {NULL, NULL, NULL, 0}
 };
 
-static JSStaticFunction Functor_staticFunctions[4] = {
+static JSStaticFunction Functor_staticFunctions[5] = {
     {"$cya", &Functor_callAsFunction_$cya, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {"toCYON", &Functor_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+    {"toPointer", &Functor_callAsFunction_$cya, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {"valueOf", &Functor_callAsFunction_valueOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {NULL, NULL, 0}
 };