]> git.saurik.com Git - cycript.git/commitdiff
Add .constant to Type (although encoding is weird).
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 15 Sep 2012 06:35:31 +0000 (23:35 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 15 Sep 2012 06:38:22 +0000 (23:38 -0700)
Execute.cpp
todo.txt

index 0abf7f66d46b50aed93cc07752e5ab98631897ba..601ed9f3fe05762a8611d7d4956f33aacda53075 100644 (file)
@@ -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<Type_privateData *>(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},
index 28f2580c42d8042595b5a31b2e0707188a45a5d9..626b4b5526863c8fc653f7a24cbe1b4a838db2c7 100644 (file)
--- 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