X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/666eedb9e858b6eb507a283012fc3bb215953f0e..c22e009d49bb891a560f8a6219fe3499859eff4b:/Handler.mm diff --git a/Handler.mm b/Handler.mm index e7b2c3b..e9a8903 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; @@ -156,7 +140,7 @@ extern "C" void CYHandleClient(int socket) { _assert(pthread_create(&client->thread_, NULL, &OnClient, client) == 0); } -extern "C" void CYHandleServer(pid_t pid) { +extern "C" void CYHandleServer(pid_t pid, char *data, size_t size) { CYInitializeDynamic(); int socket(_syscall(::socket(PF_UNIX, SOCK_STREAM, 0))); try {