From 766aef7a086cb0a95b8c9a16ffdf176dde614fe3 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 27 Oct 2009 02:41:45 +0000 Subject: [PATCH] Use .length in order to deal with Array. --- Library.mm | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 } -- 2.45.2