From 9cea6cabbaf7998ce70303ab0db4b54a056ac92e Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 20 Jan 2014 01:58:40 -0800 Subject: [PATCH 1/1] Expose the internal Type of Pointers through type. --- Execute.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- 2.47.2