From: Jay Freeman (saurik) Date: Mon, 20 Jan 2014 09:58:40 +0000 (-0800) Subject: Expose the internal Type of Pointers through type. X-Git-Tag: v0.9.500~31 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/9cea6cabbaf7998ce70303ab0db4b54a056ac92e?ds=sidebyside;hp=73439a14e93de87336e297d8a0d87b920472a489 Expose the internal Type of Pointers through type. --- diff --git a/Execute.cpp b/Execute.cpp index 7b39bb9..241ba32 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1255,6 +1255,11 @@ static JSValueRef Pointer_callAsFunction_toCYON(JSContextRef context, JSObjectRe } } CYCatch(NULL) } +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_); +} CYCatch(NULL) } + static JSValueRef Functor_getProperty_type(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry { cy::Functor *internal(reinterpret_cast(JSObjectGetPrivate(object))); return CYMakeType(context, &internal->signature_); @@ -1303,6 +1308,11 @@ static JSStaticFunction Pointer_staticFunctions[4] = { {NULL, NULL, 0} }; +static JSStaticValue Pointer_staticValues[2] = { + {"type", &Pointer_getProperty_type, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {NULL, NULL, NULL, 0} +}; + static JSStaticFunction Struct_staticFunctions[2] = { {"$cya", &Struct_callAsFunction_$cya, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {NULL, NULL, 0} @@ -1447,6 +1457,7 @@ void CYInitializeDynamic() { definition = kJSClassDefinitionEmpty; definition.className = "Pointer"; definition.staticFunctions = Pointer_staticFunctions; + definition.staticValues = Pointer_staticValues; definition.getProperty = &Pointer_getProperty; definition.setProperty = &Pointer_setProperty; definition.finalize = &CYFinalize;