Jacek Caban : jscript: Fixed null dispatch comparison.

Alexandre Julliard julliard at winehq.org
Tue Sep 15 17:46:47 CDT 2009


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Sep 11 18:47:14 2009 +0200

jscript: Fixed null dispatch comparison.

---

 dlls/jscript/engine.c      |   20 +++++++++++++++-----
 dlls/jscript/tests/lang.js |    7 +++++++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index efd5e46..783b6e5 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -245,6 +245,11 @@ static HRESULT put_value(script_ctx_t *ctx, exprval_t *ref, VARIANT *v, jsexcept
     return disp_propput(ref->u.idref.disp, ref->u.idref.id, ctx->lcid, v, ei, NULL/*FIXME*/);
 }
 
+static inline BOOL is_null(const VARIANT *v)
+{
+    return V_VT(v) == VT_NULL || (V_VT(v) == VT_DISPATCH && !V_DISPATCH(v));
+}
+
 static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
 {
     IObjectIdentity *identity;
@@ -256,6 +261,11 @@ static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
         return S_OK;
     }
 
+    if(!disp1) {
+        *ret = !disp2;
+        return S_OK;
+    }
+
     hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
     if(FAILED(hres))
         return hres;
@@ -290,12 +300,12 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
     TRACE("\n");
 
     if(V_VT(lval) != V_VT(rval)) {
-        if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) {
+        if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval)))
             *ret = num_val(lval) == num_val(rval);
-            return S_OK;
-        }
-
-        *ret = FALSE;
+        else if(is_null(lval))
+            *ret = is_null(rval);
+        else
+            *ret = FALSE;
         return S_OK;
     }
 
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index b53a224..342f3e9 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -935,6 +935,13 @@ ok(createNullBSTR() === '', "createNullBSTR() !== ''");
 
 ok(getVT(nullDisp) === "VT_DISPATCH", "getVT(nullDisp) = " + getVT(nullDisp));
 ok(typeof(nullDisp) === "object", "typeof(nullDisp) = " + typeof(nullDisp));
+ok(nullDisp === nullDisp, "nullDisp !== nullDisp");
+ok(nullDisp !== re, "nullDisp === re");
+ok(nullDisp === null, "nullDisp === null");
+ok(nullDisp == null, "nullDisp == null");
+ok(getVT(true && nullDisp) === "VT_DISPATCH",
+   "getVT(0 && nullDisp) = " + getVT(true && nullDisp));
+ok(!nullDisp === true, "!nullDisp = " + !nullDisp);
 
 function do_test() {}
 function nosemicolon() {} nosemicolon();




More information about the wine-cvs mailing list