X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/3a1b79a7408f23b6c54565ac8410dee4c0546c2c..a815a4d64f594b6c2ee7270935263289cc42f64d:/sig/parse.cpp diff --git a/sig/parse.cpp b/sig/parse.cpp index 2f007de..7fc663f 100644 --- a/sig/parse.cpp +++ b/sig/parse.cpp @@ -1,4 +1,4 @@ -/* Cycript - Remove Execution Server and Disassembler +/* Cycript - Inlining/Optimizing JavaScript Compiler * Copyright (C) 2009 Jay Freeman (saurik) */ @@ -37,17 +37,13 @@ */ /* }}} */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include "minimal/stdlib.h" - -#include - -#include - +#include #include "sig/parse.hpp" +#include "Error.hpp" + +#include +#include +#include namespace sig { @@ -85,7 +81,7 @@ void Parse_(apr_pool_t *pool, struct Signature *signature, const char **name, ch if (**name != '"') element->name = NULL; else { - char *quote = strchr(++*name, '"'); + const char *quote = strchr(++*name, '"'); element->name = apr_pstrmemdup(pool, *name, quote - *name); *name = quote + 1; } @@ -130,7 +126,7 @@ struct Type *Parse_(apr_pool_t *pool, const char **name, char eos, bool named, C case '@': if (**name == '"') { - char *quote = strchr(*name + 1, '"'); + const char *quote = strchr(*name + 1, '"'); if (!named || quote[1] == eos || quote[1] == '"') { type->name = apr_pstrmemdup(pool, *name + 1, quote - *name - 1); *name = quote + 1; @@ -205,17 +201,8 @@ struct Type *Parse_(apr_pool_t *pool, const char **name, char eos, bool named, C // XXX: this types thing is a throwback to JocStrap - char *types; - if (next != '=') { - types = NULL; - } else { - const char *temp(*name); + if (next == '=') Parse_(pool, &type->data.signature, name, end, callback); - types = (char *) apr_pstrmemdup(pool, temp, *name - temp - 1); - } - - if (callback != NULL) - (*callback)(pool, type->name, types, type); } break; case 'N': type->flags |= JOC_TYPE_INOUT; goto next; @@ -236,6 +223,9 @@ struct Type *Parse_(apr_pool_t *pool, const char **name, char eos, bool named, C _assert(false); } + if (callback != NULL) + (*callback)(pool, type); + return type; } @@ -275,11 +265,11 @@ const char *Unparse(apr_pool_t *pool, struct Type *type) { case array_P: { const char *value = Unparse(pool, type->data.data.type); - return apr_psprintf(pool, "[%lu%s]", type->data.data.size, value); + return apr_psprintf(pool, "[%"APR_SIZE_T_FMT"%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 bit_P: return apr_psprintf(pool, "b%zu", type->data.data.size); + 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%"APR_SIZE_T_FMT"", type->data.data.size); case char_P: return "c"; case double_P: return "d"; case float_P: return "f";