diff --git a/dlls/oleaut32/variant.h b/dlls/oleaut32/variant.h index 237687a3209..3202ebc3833 100644 --- a/dlls/oleaut32/variant.h +++ b/dlls/oleaut32/variant.h @@ -111,11 +111,6 @@ extern const char* wine_vflags[]; #define BOTHTST(dest, src, func, lo, hi) RETTYP _##func(src in, dest* out) { \ if (in < (dest)lo || in > hi) return DISP_E_OVERFLOW; *out = in; return S_OK; } -/* Conversions from IDispatch use the same code */ -HRESULT VARIANT_FromDisp(IDispatch*,LCID,void*,VARTYPE); -/* As do conversions from BSTR to numeric types */ -HRESULT VARIANT_NumberFromBstr(OLECHAR*,LCID,ULONG,void*,VARTYPE); - #define CY_MULTIPLIER 10000 /* 4 dp of precision */ #define CY_MULTIPLIER_F 10000.0 #define CY_HALF (CY_MULTIPLIER/2) /* 0.5 */ @@ -125,50 +120,29 @@ HRESULT VARIANT_NumberFromBstr(OLECHAR*,LCID,ULONG,void*,VARTYPE); POSTST(signed char, BYTE, VarI1FromUI1, I1_MAX); BOTHTST(signed char, SHORT, VarI1FromI2, I1_MIN, I1_MAX); BOTHTST(signed char, LONG, VarI1FromI4, I1_MIN, I1_MAX); -#define _VarI1FromR4(flt,out) VarI1FromR8((double)flt,out) -#define _VarI1FromR8 VarI1FromR8 -#define _VarI1FromCy VarI1FromCy -#define _VarI1FromDate(dt,out) VarI1FromR8((double)dt,out) -#define _VarI1FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_I1) -#define _VarI1FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, (BYTE*)out, VT_I1) SIMPLE(signed char, VARIANT_BOOL, VarI1FromBool); POSTST(signed char, USHORT, VarI1FromUI2, I1_MAX); POSTST(signed char, ULONG, VarI1FromUI4, I1_MAX); -#define _VarI1FromDec VarI1FromDec BOTHTST(signed char, LONG64, VarI1FromI8, I1_MIN, I1_MAX); POSTST(signed char, ULONG64, VarI1FromUI8, I1_MAX); /* UI1 */ BOTHTST(BYTE, SHORT, VarUI1FromI2, UI1_MIN, UI1_MAX); -#define _VarUI1FromR4(flt,out) VarUI1FromR8((double)flt,out) -#define _VarUI1FromR8 VarUI1FromR8 -#define _VarUI1FromCy VarUI1FromCy -#define _VarUI1FromDate(dt,out) VarUI1FromR8((double)dt,out) -#define _VarUI1FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_UI1) -#define _VarUI1FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_UI1) SIMPLE(BYTE, VARIANT_BOOL, VarUI1FromBool); NEGTST(BYTE, signed char, VarUI1FromI1); POSTST(BYTE, USHORT, VarUI1FromUI2, UI1_MAX); BOTHTST(BYTE, LONG, VarUI1FromI4, UI1_MIN, UI1_MAX); POSTST(BYTE, ULONG, VarUI1FromUI4, UI1_MAX); -#define _VarUI1FromDec VarUI1FromDec BOTHTST(BYTE, LONG64, VarUI1FromI8, UI1_MIN, UI1_MAX); POSTST(BYTE, ULONG64, VarUI1FromUI8, UI1_MAX); /* I2 */ SIMPLE(SHORT, BYTE, VarI2FromUI1); BOTHTST(SHORT, LONG, VarI2FromI4, I2_MIN, I2_MAX); -#define _VarI2FromR4(flt,out) VarI2FromR8((double)flt,out) -#define _VarI2FromR8 VarI2FromR8 -#define _VarI2FromCy VarI2FromCy -#define _VarI2FromDate(dt,out) VarI2FromR8((double)dt,out) -#define _VarI2FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_I2) -#define _VarI2FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, (BYTE*)out, VT_I2) SIMPLE(SHORT, VARIANT_BOOL, VarI2FromBool); SIMPLE(SHORT, signed char, VarI2FromI1); POSTST(SHORT, USHORT, VarI2FromUI2, I2_MAX); POSTST(SHORT, ULONG, VarI2FromUI4, I2_MAX); -#define _VarI2FromDec VarI2FromDec BOTHTST(SHORT, LONG64, VarI2FromI8, I2_MIN, I2_MAX); POSTST(SHORT, ULONG64, VarI2FromUI8, I2_MAX); @@ -176,33 +150,19 @@ POSTST(SHORT, ULONG64, VarI2FromUI8, I2_MAX); SIMPLE(USHORT, BYTE, VarUI2FromUI1); NEGTST(USHORT, SHORT, VarUI2FromI2); BOTHTST(USHORT, LONG, VarUI2FromI4, UI2_MIN, UI2_MAX); -#define _VarUI2FromR4(flt,out) VarUI2FromR8((double)flt,out) -#define _VarUI2FromR8 VarUI2FromR8 -#define _VarUI2FromCy VarUI2FromCy -#define _VarUI2FromDate(dt,out) VarUI2FromR8((double)dt,out) -#define _VarUI2FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_UI2) -#define _VarUI2FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_UI2) SIMPLE(USHORT, VARIANT_BOOL, VarUI2FromBool); NEGTST(USHORT, signed char, VarUI2FromI1); POSTST(USHORT, ULONG, VarUI2FromUI4, UI2_MAX); -#define _VarUI2FromDec VarUI2FromDec BOTHTST(USHORT, LONG64, VarUI2FromI8, UI2_MIN, UI2_MAX); POSTST(USHORT, ULONG64, VarUI2FromUI8, UI2_MAX); /* I4 */ SIMPLE(LONG, BYTE, VarI4FromUI1); SIMPLE(LONG, SHORT, VarI4FromI2); -#define _VarI4FromR4(flt,out) VarI4FromR8((double)flt,out) -#define _VarI4FromR8 VarI4FromR8 -#define _VarI4FromCy VarI4FromCy -#define _VarI4FromDate(dt,out) VarI4FromR8((double)dt,out) -#define _VarI4FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_I4) -#define _VarI4FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, (BYTE*)out, VT_I4) SIMPLE(LONG, VARIANT_BOOL, VarI4FromBool); SIMPLE(LONG, signed char, VarI4FromI1); SIMPLE(LONG, USHORT, VarI4FromUI2); POSTST(LONG, ULONG, VarI4FromUI4, I4_MAX); -#define _VarI4FromDec VarI4FromDec BOTHTST(LONG, LONG64, VarI4FromI8, I4_MIN, I4_MAX); POSTST(LONG, ULONG64, VarI4FromUI8, I4_MAX); @@ -210,72 +170,37 @@ POSTST(LONG, ULONG64, VarI4FromUI8, I4_MAX); SIMPLE(ULONG, BYTE, VarUI4FromUI1); NEGTST(ULONG, SHORT, VarUI4FromI2); NEGTST(ULONG, LONG, VarUI4FromI4); -#define _VarUI4FromR4(flt,out) VarUI4FromR8((double)flt,out) -#define _VarUI4FromR8 VarUI4FromR8 -#define _VarUI4FromCy VarUI4FromCy -#define _VarUI4FromDate(dt,out) VarUI4FromR8((double)dt,out) -#define _VarUI4FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_UI4) -#define _VarUI4FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_UI4) SIMPLE(ULONG, VARIANT_BOOL, VarUI4FromBool); NEGTST(ULONG, signed char, VarUI4FromI1); SIMPLE(ULONG, USHORT, VarUI4FromUI2); -#define _VarUI4FromDec VarUI4FromDec BOTHTST(ULONG, LONG64, VarUI4FromI8, UI4_MIN, UI4_MAX); POSTST(ULONG, ULONG64, VarUI4FromUI8, UI4_MAX); /* I8 */ SIMPLE(LONG64, BYTE, VarI8FromUI1); SIMPLE(LONG64, SHORT, VarI8FromI2); -#define _VarI8FromR4 VarI8FromR8 -#define _VarI8FromR8 VarI8FromR8 -#define _VarI8FromCy VarI8FromCy -#define _VarI8FromDate(dt,out) VarI8FromR8((double)dt,out) -#define _VarI8FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_I8) -#define _VarI8FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_I8) -#define _VarI8FromBool _VarI8FromI2 SIMPLE(LONG64, signed char, VarI8FromI1); SIMPLE(LONG64, USHORT, VarI8FromUI2); SIMPLE(LONG64, LONG, VarI8FromI4); SIMPLE(LONG64, ULONG, VarI8FromUI4); -#define _VarI8FromDec VarI8FromDec POSTST(LONG64, ULONG64, VarI8FromUI8, I8_MAX); /* UI8 */ SIMPLE(ULONG64, BYTE, VarUI8FromUI1); NEGTST(ULONG64, SHORT, VarUI8FromI2); -#define _VarUI8FromR4 VarUI8FromR8 -#define _VarUI8FromR8 VarUI8FromR8 -#define _VarUI8FromCy VarUI8FromCy -#define _VarUI8FromDate(dt,out) VarUI8FromR8((double)dt,out) -#define _VarUI8FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_UI8) -#define _VarUI8FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_UI8) -#define _VarUI8FromBool _VarI8FromI2 NEGTST(ULONG64, signed char, VarUI8FromI1); SIMPLE(ULONG64, USHORT, VarUI8FromUI2); NEGTST(ULONG64, LONG, VarUI8FromI4); SIMPLE(ULONG64, ULONG, VarUI8FromUI4); -#define _VarUI8FromDec VarUI8FromDec NEGTST(ULONG64, LONG64, VarUI8FromI8); /* R4 (float) */ SIMPLE(float, BYTE, VarR4FromUI1); SIMPLE(float, SHORT, VarR4FromI2); -RETTYP _VarR4FromR8(double i, float* o) { - double d = i < 0.0 ? -i : i; - if (d > R4_MAX) return DISP_E_OVERFLOW; - *o = i; - return S_OK; -} -RETTYP _VarR4FromCy(CY i, float* o) { *o = (double)i.int64 / CY_MULTIPLIER_F; return S_OK; } -#define _VarR4FromDate(dt,out) _VarR4FromR8((double)dt,out) -#define _VarR4FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_R4) -#define _VarR4FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_R4) -#define _VarR4FromBool _VarR4FromI2 SIMPLE(float, signed char, VarR4FromI1); SIMPLE(float, USHORT, VarR4FromUI2); SIMPLE(float, LONG, VarR4FromI4); SIMPLE(float, ULONG, VarR4FromUI4); -#define _VarR4FromDec VarR4FromDec SIMPLE(float, LONG64, VarR4FromI8); SIMPLE(float, ULONG64, VarR4FromUI8); @@ -285,126 +210,18 @@ SIMPLE(double, SHORT, VarR8FromI2); SIMPLE(double, float, VarR8FromR4); RETTYP _VarR8FromCy(CY i, double* o) { *o = (double)i.int64 / CY_MULTIPLIER_F; return S_OK; } SIMPLE(double, DATE, VarR8FromDate); -#define _VarR8FromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_R8) -#define _VarR8FromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_R8) -#define _VarR8FromBool _VarR8FromI2 SIMPLE(double, signed char, VarR8FromI1); SIMPLE(double, USHORT, VarR8FromUI2); SIMPLE(double, LONG, VarR8FromI4); SIMPLE(double, ULONG, VarR8FromUI4); -#define _VarR8FromDec VarR8FromDec SIMPLE(double, LONG64, VarR8FromI8); SIMPLE(double, ULONG64, VarR8FromUI8); -/* BOOL */ -#define BOOLFUNC(src, func) RETTYP _##func(src in, VARIANT_BOOL* out) { \ - *out = in ? VARIANT_TRUE : VARIANT_FALSE; return S_OK; } - -BOOLFUNC(signed char,VarBoolFromI1); -BOOLFUNC(BYTE,VarBoolFromUI1); -BOOLFUNC(SHORT,VarBoolFromI2); -BOOLFUNC(USHORT,VarBoolFromUI2); -BOOLFUNC(LONG,VarBoolFromI4); -BOOLFUNC(ULONG,VarBoolFromUI4); -BOOLFUNC(LONG64,VarBoolFromI8); -BOOLFUNC(ULONG64,VarBoolFromUI8); -#define _VarBoolFromR4(flt,out) _VarBoolFromR8((double)flt,out) -BOOLFUNC(double,VarBoolFromR8); -#define _VarBoolFromCy(i,o) _VarBoolFromI8(i.int64,o) -#define _VarBoolFromDate(dt,out) _VarBoolFromR8((double)dt,out) -#define _VarBoolFromStr VarBoolFromStr -#define _VarBoolFromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, (BYTE*)out, VT_BOOL) -#define _VarBoolFromDec VarBoolFromDec - /* Internal flags for low level conversion functions */ #define VAR_BOOLONOFF 0x0400 /* Convert bool to "On"/"Off" */ #define VAR_BOOLYESNO 0x0800 /* Convert bool to "Yes"/"No" */ #define VAR_NEGATIVE 0x1000 /* Number is negative */ -/* DECIMAL */ -#define _VarDecFromUI1 VarDecFromUI4 -#define _VarDecFromI2 VarDecFromI4 -#define _VarDecFromR4 VarDecFromR4 -#define _VarDecFromR8 VarDecFromR8 -#define _VarDecFromCy VarDecFromCy -#define _VarDecFromDate(dt,out) VarDecFromR8((double)dt,out) -#define _VarDecFromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_DECIMAL) -#define _VarDecFromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_DECIMAL) -#define _VarDecFromBool VarDecFromBool -#define _VarDecFromI1 VarDecFromI4 -#define _VarDecFromUI2 VarDecFromUI4 -#define _VarDecFromI4 VarDecFromI4 -#define _VarDecFromUI4 VarDecFromUI4 -#define _VarDecFromI8 VarDecFromI8 -#define _VarDecFromUI8 VarDecFromUI8 - -/* CY (Currency) */ -#define _VarCyFromUI1 VarCyFromR8 -#define _VarCyFromI2 VarCyFromR8 -#define _VarCyFromR4 VarCyFromR8 -#define _VarCyFromR8 VarCyFromR8 -#define _VarCyFromDate VarCyFromR8 -#define _VarCyFromStr(str,lcid,flags,out) VARIANT_NumberFromBstr(str,lcid,flags,(BYTE*)out,VT_CY) -#define _VarCyFromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_CY) -#define _VarCyFromBool VarCyFromR8 -#define _VarCyFromI1 VarCyFromR8 -#define _VarCyFromUI2 VarCyFromR8 -#define _VarCyFromI4 VarCyFromR8 -#define _VarCyFromUI4 VarCyFromR8 -#define _VarCyFromDec VarCyFromDec -RETTYP _VarCyFromI8(LONG64 i, CY* o) { - if (i <= (I8_MIN/CY_MULTIPLIER) || i >= (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW; - o->int64 = i * CY_MULTIPLIER; - return S_OK; -} -#define _VarCyFromUI8 VarCyFromR8 - -/* DATE */ -#define _VarDateFromUI1 _VarR8FromUI1 -#define _VarDateFromI2 _VarR8FromI2 -#define _VarDateFromR4 _VarDateFromR8 -RETTYP _VarDateFromR8(double i, DATE* o) { - if (i <= (DATE_MIN - 1.0) || i >= (DATE_MAX + 1.0)) return DISP_E_OVERFLOW; - *o = (DATE)i; - return S_OK; -} -#define _VarDateFromCy _VarR8FromCy -#define _VarDateFromStr VarDateFromStr -#define _VarDateFromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_DATE) -#define _VarDateFromBool _VarR8FromBool -#define _VarDateFromI1 _VarR8FromI1 -#define _VarDateFromUI2 _VarR8FromUI2 -#define _VarDateFromI4 _VarDateFromR8 -#define _VarDateFromUI4 _VarDateFromR8 -#define _VarDateFromDec _VarR8FromDec -RETTYP _VarDateFromI8(LONG64 i, DATE* o) { - if (i < DATE_MIN || i > DATE_MAX) return DISP_E_OVERFLOW; - *o = (DATE)i; - return S_OK; -} -RETTYP _VarDateFromUI8(ULONG64 i, DATE* o) { - if (i > DATE_MAX) return DISP_E_OVERFLOW; - *o = (DATE)i; - return S_OK; -} - -/* BSTR */ -#define _VarBstrFromUI1 VarBstrFromUI4 -#define _VarBstrFromI2 VarBstrFromI4 -#define _VarBstrFromR4 VarBstrFromR8 -#define _VarBstrFromR8 VarBstrFromR8 -#define _VarBstrFromCy VarBstrFromCy -#define _VarBstrFromDate VarBstrFromDate -#define _VarBstrFromDisp(disp,lcid,out) VARIANT_FromDisp(disp, lcid, out, VT_BSTR) -#define _VarBstrFromBool VarBstrFromBool -#define _VarBstrFromI1 VarBstrFromI4 -#define _VarBstrFromUI2 VarBstrFromUI4 -#define _VarBstrFromI4 VarBstrFromI4 -#define _VarBstrFromUI4 VarBstrFromUI4 -#define _VarBstrFromDec VarBstrFromDec -#define _VarBstrFromI8 VarBstrFromI8 -#define _VarBstrFromUI8 VarBstrFromUI8 - /* Macro to inline conversion from a float or double to any integer type, * rounding according to the 'dutch' convention. */ diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c index 0e1b7e836f8..71f5bf2a428 100644 --- a/dlls/oleaut32/vartype.c +++ b/dlls/oleaut32/vartype.c @@ -66,8 +66,8 @@ static inline void VARIANT_CopyData(const VARIANT *srcVar, VARTYPE vt, void *pOu /* Coerce VT_BSTR to a numeric type */ -HRESULT VARIANT_NumberFromBstr(OLECHAR* pStrIn, LCID lcid, ULONG ulFlags, - void* pOut, VARTYPE vt) +static HRESULT VARIANT_NumberFromBstr(OLECHAR* pStrIn, LCID lcid, ULONG ulFlags, + void* pOut, VARTYPE vt) { VARIANTARG dstVar; HRESULT hRet; @@ -91,7 +91,7 @@ HRESULT VARIANT_NumberFromBstr(OLECHAR* pStrIn, LCID lcid, ULONG ulFlags, } /* Coerce VT_DISPATCH to another type */ -HRESULT VARIANT_FromDisp(IDispatch* pdispIn, LCID lcid, void* pOut, VARTYPE vt) +static HRESULT VARIANT_FromDisp(IDispatch* pdispIn, LCID lcid, void* pOut, VARTYPE vt) { static const DISPPARAMS emptyParams = { NULL, NULL, 0, 0 }; VARIANTARG srcVar, dstVar; @@ -198,7 +198,7 @@ HRESULT WINAPI VarI1FromI4(LONG iIn, signed char* pcOut) */ HRESULT WINAPI VarI1FromR4(FLOAT fltIn, signed char* pcOut) { - return _VarI1FromR4(fltIn, pcOut); + return VarI1FromR8(fltIn, pcOut); } /************************************************************************ @@ -242,7 +242,7 @@ HRESULT WINAPI VarI1FromR8(double dblIn, signed char* pcOut) */ HRESULT WINAPI VarI1FromDate(DATE dateIn, signed char* pcOut) { - return _VarI1FromDate(dateIn, pcOut); + return VarI1FromR8(dateIn, pcOut); } /************************************************************************ @@ -263,7 +263,7 @@ HRESULT WINAPI VarI1FromCy(CY cyIn, signed char* pcOut) { LONG i = I1_MAX + 1; - _VarI4FromCy(cyIn, &i); + VarI4FromCy(cyIn, &i); return _VarI1FromI4(i, pcOut); } @@ -286,7 +286,7 @@ HRESULT WINAPI VarI1FromCy(CY cyIn, signed char* pcOut) */ HRESULT WINAPI VarI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, signed char* pcOut) { - return _VarI1FromStr(strIn, lcid, dwFlags, pcOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pcOut, VT_I1); } /************************************************************************ @@ -307,7 +307,7 @@ HRESULT WINAPI VarI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, signed cha */ HRESULT WINAPI VarI1FromDisp(IDispatch* pdispIn, LCID lcid, signed char* pcOut) { - return _VarI1FromDisp(pdispIn, lcid, pcOut); + return VARIANT_FromDisp(pdispIn, lcid, pcOut, VT_I1); } /************************************************************************ @@ -385,7 +385,7 @@ HRESULT WINAPI VarI1FromDec(DECIMAL *pdecIn, signed char* pcOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarI1FromI8(i64, pcOut); @@ -488,7 +488,7 @@ HRESULT WINAPI VarUI1FromI4(LONG iIn, BYTE* pbOut) */ HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE* pbOut) { - return _VarUI1FromR4(fltIn, pbOut); + return VarUI1FromR8(fltIn, pbOut); } /************************************************************************ @@ -537,7 +537,7 @@ HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) { ULONG i = UI1_MAX + 1; - _VarUI4FromCy(cyIn, &i); + VarUI4FromCy(cyIn, &i); return _VarUI1FromUI4(i, pbOut); } @@ -557,7 +557,7 @@ HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) */ HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE* pbOut) { - return _VarUI1FromDate(dateIn, pbOut); + return VarUI1FromR8(dateIn, pbOut); } /************************************************************************ @@ -579,7 +579,7 @@ HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE* pbOut) */ HRESULT WINAPI VarUI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, BYTE* pbOut) { - return _VarUI1FromStr(strIn, lcid, dwFlags, pbOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pbOut, VT_UI1); } /************************************************************************ @@ -600,7 +600,7 @@ HRESULT WINAPI VarUI1FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, BYTE* pbO */ HRESULT WINAPI VarUI1FromDisp(IDispatch* pdispIn, LCID lcid, BYTE* pbOut) { - return _VarUI1FromDisp(pdispIn, lcid, pbOut); + return VARIANT_FromDisp(pdispIn, lcid, pbOut, VT_UI1); } /************************************************************************ @@ -696,7 +696,7 @@ HRESULT WINAPI VarUI1FromDec(DECIMAL *pdecIn, BYTE* pbOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarUI1FromI8(i64, pbOut); @@ -795,7 +795,7 @@ HRESULT WINAPI VarI2FromI4(LONG iIn, SHORT* psOut) */ HRESULT WINAPI VarI2FromR4(FLOAT fltIn, SHORT* psOut) { - return _VarI2FromR4(fltIn, psOut); + return VarI2FromR8(fltIn, psOut); } /************************************************************************ @@ -839,7 +839,7 @@ HRESULT WINAPI VarI2FromCy(CY cyIn, SHORT* psOut) { LONG i = I2_MAX + 1; - _VarI4FromCy(cyIn, &i); + VarI4FromCy(cyIn, &i); return _VarI2FromI4(i, psOut); } @@ -858,7 +858,7 @@ HRESULT WINAPI VarI2FromCy(CY cyIn, SHORT* psOut) */ HRESULT WINAPI VarI2FromDate(DATE dateIn, SHORT* psOut) { - return _VarI2FromDate(dateIn, psOut); + return VarI2FromR8(dateIn, psOut); } /************************************************************************ @@ -880,7 +880,7 @@ HRESULT WINAPI VarI2FromDate(DATE dateIn, SHORT* psOut) */ HRESULT WINAPI VarI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, SHORT* psOut) { - return _VarI2FromStr(strIn, lcid, dwFlags, psOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, psOut, VT_I2); } /************************************************************************ @@ -901,7 +901,7 @@ HRESULT WINAPI VarI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, SHORT* psO */ HRESULT WINAPI VarI2FromDisp(IDispatch* pdispIn, LCID lcid, SHORT* psOut) { - return _VarI2FromDisp(pdispIn, lcid, psOut); + return VARIANT_FromDisp(pdispIn, lcid, psOut, VT_I2); } /************************************************************************ @@ -993,7 +993,7 @@ HRESULT WINAPI VarI2FromDec(DECIMAL *pdecIn, SHORT* psOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarI2FromI8(i64, psOut); @@ -1107,7 +1107,7 @@ HRESULT WINAPI VarUI2FromI4(LONG iIn, USHORT* pusOut) */ HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT* pusOut) { - return _VarUI2FromR4(fltIn, pusOut); + return VarUI2FromR8(fltIn, pusOut); } /************************************************************************ @@ -1149,7 +1149,7 @@ HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT* pusOut) */ HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT* pusOut) { - return _VarUI2FromDate(dateIn, pusOut); + return VarUI2FromR8(dateIn, pusOut); } /************************************************************************ @@ -1172,7 +1172,7 @@ HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) { ULONG i = UI2_MAX + 1; - _VarUI4FromCy(cyIn, &i); + VarUI4FromCy(cyIn, &i); return _VarUI2FromUI4(i, pusOut); } @@ -1194,7 +1194,7 @@ HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) */ HRESULT WINAPI VarUI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, USHORT* pusOut) { - return _VarUI2FromStr(strIn, lcid, dwFlags, pusOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pusOut, VT_UI2); } /************************************************************************ @@ -1215,7 +1215,7 @@ HRESULT WINAPI VarUI2FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, USHORT* p */ HRESULT WINAPI VarUI2FromDisp(IDispatch* pdispIn, LCID lcid, USHORT* pusOut) { - return _VarUI2FromDisp(pdispIn, lcid, pusOut); + return VARIANT_FromDisp(pdispIn, lcid, pusOut, VT_UI2); } /************************************************************************ @@ -1290,7 +1290,7 @@ HRESULT WINAPI VarUI2FromDec(DECIMAL *pdecIn, USHORT* pusOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarUI2FromI8(i64, pusOut); @@ -1387,7 +1387,7 @@ HRESULT WINAPI VarI4FromI2(SHORT sIn, LONG *piOut) */ HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG *piOut) { - return _VarI4FromR4(fltIn, piOut); + return VarI4FromR8(fltIn, piOut); } /************************************************************************ @@ -1430,7 +1430,7 @@ HRESULT WINAPI VarI4FromR8(double dblIn, LONG *piOut) HRESULT WINAPI VarI4FromCy(CY cyIn, LONG *piOut) { double d = cyIn.int64 / CY_MULTIPLIER_F; - return _VarI4FromR8(d, piOut); + return VarI4FromR8(d, piOut); } /************************************************************************ @@ -1448,7 +1448,7 @@ HRESULT WINAPI VarI4FromCy(CY cyIn, LONG *piOut) */ HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG *piOut) { - return _VarI4FromDate(dateIn, piOut); + return VarI4FromR8(dateIn, piOut); } /************************************************************************ @@ -1470,7 +1470,7 @@ HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG *piOut) */ HRESULT WINAPI VarI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG *piOut) { - return _VarI4FromStr(strIn, lcid, dwFlags, piOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, piOut, VT_I4); } /************************************************************************ @@ -1491,7 +1491,7 @@ HRESULT WINAPI VarI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG *piOu */ HRESULT WINAPI VarI4FromDisp(IDispatch* pdispIn, LCID lcid, LONG *piOut) { - return _VarI4FromDisp(pdispIn, lcid, piOut); + return VARIANT_FromDisp(pdispIn, lcid, piOut, VT_I4); } /************************************************************************ @@ -1582,7 +1582,7 @@ HRESULT WINAPI VarI4FromDec(DECIMAL *pdecIn, LONG *piOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarI4FromI8(i64, piOut); @@ -1696,7 +1696,7 @@ HRESULT WINAPI VarUI4FromI4(LONG iIn, ULONG *pulOut) */ HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG *pulOut) { - return _VarUI4FromR4(fltIn, pulOut); + return VarUI4FromR8(fltIn, pulOut); } /************************************************************************ @@ -1738,7 +1738,7 @@ HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG *pulOut) */ HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG *pulOut) { - return _VarUI4FromDate(dateIn, pulOut); + return VarUI4FromR8(dateIn, pulOut); } /************************************************************************ @@ -1757,7 +1757,7 @@ HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG *pulOut) HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG *pulOut) { double d = cyIn.int64 / CY_MULTIPLIER_F; - return _VarUI4FromR8(d, pulOut); + return VarUI4FromR8(d, pulOut); } /************************************************************************ @@ -1779,7 +1779,7 @@ HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG *pulOut) */ HRESULT WINAPI VarUI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG *pulOut) { - return _VarUI4FromStr(strIn, lcid, dwFlags, pulOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pulOut, VT_UI4); } /************************************************************************ @@ -1800,7 +1800,7 @@ HRESULT WINAPI VarUI4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG *pu */ HRESULT WINAPI VarUI4FromDisp(IDispatch* pdispIn, LCID lcid, ULONG *pulOut) { - return _VarUI4FromDisp(pdispIn, lcid, pulOut); + return VARIANT_FromDisp(pdispIn, lcid, pulOut, VT_UI4); } /************************************************************************ @@ -1874,7 +1874,7 @@ HRESULT WINAPI VarUI4FromDec(DECIMAL *pdecIn, ULONG *pulOut) LONG64 i64; HRESULT hRet; - hRet = _VarI8FromDec(pdecIn, &i64); + hRet = VarI8FromDec(pdecIn, &i64); if (SUCCEEDED(hRet)) hRet = _VarUI4FromI8(i64, pulOut); @@ -1971,7 +1971,7 @@ HRESULT WINAPI VarI8FromI2(SHORT sIn, LONG64* pi64Out) */ HRESULT WINAPI VarI8FromR4(FLOAT fltIn, LONG64* pi64Out) { - return _VarI8FromR4(fltIn, pi64Out); + return VarI8FromR8(fltIn, pi64Out); } /************************************************************************ @@ -2064,7 +2064,7 @@ HRESULT WINAPI VarI8FromCy(CY cyIn, LONG64* pi64Out) */ HRESULT WINAPI VarI8FromDate(DATE dateIn, LONG64* pi64Out) { - return _VarI8FromDate(dateIn, pi64Out); + return VarI8FromR8(dateIn, pi64Out); } /************************************************************************ @@ -2086,7 +2086,7 @@ HRESULT WINAPI VarI8FromDate(DATE dateIn, LONG64* pi64Out) */ HRESULT WINAPI VarI8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG64* pi64Out) { - return _VarI8FromStr(strIn, lcid, dwFlags, pi64Out); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pi64Out, VT_I8); } /************************************************************************ @@ -2107,7 +2107,7 @@ HRESULT WINAPI VarI8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, LONG64* pi */ HRESULT WINAPI VarI8FromDisp(IDispatch* pdispIn, LCID lcid, LONG64* pi64Out) { - return _VarI8FromDisp(pdispIn, lcid, pi64Out); + return VARIANT_FromDisp(pdispIn, lcid, pi64Out, VT_I8); } /************************************************************************ @@ -2124,7 +2124,7 @@ HRESULT WINAPI VarI8FromDisp(IDispatch* pdispIn, LCID lcid, LONG64* pi64Out) */ HRESULT WINAPI VarI8FromBool(VARIANT_BOOL boolIn, LONG64* pi64Out) { - return _VarI8FromBool(boolIn, pi64Out); + return VarI8FromI2(boolIn, pi64Out); } /************************************************************************ @@ -2215,7 +2215,7 @@ HRESULT WINAPI VarI8FromDec(DECIMAL *pdecIn, LONG64* pi64Out) HRESULT hRet; double dbl; - hRet = _VarR8FromDec(pdecIn, &dbl); + hRet = VarR8FromDec(pdecIn, &dbl); if (SUCCEEDED(hRet)) hRet = VarI8FromR8(dbl, pi64Out); return hRet; @@ -2310,7 +2310,7 @@ HRESULT WINAPI VarUI8FromI2(SHORT sIn, ULONG64* pui64Out) */ HRESULT WINAPI VarUI8FromR4(FLOAT fltIn, ULONG64* pui64Out) { - return _VarUI8FromR4(fltIn, pui64Out); + return VarUI8FromR8(fltIn, pui64Out); } /************************************************************************ @@ -2392,7 +2392,7 @@ HRESULT WINAPI VarUI8FromCy(CY cyIn, ULONG64* pui64Out) */ HRESULT WINAPI VarUI8FromDate(DATE dateIn, ULONG64* pui64Out) { - return _VarUI8FromDate(dateIn, pui64Out); + return VarUI8FromR8(dateIn, pui64Out); } /************************************************************************ @@ -2414,7 +2414,7 @@ HRESULT WINAPI VarUI8FromDate(DATE dateIn, ULONG64* pui64Out) */ HRESULT WINAPI VarUI8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG64* pui64Out) { - return _VarUI8FromStr(strIn, lcid, dwFlags, pui64Out); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pui64Out, VT_UI8); } /************************************************************************ @@ -2435,7 +2435,7 @@ HRESULT WINAPI VarUI8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, ULONG64* */ HRESULT WINAPI VarUI8FromDisp(IDispatch* pdispIn, LCID lcid, ULONG64* pui64Out) { - return _VarUI8FromDisp(pdispIn, lcid, pui64Out); + return VARIANT_FromDisp(pdispIn, lcid, pui64Out, VT_UI8); } /************************************************************************ @@ -2453,7 +2453,7 @@ HRESULT WINAPI VarUI8FromDisp(IDispatch* pdispIn, LCID lcid, ULONG64* pui64Out) */ HRESULT WINAPI VarUI8FromBool(VARIANT_BOOL boolIn, ULONG64* pui64Out) { - return _VarUI8FromBool(boolIn, pui64Out); + return VarI8FromI2(boolIn, (LONG64 *)pui64Out); } /************************************************************************ * VarUI8FromI1 (OLEAUT32.438) @@ -2553,7 +2553,7 @@ HRESULT WINAPI VarUI8FromDec(DECIMAL *pdecIn, ULONG64* pui64Out) HRESULT hRet; double dbl; - hRet = _VarR8FromDec(pdecIn, &dbl); + hRet = VarR8FromDec(pdecIn, &dbl); if (SUCCEEDED(hRet)) hRet = VarUI8FromR8(dbl, pui64Out); return hRet; @@ -2629,7 +2629,10 @@ HRESULT WINAPI VarR4FromI4(LONG lIn, float *pFltOut) */ HRESULT WINAPI VarR4FromR8(double dblIn, float *pFltOut) { - return _VarR4FromR8(dblIn, pFltOut); + double d = dblIn < 0.0 ? -dblIn : dblIn; + if (d > R4_MAX) return DISP_E_OVERFLOW; + *pFltOut = dblIn; + return S_OK; } /************************************************************************ @@ -2646,7 +2649,8 @@ HRESULT WINAPI VarR4FromR8(double dblIn, float *pFltOut) */ HRESULT WINAPI VarR4FromCy(CY cyIn, float *pFltOut) { - return _VarR4FromCy(cyIn, pFltOut); + *pFltOut = (double)cyIn.int64 / CY_MULTIPLIER_F; + return S_OK; } /************************************************************************ @@ -2664,7 +2668,7 @@ HRESULT WINAPI VarR4FromCy(CY cyIn, float *pFltOut) */ HRESULT WINAPI VarR4FromDate(DATE dateIn, float *pFltOut) { - return _VarR4FromDate(dateIn, pFltOut); + return VarR4FromR8(dateIn, pFltOut); } /************************************************************************ @@ -2685,7 +2689,7 @@ HRESULT WINAPI VarR4FromDate(DATE dateIn, float *pFltOut) */ HRESULT WINAPI VarR4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, float *pFltOut) { - return _VarR4FromStr(strIn, lcid, dwFlags, pFltOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pFltOut, VT_R4); } /************************************************************************ @@ -2706,7 +2710,7 @@ HRESULT WINAPI VarR4FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, float *pFl */ HRESULT WINAPI VarR4FromDisp(IDispatch* pdispIn, LCID lcid, float *pFltOut) { - return _VarR4FromDisp(pdispIn, lcid, pFltOut); + return VARIANT_FromDisp(pdispIn, lcid, pFltOut, VT_R4); } /************************************************************************ @@ -2723,7 +2727,7 @@ HRESULT WINAPI VarR4FromDisp(IDispatch* pdispIn, LCID lcid, float *pFltOut) */ HRESULT WINAPI VarR4FromBool(VARIANT_BOOL boolIn, float *pFltOut) { - return _VarR4FromBool(boolIn, pFltOut); + return VarR4FromI2(boolIn, pFltOut); } /************************************************************************ @@ -3005,7 +3009,7 @@ HRESULT WINAPI VarR8FromDate(DATE dateIn, double *pDblOut) */ HRESULT WINAPI VarR8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, double *pDblOut) { - return _VarR8FromStr(strIn, lcid, dwFlags, pDblOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pDblOut, VT_R8); } /************************************************************************ @@ -3026,7 +3030,7 @@ HRESULT WINAPI VarR8FromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, double *pD */ HRESULT WINAPI VarR8FromDisp(IDispatch* pdispIn, LCID lcid, double *pDblOut) { - return _VarR8FromDisp(pdispIn, lcid, pDblOut); + return VARIANT_FromDisp(pdispIn, lcid, pDblOut, VT_R8); } /************************************************************************ @@ -3043,7 +3047,7 @@ HRESULT WINAPI VarR8FromDisp(IDispatch* pdispIn, LCID lcid, double *pDblOut) */ HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double *pDblOut) { - return _VarR8FromBool(boolIn, pDblOut); + return VarR8FromI2(boolIn, pDblOut); } /************************************************************************ @@ -3273,7 +3277,7 @@ static const int CY_Divisors[5] = { CY_MULTIPLIER/10000, CY_MULTIPLIER/1000, */ HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pCyOut) { - return _VarCyFromUI1(bIn, pCyOut); + return VarCyFromR8(bIn, pCyOut); } /************************************************************************ @@ -3293,7 +3297,7 @@ HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromI2(SHORT sIn, CY* pCyOut) { - return _VarCyFromI2(sIn, pCyOut); + return VarCyFromR8(sIn, pCyOut); } /************************************************************************ @@ -3313,7 +3317,7 @@ HRESULT WINAPI VarCyFromI2(SHORT sIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromI4(LONG lIn, CY* pCyOut) { - return _VarCyFromI4(lIn, pCyOut); + return VarCyFromR8(lIn, pCyOut); } /************************************************************************ @@ -3333,7 +3337,7 @@ HRESULT WINAPI VarCyFromI4(LONG lIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromR4(FLOAT fltIn, CY* pCyOut) { - return _VarCyFromR4(fltIn, pCyOut); + return VarCyFromR8(fltIn, pCyOut); } /************************************************************************ @@ -3404,7 +3408,7 @@ HRESULT WINAPI VarCyFromR8(double dblIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromDate(DATE dateIn, CY* pCyOut) { - return _VarCyFromDate(dateIn, pCyOut); + return VarCyFromR8(dateIn, pCyOut); } /************************************************************************ @@ -3426,7 +3430,7 @@ HRESULT WINAPI VarCyFromDate(DATE dateIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, CY* pCyOut) { - return _VarCyFromStr(strIn, lcid, dwFlags, pCyOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pCyOut, VT_CY); } /************************************************************************ @@ -3447,7 +3451,7 @@ HRESULT WINAPI VarCyFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, CY* pCyOut */ HRESULT WINAPI VarCyFromDisp(IDispatch* pdispIn, LCID lcid, CY* pCyOut) { - return _VarCyFromDisp(pdispIn, lcid, pCyOut); + return VARIANT_FromDisp(pdispIn, lcid, pCyOut, VT_CY); } /************************************************************************ @@ -3471,7 +3475,7 @@ HRESULT WINAPI VarCyFromDisp(IDispatch* pdispIn, LCID lcid, CY* pCyOut) */ HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY* pCyOut) { - return _VarCyFromBool(boolIn, pCyOut); + return VarCyFromR8(boolIn, pCyOut); } /************************************************************************ @@ -3491,7 +3495,7 @@ HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromI1(signed char cIn, CY* pCyOut) { - return _VarCyFromI1(cIn, pCyOut); + return VarCyFromR8(cIn, pCyOut); } /************************************************************************ @@ -3511,7 +3515,7 @@ HRESULT WINAPI VarCyFromI1(signed char cIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY* pCyOut) { - return _VarCyFromUI2(usIn, pCyOut); + return VarCyFromR8(usIn, pCyOut); } /************************************************************************ @@ -3531,7 +3535,7 @@ HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromUI4(ULONG ulIn, CY* pCyOut) { - return _VarCyFromUI4(ulIn, pCyOut); + return VarCyFromR8(ulIn, pCyOut); } /************************************************************************ @@ -3567,7 +3571,7 @@ HRESULT WINAPI VarCyFromDec(DECIMAL* pdecIn, CY* pCyOut) d = (double)DEC_LO64(&rounded) / (double)CY_Divisors[DEC_SCALE(&rounded)]; if (DEC_SIGN(&rounded)) d = -d; - return _VarCyFromR8(d, pCyOut); + return VarCyFromR8(d, pCyOut); } return hRet; } @@ -3589,7 +3593,9 @@ HRESULT WINAPI VarCyFromDec(DECIMAL* pdecIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromI8(LONG64 llIn, CY* pCyOut) { - return _VarCyFromI8(llIn, pCyOut); + if (llIn <= (I8_MIN/CY_MULTIPLIER) || llIn >= (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW; + pCyOut->int64 = llIn * CY_MULTIPLIER; + return S_OK; } /************************************************************************ @@ -3609,7 +3615,7 @@ HRESULT WINAPI VarCyFromI8(LONG64 llIn, CY* pCyOut) */ HRESULT WINAPI VarCyFromUI8(ULONG64 ullIn, CY* pCyOut) { - return _VarCyFromUI8(ullIn, pCyOut); + return VarCyFromR8(ullIn, pCyOut); } /************************************************************************ @@ -3632,7 +3638,7 @@ HRESULT WINAPI VarCyAdd(const CY cyLeft, const CY cyRight, CY* pCyOut) _VarR8FromCy(cyLeft, &l); _VarR8FromCy(cyRight, &r); l = l + r; - return _VarCyFromR8(l, pCyOut); + return VarCyFromR8(l, pCyOut); } /************************************************************************ @@ -3655,7 +3661,7 @@ HRESULT WINAPI VarCyMul(const CY cyLeft, const CY cyRight, CY* pCyOut) _VarR8FromCy(cyLeft, &l); _VarR8FromCy(cyRight, &r); l = l * r; - return _VarCyFromR8(l, pCyOut); + return VarCyFromR8(l, pCyOut); } /************************************************************************ @@ -3678,7 +3684,7 @@ HRESULT WINAPI VarCyMulI4(const CY cyLeft, LONG lRight, CY* pCyOut) _VarR8FromCy(cyLeft, &d); d = d * lRight; - return _VarCyFromR8(d, pCyOut); + return VarCyFromR8(d, pCyOut); } /************************************************************************ @@ -3701,7 +3707,7 @@ HRESULT WINAPI VarCySub(const CY cyLeft, const CY cyRight, CY* pCyOut) _VarR8FromCy(cyLeft, &l); _VarR8FromCy(cyRight, &r); l = l - r; - return _VarCyFromR8(l, pCyOut); + return VarCyFromR8(l, pCyOut); } /************************************************************************ @@ -3892,7 +3898,7 @@ HRESULT WINAPI VarCyCmpR8(const CY cyLeft, double dblRight) HRESULT hRet; CY cyRight; - hRet = _VarCyFromR8(dblRight, &cyRight); + hRet = VarCyFromR8(dblRight, &cyRight); if (SUCCEEDED(hRet)) hRet = VarCyCmp(cyLeft, cyRight); @@ -3920,7 +3926,7 @@ HRESULT WINAPI VarCyMulI8(const CY cyLeft, LONG64 llRight, CY* pCyOut) _VarR8FromCy(cyLeft, &d); d = d * (double)llRight; - return _VarCyFromR8(d, pCyOut); + return VarCyFromR8(d, pCyOut); } /* DECIMAL @@ -3940,7 +3946,7 @@ HRESULT WINAPI VarCyMulI8(const CY cyLeft, LONG64 llRight, CY* pCyOut) */ HRESULT WINAPI VarDecFromUI1(BYTE bIn, DECIMAL* pDecOut) { - return _VarDecFromUI1(bIn, pDecOut); + return VarDecFromUI4(bIn, pDecOut); } /************************************************************************ @@ -3957,7 +3963,7 @@ HRESULT WINAPI VarDecFromUI1(BYTE bIn, DECIMAL* pDecOut) */ HRESULT WINAPI VarDecFromI2(SHORT sIn, DECIMAL* pDecOut) { - return _VarDecFromI2(sIn, pDecOut); + return VarDecFromI4(sIn, pDecOut); } /************************************************************************ @@ -4009,7 +4015,7 @@ HRESULT WINAPI VarDecFromR4(FLOAT fltIn, DECIMAL* pDecOut) WCHAR buff[256]; sprintfW( buff, szFloatFormatW, fltIn ); - return _VarDecFromStr(buff, LOCALE_EN_US, 0, pDecOut); + return VarDecFromStr(buff, LOCALE_EN_US, 0, pDecOut); } /************************************************************************ @@ -4029,7 +4035,7 @@ HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL* pDecOut) WCHAR buff[256]; sprintfW( buff, szDoubleFormatW, dblIn ); - return _VarDecFromStr(buff, LOCALE_EN_US, 0, pDecOut); + return VarDecFromStr(buff, LOCALE_EN_US, 0, pDecOut); } /************************************************************************ @@ -4046,7 +4052,7 @@ HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL* pDecOut) */ HRESULT WINAPI VarDecFromDate(DATE dateIn, DECIMAL* pDecOut) { - return _VarDecFromDate(dateIn, pDecOut); + return VarDecFromR8(dateIn, pDecOut); } /************************************************************************ @@ -4097,7 +4103,7 @@ HRESULT WINAPI VarDecFromCy(CY cyIn, DECIMAL* pDecOut) */ HRESULT WINAPI VarDecFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, DECIMAL* pDecOut) { - return _VarDecFromStr(strIn, lcid, dwFlags, pDecOut); + return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pDecOut, VT_DECIMAL); } /************************************************************************ @@ -4116,7 +4122,7 @@ HRESULT WINAPI VarDecFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, DECIMAL* */ HRESULT WINAPI VarDecFromDisp(IDispatch* pdispIn, LCID lcid, DECIMAL* pDecOut) { - return _VarDecFromDisp(pdispIn, lcid, pDecOut); + return VARIANT_FromDisp(pdispIn, lcid, pDecOut, VT_DECIMAL); } /************************************************************************ @@ -4165,7 +4171,7 @@ HRESULT WINAPI VarDecFromBool(VARIANT_BOOL bIn, DECIMAL* pDecOut) */ HRESULT WINAPI VarDecFromI1(signed char cIn, DECIMAL* pDecOut) { - return _VarDecFromI1(cIn, pDecOut); + return VarDecFromI4(cIn, pDecOut); } /************************************************************************ @@ -4182,7 +4188,7 @@ HRESULT WINAPI VarDecFromI1(signed char cIn, DECIMAL* pDecOut) */ HRESULT WINAPI VarDecFromUI2(USHORT usIn, DECIMAL* pDecOut) { - return _VarDecFromUI2(usIn, pDecOut); + return VarDecFromUI4(usIn, pDecOut); } /************************************************************************ @@ -4750,7 +4756,8 @@ HRESULT WINAPI VarDecCmpR8(const DECIMAL* pDecLeft, double dblRight) */ HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromUI1(bIn, pBoolOut); + *pBoolOut = bIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4767,7 +4774,8 @@ HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromI2(SHORT sIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromI2(sIn, pBoolOut); + *pBoolOut = sIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4784,7 +4792,8 @@ HRESULT WINAPI VarBoolFromI2(SHORT sIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromI4(lIn, pBoolOut); + *pBoolOut = lIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4801,7 +4810,8 @@ HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromR4(fltIn, pBoolOut); + *pBoolOut = fltIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4818,7 +4828,8 @@ HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromR8(dblIn, pBoolOut); + *pBoolOut = dblIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4835,7 +4846,8 @@ HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromDate(dateIn, pBoolOut); + *pBoolOut = dateIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -4852,7 +4864,8 @@ HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromCy(cyIn, pBoolOut); + *pBoolOut = cyIn.int64 ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest) @@ -4979,9 +4992,8 @@ VarBoolFromStr_CheckLocalised: double d; /* If this string is a number, convert it as one */ - hRes = _VarR8FromStr(strIn, lcid, dwFlags, &d); - if (SUCCEEDED(hRes)) - hRes = _VarBoolFromR8(d, pBoolOut); + hRes = VarR8FromStr(strIn, lcid, dwFlags, &d); + if (SUCCEEDED(hRes)) *pBoolOut = d ? VARIANT_TRUE : VARIANT_FALSE; } return hRes; } @@ -5004,7 +5016,7 @@ VarBoolFromStr_CheckLocalised: */ HRESULT WINAPI VarBoolFromDisp(IDispatch* pdispIn, LCID lcid, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromDisp(pdispIn, lcid, pBoolOut); + return VARIANT_FromDisp(pdispIn, lcid, pBoolOut, VT_BOOL); } /************************************************************************ @@ -5021,7 +5033,8 @@ HRESULT WINAPI VarBoolFromDisp(IDispatch* pdispIn, LCID lcid, VARIANT_BOOL *pBoo */ HRESULT WINAPI VarBoolFromI1(signed char cIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromI1(cIn, pBoolOut); + *pBoolOut = cIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -5038,7 +5051,8 @@ HRESULT WINAPI VarBoolFromI1(signed char cIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromUI2(USHORT usIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromUI2(usIn, pBoolOut); + *pBoolOut = usIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -5055,7 +5069,8 @@ HRESULT WINAPI VarBoolFromUI2(USHORT usIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromUI4(ULONG ulIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromUI4(ulIn, pBoolOut); + *pBoolOut = ulIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -5097,7 +5112,8 @@ HRESULT WINAPI VarBoolFromDec(DECIMAL* pDecIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromI8(LONG64 llIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromI8(llIn, pBoolOut); + *pBoolOut = llIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /************************************************************************ @@ -5114,7 +5130,8 @@ HRESULT WINAPI VarBoolFromI8(LONG64 llIn, VARIANT_BOOL *pBoolOut) */ HRESULT WINAPI VarBoolFromUI8(ULONG64 ullIn, VARIANT_BOOL *pBoolOut) { - return _VarBoolFromUI8(ullIn, pBoolOut); + *pBoolOut = ullIn ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } /* BSTR @@ -5769,7 +5786,7 @@ HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFl */ HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE* pdateOut) { - return _VarDateFromUI1(bIn, pdateOut); + return VarR8FromUI1(bIn, pdateOut); } /****************************************************************************** @@ -5786,7 +5803,7 @@ HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromI2(short sIn, DATE* pdateOut) { - return _VarDateFromI2(sIn, pdateOut); + return VarR8FromI2(sIn, pdateOut); } /****************************************************************************** @@ -5803,7 +5820,7 @@ HRESULT WINAPI VarDateFromI2(short sIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromI4(LONG lIn, DATE* pdateOut) { - return _VarDateFromI4(lIn, pdateOut); + return VarDateFromR8(lIn, pdateOut); } /****************************************************************************** @@ -5820,7 +5837,7 @@ HRESULT WINAPI VarDateFromI4(LONG lIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE* pdateOut) { - return _VarDateFromR4(fltIn, pdateOut); + return VarR8FromR4(fltIn, pdateOut); } /****************************************************************************** @@ -5837,7 +5854,9 @@ HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromR8(double dblIn, DATE* pdateOut) { - return _VarDateFromR8(dblIn, pdateOut); + if (dblIn <= (DATE_MIN - 1.0) || dblIn >= (DATE_MAX + 1.0)) return DISP_E_OVERFLOW; + *pdateOut = (DATE)dblIn; + return S_OK; } /********************************************************************** @@ -5858,7 +5877,7 @@ HRESULT WINAPI VarDateFromR8(double dblIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromDisp(IDispatch* pdispIn, LCID lcid, DATE* pdateOut) { - return _VarDateFromDisp(pdispIn, lcid, pdateOut); + return VARIANT_FromDisp(pdispIn, lcid, pdateOut, VT_DATE); } /****************************************************************************** @@ -5875,7 +5894,7 @@ HRESULT WINAPI VarDateFromDisp(IDispatch* pdispIn, LCID lcid, DATE* pdateOut) */ HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE* pdateOut) { - return _VarDateFromBool(boolIn, pdateOut); + return VarR8FromBool(boolIn, pdateOut); } /********************************************************************** @@ -5892,7 +5911,7 @@ HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromCy(CY cyIn, DATE* pdateOut) { - return _VarDateFromCy(cyIn, pdateOut); + return VarR8FromCy(cyIn, pdateOut); } /* Date string parsing */ @@ -6480,7 +6499,7 @@ HRESULT WINAPI VarDateFromStr(OLECHAR* strIn, LCID lcid, ULONG dwFlags, DATE* pd */ HRESULT WINAPI VarDateFromI1(signed char cIn, DATE* pdateOut) { - return _VarDateFromI1(cIn, pdateOut); + return VarR8FromI1(cIn, pdateOut); } /****************************************************************************** @@ -6497,7 +6516,7 @@ HRESULT WINAPI VarDateFromI1(signed char cIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE* pdateOut) { - return _VarDateFromUI2(uiIn, pdateOut); + return VarR8FromUI2(uiIn, pdateOut); } /****************************************************************************** @@ -6514,7 +6533,7 @@ HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE* pdateOut) { - return _VarDateFromUI4(ulIn, pdateOut); + return VarDateFromR8(ulIn, pdateOut); } /********************************************************************** @@ -6531,7 +6550,7 @@ HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromDec(DECIMAL *pdecIn, DATE* pdateOut) { - return _VarDateFromDec(pdecIn, pdateOut); + return VarR8FromDec(pdecIn, pdateOut); } /****************************************************************************** @@ -6549,7 +6568,9 @@ HRESULT WINAPI VarDateFromDec(DECIMAL *pdecIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromI8(LONG64 llIn, DATE* pdateOut) { - return _VarDateFromI8(llIn, pdateOut); + if (llIn < DATE_MIN || llIn > DATE_MAX) return DISP_E_OVERFLOW; + *pdateOut = (DATE)llIn; + return S_OK; } /****************************************************************************** @@ -6567,5 +6588,7 @@ HRESULT WINAPI VarDateFromI8(LONG64 llIn, DATE* pdateOut) */ HRESULT WINAPI VarDateFromUI8(ULONG64 ullIn, DATE* pdateOut) { - return _VarDateFromUI8(ullIn, pdateOut); + if (ullIn > DATE_MAX) return DISP_E_OVERFLOW; + *pdateOut = (DATE)ullIn; + return S_OK; }