]> git.saurik.com Git - cycript.git/blobdiff - sig/parse.cpp
Insanely massive refactoring, bringing both exceptions and languages into near parity.
[cycript.git] / sig / parse.cpp
index 1c0ec2339494bcfeb2f9be18b1ca476c976e8439..57e5a10669b166aae90e027b51167c516a30b35a 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "minimal/stdlib.h"
 
-#include <apr-1/apr_strings.h>
+#include <apr_strings.h>
 
 #include <string.h>
 
@@ -118,7 +118,10 @@ struct Type *Parse_(apr_pool_t *pool, const char **name, char eos, bool named, C
         case '#': type->primitive = typename_P; break;
 
         case '(':
-            type->primitive = union_P;
+            if (type->data.signature.count < 2)
+                type->primitive = struct_P;
+            else
+                type->primitive = union_P;
             next = ')';
         goto aggregate;
 
@@ -157,13 +160,13 @@ struct Type *Parse_(apr_pool_t *pool, const char **name, char eos, bool named, C
 
         case '^':
             type->primitive = pointer_P;
-            if (**name == 'v') {
-                type->data.data.type = NULL;
-                ++*name;
-            } else if (**name == '"') {
+            if (**name == '"') {
                 type->data.data.type = NULL;
             } else {
                 type->data.data.type = Parse_(pool, name, eos, named, callback);
+                sig::Type *&target(type->data.data.type);
+                if (target != NULL && target->primitive == void_P)
+                    target = NULL;
             }
         break;
 
@@ -275,7 +278,7 @@ const char *Unparse(apr_pool_t *pool, struct Type *type) {
             return apr_psprintf(pool, "[%lu%s]", type->data.data.size, value);
         } break;
 
-        case pointer_P: return apr_psprintf(pool, "^%s", type->data.data.type == NULL ? "" : Unparse(pool, type->data.data.type));
+        case pointer_P: return apr_psprintf(pool, "^%s", type->data.data.type == NULL ? "v" : Unparse(pool, type->data.data.type));
         case bit_P: return apr_psprintf(pool, "b%zu", type->data.data.size);
         case char_P: return "c";
         case double_P: return "d";