propsys: Implement PropVariantToDouble().
Signed-off-by: Jactry Zeng <jzeng@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2e2fc55009
commit
3fc1180623
|
@ -112,7 +112,7 @@
|
||||||
@ stub PropVariantToBooleanVectorAlloc
|
@ stub PropVariantToBooleanVectorAlloc
|
||||||
@ stub PropVariantToBooleanWithDefault
|
@ stub PropVariantToBooleanWithDefault
|
||||||
@ stub PropVariantToBuffer
|
@ stub PropVariantToBuffer
|
||||||
@ stub PropVariantToDouble
|
@ stdcall PropVariantToDouble(ptr ptr)
|
||||||
@ stub PropVariantToDoubleVector
|
@ stub PropVariantToDoubleVector
|
||||||
@ stub PropVariantToDoubleVectorAlloc
|
@ stub PropVariantToDoubleVectorAlloc
|
||||||
@ stub PropVariantToDoubleWithDefault
|
@ stub PropVariantToDoubleWithDefault
|
||||||
|
|
|
@ -129,6 +129,12 @@ static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits,
|
||||||
src_signed = *res < 0;
|
src_signed = *res < 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case VT_R8:
|
||||||
|
{
|
||||||
|
src_signed = TRUE;
|
||||||
|
*res = pv->u.dblVal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
FIXME("unhandled vt %d\n", pv->vt);
|
FIXME("unhandled vt %d\n", pv->vt);
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
@ -155,6 +161,18 @@ static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits,
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret)
|
||||||
|
{
|
||||||
|
LONGLONG res;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE("(%p, %p)\n", propvarIn, ret);
|
||||||
|
|
||||||
|
hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
|
||||||
|
if (SUCCEEDED(hr)) *ret = (double)res;
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
|
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
|
||||||
{
|
{
|
||||||
LONGLONG res;
|
LONGLONG res;
|
||||||
|
|
|
@ -1248,6 +1248,62 @@ static void test_InitPropVariantFromCLSID(void)
|
||||||
PropVariantClear(&propvar);
|
PropVariantClear(&propvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_PropVariantToDouble(void)
|
||||||
|
{
|
||||||
|
PROPVARIANT propvar;
|
||||||
|
double value;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
PropVariantInit(&propvar);
|
||||||
|
propvar.vt = VT_R8;
|
||||||
|
propvar.u.dblVal = 15.0;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 15.0, "Unexpected value: %f.\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_I4;
|
||||||
|
propvar.u.lVal = 123;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 123.0, "Unexpected value: %f.\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_I4;
|
||||||
|
propvar.u.lVal = -256;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == -256, "Unexpected value: %f\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_I8;
|
||||||
|
propvar.u.lVal = 65536;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 65536.0, "Unexpected value: %f.\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_I8;
|
||||||
|
propvar.u.lVal = -321;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 4294966975.0, "Unexpected value: %f.\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_UI4;
|
||||||
|
propvar.u.ulVal = 6;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 6.0, "Unexpected value: %f.\n", value);
|
||||||
|
|
||||||
|
PropVariantClear(&propvar);
|
||||||
|
propvar.vt = VT_UI8;
|
||||||
|
propvar.u.uhVal.QuadPart = 8;
|
||||||
|
hr = PropVariantToDouble(&propvar, &value);
|
||||||
|
ok(hr == S_OK, "PropVariantToDouble failed: 0x%08x.\n", hr);
|
||||||
|
ok(value == 8.0, "Unexpected value: %f.\n", value);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(propsys)
|
START_TEST(propsys)
|
||||||
{
|
{
|
||||||
test_PSStringFromPropertyKey();
|
test_PSStringFromPropertyKey();
|
||||||
|
@ -1263,4 +1319,5 @@ START_TEST(propsys)
|
||||||
test_PropVariantToBoolean();
|
test_PropVariantToBoolean();
|
||||||
test_PropVariantToStringWithDefault();
|
test_PropVariantToStringWithDefault();
|
||||||
test_InitPropVariantFromCLSID();
|
test_InitPropVariantFromCLSID();
|
||||||
|
test_PropVariantToDouble();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid);
|
||||||
INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
|
INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
|
||||||
PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags);
|
PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags);
|
||||||
|
|
||||||
|
HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret);
|
||||||
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret);
|
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret);
|
||||||
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
|
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
|
||||||
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
|
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
|
||||||
|
|
Loading…
Reference in New Issue