From: Jay Freeman (saurik) Date: Tue, 27 Oct 2009 02:41:45 +0000 (+0000) Subject: Use .length in order to deal with Array. X-Git-Tag: v0.9.432~248 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/766aef7a086cb0a95b8c9a16ffdf176dde614fe3?ds=inline Use .length in order to deal with Array. --- diff --git a/Library.mm b/Library.mm index 3f88ae6..fe9f968 100644 --- a/Library.mm +++ b/Library.mm @@ -2136,15 +2136,11 @@ static JSValueRef Array_callAsFunction_toCYON(JSContextRef context, JSObjectRef 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); - 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 << ','; @@ -2161,8 +2157,6 @@ static JSValueRef Array_callAsFunction_toCYON(JSContextRef context, JSObjectRef str << ']'; - JSPropertyNameArrayRelease(names); - std::string value(str.str()); return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size()))); } CYCatch }