From: Jay Freeman (saurik) Date: Sat, 15 Sep 2012 06:35:31 +0000 (-0700) Subject: Add .constant to Type (although encoding is weird). X-Git-Tag: v0.9.460~11 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/fbc1726819c109cdcd4df169fb39c41bb827808f?hp=85e9041079aa3e988ceeba13992a00d7be189d14 Add .constant to Type (although encoding is weird). --- diff --git a/Execute.cpp b/Execute.cpp index 0abf7f6..601ed9f 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1071,6 +1071,16 @@ static JSValueRef Type_callAsFunction_arrayOf(JSContextRef context, JSObjectRef return CYMakeType(context, &type); } CYCatch } +static JSValueRef Type_callAsFunction_constant(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { + if (count != 0) + throw CYJSError(context, "incorrect number of arguments to Type.constant"); + Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(_this))); + + sig::Type type(*internal->type_); + type.flags |= JOC_TYPE_CONST; + return CYMakeType(context, &type); +} CYCatch } + static JSValueRef Type_callAsFunction_pointerTo(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { if (count != 0) throw CYJSError(context, "incorrect number of arguments to Type.pointerTo"); @@ -1221,8 +1231,9 @@ static JSStaticValue Type_staticValues[3] = { {NULL, NULL, NULL, 0} }; -static JSStaticFunction Type_staticFunctions[6] = { +static JSStaticFunction Type_staticFunctions[7] = { {"arrayOf", &Type_callAsFunction_arrayOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {"constant", &Type_callAsFunction_constant, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"pointerTo", &Type_callAsFunction_pointerTo, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"toCYON", &Type_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"toJSON", &Type_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, diff --git a/todo.txt b/todo.txt index 28f2580..626b4b5 100644 --- a/todo.txt +++ b/todo.txt @@ -106,3 +106,8 @@ apparently you can have random escape sequences in strings, like \! cycript -p with processes that have spaces doesn't work CYDriver uses std::istream, but it should use std::streambuf the mechanism I used to autodetect readline is horrible: use autoconf + +constant flags on types are encoded using something horribly wrong +http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html +http://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html +http://gcc.gnu.org/onlinedocs/gcc/Legacy-type-encoding.html