From b48489be3c884aecca8b5f3dd8f9eb21d4baa989 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 17 Sep 2008 23:35:12 +0200 Subject: [PATCH] jscript: Added String.length implementation. --- dlls/jscript/string.c | 18 ++++++++++++++++-- dlls/jscript/tests/api.js | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index b310cabec32..083153220b3 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -70,8 +70,22 @@ static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p',' static HRESULT String_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + TRACE("%p\n", dispex); + + switch(flags) { + case DISPATCH_PROPERTYGET: { + StringInstance *jsthis = (StringInstance*)dispex; + + V_VT(retv) = VT_I4; + V_I4(retv) = jsthis->length; + break; + } + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; } static HRESULT String_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index eed48dc2056..d6893e03ccb 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -16,6 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +ok("".length === 0, "\"\".length = " + "".length); +ok(getVT("".length) == "VT_I4", "\"\".length = " + "".length); +ok("abc".length === 3, "\"abc\".length = " + "abc".length); +ok(String.prototype.length === 0, "String.prototype.length = " + String.prototype.length); + var arr = new Array(); ok(typeof(arr) === "object", "arr () is not object"); ok((arr.length === 0), "arr.length is not 0"); -- 2.11.4.GIT