Andrew Nguyen : jscript: Implement the String.toLowerCase() method.

Alexandre Julliard julliard at winehq.org
Mon Nov 24 09:16:42 CST 2008


Module: wine
Branch: master
Commit: c4148203c60e19ce01ebccc51eff7993534eb4f8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c4148203c60e19ce01ebccc51eff7993534eb4f8

Author: Andrew Nguyen <arethusa26 at gmail.com>
Date:   Sun Nov 23 16:35:40 2008 -0600

jscript: Implement the String.toLowerCase() method.

---

 dlls/jscript/string.c     |   30 ++++++++++++++++++++++++++++--
 dlls/jscript/tests/api.js |   11 +++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index c6d789e..391f370 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -1069,8 +1069,34 @@ static HRESULT String_sup(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
 static HRESULT String_toLowerCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    StringInstance *string;
+    const WCHAR* str;
+    DWORD length;
+    BSTR bstr;
+
+    TRACE("\n");
+
+    if(is_class(dispex, JSCLASS_STRING)) {
+        string = (StringInstance*)dispex;
+
+        length = string->length;
+        str = string->str;
+    }else {
+        FIXME("not string this not supported\n");
+        return E_NOTIMPL;
+    }
+
+    if(retv) {
+        bstr = SysAllocStringLen(str, length);
+        if (!bstr)
+            return E_OUTOFMEMORY;
+
+        strlwrW(bstr);
+
+        V_VT(retv) = VT_BSTR;
+        V_BSTR(retv) = bstr;
+    }
+    return S_OK;
 }
 
 static HRESULT String_toUpperCase(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 6378bdd..fc913eb 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -247,6 +247,17 @@ ok(tmp === 1, "indexOf = " + tmp);
 tmp = "abcd".indexOf();
 ok(tmp == -1, "indexOf = " + tmp);
 
+tmp = "".toLowerCase();
+ok(tmp === "", "''.toLowerCase() = " + tmp);
+tmp = "test".toLowerCase();
+ok(tmp === "test", "''.toLowerCase() = " + tmp);
+tmp = "test".toLowerCase(3);
+ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
+tmp = "tEsT".toLowerCase();
+ok(tmp === "test", "''.toLowerCase() = " + tmp);
+tmp = "tEsT".toLowerCase(3);
+ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
+
 var arr = new Array();
 ok(typeof(arr) === "object", "arr () is not object");
 ok((arr.length === 0), "arr.length is not 0");




More information about the wine-cvs mailing list