void jsV_resizearray(js_State *J, js_Object *obj, int newlen) { char buf[32]; const char *s; int k; if (newlen < obj->u.a.length) { if (obj->u.a.length > obj->count * 2) { js_Object *it = jsV_newiterator(J, obj, 1); while ((s = jsV_nextiterator(J, it))) { k = jsV_numbertointeger(jsV_stringtonumber(J, s)); if (k >= newlen && !strcmp(s, jsV_numbertostring(J, buf, k))) jsV_delproperty(J, obj, s); } } else { for (k = newlen; k < obj->u.a.length; ++k) { jsV_delproperty(J, obj, js_itoa(buf, k)); } } } obj->u.a.length = newlen; }
double js_tointeger(js_State *J, int idx) { return jsV_numbertointeger(jsV_tonumber(J, stackidx(J, idx))); }
double jsV_tointeger(js_State *J, js_Value *v) { return jsV_numbertointeger(jsV_tonumber(J, v)); }