Jacek Caban : jscript: Added bool and null to number conversion implementation.

Alexandre Julliard julliard at winehq.org
Thu Sep 18 07:55:52 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 17 23:33:32 2008 +0200

jscript: Added bool and null to number conversion implementation.

---

 dlls/jscript/jsutils.c     |    8 ++++++++
 dlls/jscript/tests/lang.js |    3 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 09eed5b..19c3b8d 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -219,10 +219,18 @@ HRESULT to_boolean(VARIANT *v, VARIANT_BOOL *b)
 HRESULT to_number(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret)
 {
     switch(V_VT(v)) {
+    case VT_NULL:
+        V_VT(ret) = VT_I4;
+        V_I4(ret) = 0;
+        break;
     case VT_I4:
     case VT_R8:
         *ret = *v;
         break;
+    case VT_BOOL:
+        V_VT(ret) = VT_I4;
+        V_I4(ret) = V_BOOL(v) ? 1 : 0;
+        break;
     default:
         FIXME("unimplemented for vt %d\n", V_VT(v));
         return E_NOTIMPL;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index b4ab2b7..140ed0f 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -308,6 +308,9 @@ ok(getVT(tmp) === "VT_I4", "getVT(~1) = " + getVT(tmp));
 ok((3,4) === 4, "(3,4) !== 4");
 
 ok(+3 === 3, "+3 !== 3");
+ok(+true === 1, "+true !== 1");
+ok(+false === 0, "+false !== 0");
+ok(+null === 0, "+null !== 0");
 
 ok(1 < 3.4, "1 < 3.4 failed");
 ok(!(3.4 < 1), "3.4 < 1");




More information about the wine-cvs mailing list