]> git.saurik.com Git - cycript.git/commitdiff
Use .length in order to deal with Array.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 27 Oct 2009 02:41:45 +0000 (02:41 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 27 Oct 2009 02:41:45 +0000 (02:41 +0000)
Library.mm

index 3f88ae6c38cdbc26b23be0820069710572f96bae..fe9f9686da39ee85b563191523bf56d886f534eb 100644 (file)
@@ -2136,15 +2136,11 @@ static JSValueRef Array_callAsFunction_toCYON(JSContextRef context, JSObjectRef
 
     str << '[';
 
 
     str << '[';
 
-    // XXX: this is, sadly, going to leak
-    // XXX: shouldn't this be done with .length?!
-    JSPropertyNameArrayRef names(JSObjectCopyPropertyNames(context, _this));
-
+    JSValueRef length(CYGetProperty(context, _this, length_));
     bool comma(false);
 
     bool comma(false);
 
-    for (size_t index(0), count(JSPropertyNameArrayGetCount(names)); index != count; ++index) {
-        JSStringRef name(JSPropertyNameArrayGetNameAtIndex(names, index));
-        JSValueRef value(CYGetProperty(context, _this, name));
+    for (size_t index(0), count(CYCastDouble(context, length)); index != count; ++index) {
+        JSValueRef value(CYGetProperty(context, _this, index));
 
         if (comma)
             str << ',';
 
         if (comma)
             str << ',';
@@ -2161,8 +2157,6 @@ static JSValueRef Array_callAsFunction_toCYON(JSContextRef context, JSObjectRef
 
     str << ']';
 
 
     str << ']';
 
-    JSPropertyNameArrayRelease(names);
-
     std::string value(str.str());
     return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size())));
 } CYCatch }
     std::string value(str.str());
     return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size())));
 } CYCatch }