X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/666eedb9e858b6eb507a283012fc3bb215953f0e..7eb6c2f23b20ac241ec4cc1183654d9b01fd86ef:/Handler.mm?ds=inline diff --git a/Handler.mm b/Handler.mm index e7b2c3b..3298148 100644 --- a/Handler.mm +++ b/Handler.mm @@ -57,7 +57,7 @@ struct CYExecute_ { CYExecute_ *execute(reinterpret_cast([value pointerValue])); const char *data(execute->data_); execute->data_ = NULL; - execute->data_ = CYExecute(execute->pool_, CYUTF8String(data)); + execute->data_ = CYExecute(CYGetJSContext(), execute->pool_, CYUTF8String(data)); } @end @@ -100,36 +100,20 @@ struct CYClient : return; data[size] = '\0'; - CYStream stream(data, data + size); - CYDriver driver(stream); - - cy::parser parser(driver); - - const char *json; - if (parser.parse() != 0 || !driver.errors_.empty()) { - json = NULL; - size = _not(uint32_t); - } else { - NSAutoreleasePool *ar = [[NSAutoreleasePool alloc] init]; - - CYOptions options; - CYContext context(options); - driver.program_->Replace(context); - std::ostringstream str; - CYOutput out(str, options); - out << *driver.program_; - std::string code(str.str()); - CYExecute_ execute = {pool, code.c_str()}; - NSValue *value([NSValue valueWithPointer:&execute]); - if (dispatch) - [client performSelectorOnMainThread:@selector(execute:) withObject:value waitUntilDone:YES]; - else - [client execute:value]; - json = execute.data_; - size = json == NULL ? _not(uint32_t) : strlen(json); - - [ar release]; - } + NSAutoreleasePool *ar = [[NSAutoreleasePool alloc] init]; + + std::string code(data, size); + CYExecute_ execute = {pool, code.c_str()}; + NSValue *value([NSValue valueWithPointer:&execute]); + if (dispatch) + [client performSelectorOnMainThread:@selector(execute:) withObject:value waitUntilDone:YES]; + else + [client execute:value]; + + const char *json(execute.data_); + size = json == NULL ? _not(uint32_t) : strlen(json); + + [ar release]; if (!CYSendAll(socket_, &size, sizeof(size))) return;