]> git.saurik.com Git - cycript.git/blobdiff - ObjectiveC/Library.mm
Use Array.prototype, not Array, to look up functions.
[cycript.git] / ObjectiveC / Library.mm
index 2cb81b741ca674cac1f28001ff2dc166d59eaf6d..957c80ce28a1607c7805a550e4587899d96ba0d4 100644 (file)
@@ -252,6 +252,7 @@ static JSClassRef ObjectiveC_Images_;
 #ifdef __APPLE__
 static Class NSCFBoolean_;
 static Class NSCFType_;
+static Class NSGenericDeallocHandler_;
 static Class NSMessageBuilder_;
 static Class NSZombie_;
 #else
@@ -419,7 +420,7 @@ NSString *CYCastNSCYON(id value) {
             else if (_class == NSZombie_)
                 string = [NSString stringWithFormat:@"<_NSZombie_: %p>", value];
             // XXX: frowny /in/ the pants
-            else if (value == NSMessageBuilder_ || value == Object_)
+            else if (value == NSGenericDeallocHandler_ || value == NSMessageBuilder_ || value == Object_)
                 string = nil;
 #endif
             else
@@ -1243,7 +1244,7 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry {
     JSValueRef exception(NULL);
     JSValueRef arguments[1];
     arguments[0] = CYCastJSValue(context_, (NSObject *) object);
-    JSObjectRef Array(CYGetCachedObject(context_, Array_s));
+    JSObjectRef Array(CYGetCachedObject(context_, CYJSString("Array_prototype")));
     JSObjectCallAsFunction(context_, CYCastJSObject(context_, CYGetProperty(context_, Array, push_s)), object_, 1, arguments, &exception);
     CYThrow(context_, exception);
 } CYObjectiveCatch }
@@ -1257,14 +1258,14 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry {
     arguments[0] = CYCastJSValue(context_, index);
     arguments[1] = CYCastJSValue(context_, 0);
     arguments[2] = CYCastJSValue(context_, (NSObject *) object);
-    JSObjectRef Array(CYGetCachedObject(context_, Array_s));
+    JSObjectRef Array(CYGetCachedObject(context_, CYJSString("Array_prototype")));
     JSObjectCallAsFunction(context_, CYCastJSObject(context_, CYGetProperty(context_, Array, splice_s)), object_, 3, arguments, &exception);
     CYThrow(context_, exception);
 } CYObjectiveCatch }
 
 - (void) removeLastObject { CYObjectiveTry {
     JSValueRef exception(NULL);
-    JSObjectRef Array(CYGetCachedObject(context_, Array_s));
+    JSObjectRef Array(CYGetCachedObject(context_, CYJSString("Array_prototype")));
     JSObjectCallAsFunction(context_, CYCastJSObject(context_, CYGetProperty(context_, Array, pop_s)), object_, 0, NULL, &exception);
     CYThrow(context_, exception);
 } CYObjectiveCatch }
@@ -1277,7 +1278,7 @@ JSValueRef CYCastJSValue(JSContextRef context, NSObject *value) { CYPoolTry {
     JSValueRef arguments[2];
     arguments[0] = CYCastJSValue(context_, index);
     arguments[1] = CYCastJSValue(context_, 1);
-    JSObjectRef Array(CYGetCachedObject(context_, Array_s));
+    JSObjectRef Array(CYGetCachedObject(context_, CYJSString("Array_prototype")));
     JSObjectCallAsFunction(context_, CYCastJSObject(context_, CYGetProperty(context_, Array, splice_s)), object_, 2, arguments, &exception);
     CYThrow(context_, exception);
 } CYObjectiveCatch }
@@ -2220,7 +2221,7 @@ static JSValueRef Instance_getProperty_constructor(JSContextRef context, JSObjec
     return Instance::Make(context, (id) object_getClass(internal->GetValue()));
 }
 
-static JSValueRef Instance_getProperty_protocol(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
+static JSValueRef Instance_getProperty_prototype(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
     Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(object)));
     id self(internal->GetValue());
     if (!CYIsClass(self))
@@ -2343,7 +2344,7 @@ static JSStaticValue Selector_staticValues[2] = {
 static JSStaticValue Instance_staticValues[5] = {
     {"constructor", &Instance_getProperty_constructor, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {"messages", &Instance_getProperty_messages, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
-    {"prototype", &Instance_getProperty_protocol, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+    {"prototype", &Instance_getProperty_prototype, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {"value", &CYValue_getProperty_value, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
     {NULL, NULL, NULL, 0}
 };
@@ -2386,6 +2387,7 @@ void CYObjectiveC_Initialize() { /*XXX*/ JSContextRef context(NULL); CYPoolTry {
 #ifdef __APPLE__
     NSCFBoolean_ = objc_getClass("NSCFBoolean");
     NSCFType_ = objc_getClass("NSCFType");
+    NSGenericDeallocHandler_ = objc_getClass("__NSGenericDeallocHandler");
     NSMessageBuilder_ = objc_getClass("NSMessageBuilder");
     NSZombie_ = objc_getClass("_NSZombie_");
 #else