Commit 47f3abb6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Fix VT_UNKNOWN handling in is expressions.

parent 1c194f3b
...@@ -1928,75 +1928,57 @@ static HRESULT interp_case(exec_ctx_t *ctx) ...@@ -1928,75 +1928,57 @@ static HRESULT interp_case(exec_ctx_t *ctx)
return S_OK; return S_OK;
} }
static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, VARIANT_BOOL *ret) static HRESULT interp_is(exec_ctx_t *ctx)
{ {
IObjectIdentity *identity; IUnknown *l = NULL, *r = NULL;
IUnknown *unk1, *unk2; variant_val_t v;
HRESULT hres; HRESULT hres = S_OK;
if(disp1 == disp2) { TRACE("\n");
*ret = VARIANT_TRUE;
return S_OK;
}
if(!disp1 || !disp2) { stack_pop_deref(ctx, &v);
*ret = VARIANT_FALSE; if(V_VT(v.v) != VT_DISPATCH && V_VT(v.v) != VT_UNKNOWN) {
return S_OK; FIXME("Unhandled type %s\n", debugstr_variant(v.v));
hres = E_NOTIMPL;
}else if(V_UNKNOWN(v.v)) {
hres = IUnknown_QueryInterface(V_UNKNOWN(v.v), &IID_IUnknown, (void**)&r);
} }
if(v.owned) VariantClear(v.v);
hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2); stack_pop_deref(ctx, &v);
if(FAILED(hres)) { if(V_VT(v.v) != VT_DISPATCH && V_VT(v.v) != VT_UNKNOWN) {
IUnknown_Release(unk1); FIXME("Unhandled type %s\n", debugstr_variant(v.v));
return hres; hres = E_NOTIMPL;
} }else if(V_UNKNOWN(v.v)) {
hres = IUnknown_QueryInterface(V_UNKNOWN(v.v), &IID_IUnknown, (void**)&l);
if(unk1 == unk2) {
*ret = VARIANT_TRUE;
}else {
hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
if(SUCCEEDED(hres)) {
hres = IObjectIdentity_IsEqualObject(identity, unk2);
IObjectIdentity_Release(identity);
*ret = hres == S_OK ? VARIANT_TRUE : VARIANT_FALSE;
}else {
*ret = VARIANT_FALSE;
}
} }
if(v.owned) VariantClear(v.v);
IUnknown_Release(unk1);
IUnknown_Release(unk2);
return S_OK;
}
static HRESULT interp_is(exec_ctx_t *ctx)
{
IDispatch *l, *r;
VARIANT v;
HRESULT hres;
TRACE("\n");
hres = stack_pop_disp(ctx, &r);
if(FAILED(hres))
return hres;
hres = stack_pop_disp(ctx, &l);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
V_VT(&v) = VT_BOOL; VARIANT res;
hres = disp_cmp(l, r, &V_BOOL(&v)); V_VT(&res) = VT_BOOL;
if(l) if(r == l)
IDispatch_Release(l); V_BOOL(&res) = VARIANT_TRUE;
else if(!r || !l)
V_BOOL(&res) = VARIANT_FALSE;
else {
IObjectIdentity *identity;
hres = IUnknown_QueryInterface(l, &IID_IObjectIdentity, (void**)&identity);
if(SUCCEEDED(hres)) {
hres = IObjectIdentity_IsEqualObject(identity, r);
IObjectIdentity_Release(identity);
}
V_BOOL(&res) = hres == S_OK ? VARIANT_TRUE : VARIANT_FALSE;
}
hres = stack_push(ctx, &res);
} }
if(r) if(r)
IDispatch_Release(r); IUnknown_Release(r);
if(FAILED(hres)) if(l)
return hres; IUnknown_Release(l);
return hres;
return stack_push(ctx, &v);
} }
static HRESULT interp_concat(exec_ctx_t *ctx) static HRESULT interp_concat(exec_ctx_t *ctx)
......
...@@ -1202,6 +1202,7 @@ set x = obj ...@@ -1202,6 +1202,7 @@ set x = obj
call ok(getVT(obj) = "VT_UNKNOWN*", "getVT(obj) = " & getVT(obj)) call ok(getVT(obj) = "VT_UNKNOWN*", "getVT(obj) = " & getVT(obj))
call ok(getVT(x) = "VT_UNKNOWN*", "getVT(x) = " & getVT(x)) call ok(getVT(x) = "VT_UNKNOWN*", "getVT(x) = " & getVT(x))
call ok(getVT(unkObj) = "VT_UNKNOWN", "getVT(unkObj) = " & getVT(unkObj)) call ok(getVT(unkObj) = "VT_UNKNOWN", "getVT(unkObj) = " & getVT(unkObj))
call ok(obj is unkObj, "obj is not unkObj")
' Array tests ' Array tests
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment