From: Jay Freeman (saurik) Date: Mon, 28 Dec 2015 02:53:56 +0000 (-0800) Subject: Make Pointer/Struct .type compatible with Functor. X-Git-Tag: v0.9.590~130 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/bd5734cc00d2257272e8f7702f9e9b6f64858907?ds=sidebyside Make Pointer/Struct .type compatible with Functor. --- diff --git a/Execute.cpp b/Execute.cpp index d27183c..6156422 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1055,6 +1055,11 @@ static JSValueRef Struct_callAsFunction_$cya(JSContextRef context, JSObjectRef o return CYMakePointer(context, internal->value_, _not(size_t), typical->type_, typical->ffi_, _this); } CYCatch(NULL) } +static JSValueRef Struct_getProperty_type(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { + Struct_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); + return CYMakeType(context, internal->type_->type_); +} CYCatch(NULL) } + static JSValueRef Struct_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { CYPool pool; Struct_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); @@ -1743,7 +1748,16 @@ static JSValueRef CString_getProperty_type(JSContextRef context, JSObjectRef obj static JSValueRef Pointer_getProperty_type(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { Pointer *internal(reinterpret_cast(JSObjectGetPrivate(object))); - return CYMakeType(context, internal->type_->type_); + + sig::Type type; + type.name = NULL; + type.flags = 0; + + type.primitive = sig::pointer_P; + type.data.data.type = internal->type_->type_; + type.data.data.size = 0; + + return CYMakeType(context, &type); } CYCatch(NULL) } static JSValueRef CString_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { @@ -1841,6 +1855,11 @@ static JSStaticFunction Struct_staticFunctions[2] = { {NULL, NULL, 0} }; +static JSStaticValue Struct_staticValues[2] = { + {"type", &Struct_getProperty_type, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {NULL, NULL, NULL, 0} +}; + static JSStaticFunction Functor_staticFunctions[5] = { {"$cya", &Functor_callAsFunction_$cya, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"toCYON", &CYValue_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, @@ -2023,6 +2042,7 @@ void CYInitializeDynamic() { definition = kJSClassDefinitionEmpty; definition.className = "Struct"; definition.staticFunctions = Struct_staticFunctions; + definition.staticValues = Struct_staticValues; definition.getProperty = &Struct_getProperty; definition.setProperty = &Struct_setProperty; definition.getPropertyNames = &Struct_getPropertyNames;