Jacek Caban : jscript: Added more to_string implementation.

Alexandre Julliard julliard at winehq.org
Fri Sep 19 07:14:55 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Sep 19 00:46:05 2008 +0200

jscript: Added more to_string implementation.

---

 dlls/jscript/jsutils.c     |   26 +++++++++++++++++++++++++-
 dlls/jscript/tests/lang.js |    4 ++++
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 4913568..f368c3e 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -320,15 +320,39 @@ static BSTR int_to_bstr(INT i)
 /* ECMA-262 3rd Edition    9.8 */
 HRESULT to_string(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, BSTR *str)
 {
+    const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
+    const WCHAR nullW[] = {'n','u','l','l',0};
+    const WCHAR trueW[] = {'t','r','u','e',0};
+    const WCHAR falseW[] = {'f','a','l','s','e',0};
+
     switch(V_VT(v)) {
+    case VT_EMPTY:
+        *str = SysAllocString(undefinedW);
+        break;
+    case VT_NULL:
+        *str = SysAllocString(nullW);
+        break;
     case VT_I4:
         *str = int_to_bstr(V_I4(v));
         break;
-
     case VT_BSTR:
         *str = SysAllocString(V_BSTR(v));
         break;
+    case VT_DISPATCH: {
+        VARIANT prim;
+        HRESULT hres;
 
+        hres = to_primitive(ctx, v, ei, &prim);
+        if(FAILED(hres))
+            return hres;
+
+        hres = to_string(ctx, &prim, ei, str);
+        VariantClear(&prim);
+        return hres;
+    }
+    case VT_BOOL:
+        *str = SysAllocString(V_BOOL(v) ? trueW : falseW);
+        break;
     default:
         FIXME("unsupported vt %d\n", V_VT(v));
         return E_NOTIMPL;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 82a612a..3a24864 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -342,6 +342,10 @@ ok(+null === 0, "+null !== 0");
 ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
 ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
 ok("" + (-5) === "-5", "\"\" + (-5) !== \"-5\"");
+ok("" + null === "null", "\"\" + null !== \"null\"");
+ok("" + undefined === "undefined", "\"\" + undefined !== \"undefined\"");
+ok("" + true === "true", "\"\" + true !== \"true\"");
+ok("" + false === "false", "\"\" + false !== \"false\"");
 
 ok(1 < 3.4, "1 < 3.4 failed");
 ok(!(3.4 < 1), "3.4 < 1");




More information about the wine-cvs mailing list