From 89d16b11d9ce1c739871f92c3170128e0befc96c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 10 Jan 2014 02:35:10 -0800 Subject: [PATCH] CYExecute() should run code in a specific context. --- Console.cpp | 2 +- Execute.cpp | 3 +-- Handler.mm | 2 +- JavaScript.hpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Console.cpp b/Console.cpp index 35aa586..8a525f6 100644 --- a/Console.cpp +++ b/Console.cpp @@ -123,7 +123,7 @@ static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { if (client == -1) { mode_ = Running; #ifdef CY_EXECUTE - json = CYExecute(pool, code); + json = CYExecute(CYGetJSContext(), pool, code); #else json = NULL; #endif diff --git a/Execute.cpp b/Execute.cpp index e118146..4f2aa91 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1294,8 +1294,7 @@ JSObjectRef CYGetGlobalObject(JSContextRef context) { return JSContextGetGlobalObject(context); } -const char *CYExecute(CYPool &pool, CYUTF8String code) { - JSContextRef context(CYGetJSContext()); +const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code) { JSValueRef exception(NULL); void *handle; diff --git a/Handler.mm b/Handler.mm index a064c78..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 diff --git a/JavaScript.hpp b/JavaScript.hpp index 944c89e..1ede364 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -56,7 +56,7 @@ JSGlobalContextRef CYGetJSContext(); JSObjectRef CYGetGlobalObject(JSContextRef context); extern "C" void CYSetupContext(JSGlobalContextRef context); -const char *CYExecute(CYPool &pool, CYUTF8String code); +const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code); void CYSetArgs(int argc, const char *argv[]); -- 2.47.2