From f2e7626c7a24c1c927b9469fa29cef55689ef894 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 15 Sep 2008 20:37:46 +0200 Subject: [PATCH] jscript: Added ArrayInstance::on_put implementation. --- dlls/jscript/array.c | 18 +++++++++++++++++- dlls/jscript/tests/api.js | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 65097be4a3..c131865be1 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -194,7 +194,23 @@ static void Array_destructor(DispatchEx *dispex) static void Array_on_put(DispatchEx *dispex, const WCHAR *name) { - FIXME("\n"); + ArrayInstance *array = (ArrayInstance*)dispex; + const WCHAR *ptr = name; + DWORD id = 0; + + if(!isdigitW(*ptr)) + return; + + while(*ptr && isdigitW(*ptr)) { + id = id*10 + (*ptr-'0'); + ptr++; + } + + if(*ptr) + return; + + if(id >= array->length) + array->length = id+1; } static const builtin_prop_t Array_props[] = { diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index e874027587..eed48dc205 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -28,6 +28,9 @@ ok(arr["0"] === 1, "arr[0] is not 1"); ok(arr["1"] === 2, "arr[1] is not 2"); ok(arr["2"] === "test", "arr[2] is not \"test\""); +arr["7"] = true; +ok((arr.length === 8), "arr.length is not 8"); + var arr = new Array(6); ok(typeof(arr) === "object", "arr (6) is not object"); ok((arr.length === 6), "arr.length is not 6"); -- 2.32.0.93.g670b81a890