From: Jay Freeman (saurik) Date: Wed, 11 Nov 2009 04:22:17 +0000 (+0000) Subject: Removed with(Cycript.all), unified the All_ instances, and moved Cycript.all prototyp... X-Git-Tag: v0.9.432~171 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/98ea05a3b0deae271e486d5f3614b05045fc4ad4?ds=inline Removed with(Cycript.all), unified the All_ instances, and moved Cycript.all prototype to CYSetupContext. --- diff --git a/Console.cpp b/Console.cpp index a6a1c54..5357103 100644 --- a/Console.cpp +++ b/Console.cpp @@ -332,8 +332,6 @@ static void Console(apr_pool_t *pool, int client) { if (debug) std::cout << code << std::endl; - if (!bypass) - code = "with(Cycript.all){" + code + "}"; Run(client, code, fout, expand); } @@ -601,7 +599,6 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { } else if (driver.program_ != NULL) if (client != -1) { std::string code(start, end-start); - code = "with(Cycript.all){" + code + "}"; Run(client, code, stdout); } else { std::ostringstream str; @@ -611,10 +608,8 @@ int Main(int argc, char const * const argv[], char const * const envp[]) { std::string code(str.str()); if (compile) std::cout << code; - else { - code = "with(Cycript.all){" + code + "}"; + else Run(client, code, stdout); - } } } diff --git a/Library.cpp b/Library.cpp index 2c6e31b..f95cf9e 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1466,21 +1466,6 @@ const char *CYExecute(apr_pool_t *pool, const char *code) { extern "C" void CydgetSetupContext(JSGlobalContextRef context) { CYSetupContext(context); - - JSObjectRef last(NULL); - JSObjectRef curr(CYGetGlobalObject(context)); - - goto next; for (JSValueRef next;;) { - if (JSValueIsNull(context, next)) - break; - last = curr; - curr = CYCastJSObject(context, next); - next: - next = JSObjectGetPrototype(context, curr); - } - - JSObjectRef all(JSObjectMake(context, All_, NULL)); - JSObjectSetPrototype(context, last, all); } extern "C" void CydgetPoolParse(apr_pool_t *pool, const uint16_t **data, size_t *size) { @@ -1716,6 +1701,19 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) { JSObjectRef all(JSObjectMake(context, All_, NULL)); CYSetProperty(context, cycript, CYJSString("all"), all); + JSObjectRef last(NULL), curr(global); + + goto next; for (JSValueRef next;;) { + if (JSValueIsNull(context, next)) + break; + last = curr; + curr = CYCastJSObject(context, next); + next: + next = JSObjectGetPrototype(context, curr); + } + + JSObjectSetPrototype(context, last, all); + CYSetProperty(context, global, CYJSString("$cyq"), &$cyq); JSObjectRef System(JSObjectMake(context, NULL, NULL)); @@ -1738,7 +1736,6 @@ JSGlobalContextRef CYGetJSContext() { if (context_ == NULL) { context_ = JSGlobalContextCreate(Global_); CYSetupContext(context_); - JSObjectSetPrototype(context_, CYGetGlobalObject(context_), JSObjectMake(context_, All_, NULL)); } return context_; diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index a39d4c3..88c7426 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2425,10 +2425,10 @@ void CYObjectiveC_SetupContext(JSContextRef context) { CYPoolTry { CYSetProperty(context, cycript, CYJSString("Super"), Super); #if defined(__APPLE__) && defined(__arm__) - CYSetProperty(context, all, CYJSString("objc_registerClassPair"), &objc_registerClassPair_); + CYSetProperty(context, all, CYJSString("objc_registerClassPair"), &objc_registerClassPair_, kJSPropertyAttributeDontEnum); #endif - CYSetProperty(context, all, CYJSString("objc_msgSend"), &$objc_msgSend); + CYSetProperty(context, all, CYJSString("objc_msgSend"), &$objc_msgSend, kJSPropertyAttributeDontEnum); JSObjectRef Function_prototype(CYGetCachedObject(context, CYJSString("Function_prototype"))); JSObjectSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Message, prototype_s)), Function_prototype);