oleaut32: Report the parameter index for any failure in DispGetParam.

This commit is contained in:
James Hawkins 2009-12-04 17:15:11 -08:00 committed by Alexandre Julliard
parent 02dcc19854
commit 89b2cde891
2 changed files with 31 additions and 32 deletions

View File

@ -131,16 +131,13 @@ HRESULT WINAPI DispGetParam(
TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
position, pdispparams->cArgs, pdispparams->cNamedArgs);
if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
return E_INVALIDARG;
if (!pvarResult)
return E_INVALIDARG;
if (position < pdispparams->cArgs) {
if (position < pdispparams->cArgs)
{
/* positional arg? */
pos = pdispparams->cArgs - position - 1;
} else {
}
else
{
/* FIXME: is this how to handle named args? */
for (pos=0; pos<pdispparams->cNamedArgs; pos++)
if (pdispparams->rgdispidNamedArgs[pos] == position) break;
@ -148,10 +145,27 @@ HRESULT WINAPI DispGetParam(
if (pos==pdispparams->cNamedArgs)
return DISP_E_PARAMNOTFOUND;
}
if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
{
hr = E_INVALIDARG;
goto done;
}
if (!pvarResult)
{
hr = E_INVALIDARG;
goto done;
}
hr = VariantChangeType(pvarResult,
&pdispparams->rgvarg[pos],
0, vtTarg);
if (hr == DISP_E_TYPEMISMATCH) *puArgErr = pos;
done:
if (FAILED(hr))
*puArgErr = pos;
return hr;
}
@ -241,8 +255,8 @@ static HRESULT WINAPI StdDispatch_QueryInterface(
IsEqualIID(riid, &IID_IUnknown))
{
*ppvObject = This;
IUnknown_AddRef((LPUNKNOWN)*ppvObject);
return S_OK;
IUnknown_AddRef((LPUNKNOWN)*ppvObject);
return S_OK;
}
return E_NOINTERFACE;
}

View File

@ -103,11 +103,8 @@ void test_DispGetParam(void)
INIT_DISPPARAMS(dispparams, NULL, NULL, 0, 0);
err_index = 0xdeadbeef;
hr = DispGetParam(&dispparams, 0, VT_I2, NULL, &err_index);
todo_wine
{
ok(hr == DISP_E_PARAMNOTFOUND,
"Expected DISP_E_PARAMNOTFOUND, got %08x\n", hr);
}
ok(hr == DISP_E_PARAMNOTFOUND,
"Expected DISP_E_PARAMNOTFOUND, got %08x\n", hr);
ok(err_index == 0xdeadbeef,
"Expected err_index to be unchanged, got %d\n", err_index);
@ -128,10 +125,7 @@ void test_DispGetParam(void)
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
ok(err_index == 0, "Expected 0, got %d\n", err_index);
/* pdispparams.cNamedArgs is 1, yet pdispparams.rgdispidNamedArgs is NULL.
*
@ -195,10 +189,7 @@ void test_DispGetParam(void)
err_index = 0xdeadbeef;
hr = DispGetParam(&dispparams, 2, VT_I2, NULL, &err_index);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
ok(err_index == 0, "Expected 0, got %d\n", err_index);
/* puArgErr is NULL. */
INIT_DISPPARAMS(dispparams, vararg, NULL, 3, 0);
@ -239,10 +230,7 @@ void test_DispGetParam(void)
ok(hr == DISP_E_OVERFLOW, "Expected DISP_E_OVERFLOW, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 1, "Expected 1, got %d\n", err_index);
}
ok(err_index == 1, "Expected 1, got %d\n", err_index);
/* Coerce the third (VT_BSTR) param to VT_I2. */
INIT_DISPPARAMS(dispparams, vararg, NULL, 3, 0);
@ -263,10 +251,7 @@ void test_DispGetParam(void)
ok(hr == DISP_E_BADVARTYPE, "Expected DISP_E_BADVARTYPE, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
ok(err_index == 0, "Expected 0, got %d\n", err_index);
CLEAR_VARARG(vararg);