Commit 1c194f3b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Fix VT_UNKNOWN handling in set statements.

parent cd191894
...@@ -458,22 +458,22 @@ static HRESULT stack_assume_disp(exec_ctx_t *ctx, unsigned n, IDispatch **disp) ...@@ -458,22 +458,22 @@ static HRESULT stack_assume_disp(exec_ctx_t *ctx, unsigned n, IDispatch **disp)
{ {
VARIANT *v = stack_top(ctx, n), *ref; VARIANT *v = stack_top(ctx, n), *ref;
if(V_VT(v) != VT_DISPATCH) { if(V_VT(v) != VT_DISPATCH && (disp || V_VT(v) != VT_UNKNOWN)) {
if(V_VT(v) != (VT_VARIANT|VT_BYREF)) { if(V_VT(v) != (VT_VARIANT|VT_BYREF)) {
FIXME("not supported type: %s\n", debugstr_variant(v)); FIXME("not supported type: %s\n", debugstr_variant(v));
return E_FAIL; return E_FAIL;
} }
ref = V_VARIANTREF(v); ref = V_VARIANTREF(v);
if(V_VT(ref) != VT_DISPATCH) { if(V_VT(ref) != VT_DISPATCH && (disp || V_VT(ref) != VT_UNKNOWN)) {
FIXME("not disp %s\n", debugstr_variant(ref)); FIXME("not disp %s\n", debugstr_variant(ref));
return E_FAIL; return E_FAIL;
} }
V_VT(v) = VT_DISPATCH; V_VT(v) = V_VT(ref);
V_DISPATCH(v) = V_DISPATCH(ref); V_UNKNOWN(v) = V_UNKNOWN(ref);
if(V_DISPATCH(v)) if(V_UNKNOWN(v))
IDispatch_AddRef(V_DISPATCH(v)); IUnknown_AddRef(V_UNKNOWN(v));
} }
if(disp) if(disp)
......
...@@ -1197,6 +1197,12 @@ Call ok(obj.Test1 = 6, "obj.Test1 is not 6") ...@@ -1197,6 +1197,12 @@ Call ok(obj.Test1 = 6, "obj.Test1 is not 6")
obj.AddToTest1(5) obj.AddToTest1(5)
Call ok(obj.Test1 = 11, "obj.Test1 is not 11") Call ok(obj.Test1 = 11, "obj.Test1 is not 11")
set obj = unkObj
set x = obj
call ok(getVT(obj) = "VT_UNKNOWN*", "getVT(obj) = " & getVT(obj))
call ok(getVT(x) = "VT_UNKNOWN*", "getVT(x) = " & getVT(x))
call ok(getVT(unkObj) = "VT_UNKNOWN", "getVT(unkObj) = " & getVT(unkObj))
' Array tests ' Array tests
Call ok(getVT(arr) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr)) Call ok(getVT(arr) = "VT_EMPTY*", "getVT(arr) = " & getVT(arr))
......
...@@ -144,6 +144,7 @@ DEFINE_EXPECT(OnLeaveScript); ...@@ -144,6 +144,7 @@ DEFINE_EXPECT(OnLeaveScript);
#define DISPID_GLOBAL_TESTERROROBJECT 1023 #define DISPID_GLOBAL_TESTERROROBJECT 1023
#define DISPID_GLOBAL_THROWWITHDESC 1024 #define DISPID_GLOBAL_THROWWITHDESC 1024
#define DISPID_GLOBAL_PROPARGSET 1025 #define DISPID_GLOBAL_PROPARGSET 1025
#define DISPID_GLOBAL_UNKOBJ 1026
#define DISPID_TESTOBJ_PROPGET 2000 #define DISPID_TESTOBJ_PROPGET 2000
#define DISPID_TESTOBJ_PROPPUT 2001 #define DISPID_TESTOBJ_PROPPUT 2001
...@@ -214,6 +215,8 @@ static const char *vt2a(VARIANT *v) ...@@ -214,6 +215,8 @@ static const char *vt2a(VARIANT *v)
return "VT_BSTR"; return "VT_BSTR";
case VT_DISPATCH: case VT_DISPATCH:
return "VT_DISPATCH"; return "VT_DISPATCH";
case VT_UNKNOWN:
return "VT_UNKNOWN";
case VT_BOOL: case VT_BOOL:
return "VT_BOOL"; return "VT_BOOL";
case VT_ARRAY|VT_VARIANT: case VT_ARRAY|VT_VARIANT:
...@@ -595,6 +598,35 @@ static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect) ...@@ -595,6 +598,35 @@ static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect)
static IDispatchEx enumDisp; static IDispatchEx enumDisp;
static HRESULT WINAPI unkObj_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
{
if(IsEqualGUID(riid, &IID_IUnknown)) {
*ppv = iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI unkObj_AddRef(IUnknown *iface)
{
return 2;
}
static ULONG WINAPI unkObj_Release(IUnknown *iface)
{
return 1;
}
static const IUnknownVtbl unkObjVtbl = {
unkObj_QueryInterface,
unkObj_AddRef,
unkObj_Release
};
static IUnknown unkObj = { &unkObjVtbl };
static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv) static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
{ {
if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumVARIANT)) { if(IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumVARIANT)) {
...@@ -1138,7 +1170,8 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD ...@@ -1138,7 +1170,8 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
{ L"throwInt", DISPID_GLOBAL_THROWINT }, { L"throwInt", DISPID_GLOBAL_THROWINT },
{ L"testOptionalArg", DISPID_GLOBAL_TESTOPTIONALARG }, { L"testOptionalArg", DISPID_GLOBAL_TESTOPTIONALARG },
{ L"testErrorObject", DISPID_GLOBAL_TESTERROROBJECT }, { L"testErrorObject", DISPID_GLOBAL_TESTERROROBJECT },
{ L"throwWithDesc", DISPID_GLOBAL_THROWWITHDESC } { L"throwWithDesc", DISPID_GLOBAL_THROWWITHDESC },
{ L"unkObj", DISPID_GLOBAL_UNKOBJ }
}; };
test_grfdex(grfdex, fdexNameCaseInsensitive); test_grfdex(grfdex, fdexNameCaseInsensitive);
...@@ -1657,6 +1690,10 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, ...@@ -1657,6 +1690,10 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
ok(hres == S_OK, "Invoke failed: %08x\n", hres); ok(hres == S_OK, "Invoke failed: %08x\n", hres);
return S_OK; return S_OK;
} }
case DISPID_GLOBAL_UNKOBJ:
V_VT(pvarRes) = VT_UNKNOWN;
V_UNKNOWN(pvarRes) = &unkObj;
return S_OK;
} }
ok(0, "unexpected call %d\n", id); ok(0, "unexpected call %d\n", id);
......
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