Jacek Caban : jscript: Added Array.length implementation.
Module: wine Branch: master Commit: 06d19171be21fde7bff7b7551c1b56baba301cdb URL: http://source.winehq.org/git/wine.git/?a=commit;h=06d19171be21fde7bff7b7551c... Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 15 20:37:29 2008 +0200 jscript: Added Array.length implementation. --- dlls/jscript/array.c | 17 +++++++++++++++-- dlls/jscript/tests/api.js | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 764633d..65097be 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -51,8 +51,21 @@ static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p',' static HRESULT Array_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + ArrayInstance *This = (ArrayInstance*)dispex; + + TRACE("%p %d\n", This, This->length); + + switch(flags) { + case DISPATCH_PROPERTYGET: + V_VT(retv) = VT_I4; + V_I4(retv) = This->length; + break; + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; } static HRESULT Array_concat(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 7a7b48f..e874027 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -18,16 +18,19 @@ var arr = new Array(); ok(typeof(arr) === "object", "arr () is not object"); +ok((arr.length === 0), "arr.length is not 0"); ok(arr["0"] === undefined, "arr[0] is not undefined"); var arr = new Array(1, 2, "test"); ok(typeof(arr) === "object", "arr (1,2,test) is not object"); +ok((arr.length === 3), "arr.length is not 3"); 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\""); var arr = new Array(6); ok(typeof(arr) === "object", "arr (6) is not object"); +ok((arr.length === 6), "arr.length is not 6"); ok(arr["0"] === undefined, "arr[0] is not undefined"); reportSuccess();
participants (1)
-
Alexandre Julliard