Commit e98a49de authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

oleaut32: Support for VT_DISPATCH in VarOr.

parent a5e3a999
...@@ -3960,16 +3960,40 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut) ...@@ -3960,16 +3960,40 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
VARTYPE vt = VT_I4; VARTYPE vt = VT_I4;
VARIANT varLeft, varRight, varStr; VARIANT varLeft, varRight, varStr;
HRESULT hRet; HRESULT hRet;
VARIANT tempLeft, tempRight;
VariantInit(&tempLeft);
VariantInit(&tempRight);
VariantInit(&varLeft);
VariantInit(&varRight);
VariantInit(&varStr);
TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", pVarLeft, debugstr_VT(pVarLeft), TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", pVarLeft, debugstr_VT(pVarLeft),
debugstr_VF(pVarLeft), pVarRight, debugstr_VT(pVarRight), debugstr_VF(pVarLeft), pVarRight, debugstr_VT(pVarRight),
debugstr_VF(pVarRight), pVarOut); debugstr_VF(pVarRight), pVarOut);
/* Handle VT_DISPATCH by storing and taking address of returned value */
if ((V_VT(pVarLeft) & VT_TYPEMASK) == VT_DISPATCH)
{
hRet = VARIANT_FetchDispatchValue(pVarLeft, &tempLeft);
if (FAILED(hRet)) goto VarOr_Exit;
pVarLeft = &tempLeft;
}
if ((V_VT(pVarRight) & VT_TYPEMASK) == VT_DISPATCH)
{
hRet = VARIANT_FetchDispatchValue(pVarRight, &tempRight);
if (FAILED(hRet)) goto VarOr_Exit;
pVarRight = &tempRight;
}
if (V_EXTRA_TYPE(pVarLeft) || V_EXTRA_TYPE(pVarRight) || if (V_EXTRA_TYPE(pVarLeft) || V_EXTRA_TYPE(pVarRight) ||
V_VT(pVarLeft) == VT_UNKNOWN || V_VT(pVarRight) == VT_UNKNOWN || V_VT(pVarLeft) == VT_UNKNOWN || V_VT(pVarRight) == VT_UNKNOWN ||
V_VT(pVarLeft) == VT_DISPATCH || V_VT(pVarRight) == VT_DISPATCH || V_VT(pVarLeft) == VT_DISPATCH || V_VT(pVarRight) == VT_DISPATCH ||
V_VT(pVarLeft) == VT_RECORD || V_VT(pVarRight) == VT_RECORD) V_VT(pVarLeft) == VT_RECORD || V_VT(pVarRight) == VT_RECORD)
return DISP_E_BADVARTYPE; {
hRet = DISP_E_BADVARTYPE;
goto VarOr_Exit;
}
V_VT(&varLeft) = V_VT(&varRight) = V_VT(&varStr) = VT_EMPTY; V_VT(&varLeft) = V_VT(&varRight) = V_VT(&varStr) = VT_EMPTY;
...@@ -3987,49 +4011,62 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut) ...@@ -3987,49 +4011,62 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
case VT_DATE: case VT_R8: case VT_DATE: case VT_R8:
if (V_R8(pVarLeft)) if (V_R8(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_BOOL: case VT_BOOL:
if (V_BOOL(pVarLeft)) if (V_BOOL(pVarLeft))
*pVarOut = *pVarLeft; *pVarOut = *pVarLeft;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_I2: case VT_UI2: case VT_I2: case VT_UI2:
if (V_I2(pVarLeft)) if (V_I2(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_I1: case VT_I1:
if (V_I1(pVarLeft)) if (V_I1(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_UI1: case VT_UI1:
if (V_UI1(pVarLeft)) if (V_UI1(pVarLeft))
*pVarOut = *pVarLeft; *pVarOut = *pVarLeft;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_R4: case VT_R4:
if (V_R4(pVarLeft)) if (V_R4(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_I4: case VT_UI4: case VT_INT: case VT_UINT: case VT_I4: case VT_UI4: case VT_INT: case VT_UINT:
if (V_I4(pVarLeft)) if (V_I4(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_CY: case VT_CY:
if (V_CY(pVarLeft).int64) if (V_CY(pVarLeft).int64)
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_I8: case VT_UI8: case VT_I8: case VT_UI8:
if (V_I8(pVarLeft)) if (V_I8(pVarLeft))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_DECIMAL: case VT_DECIMAL:
if (DEC_HI32(&V_DECIMAL(pVarLeft)) || DEC_LO64(&V_DECIMAL(pVarLeft))) if (DEC_HI32(&V_DECIMAL(pVarLeft)) || DEC_LO64(&V_DECIMAL(pVarLeft)))
goto VarOr_AsEmpty; goto VarOr_AsEmpty;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
case VT_BSTR: case VT_BSTR:
{ {
VARIANT_BOOL b; VARIANT_BOOL b;
if (!V_BSTR(pVarLeft)) if (!V_BSTR(pVarLeft))
return DISP_E_BADVARTYPE; {
hRet = DISP_E_BADVARTYPE;
goto VarOr_Exit;
}
hRet = VarBoolFromStr(V_BSTR(pVarLeft), LOCALE_USER_DEFAULT, VAR_LOCALBOOL, &b); hRet = VarBoolFromStr(V_BSTR(pVarLeft), LOCALE_USER_DEFAULT, VAR_LOCALBOOL, &b);
if (SUCCEEDED(hRet) && b) if (SUCCEEDED(hRet) && b)
...@@ -4037,13 +4074,15 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut) ...@@ -4037,13 +4074,15 @@ HRESULT WINAPI VarOr(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
V_VT(pVarOut) = VT_BOOL; V_VT(pVarOut) = VT_BOOL;
V_BOOL(pVarOut) = b; V_BOOL(pVarOut) = b;
} }
return hRet; goto VarOr_Exit;
} }
case VT_NULL: case VT_EMPTY: case VT_NULL: case VT_EMPTY:
V_VT(pVarOut) = VT_NULL; V_VT(pVarOut) = VT_NULL;
return S_OK; hRet = S_OK;
goto VarOr_Exit;
default: default:
return DISP_E_BADVARTYPE; hRet = DISP_E_BADVARTYPE;
goto VarOr_Exit;
} }
} }
...@@ -4061,7 +4100,10 @@ VarOr_AsEmpty: ...@@ -4061,7 +4100,10 @@ VarOr_AsEmpty:
{ {
case VT_BSTR: case VT_BSTR:
if (!V_BSTR(pVarLeft)) if (!V_BSTR(pVarLeft))
return DISP_E_BADVARTYPE; {
hRet = DISP_E_BADVARTYPE;
goto VarOr_Exit;
}
hRet = VariantCopy(&varStr, pVarLeft); hRet = VariantCopy(&varStr, pVarLeft);
if (FAILED(hRet)) if (FAILED(hRet))
...@@ -4083,7 +4125,8 @@ VarOr_AsEmpty: ...@@ -4083,7 +4125,8 @@ VarOr_AsEmpty:
V_VT(pVarOut) = VT_I8; V_VT(pVarOut) = VT_I8;
break; break;
default: default:
return DISP_E_BADVARTYPE; hRet = DISP_E_BADVARTYPE;
goto VarOr_Exit;
} }
hRet = VariantCopy(&varLeft, pVarLeft); hRet = VariantCopy(&varLeft, pVarLeft);
if (FAILED(hRet)) if (FAILED(hRet))
...@@ -4097,14 +4140,16 @@ VarOr_AsEmpty: ...@@ -4097,14 +4140,16 @@ VarOr_AsEmpty:
{ {
V_VT(pVarOut) = VT_BOOL; V_VT(pVarOut) = VT_BOOL;
V_BOOL(pVarOut) = V_BOOL(pVarLeft) | V_BOOL(pVarRight); V_BOOL(pVarOut) = V_BOOL(pVarLeft) | V_BOOL(pVarRight);
return S_OK; hRet = S_OK;
goto VarOr_Exit;
} }
if (V_VT(pVarLeft) == VT_UI1 && V_VT(pVarRight) == VT_UI1) if (V_VT(pVarLeft) == VT_UI1 && V_VT(pVarRight) == VT_UI1)
{ {
V_VT(pVarOut) = VT_UI1; V_VT(pVarOut) = VT_UI1;
V_UI1(pVarOut) = V_UI1(pVarLeft) | V_UI1(pVarRight); V_UI1(pVarOut) = V_UI1(pVarLeft) | V_UI1(pVarRight);
return S_OK; hRet = S_OK;
goto VarOr_Exit;
} }
if (V_VT(pVarLeft) == VT_BSTR) if (V_VT(pVarLeft) == VT_BSTR)
...@@ -4133,7 +4178,10 @@ VarOr_AsEmpty: ...@@ -4133,7 +4178,10 @@ VarOr_AsEmpty:
else if (V_VT(pVarLeft) == VT_I8 || V_VT(pVarRight) == VT_I8) else if (V_VT(pVarLeft) == VT_I8 || V_VT(pVarRight) == VT_I8)
{ {
if (V_VT(pVarLeft) == VT_INT || V_VT(pVarRight) == VT_INT) if (V_VT(pVarLeft) == VT_INT || V_VT(pVarRight) == VT_INT)
return DISP_E_TYPEMISMATCH; {
hRet = DISP_E_TYPEMISMATCH;
goto VarOr_Exit;
}
vt = VT_I8; vt = VT_I8;
} }
...@@ -4193,6 +4241,8 @@ VarOr_Exit: ...@@ -4193,6 +4241,8 @@ VarOr_Exit:
VariantClear(&varStr); VariantClear(&varStr);
VariantClear(&varLeft); VariantClear(&varLeft);
VariantClear(&varRight); VariantClear(&varRight);
VariantClear(&tempLeft);
VariantClear(&tempRight);
return hRet; return hRet;
} }
......
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