X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/cf7d4c691503f6711d7e407b2bc30100de19ce2e..5999c31517bb72b55257d25f482edc566adec045:/Library.mm diff --git a/Library.mm b/Library.mm index f3a18bb..8135429 100644 --- a/Library.mm +++ b/Library.mm @@ -45,8 +45,7 @@ #include "sig/parse.hpp" #include "sig/ffi_type.hpp" -#include -#include +#include "Pooling.hpp" #include @@ -89,41 +88,6 @@ CFLog(kCFLogLevelNotice, CFSTR("_trace():%u"), __LINE__); \ } while (false) -/* APR Pool Helpers {{{ */ -void *operator new(size_t size, apr_pool_t *pool) { - return apr_palloc(pool, size); -} - -void *operator new [](size_t size, apr_pool_t *pool) { - return apr_palloc(pool, size); -} - -class CYPool { - private: - apr_pool_t *pool_; - - public: - CYPool() { - apr_pool_create(&pool_, NULL); - } - - ~CYPool() { - apr_pool_destroy(pool_); - } - - operator apr_pool_t *() const { - return pool_; - } - - char *operator ()(const char *data) const { - return apr_pstrdup(pool_, data); - } - - char *operator ()(const char *data, size_t size) const { - return apr_pstrndup(pool_, data, size); - } -}; -/* }}} */ #define _pooled _H _pool([[NSAutoreleasePool alloc] init], true); @@ -952,11 +916,14 @@ static JSStaticValue Pointer_staticValues[2] = { {NULL, NULL, NULL, 0} }; -CYParser::CYParser() { +CYDriver::CYDriver(const std::string &filename) : + filename_(filename), + source_(NULL) +{ ScannerInit(); } -CYParser::~CYParser() { +CYDriver::~CYDriver() { ScannerDestroy(); } @@ -968,9 +935,10 @@ void cy::parser::error(const cy::parser::location_type &loc, const std::string & void CYConsole(FILE *fin, FILE *fout, FILE *ferr) { cydebug = 1; - CYParser driver; - cy::parser parser(&driver); - parser.parse(); + CYDriver driver(""); + cy::parser parser(driver); + if (parser.parse() == 0) + driver.source_->Part(std::cout); } MSInitialize { _pooled