From: Jay Freeman (saurik) Date: Wed, 23 Dec 2015 13:57:49 +0000 (+0000) Subject: Move pre-cached bridge data into the bridge cache. X-Git-Tag: v0.9.590~147 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/8aae0f85ad333a78139595a81e02ee359979a4f3?ds=inline Move pre-cached bridge data into the bridge cache. --- diff --git a/Execute.cpp b/Execute.cpp index 2a314ca..1c6b7ba 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -2184,19 +2184,19 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) { } #endif - CYSetProperty(context, global, CYJSString("dlerror"), CYMakeFunctor(context, "dlerror", "*"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("RTLD_DEFAULT"), CYCastJSValue(context, reinterpret_cast(RTLD_DEFAULT)), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("dlsym"), CYMakeFunctor(context, "dlsym", "^v^v*"), kJSPropertyAttributeDontEnum); - - CYSetProperty(context, global, CYJSString("NULL"), CYJSNull(context), kJSPropertyAttributeDontEnum); - - CYSetProperty(context, global, CYJSString("bool"), CYMakeType(context, "B"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("char"), CYMakeType(context, "c"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("short"), CYMakeType(context, "s"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("int"), CYMakeType(context, "i"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("long"), CYMakeType(context, "l"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("float"), CYMakeType(context, "f"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("double"), CYMakeType(context, "d"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("dlerror"), CYMakeFunctor(context, "dlerror", "*"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("RTLD_DEFAULT"), CYCastJSValue(context, reinterpret_cast(RTLD_DEFAULT)), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("dlsym"), CYMakeFunctor(context, "dlsym", "^v^v*"), kJSPropertyAttributeDontEnum); + + CYSetProperty(context, cache, CYJSString("NULL"), CYJSNull(context), kJSPropertyAttributeDontEnum); + + CYSetProperty(context, cache, CYJSString("bool"), CYMakeType(context, "B"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("char"), CYMakeType(context, "c"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("short"), CYMakeType(context, "s"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("int"), CYMakeType(context, "i"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("long"), CYMakeType(context, "l"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("float"), CYMakeType(context, "f"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("double"), CYMakeType(context, "d"), kJSPropertyAttributeDontEnum); CYRunScript(context, "libcycript.cy"); diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index b5a2d64..8e50804 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2978,11 +2978,12 @@ void CYObjectiveC_SetupContext(JSContextRef context) { CYPoolTry { CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Message, prototype_s)), Function_prototype); CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Selector, prototype_s)), Function_prototype); - CYSetProperty(context, global, CYJSString("YES"), JSValueMakeBoolean(context, true), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("NO"), JSValueMakeBoolean(context, false), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("id"), CYMakeType(context, "@"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("Class"), CYMakeType(context, "#"), kJSPropertyAttributeDontEnum); - CYSetProperty(context, global, CYJSString("SEL"), CYMakeType(context, ":"), kJSPropertyAttributeDontEnum); + JSObjectRef cache(CYGetCachedObject(context, CYJSString("cache"))); + CYSetProperty(context, cache, CYJSString("YES"), JSValueMakeBoolean(context, true), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("NO"), JSValueMakeBoolean(context, false), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("id"), CYMakeType(context, "@"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("Class"), CYMakeType(context, "#"), kJSPropertyAttributeDontEnum); + CYSetProperty(context, cache, CYJSString("SEL"), CYMakeType(context, ":"), kJSPropertyAttributeDontEnum); } CYPoolCatch() } static void *CYObjectiveC_CastSymbol(const char *name) {