jscript: Fixed null dispatch comparison.

This commit is contained in:
Jacek Caban 2009-09-11 18:47:14 +02:00 committed by Alexandre Julliard
parent 176ba8cf95
commit 3e1430e0e4
2 changed files with 22 additions and 5 deletions

View File

@ -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;
}

View File

@ -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();