]> git.saurik.com Git - cycript.git/commitdiff
Make @encode(char *) and new Type("r*") both work.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 12 Jan 2014 05:58:27 +0000 (21:58 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 12 Jan 2014 05:58:27 +0000 (21:58 -0800)
Decode.cpp
Execute.cpp

index 7901515ba39be2d7cfa5e67dca094e4737e607a2..f99f61fa20bb0ee89f954fc886e0e0f2e0c30d44 100644 (file)
@@ -36,7 +36,7 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
 
         case sig::typename_P: return $ CYTypedIdentifier($V("Class"));
         case sig::union_P: _assert(false); break;
-        case sig::string_P: return $ CYTypedIdentifier($V("char"), $ CYTypeConstant($ CYTypePointerTo()));
+        case sig::string_P: return $ CYTypedIdentifier($V("char"), $ CYTypePointerTo());
         case sig::selector_P: return $ CYTypedIdentifier($V("SEL"));
         case sig::block_P: _assert(false); break;
 
@@ -89,7 +89,11 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
 
 CYTypedIdentifier *Decode(CYPool &pool, struct sig::Type *type) {
     CYTypedIdentifier *typed(Decode_(pool, type));
-    if ((type->flags & JOC_TYPE_CONST) != 0)
-        typed = typed->Modify($ CYTypeConstant());
+    if ((type->flags & JOC_TYPE_CONST) != 0) {
+        if (type->primitive == sig::string_P)
+            typed->modifier_ = $ CYTypeConstant(typed->modifier_);
+        else
+            typed = typed->Modify($ CYTypeConstant());
+    }
     return typed;
 }
index 4282965048dc39457253f8d35b627c6d9cd994fe..eb1970e89e7d38b6da286f3c9e8ace794d3341bb 100644 (file)
@@ -1139,11 +1139,18 @@ static JSValueRef Type_callAsFunction_pointerTo(JSContextRef context, JSObjectRe
 
     sig::Type type;
     type.name = NULL;
-    type.flags = 0;
 
-    type.primitive = sig::pointer_P;
-    type.data.data.type = internal->type_;
-    type.data.data.size = 0;
+    if (internal->type_->primitive == sig::char_P) {
+        type.flags = internal->type_->flags;
+        type.primitive = sig::string_P;
+        type.data.data.type = NULL;
+        type.data.data.size = 0;
+    } else {
+        type.flags = 0;
+        type.primitive = sig::pointer_P;
+        type.data.data.type = internal->type_;
+        type.data.data.size = 0;
+    }
 
     return CYMakeType(context, &type);
 } CYCatch(NULL) }