Without a test how can you know if this implementation produces the correct values? What about variant type conversions? It seems silly to send a patch without testing it...
Chris
From: Fabian Cenedese Cenedese@indel.ch Date: 2004/02/19 Thu AM 08:20:21 EST To: wine-patches@winehq.org Subject: VarRound implementation
Hi
This is the implementation of the Variant Round function. I tried to also create a test function. But I didn't manage to.
Changelog: Fabian Cenedese Cenedese@indel.ch Implementation of Variant Round function.
Index: wine/dlls/oleaut32/oleaut32.spec
RCS file: /home/wine/wine/dlls/oleaut32/oleaut32.spec,v retrieving revision 1.64 diff -u -r1.64 oleaut32.spec --- wine/dlls/oleaut32/oleaut32.spec 21 Jan 2004 22:24:08 -0000 1.64 +++ wine/dlls/oleaut32/oleaut32.spec 19 Feb 2004 13:09:04 -0000 @@ -170,7 +170,7 @@ 172 stdcall VarInt(ptr ptr) 173 stdcall VarNeg(ptr ptr) 174 stdcall VarNot(ptr ptr) -175 stub VarRound # stdcall (ptr long ptr) +175 stdcall VarRound(ptr long ptr) 176 stdcall VarCmp(ptr ptr long long) 177 stdcall VarDecAdd(ptr ptr ptr) 178 stdcall VarDecDiv(ptr ptr ptr) Index: wine/dlls/oleaut32/variant.c =================================================================== RCS file: /home/wine/wine/dlls/oleaut32/variant.c,v retrieving revision 1.87 diff -u -r1.87 variant.c --- wine/dlls/oleaut32/variant.c 17 Feb 2004 20:25:41 -0000 1.87 +++ wine/dlls/oleaut32/variant.c 19 Feb 2004 13:09:04 -0000 @@ -3437,6 +3437,94 @@ return hRet; }
+/**********************************************************************
VarRound [OLEAUT32.175]
- Perform a round operation on a variant.
- PARAMS
- pVarIn [I] Source variant
- deci [I] Number of decimals to round to
- pVarOut [O] Destination for converted value
- RETURNS
- Success: S_OK. pVarOut contains the converted value.
- Failure: An HRESULT error code indicating the error.
- NOTES
- Floating point values are rounded to the desired number of decimals.
- Negative values are rounded nearer to zero (and not bigger in absolute).
- Some integer types are just copied to the return variable.
- Some other integer types are not handled and fail.
- */
+HRESULT WINAPI VarRound(LPVARIANT pVarIn, int deci, LPVARIANT pVarOut) +{
- HRESULT hRet = S_OK;
+wine_dbg_printf("FABI: VARIANT: VarRound1\n");
- TRACE("(%p->(%s%s),%d)\n", pVarIn, debugstr_VT(pVarIn), debugstr_VF(pVarIn), deci);
- switch (V_VT(pVarIn))
- {
- /* cases that fail on windows */
- case VT_I1:
- case VT_UI2:
- case VT_UI4:
- hRet = DISP_E_BADVARTYPE;
- break;
- /* cases just copying in to out */
- case VT_UI1:
- V_VT(pVarOut) = V_VT(pVarIn);
- V_UI1(pVarOut) = V_UI1(pVarIn);
- break;
- case VT_I2:
- V_VT(pVarOut) = V_VT(pVarIn);
- V_I2(pVarOut) = V_I2(pVarIn);
- break;
- case VT_I4:
- V_VT(pVarOut) = V_VT(pVarIn);
- V_I4(pVarOut) = V_I4(pVarIn);
- break;
- /* cases we need to do math */
- case VT_R4:
- if (V_R4(pVarIn)>0) {
V_R4(pVarOut)=floor(V_R4(pVarIn)*pow(10, deci))/pow(10, deci);
- } else {
V_R4(pVarOut)=ceil(V_R4(pVarIn)*pow(10, deci))/pow(10, deci);
- }
- V_VT(pVarOut) = V_VT(pVarIn);
- break;
- case VT_R8:
- if (V_R8(pVarIn)>0) {
V_R8(pVarOut)=floor(V_R8(pVarIn)*pow(10, deci))/pow(10, deci);
- } else {
V_R8(pVarOut)=ceil(V_R8(pVarIn)*pow(10, deci))/pow(10, deci);
- }
- V_VT(pVarOut) = V_VT(pVarIn);
- break;
- /* cases we don't know yet */
- default:
- FIXME("Not yet implemented, V_VT(pVarIn) = 0x%X, deci = %d\n",
V_VT(pVarIn) & VT_TYPEMASK, deci);
- hRet = DISP_E_BADVARTYPE;
- }
- if (FAILED(hRet))
V_VT(pVarOut) = VT_EMPTY;
- TRACE("returning 0x%08lx (%s%s),%f\n", hRet, debugstr_VT(pVarOut),
debugstr_VF(pVarOut), V_VT(pVarOut) == VT_R4 ? V_R4(pVarOut):-1);
- return hRet;
+}
/**********************************************************************
VarMod [OLEAUT32.154]