Commit 743fb99a authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

Use variant macros instead of accessing the union directly.

parent 5f8797f1
......@@ -1827,7 +1827,7 @@ static HRESULT WINAPI OLEPictureImpl_Invoke(
VariantInit(pVarResult);
V_VT(pVarResult) = VT_BOOL;
V_UNION(pVarResult,boolVal) = FALSE;
V_BOOL(pVarResult) = FALSE;
return S_OK;
}
......
......@@ -1497,7 +1497,7 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
if(offset <0) { /* data are packed in here */
V_VT(pVar) = (offset & 0x7c000000 )>> 26;
V_UNION(pVar, iVal) = offset & 0x3ffffff;
V_I2(pVar) = offset & 0x3ffffff;
return;
}
MSFT_ReadLEWords(&(V_VT(pVar)), sizeof(VARTYPE), pcx,
......@@ -1537,7 +1537,7 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
} else {
ptr=TLB_Alloc(size);/* allocate temp buffer */
MSFT_Read(ptr, size, pcx, DO_NOT_SEEK);/* read string (ANSI) */
V_UNION(pVar, bstrVal)=SysAllocStringLen(NULL,size);
V_BSTR(pVar)=SysAllocStringLen(NULL,size);
/* FIXME: do we need a AtoW conversion here? */
V_UNION(pVar, bstrVal[size])=L'\0';
while(size--) V_UNION(pVar, bstrVal[size])=ptr[size];
......@@ -1570,7 +1570,7 @@ static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
}
if(size>0) /* (big|small) endian correct? */
MSFT_Read(&(V_UNION(pVar, iVal)), size, pcx, DO_NOT_SEEK );
MSFT_Read(&(V_I2(pVar)), size, pcx, DO_NOT_SEEK );
return;
}
/*
......@@ -4523,12 +4523,12 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
}
if (V_VT(arg) == vt) {
memcpy(argpos, &V_UNION(arg,lVal), arglen);
memcpy(argpos, &V_I4(arg), arglen);
return S_OK;
}
if (V_ISARRAY(arg) && (vt == VT_SAFEARRAY)) {
memcpy(argpos, &V_UNION(arg,parray), sizeof(SAFEARRAY*));
memcpy(argpos, &V_ARRAY(arg), sizeof(SAFEARRAY*));
return S_OK;
}
......@@ -4538,13 +4538,13 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
}
/* Deref BYREF vars if there is need */
if(V_ISBYREF(arg) && ((V_VT(arg) & ~VT_BYREF)==vt)) {
memcpy(argpos,(void*)V_UNION(arg,lVal), arglen);
memcpy(argpos,(void*)V_I4(arg), arglen);
return S_OK;
}
if (vt==VT_UNKNOWN && V_VT(arg)==VT_DISPATCH) {
/* in this context, if the type lib specifies IUnknown*, giving an
IDispatch* is correct; so, don't invoke VariantChangeType */
memcpy(argpos,&V_UNION(arg,lVal), arglen);
memcpy(argpos,&V_I4(arg), arglen);
return S_OK;
}
if ((vt == VT_PTR) && tdesc)
......@@ -4560,7 +4560,7 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED, "
"while coercing from vt 0x%x. Copying 4 byte.\n",
tdesc->u.hreftype,V_VT(arg));
memcpy(argpos, &V_UNION(arg,lVal), 4);
memcpy(argpos, &V_I4(arg), 4);
return S_OK;
}
hres = ITypeInfo_GetTypeAttr(tinfo2,&tattr);
......@@ -4574,11 +4574,11 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
case TKIND_ENUM:
switch ( V_VT( arg ) ) {
case VT_I2:
*argpos = V_UNION(arg,iVal);
*argpos = V_I2(arg);
hres = S_OK;
break;
case VT_I4:
memcpy(argpos, &V_UNION(arg,lVal), 4);
memcpy(argpos, &V_I4(arg), 4);
hres = S_OK;
break;
default:
......@@ -4597,15 +4597,15 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
if (V_VT(arg) == VT_DISPATCH) {
IDispatch *disp;
if (IsEqualIID(&IID_IDispatch,&(tattr->guid))) {
memcpy(argpos, &V_UNION(arg,pdispVal), 4);
memcpy(argpos, &V_DISPATCH(arg), 4);
hres = S_OK;
break;
}
hres=IUnknown_QueryInterface(V_UNION(arg,pdispVal),
hres=IUnknown_QueryInterface(V_DISPATCH(arg),
&IID_IDispatch,(LPVOID*)&disp);
if (SUCCEEDED(hres)) {
memcpy(argpos,&disp,4);
IUnknown_Release(V_UNION(arg,pdispVal));
IUnknown_Release(V_DISPATCH(arg));
hres = S_OK;
break;
}
......@@ -4615,7 +4615,7 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
break;
}
if (V_VT(arg) == VT_UNKNOWN) {
memcpy(argpos, &V_UNION(arg,punkVal), 4);
memcpy(argpos, &V_UNKNOWN(arg), 4);
hres = S_OK;
break;
}
......@@ -4626,7 +4626,7 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
case TKIND_DISPATCH:
if (V_VT(arg) == VT_DISPATCH) {
memcpy(argpos, &V_UNION(arg,pdispVal), 4);
memcpy(argpos, &V_DISPATCH(arg), 4);
hres = S_OK;
}
else {
......@@ -4651,7 +4651,7 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc,
oldvt = V_VT(arg);
VariantInit(&va);
if (VariantChangeType(&va,arg,0,vt)==S_OK) {
memcpy(argpos,&V_UNION(&va,lVal), arglen);
memcpy(argpos,&V_I4(&va), arglen);
FIXME("Should not use VariantChangeType here."
" (conversion from 0x%x -> 0x%x) %08lx\n",
V_VT(arg), vt, *argpos
......@@ -4773,7 +4773,7 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
if(i < func_desc->cParams - func_desc->cParamsOpt)
ERR("Parameter has PARAMFLAG_FOPT flag but is not one of last cParamOpt parameters\n");
if(V_VT(arg) == VT_EMPTY
|| ((V_VT(arg) & VT_BYREF) && !V_BYREF(arg))) {
|| ((V_ISBYREF(arg)) && !V_BYREF(arg))) {
/* FIXME: Documentation says that we do this when parameter is left unspecified.
How to determine it? */
......@@ -4839,7 +4839,7 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
continue;
VariantInit(pVarResult);
memcpy(&V_UNION(pVarResult,intVal),&args2[args2pos],arglen*sizeof(DWORD));
memcpy(&V_INT(pVarResult),&args2[args2pos],arglen*sizeof(DWORD));
if (tdesc->vt == VT_PTR)
tdesc = tdesc->u.lptdesc;
......
......@@ -190,7 +190,7 @@ static unsigned wire_extra(unsigned long *pFlags, VARIANT *pvar)
ULONG size;
HRESULT hr;
if (V_VT(pvar) & VT_ARRAY) {
if (V_ISARRAY(pvar)) {
FIXME("wire-size safearray\n");
return 0;
}
......@@ -527,7 +527,7 @@ HRESULT CALLBACK IDispatch_Invoke_Proxy(
/* count by-ref args */
for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
VARIANTARG* arg = &pDispParams->rgvarg[u];
if (V_VT(arg) & VT_BYREF) {
if (V_ISBYREF(arg)) {
cVarRef++;
}
}
......@@ -537,7 +537,7 @@ HRESULT CALLBACK IDispatch_Invoke_Proxy(
/* make list of by-ref args */
for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
VARIANTARG* arg = &pDispParams->rgvarg[u];
if (V_VT(arg) & VT_BYREF) {
if (V_ISBYREF(arg)) {
rgVarRefIdx[cVarRef] = u;
VariantInit(&rgVarRef[cVarRef]);
cVarRef++;
......
......@@ -984,7 +984,7 @@ HRESULT WINAPI VariantChangeTypeEx(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
{
VARIANTARG vTmp, vSrcDeref;
if(V_VT(pvargSrc)&VT_BYREF && !V_BYREF(pvargSrc))
if(V_ISBYREF(pvargSrc) && !V_BYREF(pvargSrc))
res = DISP_E_TYPEMISMATCH;
else
{
......@@ -2531,7 +2531,7 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
}
xmask = (1<<(V_VT(left)&VT_TYPEMASK))|(1<<(V_VT(right)&VT_TYPEMASK));
if (xmask & (1<<VT_R8)) {
if (xmask & VTBIT_R8) {
rc = VariantChangeType(&lv,left,0,VT_R8);
if (FAILED(rc)) return rc;
rc = VariantChangeType(&rv,right,0,VT_R8);
......@@ -2542,7 +2542,7 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
if (V_R8(&lv) > V_R8(&rv)) return VARCMP_GT;
return E_FAIL; /* can't get here */
}
if (xmask & (1<<VT_R4)) {
if (xmask & VTBIT_R4) {
rc = VariantChangeType(&lv,left,0,VT_R4);
if (FAILED(rc)) return rc;
rc = VariantChangeType(&rv,right,0,VT_R4);
......@@ -2558,29 +2558,29 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
Use LONGLONG to maximize ranges */
lOk = TRUE;
switch (V_VT(left)&VT_TYPEMASK) {
case VT_I1 : lVal = V_UNION(left,cVal); break;
case VT_I2 : lVal = V_UNION(left,iVal); break;
case VT_I4 : lVal = V_UNION(left,lVal); break;
case VT_INT : lVal = V_UNION(left,lVal); break;
case VT_UI1 : lVal = V_UNION(left,bVal); break;
case VT_UI2 : lVal = V_UNION(left,uiVal); break;
case VT_UI4 : lVal = V_UNION(left,ulVal); break;
case VT_UINT : lVal = V_UNION(left,ulVal); break;
case VT_BOOL : lVal = V_UNION(left,boolVal); break;
case VT_I1 : lVal = V_I1(left); break;
case VT_I2 : lVal = V_I2(left); break;
case VT_I4 :
case VT_INT : lVal = V_I4(left); break;
case VT_UI1 : lVal = V_UI1(left); break;
case VT_UI2 : lVal = V_UI2(left); break;
case VT_UI4 :
case VT_UINT : lVal = V_UI4(left); break;
case VT_BOOL : lVal = V_BOOL(left); break;
default: lOk = FALSE;
}
rOk = TRUE;
switch (V_VT(right)&VT_TYPEMASK) {
case VT_I1 : rVal = V_UNION(right,cVal); break;
case VT_I2 : rVal = V_UNION(right,iVal); break;
case VT_I4 : rVal = V_UNION(right,lVal); break;
case VT_INT : rVal = V_UNION(right,lVal); break;
case VT_UI1 : rVal = V_UNION(right,bVal); break;
case VT_UI2 : rVal = V_UNION(right,uiVal); break;
case VT_UI4 : rVal = V_UNION(right,ulVal); break;
case VT_UINT : rVal = V_UNION(right,ulVal); break;
case VT_BOOL : rVal = V_UNION(right,boolVal); break;
case VT_I1 : rVal = V_I1(right); break;
case VT_I2 : rVal = V_I2(right); break;
case VT_I4 :
case VT_INT : rVal = V_I4(right); break;
case VT_UI1 : rVal = V_UI1(right); break;
case VT_UI2 : rVal = V_UI2(right); break;
case VT_UI4 :
case VT_UINT : rVal = V_UI4(right); break;
case VT_BOOL : rVal = V_BOOL(right); break;
default: rOk = FALSE;
}
......@@ -2598,20 +2598,20 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
if ((V_VT(left)&VT_TYPEMASK) == VT_DATE &&
(V_VT(right)&VT_TYPEMASK) == VT_DATE) {
if (floor(V_UNION(left,date)) == floor(V_UNION(right,date))) {
if (floor(V_DATE(left)) == floor(V_DATE(right))) {
/* Due to floating point rounding errors, calculate varDate in whole numbers) */
double wholePart = 0.0;
double leftR;
double rightR;
/* Get the fraction * 24*60*60 to make it into whole seconds */
wholePart = (double) floor( V_UNION(left,date) );
wholePart = (double) floor( V_DATE(left) );
if (wholePart == 0) wholePart = 1;
leftR = floor(fmod( V_UNION(left,date), wholePart ) * (24*60*60));
leftR = floor(fmod( V_DATE(left), wholePart ) * (24*60*60));
wholePart = (double) floor( V_UNION(right,date) );
wholePart = (double) floor( V_DATE(right) );
if (wholePart == 0) wholePart = 1;
rightR = floor(fmod( V_UNION(right,date), wholePart ) * (24*60*60));
rightR = floor(fmod( V_DATE(right), wholePart ) * (24*60*60));
if (leftR < rightR) {
return VARCMP_LT;
......@@ -2621,9 +2621,9 @@ HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
return VARCMP_EQ;
}
} else if (V_UNION(left,date) < V_UNION(right,date)) {
} else if (V_DATE(left) < V_DATE(right)) {
return VARCMP_LT;
} else if (V_UNION(left,date) > V_UNION(right,date)) {
} else if (V_DATE(left) > V_DATE(right)) {
return VARCMP_GT;
}
}
......@@ -2665,29 +2665,29 @@ HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lOk = TRUE;
switch (V_VT(left)&VT_TYPEMASK) {
case VT_I1 : lVal = V_UNION(left,cVal); resT=VT_I4; break;
case VT_I2 : lVal = V_UNION(left,iVal); resT=VT_I2; break;
case VT_I4 : lVal = V_UNION(left,lVal); resT=VT_I4; break;
case VT_INT : lVal = V_UNION(left,lVal); resT=VT_I4; break;
case VT_UI1 : lVal = V_UNION(left,bVal); resT=VT_I4; break;
case VT_UI2 : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
case VT_UI4 : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
case VT_BOOL : rVal = V_UNION(left,boolVal); resT=VT_I4; break;
case VT_I1 : lVal = V_I1(left); resT=VT_I4; break;
case VT_I2 : lVal = V_I2(left); resT=VT_I2; break;
case VT_I4 :
case VT_INT : lVal = V_I4(left); resT=VT_I4; break;
case VT_UI1 : lVal = V_UI1(left); resT=VT_I4; break;
case VT_UI2 : lVal = V_UI2(left); resT=VT_I4; break;
case VT_UI4 :
case VT_UINT : lVal = V_UI4(left); resT=VT_I4; break;
case VT_BOOL : rVal = V_BOOL(left); resT=VT_I4; break;
default: lOk = FALSE;
}
rOk = TRUE;
switch (V_VT(right)&VT_TYPEMASK) {
case VT_I1 : rVal = V_UNION(right,cVal); resT=VT_I4; break;
case VT_I2 : rVal = V_UNION(right,iVal); resT=max(VT_I2, resT); break;
case VT_I4 : rVal = V_UNION(right,lVal); resT=VT_I4; break;
case VT_INT : rVal = V_UNION(right,lVal); resT=VT_I4; break;
case VT_UI1 : rVal = V_UNION(right,bVal); resT=VT_I4; break;
case VT_UI2 : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
case VT_UI4 : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
case VT_BOOL : rVal = V_UNION(right,boolVal); resT=VT_I4; break;
case VT_I1 : rVal = V_I1(right); resT=VT_I4; break;
case VT_I2 : rVal = V_I2(right); resT=max(VT_I2, resT); break;
case VT_I4 :
case VT_INT : rVal = V_I4(right); resT=VT_I4; break;
case VT_UI1 : rVal = V_UI1(right); resT=VT_I4; break;
case VT_UI2 : rVal = V_UI2(right); resT=VT_I4; break;
case VT_UI4 :
case VT_UINT : rVal = V_UI4(right); resT=VT_I4; break;
case VT_BOOL : rVal = V_BOOL(right); resT=VT_I4; break;
default: rOk = FALSE;
}
......@@ -2695,11 +2695,11 @@ HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
res = (lVal & rVal);
V_VT(result) = resT;
switch (resT) {
case VT_I2 : V_UNION(result,iVal) = res; break;
case VT_I4 : V_UNION(result,lVal) = res; break;
case VT_I2 : V_I2(result) = res; break;
case VT_I4 : V_I4(result) = res; break;
default:
FIXME("Unexpected result variant type %x\n", resT);
V_UNION(result,lVal) = res;
V_I4(result) = res;
}
rc = S_OK;
......@@ -2747,32 +2747,32 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lOk = TRUE;
switch (V_VT(left)&VT_TYPEMASK) {
case VT_I1 : lVal = V_UNION(left,cVal); break;
case VT_I2 : lVal = V_UNION(left,iVal); break;
case VT_I4 : lVal = V_UNION(left,lVal); break;
case VT_INT : lVal = V_UNION(left,lVal); break;
case VT_UI1 : lVal = V_UNION(left,bVal); break;
case VT_UI2 : lVal = V_UNION(left,uiVal); break;
case VT_UI4 : lVal = V_UNION(left,ulVal); break;
case VT_UINT : lVal = V_UNION(left,ulVal); break;
case VT_R4 : lVal = V_UNION(left,fltVal); break;
case VT_R8 : lVal = V_UNION(left,dblVal); break;
case VT_I1 : lVal = V_I1(left); break;
case VT_I2 : lVal = V_I2(left); break;
case VT_I4 :
case VT_INT : lVal = V_I4(left); break;
case VT_UI1 : lVal = V_UI1(left); break;
case VT_UI2 : lVal = V_UI2(left); break;
case VT_UI4 :
case VT_UINT : lVal = V_UI4(left); break;
case VT_R4 : lVal = V_R4(left); break;
case VT_R8 : lVal = V_R8(left); break;
case VT_NULL : lVal = 0.0; break;
default: lOk = FALSE;
}
rOk = TRUE;
switch (V_VT(right)&VT_TYPEMASK) {
case VT_I1 : rVal = V_UNION(right,cVal); break;
case VT_I2 : rVal = V_UNION(right,iVal); break;
case VT_I4 : rVal = V_UNION(right,lVal); break;
case VT_INT : rVal = V_UNION(right,lVal); break;
case VT_UI1 : rVal = V_UNION(right,bVal); break;
case VT_UI2 : rVal = V_UNION(right,uiVal); break;
case VT_UI4 : rVal = V_UNION(right,ulVal); break;
case VT_UINT : rVal = V_UNION(right,ulVal); break;
case VT_R4 : rVal = V_UNION(right,fltVal);break;
case VT_R8 : rVal = V_UNION(right,dblVal);break;
case VT_I1 : rVal = V_I1(right); break;
case VT_I2 : rVal = V_I2(right); break;
case VT_I4 :
case VT_INT : rVal = V_I4(right); break;
case VT_UI1 : rVal = V_UI1(right); break;
case VT_UI2 : rVal = V_UI2(right); break;
case VT_UI4 :
case VT_UINT : rVal = V_UI4(right); break;
case VT_R4 : rVal = V_R4(right);break;
case VT_R8 : rVal = V_R8(right);break;
case VT_NULL : rVal = 0.0; break;
default: rOk = FALSE;
}
......@@ -2780,7 +2780,7 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
if (lOk && rOk) {
res = (lVal + rVal);
V_VT(result) = VT_R8;
V_UNION(result,dblVal) = res;
V_R8(result) = res;
rc = S_OK;
} else {
FIXME("Unhandled type pair %d / %d in double addition.\n",
......@@ -2801,30 +2801,30 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lOk = TRUE;
switch (V_VT(left)&VT_TYPEMASK) {
case VT_I1 : lVal = V_UNION(left,cVal); break;
case VT_I2 : lVal = V_UNION(left,iVal); break;
case VT_I4 : lVal = V_UNION(left,lVal); break;
case VT_INT : lVal = V_UNION(left,lVal); break;
case VT_UI1 : lVal = V_UNION(left,bVal); break;
case VT_UI2 : lVal = V_UNION(left,uiVal); break;
case VT_UI4 : lVal = V_UNION(left,ulVal); break;
case VT_UINT : lVal = V_UNION(left,ulVal); break;
case VT_R4 : lVal = V_UNION(left,fltVal); break;
case VT_I1 : lVal = V_I1(left); break;
case VT_I2 : lVal = V_I2(left); break;
case VT_I4 :
case VT_INT : lVal = V_I4(left); break;
case VT_UI1 : lVal = V_UI1(left); break;
case VT_UI2 : lVal = V_UI2(left); break;
case VT_UI4 :
case VT_UINT : lVal = V_UI4(left); break;
case VT_R4 : lVal = V_R4(left); break;
case VT_NULL : lVal = 0.0; break;
default: lOk = FALSE;
}
rOk = TRUE;
switch (V_VT(right)&VT_TYPEMASK) {
case VT_I1 : rVal = V_UNION(right,cVal); break;
case VT_I2 : rVal = V_UNION(right,iVal); break;
case VT_I4 : rVal = V_UNION(right,lVal); break;
case VT_INT : rVal = V_UNION(right,lVal); break;
case VT_UI1 : rVal = V_UNION(right,bVal); break;
case VT_UI2 : rVal = V_UNION(right,uiVal); break;
case VT_UI4 : rVal = V_UNION(right,ulVal); break;
case VT_UINT : rVal = V_UNION(right,ulVal); break;
case VT_R4 : rVal = V_UNION(right,fltVal);break;
case VT_I1 : rVal = V_I1(right); break;
case VT_I2 : rVal = V_I2(right); break;
case VT_I4 :
case VT_INT : rVal = V_I4(right); break;
case VT_UI1 : rVal = V_UI1(right); break;
case VT_UI2 : rVal = V_UI2(right); break;
case VT_UI4 :
case VT_UINT : rVal = V_UI4(right); break;
case VT_R4 : rVal = V_R4(right);break;
case VT_NULL : rVal = 0.0; break;
default: rOk = FALSE;
}
......@@ -2832,7 +2832,7 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
if (lOk && rOk) {
res = (lVal + rVal);
V_VT(result) = VT_R4;
V_UNION(result,fltVal) = res;
V_R4(result) = res;
rc = S_OK;
} else {
FIXME("Unhandled type pair %d / %d in float addition.\n",
......@@ -2861,28 +2861,28 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lOk = TRUE;
switch (V_VT(left)&VT_TYPEMASK) {
case VT_I1 : lVal = V_UNION(left,cVal); resT=VT_I4; break;
case VT_I2 : lVal = V_UNION(left,iVal); resT=VT_I2; break;
case VT_I4 : lVal = V_UNION(left,lVal); resT=VT_I4; break;
case VT_INT : lVal = V_UNION(left,lVal); resT=VT_I4; break;
case VT_UI1 : lVal = V_UNION(left,bVal); resT=VT_I4; break;
case VT_UI2 : lVal = V_UNION(left,uiVal); resT=VT_I4; break;
case VT_UI4 : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
case VT_UINT : lVal = V_UNION(left,ulVal); resT=VT_I4; break;
case VT_I1 : lVal = V_I1(left); resT=VT_I4; break;
case VT_I2 : lVal = V_I2(left); resT=VT_I2; break;
case VT_I4 :
case VT_INT : lVal = V_I4(left); resT=VT_I4; break;
case VT_UI1 : lVal = V_UI1(left); resT=VT_I4; break;
case VT_UI2 : lVal = V_UI2(left); resT=VT_I4; break;
case VT_UI4 :
case VT_UINT : lVal = V_UI4(left); resT=VT_I4; break;
case VT_NULL : lVal = 0; resT = VT_I4; break;
default: lOk = FALSE;
}
rOk = TRUE;
switch (V_VT(right)&VT_TYPEMASK) {
case VT_I1 : rVal = V_UNION(right,cVal); resT=VT_I4; break;
case VT_I2 : rVal = V_UNION(right,iVal); resT=max(VT_I2, resT); break;
case VT_I4 : rVal = V_UNION(right,lVal); resT=VT_I4; break;
case VT_INT : rVal = V_UNION(right,lVal); resT=VT_I4; break;
case VT_UI1 : rVal = V_UNION(right,bVal); resT=VT_I4; break;
case VT_UI2 : rVal = V_UNION(right,uiVal); resT=VT_I4; break;
case VT_UI4 : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
case VT_UINT : rVal = V_UNION(right,ulVal); resT=VT_I4; break;
case VT_I1 : rVal = V_I1(right); resT=VT_I4; break;
case VT_I2 : rVal = V_I2(right); resT=max(VT_I2, resT); break;
case VT_I4 :
case VT_INT : rVal = V_I4(right); resT=VT_I4; break;
case VT_UI1 : rVal = V_UI1(right); resT=VT_I4; break;
case VT_UI2 : rVal = V_UI2(right); resT=VT_I4; break;
case VT_UI4 :
case VT_UINT : rVal = V_UI4(right); resT=VT_I4; break;
case VT_NULL : rVal = 0; resT=VT_I4; break;
default: rOk = FALSE;
}
......@@ -2891,11 +2891,11 @@ HRESULT WINAPI VarAdd(LPVARIANT left, LPVARIANT right, LPVARIANT result)
res = (lVal + rVal);
V_VT(result) = resT;
switch (resT) {
case VT_I2 : V_UNION(result,iVal) = res; break;
case VT_I4 : V_UNION(result,lVal) = res; break;
case VT_I2 : V_I2(result) = res; break;
case VT_I4 : V_I4(result) = res; break;
default:
FIXME("Unexpected result variant type %x\n", resT);
V_UNION(result,lVal) = res;
V_I4(result) = res;
}
rc = S_OK;
......@@ -2927,11 +2927,11 @@ HRESULT WINAPI VarMul(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lvt = V_VT(left)&VT_TYPEMASK;
rvt = V_VT(right)&VT_TYPEMASK;
found = FALSE;resvt=VT_VOID;
if (((1<<lvt) | (1<<rvt)) & ((1<<VT_R4)|(1<<VT_R8))) {
if (((1<<lvt) | (1<<rvt)) & (VTBIT_R4|VTBIT_R8)) {
found = TRUE;
resvt = VT_R8;
}
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
if (!found && (((1<<lvt) | (1<<rvt)) & (VTBIT_I1|VTBIT_I2|VTBIT_UI1|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|(1<<VT_INT)|(1<<VT_UINT)))) {
found = TRUE;
resvt = VT_I4;
}
......@@ -2984,11 +2984,11 @@ HRESULT WINAPI VarDiv(LPVARIANT left, LPVARIANT right, LPVARIANT result)
lvt = V_VT(left)&VT_TYPEMASK;
rvt = V_VT(right)&VT_TYPEMASK;
found = FALSE;resvt = VT_VOID;
if (((1<<lvt) | (1<<rvt)) & ((1<<VT_R4)|(1<<VT_R8))) {
if (((1<<lvt) | (1<<rvt)) & (VTBIT_R4|VTBIT_R8)) {
found = TRUE;
resvt = VT_R8;
}
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
if (!found && (((1<<lvt) | (1<<rvt)) & (VTBIT_I1|VTBIT_I2|VTBIT_UI1|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|(1<<VT_INT)|(1<<VT_UINT)))) {
found = TRUE;
resvt = VT_I4;
}
......@@ -3045,7 +3045,7 @@ HRESULT WINAPI VarSub(LPVARIANT left, LPVARIANT right, LPVARIANT result)
found = TRUE;
resvt = VT_R8;
}
if (!found && (((1<<lvt) | (1<<rvt)) & ((1<<VT_I1)|(1<<VT_I2)|(1<<VT_UI1)|(1<<VT_UI2)|(1<<VT_I4)|(1<<VT_UI4)|(1<<VT_INT)|(1<<VT_UINT)))) {
if (!found && (((1<<lvt) | (1<<rvt)) & (VTBIT_I1|VTBIT_I2|VTBIT_UI1|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|(1<<VT_INT)|(1<<VT_UINT)))) {
found = TRUE;
resvt = VT_I4;
}
......
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