-/* Cycript - Remove Execution Server and Disassembler
+/* Cycript - Inlining/Optimizing JavaScript Compiler
* Copyright (C) 2009 Jay Freeman (saurik)
*/
*/
/* }}} */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include "minimal/stdlib.h"
-
-#include <apr-1/apr_strings.h>
-
-#include <string.h>
-
+#include <apr_strings.h>
#include "sig/parse.hpp"
+#include "Error.hpp"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
namespace sig {
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;
}
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;
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;
// 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;
_assert(false);
}
+ if (callback != NULL)
+ (*callback)(pool, type);
+
return 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";