ReactOS 0.4.15-dev-5666-gc548b97
variant.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "variant.h"
#include "resource.h"
#include "wine/debug.h"
Include dependency graph for variant.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define IsLeapYear(y)   (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
 
#define DOS_YEAR(x)   (1980 + (x >> 9))
 
#define DOS_MONTH(x)   ((x >> 5) & 0xf)
 
#define DOS_DAY(x)   (x & 0x1f)
 
#define DOS_HOUR(x)   (x >> 11)
 
#define DOS_MINUTE(x)   ((x >> 5) & 0x3f)
 
#define DOS_SECOND(x)   ((x & 0x1f) << 1)
 
#define DOS_DATE(d, m, y)   (d | (m << 5) | ((y-1980) << 9))
 
#define DOS_TIME(h, m, s)   ((s >> 1) | (m << 5) | (h << 11))
 
#define GET_NUMBER_TEXT(fld, name)
 
#define B_PROCESSING_EXPONENT   0x1
 
#define B_NEGATIVE_EXPONENT   0x2
 
#define B_EXPONENT_START   0x4
 
#define B_INEXACT_ZEROS   0x8
 
#define B_LEADING_ZERO   0x10
 
#define B_PROCESSING_HEX   0x20
 
#define B_PROCESSING_OCT   0x40
 
#define INTEGER_VTBITS   (VTBIT_I1|VTBIT_UI1|VTBIT_I2|VTBIT_UI2|VTBIT_I4|VTBIT_UI4|VTBIT_I8|VTBIT_UI8)
 
#define REAL_VTBITS   (VTBIT_R4|VTBIT_R8|VTBIT_CY)
 
#define FITS_AS_I1(x)   ((x) >> 8 == 0)
 
#define FITS_AS_I2(x)   ((x) >> 16 == 0)
 
#define FITS_AS_I4(x)   ((x) >> 32 == 0)
 
#define _VARCMP(a, b)    (((a) == (b)) ? VARCMP_EQ : (((a) < (b)) ? VARCMP_LT : VARCMP_GT))
 
#define ABS_CASE(typ, min)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (variant)
 
static HRESULT VARIANT_Coerce (VARIANTARG *pd, LCID lcid, USHORT wFlags, VARIANTARG *ps, VARTYPE vt)
 
static HRESULT VARIANT_CoerceArray (VARIANTARG *pd, VARIANTARG *ps, VARTYPE vt)
 
static HRESULT VARIANT_FetchDispatchValue (LPVARIANT pvDispatch, LPVARIANT pValue)
 
static HRESULT VARIANT_ValidateType (VARTYPE vt)
 
void WINAPI VariantInit (VARIANTARG *pVarg)
 
HRESULT VARIANT_ClearInd (VARIANTARG *pVarg)
 
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear (VARIANTARG *pVarg)
 
static HRESULT VARIANT_CopyIRecordInfo (VARIANT *dest, VARIANT *src)
 
HRESULT WINAPI VariantCopy (VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
 
static size_t VARIANT_DataSize (const VARIANT *pv)
 
HRESULT WINAPI VariantCopyInd (VARIANT *pvargDest, VARIANTARG *pvargSrc)
 
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType (VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
 
HRESULT WINAPI VariantChangeTypeEx (VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
 
static int VARIANT_JulianFromDate (int dateIn)
 
static int VARIANT_DateFromJulian (int dateIn)
 
static void VARIANT_DMYFromJulian (int jd, USHORT *year, USHORT *month, USHORT *day)
 
static double VARIANT_JulianFromDMY (USHORT year, USHORT month, USHORT day)
 
static HRESULT VARIANT_RollUdate (UDATE *lpUd)
 
INT WINAPI DosDateTimeToVariantTime (USHORT wDosDate, USHORT wDosTime, double *pDateOut)
 
INT WINAPI VariantTimeToDosDateTime (double dateIn, USHORT *pwDosDate, USHORT *pwDosTime)
 
INT WINAPI SystemTimeToVariantTime (LPSYSTEMTIME lpSt, double *pDateOut)
 
INT WINAPI VariantTimeToSystemTime (double dateIn, LPSYSTEMTIME lpSt)
 
HRESULT WINAPI VarDateFromUdateEx (UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
 
HRESULT WINAPI VarDateFromUdate (UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
 
HRESULT WINAPI VarUdateFromDate (DATE dateIn, ULONG dwFlags, UDATE *lpUdate)
 
static void VARIANT_GetLocalisedNumberChars (VARIANT_NUMBER_CHARS *lpChars, LCID lcid, DWORD dwFlags)
 
HRESULT WINAPI VarParseNumFromStr (OLECHAR *lpszStr, LCID lcid, ULONG dwFlags, NUMPARSE *pNumprs, BYTE *rgbDig)
 
HRESULT WINAPI VarNumFromParseNum (NUMPARSE *pNumprs, BYTE *rgbDig, ULONG dwVtBits, VARIANT *pVarDst)
 
HRESULT WINAPI VarCat (LPVARIANT left, LPVARIANT right, LPVARIANT out)
 
static HRESULT _VarChangeTypeExWrap (VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
 
HRESULT WINAPI VarCmp (LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags)
 
HRESULT WINAPI VarAnd (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarAdd (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarMul (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarDiv (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarSub (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarOr (LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
 
HRESULT WINAPI VarAbs (LPVARIANT pVarIn, LPVARIANT pVarOut)
 
HRESULT WINAPI VarFix (LPVARIANT pVarIn, LPVARIANT pVarOut)
 
HRESULT WINAPI VarInt (LPVARIANT pVarIn, LPVARIANT pVarOut)
 
HRESULT WINAPI VarXor (LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
 
HRESULT WINAPI VarEqv (LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
 
HRESULT WINAPI VarNeg (LPVARIANT pVarIn, LPVARIANT pVarOut)
 
HRESULT WINAPI VarNot (LPVARIANT pVarIn, LPVARIANT pVarOut)
 
HRESULT WINAPI VarRound (LPVARIANT pVarIn, int deci, LPVARIANT pVarOut)
 
HRESULT WINAPI VarIdiv (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarMod (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarPow (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 
HRESULT WINAPI VarImp (LPVARIANT left, LPVARIANT right, LPVARIANT result)
 

Variables

static CRITICAL_SECTION cache_cs = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 

Macro Definition Documentation

◆ _VARCMP

#define _VARCMP (   a,
  b 
)     (((a) == (b)) ? VARCMP_EQ : (((a) < (b)) ? VARCMP_LT : VARCMP_GT))

◆ ABS_CASE

#define ABS_CASE (   typ,
  min 
)
Value:
case VT_##typ: if (V_##typ(pVarIn) == min) hRet = DISP_E_OVERFLOW; \
else if (V_##typ(pVarIn) < 0) V_##typ(pVarOut) = -V_##typ(pVarIn); \
break
#define min(a, b)
Definition: monoChain.cc:55
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

◆ B_EXPONENT_START

#define B_EXPONENT_START   0x4

Definition at line 1568 of file variant.c.

◆ B_INEXACT_ZEROS

#define B_INEXACT_ZEROS   0x8

Definition at line 1569 of file variant.c.

◆ B_LEADING_ZERO

#define B_LEADING_ZERO   0x10

Definition at line 1570 of file variant.c.

◆ B_NEGATIVE_EXPONENT

#define B_NEGATIVE_EXPONENT   0x2

Definition at line 1567 of file variant.c.

◆ B_PROCESSING_EXPONENT

#define B_PROCESSING_EXPONENT   0x1

Definition at line 1566 of file variant.c.

◆ B_PROCESSING_HEX

#define B_PROCESSING_HEX   0x20

Definition at line 1571 of file variant.c.

◆ B_PROCESSING_OCT

#define B_PROCESSING_OCT   0x40

Definition at line 1572 of file variant.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 32 of file variant.c.

◆ DOS_DATE

#define DOS_DATE (   d,
  m,
  y 
)    (d | (m << 5) | ((y-1980) << 9))

Definition at line 1104 of file variant.c.

◆ DOS_DAY

#define DOS_DAY (   x)    (x & 0x1f)

Definition at line 1099 of file variant.c.

◆ DOS_HOUR

#define DOS_HOUR (   x)    (x >> 11)

Definition at line 1100 of file variant.c.

◆ DOS_MINUTE

#define DOS_MINUTE (   x)    ((x >> 5) & 0x3f)

Definition at line 1101 of file variant.c.

◆ DOS_MONTH

#define DOS_MONTH (   x)    ((x >> 5) & 0xf)

Definition at line 1098 of file variant.c.

◆ DOS_SECOND

#define DOS_SECOND (   x)    ((x & 0x1f) << 1)

Definition at line 1102 of file variant.c.

◆ DOS_TIME

#define DOS_TIME (   h,
  m,
  s 
)    ((s >> 1) | (m << 5) | (h << 11))

Definition at line 1105 of file variant.c.

◆ DOS_YEAR

#define DOS_YEAR (   x)    (1980 + (x >> 9))

Definition at line 1097 of file variant.c.

◆ FITS_AS_I1

#define FITS_AS_I1 (   x)    ((x) >> 8 == 0)

Definition at line 1964 of file variant.c.

◆ FITS_AS_I2

#define FITS_AS_I2 (   x)    ((x) >> 16 == 0)

Definition at line 1965 of file variant.c.

◆ FITS_AS_I4

#define FITS_AS_I4 (   x)    ((x) >> 32 == 0)

Definition at line 1966 of file variant.c.

◆ GET_NUMBER_TEXT

#define GET_NUMBER_TEXT (   fld,
  name 
)
Value:
buff[0] = 0; \
if (!GetLocaleInfoW(lcid, lctype|fld, buff, 2)) \
WARN("buffer too small for " #fld "\n"); \
else \
if (buff[0]) lpChars->name = buff[0]; \
TRACE("lcid 0x%x, " #name "=%d '%c'\n", lcid, lpChars->name, lpChars->name)
static unsigned char buff[32768]
Definition: fatten.c:17
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1102
Definition: name.c:39
WCHAR * name
Definition: name.c:42

Definition at line 1509 of file variant.c.

◆ INTEGER_VTBITS

Definition at line 1959 of file variant.c.

◆ IsLeapYear

#define IsLeapYear (   y)    (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))

Definition at line 1048 of file variant.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 34 of file variant.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 33 of file variant.c.

◆ REAL_VTBITS

#define REAL_VTBITS   (VTBIT_R4|VTBIT_R8|VTBIT_CY)

Definition at line 1961 of file variant.c.

Function Documentation

◆ _VarChangeTypeExWrap()

static HRESULT _VarChangeTypeExWrap ( VARIANTARG pvargDest,
VARIANTARG pvargSrc,
LCID  lcid,
USHORT  wFlags,
VARTYPE  vt 
)
static

Definition at line 2659 of file variant.c.

2661{
2662 VARIANTARG vtmpsrc = *pvargSrc;
2663
2664 V_VT(&vtmpsrc) &= ~VT_RESERVED;
2665 return VariantChangeTypeEx(pvargDest,&vtmpsrc,lcid,wFlags,vt);
2666}
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:86
#define V_VT(A)
Definition: oleauto.h:211
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:988
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531

Referenced by VarCmp().

◆ DosDateTimeToVariantTime()

INT WINAPI DosDateTimeToVariantTime ( USHORT  wDosDate,
USHORT  wDosTime,
double pDateOut 
)

Definition at line 1211 of file variant.c.

1213{
1214 UDATE ud;
1215
1216 TRACE("(0x%x(%d/%d/%d),0x%x(%d:%d:%d),%p)\n",
1217 wDosDate, DOS_YEAR(wDosDate), DOS_MONTH(wDosDate), DOS_DAY(wDosDate),
1218 wDosTime, DOS_HOUR(wDosTime), DOS_MINUTE(wDosTime), DOS_SECOND(wDosTime),
1219 pDateOut);
1220
1221 ud.st.wYear = DOS_YEAR(wDosDate);
1222 ud.st.wMonth = DOS_MONTH(wDosDate);
1223 if (ud.st.wYear > 2099 || ud.st.wMonth > 12)
1224 return FALSE;
1225 ud.st.wDay = DOS_DAY(wDosDate);
1226 ud.st.wHour = DOS_HOUR(wDosTime);
1227 ud.st.wMinute = DOS_MINUTE(wDosTime);
1228 ud.st.wSecond = DOS_SECOND(wDosTime);
1229 ud.st.wDayOfWeek = ud.st.wMilliseconds = 0;
1230 if (ud.st.wHour > 23 || ud.st.wMinute > 59 || ud.st.wSecond > 59)
1231 return FALSE; /* Invalid values in Dos*/
1232
1233 return VarDateFromUdate(&ud, 0, pDateOut) == S_OK;
1234}
#define FALSE
Definition: types.h:117
#define S_OK
Definition: intsafe.h:52
#define TRACE(s)
Definition: solgame.cpp:4
Definition: oleauto.h:720
SYSTEMTIME st
Definition: oleauto.h:721
WORD wYear
Definition: winbase.h:905
WORD wMilliseconds
Definition: winbase.h:912
WORD wMonth
Definition: winbase.h:906
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
WORD wDay
Definition: winbase.h:908
WORD wDayOfWeek
Definition: winbase.h:907
#define DOS_MONTH(x)
Definition: variant.c:1098
#define DOS_DAY(x)
Definition: variant.c:1099
#define DOS_SECOND(x)
Definition: variant.c:1102
#define DOS_MINUTE(x)
Definition: variant.c:1101
#define DOS_YEAR(x)
Definition: variant.c:1097
#define DOS_HOUR(x)
Definition: variant.c:1100
HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1406

Referenced by test_DosDateTimeToVariantTime().

◆ SystemTimeToVariantTime()

INT WINAPI SystemTimeToVariantTime ( LPSYSTEMTIME  lpSt,
double pDateOut 
)

Definition at line 1286 of file variant.c.

1287{
1288 UDATE ud;
1289
1290 TRACE("(%p->%d/%d/%d %d:%d:%d,%p)\n", lpSt, lpSt->wDay, lpSt->wMonth,
1291 lpSt->wYear, lpSt->wHour, lpSt->wMinute, lpSt->wSecond, pDateOut);
1292
1293 if (lpSt->wMonth > 12)
1294 return FALSE;
1295 if (lpSt->wDay > 31)
1296 return FALSE;
1297 if ((short)lpSt->wYear < 0)
1298 return FALSE;
1299
1300 ud.st = *lpSt;
1301 return VarDateFromUdate(&ud, 0, pDateOut) == S_OK;
1302}

Referenced by get_date_from_filetime(), Global_Now(), summaryinfo_invoke(), test_SummaryInfo(), test_SystemTimeToVariantTime(), and VarDateFromStr().

◆ VarAbs()

HRESULT WINAPI VarAbs ( LPVARIANT  pVarIn,
LPVARIANT  pVarOut 
)

Definition at line 4263 of file variant.c.

4264{
4265 VARIANT varIn;
4266 HRESULT hRet = S_OK;
4267 VARIANT temp;
4268
4269 VariantInit(&temp);
4270
4271 TRACE("(%s,%p)\n", debugstr_variant(pVarIn), pVarOut);
4272
4273 /* Handle VT_DISPATCH by storing and taking address of returned value */
4274 if ((V_VT(pVarIn) & VT_TYPEMASK) == VT_DISPATCH && ((V_VT(pVarIn) & ~VT_TYPEMASK) == 0))
4275 {
4276 hRet = VARIANT_FetchDispatchValue(pVarIn, &temp);
4277 if (FAILED(hRet)) goto VarAbs_Exit;
4278 pVarIn = &temp;
4279 }
4280
4281 if (V_ISARRAY(pVarIn) || V_VT(pVarIn) == VT_UNKNOWN ||
4282 V_VT(pVarIn) == VT_DISPATCH || V_VT(pVarIn) == VT_RECORD ||
4283 V_VT(pVarIn) == VT_ERROR)
4284 {
4285 hRet = DISP_E_TYPEMISMATCH;
4286 goto VarAbs_Exit;
4287 }
4288 *pVarOut = *pVarIn; /* Shallow copy the value, and invert it if needed */
4289
4290#define ABS_CASE(typ,min) \
4291 case VT_##typ: if (V_##typ(pVarIn) == min) hRet = DISP_E_OVERFLOW; \
4292 else if (V_##typ(pVarIn) < 0) V_##typ(pVarOut) = -V_##typ(pVarIn); \
4293 break
4294
4295 switch (V_VT(pVarIn))
4296 {
4297 ABS_CASE(I1,I1_MIN);
4298 case VT_BOOL:
4299 V_VT(pVarOut) = VT_I2;
4300 /* BOOL->I2, Fall through ... */
4301 ABS_CASE(I2,I2_MIN);
4302 case VT_INT:
4303 ABS_CASE(I4,I4_MIN);
4304 ABS_CASE(I8,I8_MIN);
4306 case VT_BSTR:
4307 hRet = VarR8FromStr(V_BSTR(pVarIn), LOCALE_USER_DEFAULT, 0, &V_R8(&varIn));
4308 if (FAILED(hRet))
4309 break;
4310 V_VT(pVarOut) = VT_R8;
4311 pVarIn = &varIn;
4312 /* Fall through ... */
4313 case VT_DATE:
4315 case VT_CY:
4316 hRet = VarCyAbs(V_CY(pVarIn), & V_CY(pVarOut));
4317 break;
4318 case VT_DECIMAL:
4319 DEC_SIGN(&V_DECIMAL(pVarOut)) &= ~DECIMAL_NEG;
4320 break;
4321 case VT_UI1:
4322 case VT_UI2:
4323 case VT_UINT:
4324 case VT_UI4:
4325 case VT_UI8:
4326 /* No-Op */
4327 break;
4328 case VT_EMPTY:
4329 V_VT(pVarOut) = VT_I2;
4330 case VT_NULL:
4331 V_I2(pVarOut) = 0;
4332 break;
4333 default:
4334 hRet = DISP_E_BADVARTYPE;
4335 }
4336
4337VarAbs_Exit:
4339 return hRet;
4340}
@ R8
Definition: amd64_sup.c:13
@ VT_UI8
Definition: compat.h:2315
@ VT_BSTR
Definition: compat.h:2303
@ VT_INT
Definition: compat.h:2316
@ VT_NULL
Definition: compat.h:2296
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_TYPEMASK
Definition: compat.h:2346
@ VT_UI2
Definition: compat.h:2312
@ VT_DECIMAL
Definition: compat.h:2309
@ VT_ERROR
Definition: compat.h:2305
@ VT_R8
Definition: compat.h:2300
@ VT_CY
Definition: compat.h:2301
@ VT_DATE
Definition: compat.h:2302
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
@ VT_UINT
Definition: compat.h:2317
@ VT_EMPTY
Definition: compat.h:2295
@ VT_RECORD
Definition: compat.h:2326
@ VT_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
HRESULT WINAPI VarCyAbs(CY cyIn, CY *pCyOut)
Definition: vartype.c:3876
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3151
#define FAILED(hr)
Definition: intsafe.h:51
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define LOCALE_USER_DEFAULT
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_ISARRAY(A)
Definition: oleauto.h:218
#define V_DECIMAL(A)
Definition: oleauto.h:236
#define V_CY(A)
Definition: oleauto.h:229
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2(A)
Definition: oleauto.h:245
static calc_node_t temp
Definition: rpn_ieee.c:38
#define R4(v, w, x, y, z, i)
Definition: sha1.c:39
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
#define ABS_CASE(typ, min)
static HRESULT VARIANT_FetchDispatchValue(LPVARIANT pvDispatch, LPVARIANT pValue)
Definition: variant.c:515
#define I2_MIN
Definition: variant.h:58
#define I8_MIN
Definition: variant.h:66
#define I1_MIN
Definition: variant.h:54
#define DEC_SIGN(d)
Definition: variant.h:91
#define R4_MIN
Definition: variant.h:72
#define I4_MIN
Definition: variant.h:62
#define R8_MIN
Definition: variant.h:74
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514

Referenced by Global_Abs(), and test_VarAbs().

◆ VarAdd()

HRESULT WINAPI VarAdd ( LPVARIANT  left,
LPVARIANT  right,
LPVARIANT  result 
)

Definition at line 3130 of file variant.c.

3131{
3132 HRESULT hres;
3133 VARTYPE lvt, rvt, resvt, tvt;
3134 VARIANT lv, rv, tv;
3135 VARIANT tempLeft, tempRight;
3136 double r8res;
3137
3138 /* Variant priority for coercion. Sorted from lowest to highest.
3139 VT_ERROR shows an invalid input variant type. */
3140 enum coerceprio { vt_EMPTY, vt_UI1, vt_I2, vt_I4, vt_I8, vt_BSTR,vt_R4,
3141 vt_R8, vt_CY, vt_DATE, vt_DECIMAL, vt_DISPATCH, vt_NULL,
3142 vt_ERROR };
3143 /* Mapping from priority to variant type. Keep in sync with coerceprio! */
3144 static const VARTYPE prio2vt[] = { VT_EMPTY, VT_UI1, VT_I2, VT_I4, VT_I8, VT_BSTR, VT_R4,
3146 VT_NULL, VT_ERROR };
3147
3148 /* Mapping for coercion from input variant to priority of result variant. */
3149 static const VARTYPE coerce[] = {
3150 /* VT_EMPTY, VT_NULL, VT_I2, VT_I4, VT_R4 */
3151 vt_EMPTY, vt_NULL, vt_I2, vt_I4, vt_R4,
3152 /* VT_R8, VT_CY, VT_DATE, VT_BSTR, VT_DISPATCH */
3153 vt_R8, vt_CY, vt_DATE, vt_BSTR, vt_DISPATCH,
3154 /* VT_ERROR, VT_BOOL, VT_VARIANT, VT_UNKNOWN, VT_DECIMAL */
3155 vt_ERROR, vt_I2, vt_ERROR, vt_ERROR, vt_DECIMAL,
3156 /* 15, VT_I1, VT_UI1, VT_UI2, VT_UI4 VT_I8 */
3157 vt_ERROR, vt_ERROR, vt_UI1, vt_ERROR, vt_ERROR, vt_I8
3158 };
3159
3161
3162 VariantInit(&lv);
3163 VariantInit(&rv);
3164 VariantInit(&tv);
3165 VariantInit(&tempLeft);
3166 VariantInit(&tempRight);
3167
3168 /* Handle VT_DISPATCH by storing and taking address of returned value */
3169 if ((V_VT(left) & VT_TYPEMASK) != VT_NULL && (V_VT(right) & VT_TYPEMASK) != VT_NULL)
3170 {
3171 if ((V_VT(left) & VT_TYPEMASK) == VT_DISPATCH)
3172 {
3173 hres = VARIANT_FetchDispatchValue(left, &tempLeft);
3174 if (FAILED(hres)) goto end;
3175 left = &tempLeft;
3176 }
3177 if ((V_VT(right) & VT_TYPEMASK) == VT_DISPATCH)
3178 {
3179 hres = VARIANT_FetchDispatchValue(right, &tempRight);
3180 if (FAILED(hres)) goto end;
3181 right = &tempRight;
3182 }
3183 }
3184
3185 lvt = V_VT(left)&VT_TYPEMASK;
3186 rvt = V_VT(right)&VT_TYPEMASK;
3187
3188 /* If we have any flag set (VT_ARRAY, VT_VECTOR, etc.) bail out.
3189 Same for any input variant type > VT_I8 */
3190 if (V_VT(left) & ~VT_TYPEMASK || V_VT(right) & ~VT_TYPEMASK ||
3191 lvt > VT_I8 || rvt > VT_I8) {
3193 goto end;
3194 }
3195
3196 /* Determine the variant type to coerce to. */
3197 if (coerce[lvt] > coerce[rvt]) {
3198 resvt = prio2vt[coerce[lvt]];
3199 tvt = prio2vt[coerce[rvt]];
3200 } else {
3201 resvt = prio2vt[coerce[rvt]];
3202 tvt = prio2vt[coerce[lvt]];
3203 }
3204
3205 /* Special cases where the result variant type is defined by both
3206 input variants and not only that with the highest priority */
3207 if (resvt == VT_BSTR) {
3208 if (tvt == VT_EMPTY || tvt == VT_BSTR)
3209 resvt = VT_BSTR;
3210 else
3211 resvt = VT_R8;
3212 }
3213 if (resvt == VT_R4 && (tvt == VT_BSTR || tvt == VT_I8 || tvt == VT_I4))
3214 resvt = VT_R8;
3215
3216 /* For overflow detection use the biggest compatible type for the
3217 addition */
3218 switch (resvt) {
3219 case VT_ERROR:
3221 goto end;
3222 case VT_NULL:
3223 hres = S_OK;
3224 V_VT(result) = VT_NULL;
3225 goto end;
3226 case VT_DISPATCH:
3227 FIXME("cannot handle variant type VT_DISPATCH\n");
3229 goto end;
3230 case VT_EMPTY:
3231 resvt = VT_I2;
3232 /* Fall through */
3233 case VT_UI1:
3234 case VT_I2:
3235 case VT_I4:
3236 case VT_I8:
3237 tvt = VT_I8;
3238 break;
3239 case VT_DATE:
3240 case VT_R4:
3241 tvt = VT_R8;
3242 break;
3243 default:
3244 tvt = resvt;
3245 }
3246
3247 /* Now coerce the variants */
3248 hres = VariantChangeType(&lv, left, 0, tvt);
3249 if (FAILED(hres))
3250 goto end;
3251 hres = VariantChangeType(&rv, right, 0, tvt);
3252 if (FAILED(hres))
3253 goto end;
3254
3255 /* Do the math */
3256 hres = S_OK;
3257 V_VT(result) = resvt;
3258 switch (tvt) {
3259 case VT_DECIMAL:
3260 hres = VarDecAdd(&V_DECIMAL(&lv), &V_DECIMAL(&rv),
3261 &V_DECIMAL(result));
3262 goto end;
3263 case VT_CY:
3264 hres = VarCyAdd(V_CY(&lv), V_CY(&rv), &V_CY(result));
3265 goto end;
3266 case VT_BSTR:
3267 /* We do not add those, we concatenate them. */
3268 hres = VarBstrCat(V_BSTR(&lv), V_BSTR(&rv), &V_BSTR(result));
3269 goto end;
3270 case VT_I8:
3271 /* Overflow detection */
3272 r8res = (double)V_I8(&lv) + (double)V_I8(&rv);
3273 if (r8res > (double)I8_MAX || r8res < (double)I8_MIN) {
3274 V_VT(result) = VT_R8;
3275 V_R8(result) = r8res;
3276 goto end;
3277 } else {
3278 V_VT(&tv) = tvt;
3279 V_I8(&tv) = V_I8(&lv) + V_I8(&rv);
3280 }
3281 break;
3282 case VT_R8:
3283 V_VT(&tv) = tvt;
3284 /* FIXME: overflow detection */
3285 V_R8(&tv) = V_R8(&lv) + V_R8(&rv);
3286 break;
3287 default:
3288 ERR("We shouldn't get here! tvt = %d!\n", tvt);
3289 break;
3290 }
3291 if (resvt != tvt) {
3292 if ((hres = VariantChangeType(result, &tv, 0, resvt)) != S_OK) {
3293 /* Overflow! Change to the vartype with the next higher priority.
3294 With one exception: I4 ==> R8 even if it would fit in I8 */
3295 if (resvt == VT_I4)
3296 resvt = VT_R8;
3297 else
3298 resvt = prio2vt[coerce[resvt] + 1];
3299 hres = VariantChangeType(result, &tv, 0, resvt);
3300 }
3301 } else
3302 hres = VariantCopy(result, &tv);
3303
3304end:
3305 if (hres != S_OK) {
3306 V_VT(result) = VT_EMPTY;
3307 V_I4(result) = 0; /* No V_EMPTY */
3308 }
3309 VariantClear(&lv);
3310 VariantClear(&rv);
3311 VariantClear(&tv);
3312 VariantClear(&tempLeft);
3313 VariantClear(&tempRight);
3314 TRACE("returning 0x%8x %s\n", hres, debugstr_variant(result));
3315 return hres;
3316}
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
unsigned short VARTYPE
Definition: compat.h:2254
@ VT_R4
Definition: compat.h:2299
@ VT_I8
Definition: compat.h:2314
@ VT_I4
Definition: compat.h:2298
HRESULT WINAPI VarDecAdd(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:4588
HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
Definition: vartype.c:7107
HRESULT WINAPI VarCyAdd(CY cyLeft, CY cyRight, CY *pCyOut)
Definition: vartype.c:3785
GLuint GLuint end
Definition: gl.h:1545
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLuint64EXT * result
Definition: glext.h:11304
HRESULT hres
Definition: protocol.c:465
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define V_I8(A)
Definition: oleauto.h:249
#define V_I4(A)
Definition: oleauto.h:247
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:962
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748
#define I8_MAX
Definition: variant.h:65

Referenced by interp_add(), interp_incc(), and test_VarAdd().

◆ VarAnd()

HRESULT WINAPI VarAnd ( LPVARIANT  left,
LPVARIANT  right,
LPVARIANT  result 
)

Definition at line 2893 of file variant.c.

2894{
2895 HRESULT hres = S_OK;
2896 VARTYPE resvt = VT_EMPTY;
2897 VARTYPE leftvt,rightvt;
2898 VARTYPE rightExtraFlags,leftExtraFlags,ExtraFlags;
2899 VARIANT varLeft, varRight;
2900 VARIANT tempLeft, tempRight;
2901
2902 VariantInit(&varLeft);
2903 VariantInit(&varRight);
2904 VariantInit(&tempLeft);
2905 VariantInit(&tempRight);
2906
2908
2909 /* Handle VT_DISPATCH by storing and taking address of returned value */
2910 if ((V_VT(left) & VT_TYPEMASK) == VT_DISPATCH)
2911 {
2912 hres = VARIANT_FetchDispatchValue(left, &tempLeft);
2913 if (FAILED(hres)) goto VarAnd_Exit;
2914 left = &tempLeft;
2915 }
2916 if ((V_VT(right) & VT_TYPEMASK) == VT_DISPATCH)
2917 {
2918 hres = VARIANT_FetchDispatchValue(right, &tempRight);
2919 if (FAILED(hres)) goto VarAnd_Exit;
2920 right = &tempRight;
2921 }
2922
2923 leftvt = V_VT(left)&VT_TYPEMASK;
2924 rightvt = V_VT(right)&VT_TYPEMASK;
2925 leftExtraFlags = V_VT(left)&(~VT_TYPEMASK);
2926 rightExtraFlags = V_VT(right)&(~VT_TYPEMASK);
2927
2928 if (leftExtraFlags != rightExtraFlags)
2929 {
2931 goto VarAnd_Exit;
2932 }
2933 ExtraFlags = leftExtraFlags;
2934
2935 /* Native VarAnd always returns an error when using extra
2936 * flags or if the variant combination is I8 and INT.
2937 */
2938 if ((leftvt == VT_I8 && rightvt == VT_INT) ||
2939 (leftvt == VT_INT && rightvt == VT_I8) ||
2940 ExtraFlags != 0)
2941 {
2943 goto VarAnd_Exit;
2944 }
2945
2946 /* Determine return type */
2947 else if (leftvt == VT_I8 || rightvt == VT_I8)
2948 resvt = VT_I8;
2949 else if (leftvt == VT_I4 || rightvt == VT_I4 ||
2950 leftvt == VT_UINT || rightvt == VT_UINT ||
2951 leftvt == VT_INT || rightvt == VT_INT ||
2952 leftvt == VT_R4 || rightvt == VT_R4 ||
2953 leftvt == VT_R8 || rightvt == VT_R8 ||
2954 leftvt == VT_CY || rightvt == VT_CY ||
2955 leftvt == VT_DATE || rightvt == VT_DATE ||
2956 leftvt == VT_I1 || rightvt == VT_I1 ||
2957 leftvt == VT_UI2 || rightvt == VT_UI2 ||
2958 leftvt == VT_UI4 || rightvt == VT_UI4 ||
2959 leftvt == VT_UI8 || rightvt == VT_UI8 ||
2960 leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
2961 resvt = VT_I4;
2962 else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
2963 leftvt == VT_I2 || rightvt == VT_I2 ||
2964 leftvt == VT_EMPTY || rightvt == VT_EMPTY)
2965 if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
2966 (leftvt == VT_UI1 && rightvt == VT_NULL) ||
2967 (leftvt == VT_UI1 && rightvt == VT_UI1))
2968 resvt = VT_UI1;
2969 else
2970 resvt = VT_I2;
2971 else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
2972 (leftvt == VT_BSTR && rightvt == VT_BSTR))
2973 resvt = VT_BOOL;
2974 else if (leftvt == VT_NULL || rightvt == VT_NULL ||
2975 leftvt == VT_BSTR || rightvt == VT_BSTR)
2976 resvt = VT_NULL;
2977 else
2978 {
2980 goto VarAnd_Exit;
2981 }
2982
2983 if (leftvt == VT_NULL || rightvt == VT_NULL)
2984 {
2985 /*
2986 * Special cases for when left variant is VT_NULL
2987 * (VT_NULL & 0 = VT_NULL, VT_NULL & value = value)
2988 */
2989 if (leftvt == VT_NULL)
2990 {
2992 switch(rightvt)
2993 {
2994 case VT_I1: if (V_I1(right)) resvt = VT_NULL; break;
2995 case VT_UI1: if (V_UI1(right)) resvt = VT_NULL; break;
2996 case VT_I2: if (V_I2(right)) resvt = VT_NULL; break;
2997 case VT_UI2: if (V_UI2(right)) resvt = VT_NULL; break;
2998 case VT_I4: if (V_I4(right)) resvt = VT_NULL; break;
2999 case VT_UI4: if (V_UI4(right)) resvt = VT_NULL; break;
3000 case VT_I8: if (V_I8(right)) resvt = VT_NULL; break;
3001 case VT_UI8: if (V_UI8(right)) resvt = VT_NULL; break;
3002 case VT_INT: if (V_INT(right)) resvt = VT_NULL; break;
3003 case VT_UINT: if (V_UINT(right)) resvt = VT_NULL; break;
3004 case VT_BOOL: if (V_BOOL(right)) resvt = VT_NULL; break;
3005 case VT_R4: if (V_R4(right)) resvt = VT_NULL; break;
3006 case VT_R8: if (V_R8(right)) resvt = VT_NULL; break;
3007 case VT_CY:
3008 if(V_CY(right).int64)
3009 resvt = VT_NULL;
3010 break;
3011 case VT_DECIMAL:
3012 if (DEC_HI32(&V_DECIMAL(right)) ||
3014 resvt = VT_NULL;
3015 break;
3016 case VT_BSTR:
3019 if (FAILED(hres))
3020 return hres;
3021 else if (b)
3022 V_VT(result) = VT_NULL;
3023 else
3024 {
3025 V_VT(result) = VT_BOOL;
3026 V_BOOL(result) = b;
3027 }
3028 goto VarAnd_Exit;
3029 }
3030 }
3031 V_VT(result) = resvt;
3032 goto VarAnd_Exit;
3033 }
3034
3035 hres = VariantCopy(&varLeft, left);
3036 if (FAILED(hres)) goto VarAnd_Exit;
3037
3038 hres = VariantCopy(&varRight, right);
3039 if (FAILED(hres)) goto VarAnd_Exit;
3040
3041 if (resvt == VT_I4 && V_VT(&varLeft) == VT_UI4)
3042 V_VT(&varLeft) = VT_I4; /* Don't overflow */
3043 else
3044 {
3045 double d;
3046
3047 if (V_VT(&varLeft) == VT_BSTR &&
3048 FAILED(VarR8FromStr(V_BSTR(&varLeft),
3049 LOCALE_USER_DEFAULT, 0, &d)))
3050 hres = VariantChangeType(&varLeft,&varLeft,
3052 if (SUCCEEDED(hres) && V_VT(&varLeft) != resvt)
3053 hres = VariantChangeType(&varLeft,&varLeft,0,resvt);
3054 if (FAILED(hres)) goto VarAnd_Exit;
3055 }
3056
3057 if (resvt == VT_I4 && V_VT(&varRight) == VT_UI4)
3058 V_VT(&varRight) = VT_I4; /* Don't overflow */
3059 else
3060 {
3061 double d;
3062
3063 if (V_VT(&varRight) == VT_BSTR &&
3064 FAILED(VarR8FromStr(V_BSTR(&varRight),
3065 LOCALE_USER_DEFAULT, 0, &d)))
3066 hres = VariantChangeType(&varRight, &varRight,
3068 if (SUCCEEDED(hres) && V_VT(&varRight) != resvt)
3069 hres = VariantChangeType(&varRight, &varRight, 0, resvt);
3070 if (FAILED(hres)) goto VarAnd_Exit;
3071 }
3072
3073 V_VT(result) = resvt;
3074 switch(resvt)
3075 {
3076 case VT_I8:
3077 V_I8(result) = V_I8(&varLeft) & V_I8(&varRight);
3078 break;
3079 case VT_I4:
3080 V_I4(result) = V_I4(&varLeft) & V_I4(&varRight);
3081 break;
3082 case VT_I2:
3083 V_I2(result) = V_I2(&varLeft) & V_I2(&varRight);
3084 break;
3085 case VT_UI1:
3086 V_UI1(result) = V_UI1(&varLeft) & V_UI1(&varRight);
3087 break;
3088 case VT_BOOL:
3089 V_BOOL(result) = V_BOOL(&varLeft) & V_BOOL(&varRight);
3090 break;
3091 default:
3092 FIXME("Couldn't bitwise AND variant types %d,%d\n",
3093 leftvt,rightvt);
3094 }
3095
3096VarAnd_Exit:
3097 VariantClear(&varLeft);
3098 VariantClear(&varRight);
3099 VariantClear(&tempLeft);
3100 VariantClear(&tempRight);
3101
3102 return hres;
3103}
short VARIANT_BOOL
Definition: compat.h:2290
@ VT_I1
Definition: compat.h:2310
HRESULT WINAPI VarBoolFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6114
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define d
Definition: ke_i.h:81
#define b
Definition: ke_i.h:79
#define V_UI1(A)
Definition: oleauto.h:266
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define VAR_LOCALBOOL
Definition: oleauto.h:330
#define V_R4(A)
Definition: oleauto.h:260
#define V_UINT(A)
Definition: oleauto.h:264
#define V_UI4(A)
Definition: oleauto.h:270
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
#define V_UI8(A)
Definition: oleauto.h:272
#define DEC_HI32(d)
Definition: variant.h:94
#define DEC_LO64(d)
Definition: variant.h:97
static const VARTYPE ExtraFlags[16]
Definition: vartest.c:689
#define V_INT(x)
Definition: webchild.h:78

Referenced by interp_and(), and test_VarAnd().

◆ VarCat()

HRESULT WINAPI VarCat ( LPVARIANT  left,
LPVARIANT  right,
LPVARIANT  out 
)

Definition at line 2515 of file variant.c.

2516{
2517 BSTR left_str = NULL, right_str = NULL;
2518 VARTYPE leftvt, rightvt;
2519 HRESULT hres;
2520
2522
2523 leftvt = V_VT(left);
2524 rightvt = V_VT(right);
2525
2526 /* when both left and right are NULL the result is NULL */
2527 if (leftvt == VT_NULL && rightvt == VT_NULL)
2528 {
2529 V_VT(out) = VT_NULL;
2530 return S_OK;
2531 }
2532
2533 /* There are many special case for errors and return types */
2534 if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
2535 rightvt == VT_DATE || rightvt == VT_DECIMAL))
2537 else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
2538 leftvt == VT_R4 || leftvt == VT_R8 ||
2539 leftvt == VT_CY || leftvt == VT_BOOL ||
2540 leftvt == VT_BSTR || leftvt == VT_I1 ||
2541 leftvt == VT_UI1 || leftvt == VT_UI2 ||
2542 leftvt == VT_UI4 || leftvt == VT_I8 ||
2543 leftvt == VT_UI8 || leftvt == VT_INT ||
2544 leftvt == VT_UINT || leftvt == VT_EMPTY ||
2545 leftvt == VT_NULL || leftvt == VT_DATE ||
2546 leftvt == VT_DECIMAL || leftvt == VT_DISPATCH)
2547 &&
2548 (rightvt == VT_I2 || rightvt == VT_I4 ||
2549 rightvt == VT_R4 || rightvt == VT_R8 ||
2550 rightvt == VT_CY || rightvt == VT_BOOL ||
2551 rightvt == VT_BSTR || rightvt == VT_I1 ||
2552 rightvt == VT_UI1 || rightvt == VT_UI2 ||
2553 rightvt == VT_UI4 || rightvt == VT_I8 ||
2554 rightvt == VT_UI8 || rightvt == VT_INT ||
2555 rightvt == VT_UINT || rightvt == VT_EMPTY ||
2556 rightvt == VT_NULL || rightvt == VT_DATE ||
2557 rightvt == VT_DECIMAL || rightvt == VT_DISPATCH))
2558 hres = S_OK;
2559 else if (rightvt == VT_ERROR && leftvt < VT_VOID)
2561 else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
2562 rightvt == VT_ERROR || rightvt == VT_DECIMAL))
2564 else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
2565 rightvt == VT_DECIMAL)
2567 else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
2569 else if (leftvt == VT_VARIANT)
2571 else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
2572 leftvt == VT_NULL || leftvt == VT_I2 ||
2573 leftvt == VT_I4 || leftvt == VT_R4 ||
2574 leftvt == VT_R8 || leftvt == VT_CY ||
2575 leftvt == VT_DATE || leftvt == VT_BSTR ||
2576 leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
2577 leftvt == VT_I1 || leftvt == VT_UI1 ||
2578 leftvt == VT_UI2 || leftvt == VT_UI4 ||
2579 leftvt == VT_I8 || leftvt == VT_UI8 ||
2580 leftvt == VT_INT || leftvt == VT_UINT))
2582 else
2584
2585 /* if result type is not S_OK, then no need to go further */
2586 if (hres != S_OK)
2587 {
2588 V_VT(out) = VT_EMPTY;
2589 return hres;
2590 }
2591
2592 if (leftvt == VT_BSTR)
2593 left_str = V_BSTR(left);
2594 else
2595 {
2596 VARIANT converted, *tmp = left;
2597
2598 VariantInit(&converted);
2599 if(leftvt == VT_DISPATCH)
2600 {
2601 hres = VARIANT_FetchDispatchValue(left, &converted);
2602 if(FAILED(hres))
2603 goto failed;
2604
2605 tmp = &converted;
2606 }
2607
2609 if (SUCCEEDED(hres))
2610 left_str = V_BSTR(&converted);
2611 else if (hres != DISP_E_TYPEMISMATCH)
2612 {
2613 VariantClear(&converted);
2614 goto failed;
2615 }
2616 }
2617
2618 if (rightvt == VT_BSTR)
2619 right_str = V_BSTR(right);
2620 else
2621 {
2622 VARIANT converted, *tmp = right;
2623
2624 VariantInit(&converted);
2625 if(rightvt == VT_DISPATCH)
2626 {
2627 hres = VARIANT_FetchDispatchValue(right, &converted);
2628 if(FAILED(hres))
2629 goto failed;
2630
2631 tmp = &converted;
2632 }
2633
2635 if (SUCCEEDED(hres))
2636 right_str = V_BSTR(&converted);
2637 else if (hres != DISP_E_TYPEMISMATCH)
2638 {
2639 VariantClear(&converted);
2640 goto failed;
2641 }
2642 }
2643
2644
2645 V_VT(out) = VT_BSTR;
2646 hres = VarBstrCat(left_str, right_str, &V_BSTR(out));
2647
2648failed:
2649 if(V_VT(left) != VT_BSTR)
2650 SysFreeString(left_str);
2651 if(V_VT(right) != VT_BSTR)
2652 SysFreeString(right_str);
2653 return hres;
2654}
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
@ VT_VOID
Definition: compat.h:2318
@ VT_VARIANT
Definition: compat.h:2307
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
#define VARIANT_ALPHABOOL
Definition: oleauto.h:311
static FILE * out
Definition: regtests2xml.c:44

Referenced by interp_concat(), and test_VarCat().

◆ VarCmp()

HRESULT WINAPI VarCmp ( LPVARIANT  left,
LPVARIANT  right,
LCID  lcid,
DWORD  flags 
)

Definition at line 2712 of file variant.c.

2713{
2714 VARTYPE lvt, rvt, vt;
2715 VARIANT rv,lv;
2716 DWORD xmask;
2717 HRESULT rc;
2718
2719 TRACE("(%s,%s,0x%08x,0x%08x)\n", debugstr_variant(left), debugstr_variant(right), lcid, flags);
2720
2721 lvt = V_VT(left) & VT_TYPEMASK;
2722 rvt = V_VT(right) & VT_TYPEMASK;
2723 xmask = (1 << lvt) | (1 << rvt);
2724
2725 /* If we have any flag set except VT_RESERVED bail out.
2726 Same for the left input variant type > VT_INT and for the
2727 right input variant type > VT_I8. Yes, VT_INT is only supported
2728 as left variant. Go figure */
2729 if (((V_VT(left) | V_VT(right)) & ~VT_TYPEMASK & ~VT_RESERVED) ||
2730 lvt > VT_INT || rvt > VT_I8) {
2731 return DISP_E_BADVARTYPE;
2732 }
2733
2734 /* Don't ask me why but native VarCmp cannot handle: VT_I1, VT_UI2, VT_UI4,
2735 VT_UINT and VT_UI8. Tested with DCOM98, Win2k, WinXP */
2736 if (rvt == VT_INT || xmask & (VTBIT_I1 | VTBIT_UI2 | VTBIT_UI4 | VTBIT_UI8 |
2738 return DISP_E_TYPEMISMATCH;
2739
2740 /* If both variants are VT_ERROR return VARCMP_EQ */
2741 if (xmask == VTBIT_ERROR)
2742 return VARCMP_EQ;
2743 else if (xmask & VTBIT_ERROR)
2744 return DISP_E_TYPEMISMATCH;
2745
2746 if (xmask & VTBIT_NULL)
2747 return VARCMP_NULL;
2748
2749 VariantInit(&lv);
2750 VariantInit(&rv);
2751
2752 /* Two BSTRs, ignore VT_RESERVED */
2753 if (xmask == VTBIT_BSTR)
2754 return VarBstrCmp(V_BSTR(left), V_BSTR(right), lcid, flags);
2755
2756 /* A BSTR and another variant; we have to take care of VT_RESERVED */
2757 if (xmask & VTBIT_BSTR) {
2758 VARIANT *bstrv, *nonbv;
2759 VARTYPE nonbvt;
2760 int swap = 0;
2761
2762 /* Swap the variants so the BSTR is always on the left */
2763 if (lvt == VT_BSTR) {
2764 bstrv = left;
2765 nonbv = right;
2766 nonbvt = rvt;
2767 } else {
2768 swap = 1;
2769 bstrv = right;
2770 nonbv = left;
2771 nonbvt = lvt;
2772 }
2773
2774 /* BSTR and EMPTY: ignore VT_RESERVED */
2775 if (nonbvt == VT_EMPTY)
2776 rc = (!V_BSTR(bstrv) || !*V_BSTR(bstrv)) ? VARCMP_EQ : VARCMP_GT;
2777 else {
2778 VARTYPE breserv = V_VT(bstrv) & ~VT_TYPEMASK;
2779 VARTYPE nreserv = V_VT(nonbv) & ~VT_TYPEMASK;
2780
2781 if (!breserv && !nreserv)
2782 /* No VT_RESERVED set ==> BSTR always greater */
2783 rc = VARCMP_GT;
2784 else if (breserv && !nreserv) {
2785 /* BSTR has VT_RESERVED set. Do a string comparison */
2786 rc = VariantChangeTypeEx(&rv,nonbv,lcid,0,VT_BSTR);
2787 if (FAILED(rc))
2788 return rc;
2789 rc = VarBstrCmp(V_BSTR(bstrv), V_BSTR(&rv), lcid, flags);
2790 VariantClear(&rv);
2791 } else if (V_BSTR(bstrv) && *V_BSTR(bstrv)) {
2792 /* Non NULL nor empty BSTR */
2793 /* If the BSTR is not a number the BSTR is greater */
2794 rc = _VarChangeTypeExWrap(&lv,bstrv,lcid,0,VT_R8);
2795 if (FAILED(rc))
2796 rc = VARCMP_GT;
2797 else if (breserv && nreserv)
2798 /* FIXME: This is strange: with both VT_RESERVED set it
2799 looks like the result depends only on the sign of
2800 the BSTR number */
2801 rc = (V_R8(&lv) >= 0) ? VARCMP_GT : VARCMP_LT;
2802 else
2803 /* Numeric comparison, will be handled below.
2804 VARCMP_NULL used only to break out. */
2805 rc = VARCMP_NULL;
2806 VariantClear(&lv);
2807 VariantClear(&rv);
2808 } else
2809 /* Empty or NULL BSTR */
2810 rc = VARCMP_GT;
2811 }
2812 /* Fixup the return code if we swapped left and right */
2813 if (swap) {
2814 if (rc == VARCMP_GT)
2815 rc = VARCMP_LT;
2816 else if (rc == VARCMP_LT)
2817 rc = VARCMP_GT;
2818 }
2819 if (rc != VARCMP_NULL)
2820 return rc;
2821 }
2822
2823 if (xmask & VTBIT_DECIMAL)
2824 vt = VT_DECIMAL;
2825 else if (xmask & VTBIT_BSTR)
2826 vt = VT_R8;
2827 else if (xmask & VTBIT_R4)
2828 vt = VT_R4;
2829 else if (xmask & (VTBIT_R8 | VTBIT_DATE))
2830 vt = VT_R8;
2831 else if (xmask & VTBIT_CY)
2832 vt = VT_CY;
2833 else
2834 /* default to I8 */
2835 vt = VT_I8;
2836
2837 /* Coerce the variants */
2838 rc = _VarChangeTypeExWrap(&lv,left,lcid,0,vt);
2839 if (rc == DISP_E_OVERFLOW && vt != VT_R8) {
2840 /* Overflow, change to R8 */
2841 vt = VT_R8;
2842 rc = _VarChangeTypeExWrap(&lv,left,lcid,0,vt);
2843 }
2844 if (FAILED(rc))
2845 return rc;
2846 rc = _VarChangeTypeExWrap(&rv,right,lcid,0,vt);
2847 if (rc == DISP_E_OVERFLOW && vt != VT_R8) {
2848 /* Overflow, change to R8 */
2849 vt = VT_R8;
2850 rc = _VarChangeTypeExWrap(&lv,left,lcid,0,vt);
2851 if (FAILED(rc))
2852 return rc;
2853 rc = _VarChangeTypeExWrap(&rv,right,lcid,0,vt);
2854 }
2855 if (FAILED(rc))
2856 return rc;
2857
2858#define _VARCMP(a,b) \
2859 (((a) == (b)) ? VARCMP_EQ : (((a) < (b)) ? VARCMP_LT : VARCMP_GT))
2860
2861 switch (vt) {
2862 case VT_CY:
2863 return VarCyCmp(V_CY(&lv), V_CY(&rv));
2864 case VT_DECIMAL:
2865 return VarDecCmp(&V_DECIMAL(&lv), &V_DECIMAL(&rv));
2866 case VT_I8:
2867 return _VARCMP(V_I8(&lv), V_I8(&rv));
2868 case VT_R4:
2869 return _VARCMP(V_R4(&lv), V_R4(&rv));
2870 case VT_R8:
2871 return _VARCMP(V_R8(&lv), V_R8(&rv));
2872 default:
2873 /* We should never get here */
2874 return E_FAIL;
2875 }
2876#undef _VARCMP
2877}
#define E_FAIL
Definition: ddrawi.h:102
@ VT_RESERVED
Definition: compat.h:2343
HRESULT WINAPI VarDecCmp(const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
Definition: vartype.c:5866
HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFlags)
Definition: vartype.c:7158
HRESULT WINAPI VarCyCmp(CY cyLeft, CY cyRight)
Definition: vartype.c:4012
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define VARCMP_LT
Definition: oleauto.h:657
#define VARCMP_NULL
Definition: oleauto.h:660
#define VTBIT_R4
Definition: oleauto.h:760
#define VARCMP_EQ
Definition: oleauto.h:658
#define VTBIT_CY
Definition: oleauto.h:762
#define VARCMP_GT
Definition: oleauto.h:659
#define VTBIT_DECIMAL
Definition: oleauto.h:763
#define VTBIT_UI8
Definition: oleauto.h:759
#define VTBIT_UI4
Definition: oleauto.h:757
#define VTBIT_UI2
Definition: oleauto.h:755
#define VTBIT_I1
Definition: oleauto.h:752
#define VTBIT_R8
Definition: oleauto.h:761
#define swap(a, b)
Definition: qsort.c:63
static HRESULT _VarChangeTypeExWrap(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:2659
#define _VARCMP(a, b)
#define VTBIT_15
Definition: variant.h:50
#define VTBIT_DISPATCH
Definition: variant.h:42
#define VTBIT_UNKNOWN
Definition: variant.h:48
#define VTBIT_BSTR
Definition: variant.h:40
#define VTBIT_DATE
Definition: variant.h:41
#define VTBIT_NULL
Definition: variant.h:46
#define VTBIT_ERROR
Definition: variant.h:44
#define VTBIT_VARIANT
Definition: variant.h:49

Referenced by interp_step(), submit_onclick_setret(), test_cmp(), test_VarCmp(), and var_cmp().

◆ VarDateFromUdate()

HRESULT WINAPI VarDateFromUdate ( UDATE pUdateIn,
ULONG  dwFlags,
DATE pDateOut 
)

Definition at line 1406 of file variant.c.

1407{
1409
1410 return VarDateFromUdateEx(pUdateIn, lcid, dwFlags, pDateOut);
1411}
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
DWORD LCID
Definition: nls.h:13
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1345
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by DosDateTimeToVariantTime(), SystemTimeToVariantTime(), and test_VarDateFromUdate().

◆ VarDateFromUdateEx()

HRESULT WINAPI VarDateFromUdateEx ( UDATE pUdateIn,
LCID  lcid,
ULONG  dwFlags,
DATE pDateOut 
)

Definition at line 1345 of file variant.c.

1346{
1347 UDATE ud;
1348 double dateVal = 0;
1349
1350 TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08x,0x%08x,%p)\n", pUdateIn,
1351 pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
1352 pUdateIn->st.wHour, pUdateIn->st.wMinute, pUdateIn->st.wSecond,
1353 pUdateIn->st.wMilliseconds, pUdateIn->st.wDayOfWeek,
1354 pUdateIn->wDayOfYear, lcid, dwFlags, pDateOut);
1355
1357 FIXME("lcid possibly not handled, treating as en-us\n");
1359 FIXME("unsupported flags: %x\n", dwFlags);
1360
1361 ud = *pUdateIn;
1362
1363 if (dwFlags & VAR_VALIDDATE)
1364 WARN("Ignoring VAR_VALIDDATE\n");
1365
1366 if (FAILED(VARIANT_RollUdate(&ud)))
1367 return E_INVALIDARG;
1368
1369 /* Date */
1370 if (!(dwFlags & VAR_TIMEVALUEONLY))
1372
1374 {
1375 double dateSign = (dateVal < 0.0) ? -1.0 : 1.0;
1376
1377 /* Time */
1378 dateVal += ud.st.wHour / 24.0 * dateSign;
1379 dateVal += ud.st.wMinute / 1440.0 * dateSign;
1380 dateVal += ud.st.wSecond / 86400.0 * dateSign;
1381 }
1382
1383 TRACE("Returning %g\n", dateVal);
1384 *pDateOut = dateVal;
1385 return S_OK;
1386}
#define WARN(fmt,...)
Definition: debug.h:112
#define E_INVALIDARG
Definition: ddrawi.h:101
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
#define VAR_VALIDDATE
Definition: oleauto.h:328
USHORT wDayOfYear
Definition: oleauto.h:722
static double VARIANT_JulianFromDMY(USHORT year, USHORT month, USHORT day)
Definition: variant.c:1088
static int VARIANT_DateFromJulian(int dateIn)
Definition: variant.c:1061
static HRESULT VARIANT_RollUdate(UDATE *lpUd)
Definition: variant.c:1108

Referenced by Global_Date(), Global_Time(), and VarDateFromUdate().

◆ VarDiv()

HRESULT WINAPI VarDiv ( LPVARIANT  left,
LPVARIANT  right,
LPVARIANT  result 
)

Definition at line 3521 of file variant.c.

3522{
3523 HRESULT hres = S_OK;
3524 VARTYPE resvt = VT_EMPTY;
3525 VARTYPE leftvt,rightvt;
3526 VARTYPE rightExtraFlags,leftExtraFlags,ExtraFlags;
3527 VARIANT lv,rv;
3528 VARIANT tempLeft, tempRight;
3529
3530 VariantInit(&tempLeft);
3531 VariantInit(&tempRight);
3532 VariantInit(&lv);
3533 VariantInit(&rv);
3534
3536
3537 /* Handle VT_DISPATCH by storing and taking address of returned value */
3538 if ((V_VT(left) & VT_TYPEMASK) == VT_DISPATCH)
3539 {
3540 hres = VARIANT_FetchDispatchValue(left, &tempLeft);
3541 if (FAILED(hres)) goto end;
3542 left = &tempLeft;
3543 }
3544 if ((V_VT(right) & VT_TYPEMASK) == VT_DISPATCH)
3545 {
3546 hres = VARIANT_FetchDispatchValue(right, &tempRight);
3547 if (FAILED(hres)) goto end;
3548 right = &tempRight;
3549 }
3550
3551 leftvt = V_VT(left)&VT_TYPEMASK;
3552 rightvt = V_VT(right)&VT_TYPEMASK;
3553 leftExtraFlags = V_VT(left)&(~VT_TYPEMASK);
3554 rightExtraFlags = V_VT(right)&(~VT_TYPEMASK);
3555
3556 if (leftExtraFlags != rightExtraFlags)
3557 {
3559 goto end;
3560 }
3561 ExtraFlags = leftExtraFlags;
3562
3563 /* Native VarDiv always returns an error when using extra flags */
3564 if (ExtraFlags != 0)
3565 {
3567 goto end;
3568 }
3569
3570 /* Determine return type */
3571 if (rightvt != VT_EMPTY)
3572 {
3573 if (leftvt == VT_NULL || rightvt == VT_NULL)
3574 {
3575 V_VT(result) = VT_NULL;
3576 hres = S_OK;
3577 goto end;
3578 }
3579 else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
3580 resvt = VT_DECIMAL;
3581 else if (leftvt == VT_I8 || rightvt == VT_I8 ||
3582 leftvt == VT_CY || rightvt == VT_CY ||
3583 leftvt == VT_DATE || rightvt == VT_DATE ||
3584 leftvt == VT_I4 || rightvt == VT_I4 ||
3585 leftvt == VT_BSTR || rightvt == VT_BSTR ||
3586 leftvt == VT_I2 || rightvt == VT_I2 ||
3587 leftvt == VT_BOOL || rightvt == VT_BOOL ||
3588 leftvt == VT_R8 || rightvt == VT_R8 ||
3589 leftvt == VT_UI1 || rightvt == VT_UI1)
3590 {
3591 if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
3592 (leftvt == VT_R4 && rightvt == VT_UI1))
3593 resvt = VT_R4;
3594 else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
3595 rightvt == VT_I2)) || (rightvt == VT_R4 &&
3596 (leftvt == VT_BOOL || leftvt == VT_I2)))
3597 resvt = VT_R4;
3598 else
3599 resvt = VT_R8;
3600 }
3601 else if (leftvt == VT_R4 || rightvt == VT_R4)
3602 resvt = VT_R4;
3603 }
3604 else if (leftvt == VT_NULL)
3605 {
3606 V_VT(result) = VT_NULL;
3607 hres = S_OK;
3608 goto end;
3609 }
3610 else
3611 {
3613 goto end;
3614 }
3615
3616 /* coerce to the result type */
3617 hres = VariantChangeType(&lv, left, 0, resvt);
3618 if (hres != S_OK) goto end;
3619
3620 hres = VariantChangeType(&rv, right, 0, resvt);
3621 if (hres != S_OK) goto end;
3622
3623 /* do the math */
3624 V_VT(result) = resvt;
3625 switch (resvt)
3626 {
3627 case VT_R4:
3628 if (V_R4(&lv) == 0.0 && V_R4(&rv) == 0.0)
3629 {
3631 V_VT(result) = VT_EMPTY;
3632 }
3633 else if (V_R4(&rv) == 0.0)
3634 {
3636 V_VT(result) = VT_EMPTY;
3637 }
3638 else
3639 V_R4(result) = V_R4(&lv) / V_R4(&rv);
3640 break;
3641 case VT_R8:
3642 if (V_R8(&lv) == 0.0 && V_R8(&rv) == 0.0)
3643 {
3645 V_VT(result) = VT_EMPTY;
3646 }
3647 else if (V_R8(&rv) == 0.0)
3648 {
3650 V_VT(result) = VT_EMPTY;
3651 }
3652 else
3653 V_R8(result) = V_R8(&lv) / V_R8(&rv);
3654 break;
3655 case VT_DECIMAL:
3656 hres = VarDecDiv(&(V_DECIMAL(&lv)), &(V_DECIMAL(&rv)), &(V_DECIMAL(result)));
3657 break;
3658 }
3659
3660end:
3661 VariantClear(&lv);
3662 VariantClear(&rv);
3663 VariantClear(&tempLeft);
3664 VariantClear(&tempRight);
3665 TRACE("returning 0x%8x %s\n", hres, debugstr_variant(result));
3666 return hres;
3667}
HRESULT WINAPI VarDecDiv(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:5601
#define DISP_E_DIVBYZERO
Definition: winerror.h:2527

Referenced by interp_div(), and test_VarDiv().

◆ VarEqv()

HRESULT WINAPI VarEqv ( LPVARIANT  pVarLeft,
LPVARIANT  pVarRight,
LPVARIANT  pVarOut 
)

Definition at line 4727 of file variant.c.

4728{
4729 HRESULT hRet;
4730
4731 TRACE("(%s,%s,%p)\n", debugstr_variant(pVarLeft), debugstr_variant(pVarRight), pVarOut);
4732
4733 hRet = VarXor(pVarLeft, pVarRight, pVarOut);
4734 if (SUCCEEDED(hRet))
4735 {
4736 if (V_VT(pVarOut) == VT_I8)
4737 V_I8(pVarOut) = ~V_I8(pVarOut);
4738 else
4739 V_UI4(pVarOut) = ~V_UI4(pVarOut);
4740 }
4741 return hRet;
4742}
HRESULT WINAPI VarXor(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
Definition: variant.c:4546

Referenced by interp_eqv(), and test_VarEqv().

◆ VarFix()

HRESULT WINAPI VarFix ( LPVARIANT  pVarIn,
LPVARIANT  pVarOut 
)

Definition at line 4367 of file variant.c.

4368{
4369 HRESULT hRet = S_OK;
4370 VARIANT temp;
4371
4372 VariantInit(&temp);
4373
4374 TRACE("(%s,%p)\n", debugstr_variant(pVarIn), pVarOut);
4375
4376 /* Handle VT_DISPATCH by storing and taking address of returned value */
4377 if ((V_VT(pVarIn) & VT_TYPEMASK) == VT_DISPATCH && ((V_VT(pVarIn) & ~VT_TYPEMASK) == 0))
4378 {
4379 hRet = VARIANT_FetchDispatchValue(pVarIn, &temp);
4380 if (FAILED(hRet)) goto VarFix_Exit;
4381 pVarIn = &temp;
4382 }
4383 V_VT(pVarOut) = V_VT(pVarIn);
4384
4385 switch (V_VT(pVarIn))
4386 {
4387 case VT_UI1:
4388 V_UI1(pVarOut) = V_UI1(pVarIn);
4389 break;
4390 case VT_BOOL:
4391 V_VT(pVarOut) = VT_I2;
4392 /* Fall through */
4393 case VT_I2:
4394 V_I2(pVarOut) = V_I2(pVarIn);
4395 break;
4396 case VT_I4:
4397 V_I4(pVarOut) = V_I4(pVarIn);
4398 break;
4399 case VT_I8:
4400 V_I8(pVarOut) = V_I8(pVarIn);
4401 break;
4402 case VT_R4:
4403 if (V_R4(pVarIn) < 0.0f)
4404 V_R4(pVarOut) = (float)ceil(V_R4(pVarIn));
4405 else
4406 V_R4(pVarOut) = (float)floor(V_R4(pVarIn));
4407 break;
4408 case VT_BSTR:
4409 V_VT(pVarOut) = VT_R8;
4410 hRet = VarR8FromStr(V_BSTR(pVarIn), LOCALE_USER_DEFAULT, 0, &V_R8(pVarOut));
4411 pVarIn = pVarOut;
4412 /* Fall through */
4413 case VT_DATE:
4414 case VT_R8:
4415 if (V_R8(pVarIn) < 0.0)
4416 V_R8(pVarOut) = ceil(V_R8(pVarIn));
4417 else
4418 V_R8(pVarOut) = floor(V_R8(pVarIn));
4419 break;
4420 case VT_CY:
4421 hRet = VarCyFix(V_CY(pVarIn), &V_CY(pVarOut));
4422 break;
4423 case VT_DECIMAL:
4424 hRet = VarDecFix(&V_DECIMAL(pVarIn), &V_DECIMAL(pVarOut));
4425 break;
4426 case VT_EMPTY:
4427 V_VT(pVarOut) = VT_I2;
4428 V_I2(pVarOut) = 0;
4429 break;
4430 case VT_NULL:
4431 /* No-Op */
4432 break;
4433 default:
4434 if (V_TYPE(pVarIn) == VT_CLSID || /* VT_CLSID is a special case */
4436 hRet = DISP_E_BADVARTYPE;
4437 else
4438 hRet = DISP_E_TYPEMISMATCH;
4439 }
4440VarFix_Exit:
4441 if (FAILED(hRet))
4442 V_VT(pVarOut) = VT_EMPTY;
4444
4445 return hRet;
4446}
@ VT_CLSID
Definition: compat.h:2337
HRESULT WINAPI VarCyFix(CY cyIn, CY *pCyOut)
Definition: vartype.c:3902
HRESULT WINAPI VarDecFix(const DECIMAL *pDecIn, DECIMAL *pDecOut)
Definition: vartype.c:5722
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
static float(__cdecl *square_half_float)(float x
static HRESULT VARIANT_ValidateType(VARTYPE vt)
Definition: variant.c:534
#define V_TYPE(v)
Definition: variant.h:30

Referenced by Global_Fix(), test_VarFix(), and VarInt().

◆ VARIANT_ClearInd()

HRESULT VARIANT_ClearInd ( VARIANTARG pVarg)

Definition at line 576 of file variant.c.

577{
579
580 TRACE("(%s)\n", debugstr_variant(pVarg));
581
583 if (FAILED(hres))
584 return hres;
585
586 switch (V_VT(pVarg))
587 {
588 case VT_DISPATCH:
589 case VT_UNKNOWN:
590 if (V_UNKNOWN(pVarg))
591 IUnknown_Release(V_UNKNOWN(pVarg));
592 break;
593 case VT_UNKNOWN | VT_BYREF:
594 case VT_DISPATCH | VT_BYREF:
595 if(*V_UNKNOWNREF(pVarg))
596 IUnknown_Release(*V_UNKNOWNREF(pVarg));
597 break;
598 case VT_BSTR:
599 SysFreeString(V_BSTR(pVarg));
600 break;
601 case VT_BSTR | VT_BYREF:
602 SysFreeString(*V_BSTRREF(pVarg));
603 break;
604 case VT_VARIANT | VT_BYREF:
606 break;
607 case VT_RECORD:
608 case VT_RECORD | VT_BYREF:
609 {
610 struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
611 if (pBr->pRecInfo)
612 {
613 IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord);
614 IRecordInfo_Release(pBr->pRecInfo);
615 }
616 break;
617 }
618 default:
619 if (V_ISARRAY(pVarg) || (V_VT(pVarg) & ~VT_BYREF) == VT_SAFEARRAY)
620 {
621 if (V_ISBYREF(pVarg))
622 {
623 if (*V_ARRAYREF(pVarg))
625 }
626 else if (V_ARRAY(pVarg))
627 hres = SafeArrayDestroy(V_ARRAY(pVarg));
628 }
629 break;
630 }
631
632 V_VT(pVarg) = VT_EMPTY;
633 return hres;
634}
#define __tagBRECORD
Definition: oaidl.idl:155
@ VT_BYREF
Definition: compat.h:2342
@ VT_SAFEARRAY
Definition: compat.h:2321
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_ARRAYREF(A)
Definition: oleauto.h:223
#define V_BSTRREF(A)
Definition: oleauto.h:227
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_UNKNOWNREF(A)
Definition: oleauto.h:282
#define V_ISBYREF(A)
Definition: oleauto.h:217
#define V_VARIANTREF(A)
Definition: oleauto.h:283
#define V_UNION(A, B)
Definition: oleauto.h:212

Referenced by ITypeInfo_fnInvoke().

◆ VARIANT_Coerce()

static HRESULT VARIANT_Coerce ( VARIANTARG pd,
LCID  lcid,
USHORT  wFlags,
VARIANTARG ps,
VARTYPE  vt 
)
inlinestatic

Definition at line 55 of file variant.c.

57{
59 VARTYPE vtFrom = V_TYPE(ps);
60 DWORD dwFlags = 0;
61
62 TRACE("(%s,0x%08x,0x%04x,%s,%s)\n", debugstr_variant(pd), lcid, wFlags,
63 debugstr_variant(ps), debugstr_vt(vt));
64
65 if (vt == VT_BSTR || vtFrom == VT_BSTR)
66 {
67 /* All flags passed to low level function are only used for
68 * changing to or from strings. Map these here.
69 */
82 }
83
84 /* Map int/uint to i4/ui4 */
85 if (vt == VT_INT)
86 vt = VT_I4;
87 else if (vt == VT_UINT)
88 vt = VT_UI4;
89
90 if (vtFrom == VT_INT)
91 vtFrom = VT_I4;
92 else if (vtFrom == VT_UINT)
93 vtFrom = VT_UI4;
94
95 if (vt == vtFrom)
96 return VariantCopy(pd, ps);
97
98 if (wFlags & VARIANT_NOVALUEPROP && vtFrom == VT_DISPATCH && vt != VT_UNKNOWN)
99 {
100 /* VARIANT_NOVALUEPROP prevents IDispatch objects from being coerced by
101 * accessing the default object property.
102 */
103 return DISP_E_TYPEMISMATCH;
104 }
105
106 switch (vt)
107 {
108 case VT_EMPTY:
109 if (vtFrom == VT_NULL)
110 return DISP_E_TYPEMISMATCH;
111 /* ... Fall through */
112 case VT_NULL:
113 if (vtFrom <= VT_UINT && vtFrom != (VARTYPE)15 && vtFrom != VT_ERROR)
114 {
115 res = VariantClear( pd );
116 if (vt == VT_NULL && SUCCEEDED(res))
117 V_VT(pd) = VT_NULL;
118 }
119 return res;
120
121 case VT_I1:
122 switch (vtFrom)
123 {
124 case VT_EMPTY: V_I1(pd) = 0; return S_OK;
125 case VT_I2: return VarI1FromI2(V_I2(ps), &V_I1(pd));
126 case VT_I4: return VarI1FromI4(V_I4(ps), &V_I1(pd));
127 case VT_UI1: V_I1(pd) = V_UI1(ps); return S_OK;
128 case VT_UI2: return VarI1FromUI2(V_UI2(ps), &V_I1(pd));
129 case VT_UI4: return VarI1FromUI4(V_UI4(ps), &V_I1(pd));
130 case VT_I8: return VarI1FromI8(V_I8(ps), &V_I1(pd));
131 case VT_UI8: return VarI1FromUI8(V_UI8(ps), &V_I1(pd));
132 case VT_R4: return VarI1FromR4(V_R4(ps), &V_I1(pd));
133 case VT_R8: return VarI1FromR8(V_R8(ps), &V_I1(pd));
134 case VT_DATE: return VarI1FromDate(V_DATE(ps), &V_I1(pd));
135 case VT_BOOL: return VarI1FromBool(V_BOOL(ps), &V_I1(pd));
136 case VT_CY: return VarI1FromCy(V_CY(ps), &V_I1(pd));
137 case VT_DECIMAL: return VarI1FromDec(&V_DECIMAL(ps), &V_I1(pd) );
138 case VT_DISPATCH: return VarI1FromDisp(V_DISPATCH(ps), lcid, &V_I1(pd) );
139 case VT_BSTR: return VarI1FromStr(V_BSTR(ps), lcid, dwFlags, &V_I1(pd) );
140 }
141 break;
142
143 case VT_I2:
144 switch (vtFrom)
145 {
146 case VT_EMPTY: V_I2(pd) = 0; return S_OK;
147 case VT_I1: return VarI2FromI1(V_I1(ps), &V_I2(pd));
148 case VT_I4: return VarI2FromI4(V_I4(ps), &V_I2(pd));
149 case VT_UI1: return VarI2FromUI1(V_UI1(ps), &V_I2(pd));
150 case VT_UI2: V_I2(pd) = V_UI2(ps); return S_OK;
151 case VT_UI4: return VarI2FromUI4(V_UI4(ps), &V_I2(pd));
152 case VT_I8: return VarI2FromI8(V_I8(ps), &V_I2(pd));
153 case VT_UI8: return VarI2FromUI8(V_UI8(ps), &V_I2(pd));
154 case VT_R4: return VarI2FromR4(V_R4(ps), &V_I2(pd));
155 case VT_R8: return VarI2FromR8(V_R8(ps), &V_I2(pd));
156 case VT_DATE: return VarI2FromDate(V_DATE(ps), &V_I2(pd));
157 case VT_BOOL: return VarI2FromBool(V_BOOL(ps), &V_I2(pd));
158 case VT_CY: return VarI2FromCy(V_CY(ps), &V_I2(pd));
159 case VT_DECIMAL: return VarI2FromDec(&V_DECIMAL(ps), &V_I2(pd));
160 case VT_DISPATCH: return VarI2FromDisp(V_DISPATCH(ps), lcid, &V_I2(pd));
161 case VT_BSTR: return VarI2FromStr(V_BSTR(ps), lcid, dwFlags, &V_I2(pd));
162 }
163 break;
164
165 case VT_I4:
166 switch (vtFrom)
167 {
168 case VT_EMPTY: V_I4(pd) = 0; return S_OK;
169 case VT_I1: return VarI4FromI1(V_I1(ps), &V_I4(pd));
170 case VT_I2: return VarI4FromI2(V_I2(ps), &V_I4(pd));
171 case VT_UI1: return VarI4FromUI1(V_UI1(ps), &V_I4(pd));
172 case VT_UI2: return VarI4FromUI2(V_UI2(ps), &V_I4(pd));
173 case VT_UI4: V_I4(pd) = V_UI4(ps); return S_OK;
174 case VT_I8: return VarI4FromI8(V_I8(ps), &V_I4(pd));
175 case VT_UI8: return VarI4FromUI8(V_UI8(ps), &V_I4(pd));
176 case VT_R4: return VarI4FromR4(V_R4(ps), &V_I4(pd));
177 case VT_R8: return VarI4FromR8(V_R8(ps), &V_I4(pd));
178 case VT_DATE: return VarI4FromDate(V_DATE(ps), &V_I4(pd));
179 case VT_BOOL: return VarI4FromBool(V_BOOL(ps), &V_I4(pd));
180 case VT_CY: return VarI4FromCy(V_CY(ps), &V_I4(pd));
181 case VT_DECIMAL: return VarI4FromDec(&V_DECIMAL(ps), &V_I4(pd));
182 case VT_DISPATCH: return VarI4FromDisp(V_DISPATCH(ps), lcid, &V_I4(pd));
183 case VT_BSTR: return VarI4FromStr(V_BSTR(ps), lcid, dwFlags, &V_I4(pd));
184 }
185 break;
186
187 case VT_UI1:
188 switch (vtFrom)
189 {
190 case VT_EMPTY: V_UI1(pd) = 0; return S_OK;
191 case VT_I1: V_UI1(pd) = V_I1(ps); return S_OK;
192 case VT_I2: return VarUI1FromI2(V_I2(ps), &V_UI1(pd));
193 case VT_I4: return VarUI1FromI4(V_I4(ps), &V_UI1(pd));
194 case VT_UI2: return VarUI1FromUI2(V_UI2(ps), &V_UI1(pd));
195 case VT_UI4: return VarUI1FromUI4(V_UI4(ps), &V_UI1(pd));
196 case VT_I8: return VarUI1FromI8(V_I8(ps), &V_UI1(pd));
197 case VT_UI8: return VarUI1FromUI8(V_UI8(ps), &V_UI1(pd));
198 case VT_R4: return VarUI1FromR4(V_R4(ps), &V_UI1(pd));
199 case VT_R8: return VarUI1FromR8(V_R8(ps), &V_UI1(pd));
200 case VT_DATE: return VarUI1FromDate(V_DATE(ps), &V_UI1(pd));
201 case VT_BOOL: return VarUI1FromBool(V_BOOL(ps), &V_UI1(pd));
202 case VT_CY: return VarUI1FromCy(V_CY(ps), &V_UI1(pd));
203 case VT_DECIMAL: return VarUI1FromDec(&V_DECIMAL(ps), &V_UI1(pd));
204 case VT_DISPATCH: return VarUI1FromDisp(V_DISPATCH(ps), lcid, &V_UI1(pd));
205 case VT_BSTR: return VarUI1FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI1(pd));
206 }
207 break;
208
209 case VT_UI2:
210 switch (vtFrom)
211 {
212 case VT_EMPTY: V_UI2(pd) = 0; return S_OK;
213 case VT_I1: return VarUI2FromI1(V_I1(ps), &V_UI2(pd));
214 case VT_I2: V_UI2(pd) = V_I2(ps); return S_OK;
215 case VT_I4: return VarUI2FromI4(V_I4(ps), &V_UI2(pd));
216 case VT_UI1: return VarUI2FromUI1(V_UI1(ps), &V_UI2(pd));
217 case VT_UI4: return VarUI2FromUI4(V_UI4(ps), &V_UI2(pd));
218 case VT_I8: return VarUI4FromI8(V_I8(ps), &V_UI4(pd));
219 case VT_UI8: return VarUI4FromUI8(V_UI8(ps), &V_UI4(pd));
220 case VT_R4: return VarUI2FromR4(V_R4(ps), &V_UI2(pd));
221 case VT_R8: return VarUI2FromR8(V_R8(ps), &V_UI2(pd));
222 case VT_DATE: return VarUI2FromDate(V_DATE(ps), &V_UI2(pd));
223 case VT_BOOL: return VarUI2FromBool(V_BOOL(ps), &V_UI2(pd));
224 case VT_CY: return VarUI2FromCy(V_CY(ps), &V_UI2(pd));
225 case VT_DECIMAL: return VarUI2FromDec(&V_DECIMAL(ps), &V_UI2(pd));
226 case VT_DISPATCH: return VarUI2FromDisp(V_DISPATCH(ps), lcid, &V_UI2(pd));
227 case VT_BSTR: return VarUI2FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI2(pd));
228 }
229 break;
230
231 case VT_UI4:
232 switch (vtFrom)
233 {
234 case VT_EMPTY: V_UI4(pd) = 0; return S_OK;
235 case VT_I1: return VarUI4FromI1(V_I1(ps), &V_UI4(pd));
236 case VT_I2: return VarUI4FromI2(V_I2(ps), &V_UI4(pd));
237 case VT_I4: V_UI4(pd) = V_I4(ps); return S_OK;
238 case VT_UI1: return VarUI4FromUI1(V_UI1(ps), &V_UI4(pd));
239 case VT_UI2: return VarUI4FromUI2(V_UI2(ps), &V_UI4(pd));
240 case VT_I8: return VarUI4FromI8(V_I8(ps), &V_UI4(pd));
241 case VT_UI8: return VarUI4FromUI8(V_UI8(ps), &V_UI4(pd));
242 case VT_R4: return VarUI4FromR4(V_R4(ps), &V_UI4(pd));
243 case VT_R8: return VarUI4FromR8(V_R8(ps), &V_UI4(pd));
244 case VT_DATE: return VarUI4FromDate(V_DATE(ps), &V_UI4(pd));
245 case VT_BOOL: return VarUI4FromBool(V_BOOL(ps), &V_UI4(pd));
246 case VT_CY: return VarUI4FromCy(V_CY(ps), &V_UI4(pd));
247 case VT_DECIMAL: return VarUI4FromDec(&V_DECIMAL(ps), &V_UI4(pd));
248 case VT_DISPATCH: return VarUI4FromDisp(V_DISPATCH(ps), lcid, &V_UI4(pd));
249 case VT_BSTR: return VarUI4FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI4(pd));
250 }
251 break;
252
253 case VT_UI8:
254 switch (vtFrom)
255 {
256 case VT_EMPTY: V_UI8(pd) = 0; return S_OK;
257 case VT_I4: if (V_I4(ps) < 0) return DISP_E_OVERFLOW; V_UI8(pd) = V_I4(ps); return S_OK;
258 case VT_I1: return VarUI8FromI1(V_I1(ps), &V_UI8(pd));
259 case VT_I2: return VarUI8FromI2(V_I2(ps), &V_UI8(pd));
260 case VT_UI1: return VarUI8FromUI1(V_UI1(ps), &V_UI8(pd));
261 case VT_UI2: return VarUI8FromUI2(V_UI2(ps), &V_UI8(pd));
262 case VT_UI4: return VarUI8FromUI4(V_UI4(ps), &V_UI8(pd));
263 case VT_I8: V_UI8(pd) = V_I8(ps); return S_OK;
264 case VT_R4: return VarUI8FromR4(V_R4(ps), &V_UI8(pd));
265 case VT_R8: return VarUI8FromR8(V_R8(ps), &V_UI8(pd));
266 case VT_DATE: return VarUI8FromDate(V_DATE(ps), &V_UI8(pd));
267 case VT_BOOL: return VarUI8FromBool(V_BOOL(ps), &V_UI8(pd));
268 case VT_CY: return VarUI8FromCy(V_CY(ps), &V_UI8(pd));
269 case VT_DECIMAL: return VarUI8FromDec(&V_DECIMAL(ps), &V_UI8(pd));
270 case VT_DISPATCH: return VarUI8FromDisp(V_DISPATCH(ps), lcid, &V_UI8(pd));
271 case VT_BSTR: return VarUI8FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI8(pd));
272 }
273 break;
274
275 case VT_I8:
276 switch (vtFrom)
277 {
278 case VT_EMPTY: V_I8(pd) = 0; return S_OK;
279 case VT_I4: V_I8(pd) = V_I4(ps); return S_OK;
280 case VT_I1: return VarI8FromI1(V_I1(ps), &V_I8(pd));
281 case VT_I2: return VarI8FromI2(V_I2(ps), &V_I8(pd));
282 case VT_UI1: return VarI8FromUI1(V_UI1(ps), &V_I8(pd));
283 case VT_UI2: return VarI8FromUI2(V_UI2(ps), &V_I8(pd));
284 case VT_UI4: return VarI8FromUI4(V_UI4(ps), &V_I8(pd));
285 case VT_UI8: V_I8(pd) = V_UI8(ps); return S_OK;
286 case VT_R4: return VarI8FromR4(V_R4(ps), &V_I8(pd));
287 case VT_R8: return VarI8FromR8(V_R8(ps), &V_I8(pd));
288 case VT_DATE: return VarI8FromDate(V_DATE(ps), &V_I8(pd));
289 case VT_BOOL: return VarI8FromBool(V_BOOL(ps), &V_I8(pd));
290 case VT_CY: return VarI8FromCy(V_CY(ps), &V_I8(pd));
291 case VT_DECIMAL: return VarI8FromDec(&V_DECIMAL(ps), &V_I8(pd));
292 case VT_DISPATCH: return VarI8FromDisp(V_DISPATCH(ps), lcid, &V_I8(pd));
293 case VT_BSTR: return VarI8FromStr(V_BSTR(ps), lcid, dwFlags, &V_I8(pd));
294 }
295 break;
296
297 case VT_R4:
298 switch (vtFrom)
299 {
300 case VT_EMPTY: V_R4(pd) = 0.0f; return S_OK;
301 case VT_I1: return VarR4FromI1(V_I1(ps), &V_R4(pd));
302 case VT_I2: return VarR4FromI2(V_I2(ps), &V_R4(pd));
303 case VT_I4: return VarR4FromI4(V_I4(ps), &V_R4(pd));
304 case VT_UI1: return VarR4FromUI1(V_UI1(ps), &V_R4(pd));
305 case VT_UI2: return VarR4FromUI2(V_UI2(ps), &V_R4(pd));
306 case VT_UI4: return VarR4FromUI4(V_UI4(ps), &V_R4(pd));
307 case VT_I8: return VarR4FromI8(V_I8(ps), &V_R4(pd));
308 case VT_UI8: return VarR4FromUI8(V_UI8(ps), &V_R4(pd));
309 case VT_R8: return VarR4FromR8(V_R8(ps), &V_R4(pd));
310 case VT_DATE: return VarR4FromDate(V_DATE(ps), &V_R4(pd));
311 case VT_BOOL: return VarR4FromBool(V_BOOL(ps), &V_R4(pd));
312 case VT_CY: return VarR4FromCy(V_CY(ps), &V_R4(pd));
313 case VT_DECIMAL: return VarR4FromDec(&V_DECIMAL(ps), &V_R4(pd));
314 case VT_DISPATCH: return VarR4FromDisp(V_DISPATCH(ps), lcid, &V_R4(pd));
315 case VT_BSTR: return VarR4FromStr(V_BSTR(ps), lcid, dwFlags, &V_R4(pd));
316 }
317 break;
318
319 case VT_R8:
320 switch (vtFrom)
321 {
322 case VT_EMPTY: V_R8(pd) = 0.0; return S_OK;
323 case VT_I1: return VarR8FromI1(V_I1(ps), &V_R8(pd));
324 case VT_I2: return VarR8FromI2(V_I2(ps), &V_R8(pd));
325 case VT_I4: return VarR8FromI4(V_I4(ps), &V_R8(pd));
326 case VT_UI1: return VarR8FromUI1(V_UI1(ps), &V_R8(pd));
327 case VT_UI2: return VarR8FromUI2(V_UI2(ps), &V_R8(pd));
328 case VT_UI4: return VarR8FromUI4(V_UI4(ps), &V_R8(pd));
329 case VT_I8: return VarR8FromI8(V_I8(ps), &V_R8(pd));
330 case VT_UI8: return VarR8FromUI8(V_UI8(ps), &V_R8(pd));
331 case VT_R4: return VarR8FromR4(V_R4(ps), &V_R8(pd));
332 case VT_DATE: return VarR8FromDate(V_DATE(ps), &V_R8(pd));
333 case VT_BOOL: return VarR8FromBool(V_BOOL(ps), &V_R8(pd));
334 case VT_CY: return VarR8FromCy(V_CY(ps), &V_R8(pd));
335 case VT_DECIMAL: return VarR8FromDec(&V_DECIMAL(ps), &V_R8(pd));
336 case VT_DISPATCH: return VarR8FromDisp(V_DISPATCH(ps), lcid, &V_R8(pd));
337 case VT_BSTR: return VarR8FromStr(V_BSTR(ps), lcid, dwFlags, &V_R8(pd));
338 }
339 break;
340
341 case VT_DATE:
342 switch (vtFrom)
343 {
344 case VT_EMPTY: V_DATE(pd) = 0.0; return S_OK;
345 case VT_I1: return VarDateFromI1(V_I1(ps), &V_DATE(pd));
346 case VT_I2: return VarDateFromI2(V_I2(ps), &V_DATE(pd));
347 case VT_I4: return VarDateFromI4(V_I4(ps), &V_DATE(pd));
348 case VT_UI1: return VarDateFromUI1(V_UI1(ps), &V_DATE(pd));
349 case VT_UI2: return VarDateFromUI2(V_UI2(ps), &V_DATE(pd));
350 case VT_UI4: return VarDateFromUI4(V_UI4(ps), &V_DATE(pd));
351 case VT_I8: return VarDateFromI8(V_I8(ps), &V_DATE(pd));
352 case VT_UI8: return VarDateFromUI8(V_UI8(ps), &V_DATE(pd));
353 case VT_R4: return VarDateFromR4(V_R4(ps), &V_DATE(pd));
354 case VT_R8: return VarDateFromR8(V_R8(ps), &V_DATE(pd));
355 case VT_BOOL: return VarDateFromBool(V_BOOL(ps), &V_DATE(pd));
356 case VT_CY: return VarDateFromCy(V_CY(ps), &V_DATE(pd));
357 case VT_DECIMAL: return VarDateFromDec(&V_DECIMAL(ps), &V_DATE(pd));
358 case VT_DISPATCH: return VarDateFromDisp(V_DISPATCH(ps), lcid, &V_DATE(pd));
359 case VT_BSTR: return VarDateFromStr(V_BSTR(ps), lcid, dwFlags, &V_DATE(pd));
360 }
361 break;
362
363 case VT_BOOL:
364 switch (vtFrom)
365 {
366 case VT_EMPTY: V_BOOL(pd) = 0; return S_OK;
367 case VT_I1: return VarBoolFromI1(V_I1(ps), &V_BOOL(pd));
368 case VT_I2: return VarBoolFromI2(V_I2(ps), &V_BOOL(pd));
369 case VT_I4: return VarBoolFromI4(V_I4(ps), &V_BOOL(pd));
370 case VT_UI1: return VarBoolFromUI1(V_UI1(ps), &V_BOOL(pd));
371 case VT_UI2: return VarBoolFromUI2(V_UI2(ps), &V_BOOL(pd));
372 case VT_UI4: return VarBoolFromUI4(V_UI4(ps), &V_BOOL(pd));
373 case VT_I8: return VarBoolFromI8(V_I8(ps), &V_BOOL(pd));
374 case VT_UI8: return VarBoolFromUI8(V_UI8(ps), &V_BOOL(pd));
375 case VT_R4: return VarBoolFromR4(V_R4(ps), &V_BOOL(pd));
376 case VT_R8: return VarBoolFromR8(V_R8(ps), &V_BOOL(pd));
377 case VT_DATE: return VarBoolFromDate(V_DATE(ps), &V_BOOL(pd));
378 case VT_CY: return VarBoolFromCy(V_CY(ps), &V_BOOL(pd));
379 case VT_DECIMAL: return VarBoolFromDec(&V_DECIMAL(ps), &V_BOOL(pd));
380 case VT_DISPATCH: return VarBoolFromDisp(V_DISPATCH(ps), lcid, &V_BOOL(pd));
381 case VT_BSTR: return VarBoolFromStr(V_BSTR(ps), lcid, dwFlags, &V_BOOL(pd));
382 }
383 break;
384
385 case VT_BSTR:
386 switch (vtFrom)
387 {
388 case VT_EMPTY:
389 V_BSTR(pd) = SysAllocStringLen(NULL, 0);
390 return V_BSTR(pd) ? S_OK : E_OUTOFMEMORY;
391 case VT_BOOL:
393 return VarBstrFromBool(V_BOOL(ps), lcid, dwFlags, &V_BSTR(pd));
394 return VarBstrFromI2(V_BOOL(ps), lcid, dwFlags, &V_BSTR(pd));
395 case VT_I1: return VarBstrFromI1(V_I1(ps), lcid, dwFlags, &V_BSTR(pd));
396 case VT_I2: return VarBstrFromI2(V_I2(ps), lcid, dwFlags, &V_BSTR(pd));
397 case VT_I4: return VarBstrFromI4(V_I4(ps), lcid, dwFlags, &V_BSTR(pd));
398 case VT_UI1: return VarBstrFromUI1(V_UI1(ps), lcid, dwFlags, &V_BSTR(pd));
399 case VT_UI2: return VarBstrFromUI2(V_UI2(ps), lcid, dwFlags, &V_BSTR(pd));
400 case VT_UI4: return VarBstrFromUI4(V_UI4(ps), lcid, dwFlags, &V_BSTR(pd));
401 case VT_I8: return VarBstrFromI8(V_I8(ps), lcid, dwFlags, &V_BSTR(pd));
402 case VT_UI8: return VarBstrFromUI8(V_UI8(ps), lcid, dwFlags, &V_BSTR(pd));
403 case VT_R4: return VarBstrFromR4(V_R4(ps), lcid, dwFlags, &V_BSTR(pd));
404 case VT_R8: return VarBstrFromR8(V_R8(ps), lcid, dwFlags, &V_BSTR(pd));
405 case VT_DATE: return VarBstrFromDate(V_DATE(ps), lcid, dwFlags, &V_BSTR(pd));
406 case VT_CY: return VarBstrFromCy(V_CY(ps), lcid, dwFlags, &V_BSTR(pd));
407 case VT_DECIMAL: return VarBstrFromDec(&V_DECIMAL(ps), lcid, dwFlags, &V_BSTR(pd));
408 case VT_DISPATCH: return VarBstrFromDisp(V_DISPATCH(ps), lcid, dwFlags, &V_BSTR(pd));
409 }
410 break;
411
412 case VT_CY:
413 switch (vtFrom)
414 {
415 case VT_EMPTY: V_CY(pd).int64 = 0; return S_OK;
416 case VT_I1: return VarCyFromI1(V_I1(ps), &V_CY(pd));
417 case VT_I2: return VarCyFromI2(V_I2(ps), &V_CY(pd));
418 case VT_I4: return VarCyFromI4(V_I4(ps), &V_CY(pd));
419 case VT_UI1: return VarCyFromUI1(V_UI1(ps), &V_CY(pd));
420 case VT_UI2: return VarCyFromUI2(V_UI2(ps), &V_CY(pd));
421 case VT_UI4: return VarCyFromUI4(V_UI4(ps), &V_CY(pd));
422 case VT_I8: return VarCyFromI8(V_I8(ps), &V_CY(pd));
423 case VT_UI8: return VarCyFromUI8(V_UI8(ps), &V_CY(pd));
424 case VT_R4: return VarCyFromR4(V_R4(ps), &V_CY(pd));
425 case VT_R8: return VarCyFromR8(V_R8(ps), &V_CY(pd));
426 case VT_DATE: return VarCyFromDate(V_DATE(ps), &V_CY(pd));
427 case VT_BOOL: return VarCyFromBool(V_BOOL(ps), &V_CY(pd));
428 case VT_DECIMAL: return VarCyFromDec(&V_DECIMAL(ps), &V_CY(pd));
429 case VT_DISPATCH: return VarCyFromDisp(V_DISPATCH(ps), lcid, &V_CY(pd));
430 case VT_BSTR: return VarCyFromStr(V_BSTR(ps), lcid, dwFlags, &V_CY(pd));
431 }
432 break;
433
434 case VT_DECIMAL:
435 switch (vtFrom)
436 {
437 case VT_EMPTY:
438 case VT_BOOL:
440 DEC_HI32(&V_DECIMAL(pd)) = 0;
441 DEC_MID32(&V_DECIMAL(pd)) = 0;
442 /* VarDecFromBool() coerces to -1/0, ChangeTypeEx() coerces to 1/0.
443 * VT_NULL and VT_EMPTY always give a 0 value.
444 */
445 DEC_LO32(&V_DECIMAL(pd)) = vtFrom == VT_BOOL && V_BOOL(ps) ? 1 : 0;
446 return S_OK;
447 case VT_I1: return VarDecFromI1(V_I1(ps), &V_DECIMAL(pd));
448 case VT_I2: return VarDecFromI2(V_I2(ps), &V_DECIMAL(pd));
449 case VT_I4: return VarDecFromI4(V_I4(ps), &V_DECIMAL(pd));
450 case VT_UI1: return VarDecFromUI1(V_UI1(ps), &V_DECIMAL(pd));
451 case VT_UI2: return VarDecFromUI2(V_UI2(ps), &V_DECIMAL(pd));
452 case VT_UI4: return VarDecFromUI4(V_UI4(ps), &V_DECIMAL(pd));
453 case VT_I8: return VarDecFromI8(V_I8(ps), &V_DECIMAL(pd));
454 case VT_UI8: return VarDecFromUI8(V_UI8(ps), &V_DECIMAL(pd));
455 case VT_R4: return VarDecFromR4(V_R4(ps), &V_DECIMAL(pd));
456 case VT_R8: return VarDecFromR8(V_R8(ps), &V_DECIMAL(pd));
457 case VT_DATE: return VarDecFromDate(V_DATE(ps), &V_DECIMAL(pd));
458 case VT_CY: return VarDecFromCy(V_CY(ps), &V_DECIMAL(pd));
459 case VT_DISPATCH: return VarDecFromDisp(V_DISPATCH(ps), lcid, &V_DECIMAL(pd));
460 case VT_BSTR: return VarDecFromStr(V_BSTR(ps), lcid, dwFlags, &V_DECIMAL(pd));
461 }
462 break;
463
464 case VT_UNKNOWN:
465 switch (vtFrom)
466 {
467 case VT_DISPATCH:
468 if (V_DISPATCH(ps) == NULL)
469 {
470 V_UNKNOWN(pd) = NULL;
471 res = S_OK;
472 }
473 else
474 res = IDispatch_QueryInterface(V_DISPATCH(ps), &IID_IUnknown, (LPVOID*)&V_UNKNOWN(pd));
475 break;
476 }
477 break;
478
479 case VT_DISPATCH:
480 switch (vtFrom)
481 {
482 case VT_UNKNOWN:
483 if (V_UNKNOWN(ps) == NULL)
484 {
485 V_DISPATCH(pd) = NULL;
486 res = S_OK;
487 }
488 else
489 res = IUnknown_QueryInterface(V_UNKNOWN(ps), &IID_IDispatch, (LPVOID*)&V_DISPATCH(pd));
490 break;
491 }
492 break;
493
494 case VT_RECORD:
495 break;
496 }
497 return res;
498}
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI VarUI1FromI4(LONG iIn, BYTE *pbOut)
Definition: vartype.c:609
HRESULT WINAPI VarUI8FromUI2(USHORT usIn, ULONG64 *pui64Out)
Definition: vartype.c:2628
HRESULT WINAPI VarI4FromUI8(ULONG64 ullIn, LONG *piOut)
Definition: vartype.c:1763
HRESULT WINAPI VarBstrFromUI1(BYTE bIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6396
HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT *pusOut)
Definition: vartype.c:1311
HRESULT WINAPI VarUI8FromCy(CY cyIn, ULONG64 *pui64Out)
Definition: vartype.c:2498
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3503
HRESULT WINAPI VarI2FromUI1(BYTE bIn, SHORT *psOut)
Definition: vartype.c:900
HRESULT WINAPI VarR4FromI1(signed char cIn, float *pFltOut)
Definition: vartype.c:2888
HRESULT WINAPI VarCyFromDec(DECIMAL *pdecIn, CY *pCyOut)
Definition: vartype.c:3704
HRESULT WINAPI VarBstrFromBool(VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6852
HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY *pCyOut)
Definition: vartype.c:3420
HRESULT WINAPI VarI2FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, SHORT *psOut)
Definition: vartype.c:1021
HRESULT WINAPI VarI1FromDec(DECIMAL *pdecIn, signed char *pcOut)
Definition: vartype.c:523
HRESULT WINAPI VarR4FromUI8(ULONG64 ullIn, float *pFltOut)
Definition: vartype.c:3003
HRESULT WINAPI VarI2FromBool(VARIANT_BOOL boolIn, SHORT *psOut)
Definition: vartype.c:1059
HRESULT WINAPI VarUI2FromDisp(IDispatch *pdispIn, LCID lcid, USHORT *pusOut)
Definition: vartype.c:1356
HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5940
HRESULT WINAPI VarUI1FromUI4(ULONG ulIn, BYTE *pbOut)
Definition: vartype.c:815
HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pCyOut)
Definition: vartype.c:3575
HRESULT WINAPI VarI1FromR8(double dblIn, signed char *pcOut)
Definition: vartype.c:361
HRESULT WINAPI VarI1FromR4(FLOAT fltIn, signed char *pcOut)
Definition: vartype.c:339
HRESULT WINAPI VarUI4FromDisp(IDispatch *pdispIn, LCID lcid, ULONG *pulOut)
Definition: vartype.c:1941
HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY *pCyOut)
Definition: vartype.c:3662
HRESULT WINAPI VarI1FromDisp(IDispatch *pdispIn, LCID lcid, signed char *pcOut)
Definition: vartype.c:448
HRESULT WINAPI VarDecFromCy(CY cyIn, DECIMAL *pDecOut)
Definition: vartype.c:4239
HRESULT WINAPI VarR8FromI2(SHORT sIn, double *pDblOut)
Definition: vartype.c:3062
HRESULT WINAPI VarUI4FromUI2(USHORT usIn, ULONG *pulOut)
Definition: vartype.c:1993
HRESULT WINAPI VarI1FromUI2(USHORT usIn, signed char *pcOut)
Definition: vartype.c:484
HRESULT WINAPI VarR8FromCy(CY cyIn, double *pDblOut)
Definition: vartype.c:3113
HRESULT WINAPI VarI1FromUI4(ULONG ulIn, signed char *pcOut)
Definition: vartype.c:504
HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6587
HRESULT WINAPI VarUI4FromI1(signed char cIn, ULONG *pulOut)
Definition: vartype.c:1976
HRESULT WINAPI VarI2FromUI8(ULONG64 ullIn, SHORT *psOut)
Definition: vartype.c:1174
HRESULT WINAPI VarI8FromUI1(BYTE bIn, LONG64 *pi64Out)
Definition: vartype.c:2075
HRESULT WINAPI VarBoolFromDec(DECIMAL *pDecIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6278
HRESULT WINAPI VarBstrFromI2(short sIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6417
HRESULT WINAPI VarI4FromBool(VARIANT_BOOL boolIn, LONG *piOut)
Definition: vartype.c:1649
HRESULT WINAPI VarUI8FromUI4(ULONG ulIn, ULONG64 *pui64Out)
Definition: vartype.c:2645
HRESULT WINAPI VarI8FromDisp(IDispatch *pdispIn, LCID lcid, LONG64 *pi64Out)
Definition: vartype.c:2248
HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE *pbOut)
Definition: vartype.c:651
HRESULT WINAPI VarI1FromI2(SHORT sIn, signed char *pcOut)
Definition: vartype.c:301
HRESULT WINAPI VarDateFromDisp(IDispatch *pdispIn, LCID lcid, DATE *pdateOut)
Definition: vartype.c:7315
HRESULT WINAPI VarBstrFromI4(LONG lIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6445
HRESULT WINAPI VarUI2FromDec(DECIMAL *pdecIn, USHORT *pusOut)
Definition: vartype.c:1428
HRESULT WINAPI VarDecFromI2(SHORT sIn, DECIMAL *pDecOut)
Definition: vartype.c:4114
HRESULT WINAPI VarI8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG64 *pi64Out)
Definition: vartype.c:2227
HRESULT WINAPI VarI8FromR8(double dblIn, LONG64 *pi64Out)
Definition: vartype.c:2148
HRESULT WINAPI VarR8FromI8(LONG64 llIn, double *pDblOut)
Definition: vartype.c:3306
HRESULT WINAPI VarR4FromDisp(IDispatch *pdispIn, LCID lcid, float *pFltOut)
Definition: vartype.c:2851
HRESULT WINAPI VarDateFromI1(signed char cIn, DATE *pdateOut)
Definition: vartype.c:7954
HRESULT WINAPI VarUI2FromI1(signed char cIn, USHORT *pusOut)
Definition: vartype.c:1391
HRESULT WINAPI VarDecFromUI1(BYTE bIn, DECIMAL *pDecOut)
Definition: vartype.c:4097
HRESULT WINAPI VarUI2FromI4(LONG iIn, USHORT *pusOut)
Definition: vartype.c:1230
HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE *pbOut)
Definition: vartype.c:629
HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL *pDecOut)
Definition: vartype.c:4200
HRESULT WINAPI VarI4FromI2(SHORT sIn, LONG *piOut)
Definition: vartype.c:1510
HRESULT WINAPI VarDateFromUI8(ULONG64 ullIn, DATE *pdateOut)
Definition: vartype.c:8043
HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE *pdateOut)
Definition: vartype.c:7275
HRESULT WINAPI VarBoolFromI8(LONG64 llIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6302
HRESULT WINAPI VarI1FromI4(LONG iIn, signed char *pcOut)
Definition: vartype.c:320
HRESULT WINAPI VarI4FromUI2(USHORT usIn, LONG *piOut)
Definition: vartype.c:1683
HRESULT WINAPI VarI8FromDate(DATE dateIn, LONG64 *pi64Out)
Definition: vartype.c:2205
HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG *piOut)
Definition: vartype.c:1589
HRESULT WINAPI VarI8FromCy(CY cyIn, LONG64 *pi64Out)
Definition: vartype.c:2174
HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6608
HRESULT WINAPI VarUI8FromBool(VARIANT_BOOL boolIn, ULONG64 *pui64Out)
Definition: vartype.c:2594
HRESULT WINAPI VarI8FromI2(SHORT sIn, LONG64 *pi64Out)
Definition: vartype.c:2093
HRESULT WINAPI VarR8FromUI2(USHORT usIn, double *pDblOut)
Definition: vartype.c:3229
HRESULT WINAPI VarUI8FromR4(FLOAT fltIn, ULONG64 *pui64Out)
Definition: vartype.c:2451
HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE *pbOut)
Definition: vartype.c:676
HRESULT WINAPI VarBoolFromI2(SHORT sIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5958
HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE *pdateOut)
Definition: vartype.c:7224
HRESULT WINAPI VarR8FromDate(DATE dateIn, double *pDblOut)
Definition: vartype.c:3130
HRESULT WINAPI VarDecFromDisp(IDispatch *pdispIn, LCID lcid, DECIMAL *pDecOut)
Definition: vartype.c:4292
HRESULT WINAPI VarR4FromUI4(ULONG ulIn, float *pFltOut)
Definition: vartype.c:2928
HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY *pCyOut)
Definition: vartype.c:3620
HRESULT WINAPI VarI4FromDisp(IDispatch *pdispIn, LCID lcid, LONG *piOut)
Definition: vartype.c:1632
HRESULT WINAPI VarI2FromI1(signed char cIn, SHORT *psOut)
Definition: vartype.c:1076
HRESULT WINAPI VarUI1FromDec(DECIMAL *pdecIn, BYTE *pbOut)
Definition: vartype.c:834
HRESULT WINAPI VarCyFromDate(DATE dateIn, CY *pCyOut)
Definition: vartype.c:3553
HRESULT WINAPI VarI4FromR8(double dblIn, LONG *piOut)
Definition: vartype.c:1549
HRESULT WINAPI VarI8FromR4(FLOAT fltIn, LONG64 *pi64Out)
Definition: vartype.c:2112
HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5976
HRESULT WINAPI VarR4FromUI1(BYTE bIn, float *pFltOut)
Definition: vartype.c:2718
HRESULT WINAPI VarDateFromDec(DECIMAL *pdecIn, DATE *pdateOut)
Definition: vartype.c:8005
HRESULT WINAPI VarI4FromI1(signed char cIn, LONG *piOut)
Definition: vartype.c:1666
HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6048
HRESULT WINAPI VarI2FromDate(DATE dateIn, SHORT *psOut)
Definition: vartype.c:999
HRESULT WINAPI VarUI1FromUI8(ULONG64 ullIn, BYTE *pbOut)
Definition: vartype.c:879
HRESULT WINAPI VarDecFromR4(FLOAT fltIn, DECIMAL *pDecOut)
Definition: vartype.c:4178
HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG *pulOut)
Definition: vartype.c:1858
HRESULT WINAPI VarBstrFromDate(DATE dateIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6778
HRESULT WINAPI VarI2FromI8(LONG64 llIn, SHORT *psOut)
Definition: vartype.c:1156
HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5994
HRESULT WINAPI VarR8FromUI8(ULONG64 ullIn, double *pDblOut)
Definition: vartype.c:3323
HRESULT WINAPI VarUI4FromI2(SHORT sIn, ULONG *pulOut)
Definition: vartype.c:1801
HRESULT WINAPI VarR4FromCy(CY cyIn, float *pFltOut)
Definition: vartype.c:2790
HRESULT WINAPI VarR4FromDec(DECIMAL *pDecIn, float *pFltOut)
Definition: vartype.c:2946
HRESULT WINAPI VarUI1FromI2(SHORT sIn, BYTE *pbOut)
Definition: vartype.c:590
HRESULT WINAPI VarUI4FromDec(DECIMAL *pdecIn, ULONG *pulOut)
Definition: vartype.c:2012
HRESULT WINAPI VarUI2FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, USHORT *pusOut)
Definition: vartype.c:1335
HRESULT WINAPI VarI4FromI8(LONG64 llIn, LONG *piOut)
Definition: vartype.c:1745
HRESULT WINAPI VarUI8FromR8(double dblIn, ULONG64 *pui64Out)
Definition: vartype.c:2473
HRESULT WINAPI VarUI8FromDate(DATE dateIn, ULONG64 *pui64Out)
Definition: vartype.c:2533
HRESULT WINAPI VarI8FromI1(signed char cIn, LONG64 *pi64Out)
Definition: vartype.c:2282
HRESULT WINAPI VarR4FromI2(SHORT sIn, float *pFltOut)
Definition: vartype.c:2735
HRESULT WINAPI VarI1FromUI8(ULONG64 ullIn, signed char *pcOut)
Definition: vartype.c:568
HRESULT WINAPI VarUI4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG *pulOut)
Definition: vartype.c:1920
HRESULT WINAPI VarUI8FromDisp(IDispatch *pdispIn, LCID lcid, ULONG64 *pui64Out)
Definition: vartype.c:2576
HRESULT WINAPI VarUI4FromI8(LONG64 llIn, ULONG *pulOut)
Definition: vartype.c:2037
HRESULT WINAPI VarR8FromUI4(ULONG ulIn, double *pDblOut)
Definition: vartype.c:3249
HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT *pusOut)
Definition: vartype.c:1290
HRESULT WINAPI VarDecFromUI8(ULONG64 ullIn, DECIMAL *pDecOut)
Definition: vartype.c:4429
HRESULT WINAPI VarI2FromDisp(IDispatch *pdispIn, LCID lcid, SHORT *psOut)
Definition: vartype.c:1042
HRESULT WINAPI VarDateFromCy(CY cyIn, DATE *pdateOut)
Definition: vartype.c:7349
HRESULT WINAPI VarUI2FromUI1(BYTE bIn, USHORT *pusOut)
Definition: vartype.c:1194
HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6030
HRESULT WINAPI VarI8FromDec(DECIMAL *pdecIn, LONG64 *pi64Out)
Definition: vartype.c:2335
HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE *pdateOut)
Definition: vartype.c:7988
HRESULT WINAPI VarR8FromI4(LONG lIn, double *pDblOut)
Definition: vartype.c:3079
HRESULT WINAPI VarDecFromUI2(USHORT usIn, DECIMAL *pDecOut)
Definition: vartype.c:4358
HRESULT WINAPI VarCyFromI8(LONG64 llIn, CY *pCyOut)
Definition: vartype.c:3742
HRESULT WINAPI VarUI8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG64 *pui64Out)
Definition: vartype.c:2555
HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE *pdateOut)
Definition: vartype.c:7332
HRESULT WINAPI VarI2FromR8(double dblIn, SHORT *psOut)
Definition: vartype.c:957
HRESULT WINAPI VarI1FromBool(VARIANT_BOOL boolIn, signed char *pcOut)
Definition: vartype.c:465
HRESULT WINAPI VarR4FromUI2(USHORT usIn, float *pFltOut)
Definition: vartype.c:2908
HRESULT WINAPI VarUI4FromUI8(ULONG64 ullIn, ULONG *pulOut)
Definition: vartype.c:2055
HRESULT WINAPI VarBstrFromI8(LONG64 llIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7038
HRESULT WINAPI VarUI2FromBool(VARIANT_BOOL boolIn, USHORT *pusOut)
Definition: vartype.c:1373
HRESULT WINAPI VarUI1FromUI2(USHORT usIn, BYTE *pbOut)
Definition: vartype.c:796
HRESULT WINAPI VarUI1FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, BYTE *pbOut)
Definition: vartype.c:720
HRESULT WINAPI VarDecFromUI4(ULONG ulIn, DECIMAL *pDecOut)
Definition: vartype.c:4375
HRESULT WINAPI VarUI1FromI8(LONG64 llIn, BYTE *pbOut)
Definition: vartype.c:860
HRESULT WINAPI VarI2FromR4(FLOAT fltIn, SHORT *psOut)
Definition: vartype.c:936
HRESULT WINAPI VarDecFromI4(LONG lIn, DECIMAL *pDecOut)
Definition: vartype.c:4131
HRESULT WINAPI VarBstrFromUI8(ULONG64 ullIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7066
HRESULT WINAPI VarBstrFromDec(DECIMAL *pDecIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6991
HRESULT WINAPI VarI4FromCy(CY cyIn, LONG *piOut)
Definition: vartype.c:1570
HRESULT WINAPI VarBoolFromUI8(ULONG64 ullIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6320
HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG *pulOut)
Definition: vartype.c:1837
HRESULT WINAPI VarR8FromDisp(IDispatch *pdispIn, LCID lcid, double *pDblOut)
Definition: vartype.c:3172
HRESULT WINAPI VarUI2FromUI4(ULONG ulIn, USHORT *pusOut)
Definition: vartype.c:1409
HRESULT WINAPI VarUI1FromDisp(IDispatch *pdispIn, LCID lcid, BYTE *pbOut)
Definition: vartype.c:741
HRESULT WINAPI VarUI8FromDec(DECIMAL *pdecIn, ULONG64 *pui64Out)
Definition: vartype.c:2670
HRESULT WINAPI VarUI1FromBool(VARIANT_BOOL boolIn, BYTE *pbOut)
Definition: vartype.c:758
HRESULT WINAPI VarBoolFromDisp(IDispatch *pdispIn, LCID lcid, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6206
HRESULT WINAPI VarCyFromR4(FLOAT fltIn, CY *pCyOut)
Definition: vartype.c:3483
HRESULT WINAPI VarR4FromDate(DATE dateIn, float *pFltOut)
Definition: vartype.c:2809
HRESULT WINAPI VarI4FromUI1(BYTE bIn, LONG *piOut)
Definition: vartype.c:1491
HRESULT WINAPI VarR4FromI4(LONG lIn, float *pFltOut)
Definition: vartype.c:2752
HRESULT WINAPI VarCyFromI4(LONG lIn, CY *pCyOut)
Definition: vartype.c:3462
HRESULT WINAPI VarBoolFromUI2(USHORT usIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6241
HRESULT WINAPI VarCyFromDisp(IDispatch *pdispIn, LCID lcid, CY *pCyOut)
Definition: vartype.c:3596
HRESULT WINAPI VarI2FromUI4(ULONG ulIn, SHORT *psOut)
Definition: vartype.c:1112
HRESULT WINAPI VarUI4FromBool(VARIANT_BOOL boolIn, ULONG *pulOut)
Definition: vartype.c:1958
HRESULT WINAPI VarDecFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, DECIMAL *pDecOut)
Definition: vartype.c:4273
HRESULT WINAPI VarCyFromUI8(ULONG64 ullIn, CY *pCyOut)
Definition: vartype.c:3764
HRESULT WINAPI VarI8FromUI4(ULONG ulIn, LONG64 *pi64Out)
Definition: vartype.c:2316
HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG *pulOut)
Definition: vartype.c:1897
HRESULT WINAPI VarUI8FromUI1(BYTE bIn, ULONG64 *pui64Out)
Definition: vartype.c:2416
HRESULT WINAPI VarR8FromI1(signed char cIn, double *pDblOut)
Definition: vartype.c:3209
HRESULT WINAPI VarR4FromBool(VARIANT_BOOL boolIn, float *pFltOut)
Definition: vartype.c:2868
HRESULT WINAPI VarR8FromDec(const DECIMAL *pDecIn, double *pDblOut)
Definition: vartype.c:3267
HRESULT WINAPI VarUI8FromI2(SHORT sIn, ULONG64 *pui64Out)
Definition: vartype.c:2433
HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6566
HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6012
HRESULT WINAPI VarI4FromDec(DECIMAL *pdecIn, LONG *piOut)
Definition: vartype.c:1720
HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE *pbOut)
Definition: vartype.c:698
HRESULT WINAPI VarBoolFromUI4(ULONG ulIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6259
HRESULT WINAPI VarR8FromUI1(BYTE bIn, double *pDblOut)
Definition: vartype.c:3045
HRESULT WINAPI VarDecFromDate(DATE dateIn, DECIMAL *pDecOut)
Definition: vartype.c:4222
HRESULT WINAPI VarBstrFromDisp(IDispatch *pdispIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7087
HRESULT WINAPI VarR4FromI8(LONG64 llIn, float *pFltOut)
Definition: vartype.c:2986
HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double *pDblOut)
Definition: vartype.c:3189
HRESULT WINAPI VarI1FromI8(LONG64 llIn, signed char *pcOut)
Definition: vartype.c:549
HRESULT WINAPI VarCyFromUI4(ULONG ulIn, CY *pCyOut)
Definition: vartype.c:3683
HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE *pdateOut)
Definition: vartype.c:7971
HRESULT WINAPI VarDateFromR8(double dblIn, DATE *pdateOut)
Definition: vartype.c:7292
HRESULT WINAPI VarI1FromDate(DATE dateIn, signed char *pcOut)
Definition: vartype.c:383
HRESULT WINAPI VarI1FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, signed char *pcOut)
Definition: vartype.c:427
HRESULT WINAPI VarDateFromI2(short sIn, DATE *pdateOut)
Definition: vartype.c:7241
HRESULT WINAPI VarI2FromCy(CY cyIn, SHORT *psOut)
Definition: vartype.c:978
HRESULT WINAPI VarI1FromCy(CY cyIn, signed char *pcOut)
Definition: vartype.c:402
HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG *pulOut)
Definition: vartype.c:1879
HRESULT WINAPI VarDateFromI4(LONG lIn, DATE *pdateOut)
Definition: vartype.c:7258
HRESULT WINAPI VarUI4FromUI1(BYTE bIn, ULONG *pulOut)
Definition: vartype.c:1783
HRESULT WINAPI VarBstrFromUI2(USHORT usIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6949
HRESULT WINAPI VarI8FromBool(VARIANT_BOOL boolIn, LONG64 *pi64Out)
Definition: vartype.c:2265
HRESULT WINAPI VarDecFromI1(signed char cIn, DECIMAL *pDecOut)
Definition: vartype.c:4341
HRESULT WINAPI VarI8FromUI2(USHORT usIn, LONG64 *pi64Out)
Definition: vartype.c:2299
HRESULT WINAPI VarDateFromI8(LONG64 llIn, DATE *pdateOut)
Definition: vartype.c:8023
HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT *pusOut)
Definition: vartype.c:1248
HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT *pusOut)
Definition: vartype.c:1269
HRESULT WINAPI VarI4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG *piOut)
Definition: vartype.c:1611
HRESULT WINAPI VarI2FromI4(LONG iIn, SHORT *psOut)
Definition: vartype.c:918
HRESULT WINAPI VarBoolFromI1(signed char cIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6223
HRESULT WINAPI VarUI8FromI1(signed char cIn, ULONG64 *pui64Out)
Definition: vartype.c:2611
HRESULT WINAPI VarBstrFromUI4(ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6970
HRESULT WINAPI VarR4FromR8(double dblIn, float *pFltOut)
Definition: vartype.c:2770
HRESULT WINAPI VarCyFromI2(SHORT sIn, CY *pCyOut)
Definition: vartype.c:3441
HRESULT WINAPI VarDecFromI8(LONG64 llIn, DECIMAL *pDecOut)
Definition: vartype.c:4396
HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double *pDblOut)
Definition: vartype.c:3096
HRESULT WINAPI VarR4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, float *pFltOut)
Definition: vartype.c:2830
HRESULT WINAPI VarDateFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, DATE *pdateOut)
Definition: vartype.c:7595
HRESULT WINAPI VarCyFromI1(signed char cIn, CY *pCyOut)
Definition: vartype.c:3641
HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG *piOut)
Definition: vartype.c:1528
HRESULT WINAPI VarI2FromDec(DECIMAL *pdecIn, SHORT *psOut)
Definition: vartype.c:1131
HRESULT WINAPI VarBstrFromI1(signed char cIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6921
GLuint res
Definition: glext.h:9613
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define VARIANT_CALENDAR_THAI
Definition: oleauto.h:315
#define VAR_CALENDAR_GREGORIAN
Definition: oleauto.h:334
#define VARIANT_USE_NLS
Definition: oleauto.h:317
#define VARIANT_CALENDAR_HIJRI
Definition: oleauto.h:313
#define VAR_CALENDAR_THAI
Definition: oleauto.h:333
#define VARIANT_NOVALUEPROP
Definition: oleauto.h:310
#define VARIANT_NOUSEROVERRIDE
Definition: oleauto.h:312
#define LOCALE_USE_NLS
Definition: oleauto.h:338
#define VAR_CALENDAR_HIJRI
Definition: oleauto.h:329
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define VARIANT_CALENDAR_GREGORIAN
Definition: oleauto.h:316
#define V_DATE(A)
Definition: oleauto.h:231
const GUID IID_IDispatch
#define DEC_LO32(d)
Definition: variant.h:96
#define DEC_MID32(d)
Definition: variant.h:95
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
#define DEC_SIGNSCALE(d)
Definition: variant.h:93
#define DECIMAL_POS
Definition: variant.h:77
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19

Referenced by VariantChangeTypeEx().

◆ VARIANT_CoerceArray()

static HRESULT VARIANT_CoerceArray ( VARIANTARG pd,
VARIANTARG ps,
VARTYPE  vt 
)
inlinestatic

Definition at line 501 of file variant.c.

502{
503 if (vt == VT_BSTR && V_VT(ps) == (VT_ARRAY|VT_UI1))
504 return BstrFromVector(V_ARRAY(ps), &V_BSTR(pd));
505
506 if (V_VT(ps) == VT_BSTR && vt == (VT_ARRAY|VT_UI1))
507 return VectorFromBstr(V_BSTR(ps), &V_ARRAY(pd));
508
509 if (V_VT(ps) == vt)
510 return SafeArrayCopy(V_ARRAY(ps), &V_ARRAY(pd));
511
512 return DISP_E_TYPEMISMATCH;
513}
@ VT_ARRAY
Definition: compat.h:2341
HRESULT WINAPI SafeArrayCopy(SAFEARRAY *psa, SAFEARRAY **ppsaOut)
Definition: safearray.c:1379
HRESULT WINAPI VectorFromBstr(BSTR bstr, SAFEARRAY **ppsa)
Definition: safearray.c:1699
HRESULT WINAPI BstrFromVector(SAFEARRAY *psa, BSTR *pbstr)
Definition: safearray.c:1740

Referenced by VariantChangeTypeEx().

◆ VARIANT_CopyIRecordInfo()

static HRESULT VARIANT_CopyIRecordInfo ( VARIANT dest,
VARIANT src 
)
static

Definition at line 692 of file variant.c.

693{
694 struct __tagBRECORD *dest_rec = &V_UNION(dest, brecVal);
695 struct __tagBRECORD *src_rec = &V_UNION(src, brecVal);
696 HRESULT hr = S_OK;
697 ULONG size;
698
699 if (!src_rec->pRecInfo)
700 {
701 if (src_rec->pvRecord) return E_INVALIDARG;
702 return S_OK;
703 }
704
705 hr = IRecordInfo_GetSize(src_rec->pRecInfo, &size);
706 if (FAILED(hr)) return hr;
707
708 /* This could look cleaner if only RecordCreate() was used, but native doesn't use it.
709 Memory should be allocated in a same way as RecordCreate() does, so RecordDestroy()
710 could free it later. */
711 dest_rec->pvRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
712 if (!dest_rec->pvRecord) return E_OUTOFMEMORY;
713
714 dest_rec->pRecInfo = src_rec->pRecInfo;
715 IRecordInfo_AddRef(src_rec->pRecInfo);
716
717 return IRecordInfo_RecordCopy(src_rec->pRecInfo, src_rec->pvRecord, dest_rec->pvRecord);
718}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
unsigned int ULONG
Definition: retypes.h:1
static char * dest
Definition: rtl.c:135
HRESULT hr
Definition: shlfolder.c:183

Referenced by VariantCopy(), and VariantCopyInd().

◆ VARIANT_DataSize()

static size_t VARIANT_DataSize ( const VARIANT pv)
inlinestatic

Definition at line 791 of file variant.c.

792{
793 switch (V_TYPE(pv))
794 {
795 case VT_I1:
796 case VT_UI1: return sizeof(BYTE);
797 case VT_I2:
798 case VT_UI2: return sizeof(SHORT);
799 case VT_INT:
800 case VT_UINT:
801 case VT_I4:
802 case VT_UI4: return sizeof(LONG);
803 case VT_I8:
804 case VT_UI8: return sizeof(LONGLONG);
805 case VT_R4: return sizeof(float);
806 case VT_R8: return sizeof(double);
807 case VT_DATE: return sizeof(DATE);
808 case VT_BOOL: return sizeof(VARIANT_BOOL);
809 case VT_DISPATCH:
810 case VT_UNKNOWN:
811 case VT_BSTR: return sizeof(void*);
812 case VT_CY: return sizeof(CY);
813 case VT_ERROR: return sizeof(SCODE);
814 }
815 TRACE("Shouldn't be called for variant %s!\n", debugstr_variant(pv));
816 return 0;
817}
double DATE
Definition: compat.h:2253
union tagCY CY
LONG SCODE
Definition: compat.h:2252
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
int64_t LONGLONG
Definition: typedefs.h:68
unsigned char BYTE
Definition: xxhash.c:193

Referenced by VariantCopyInd().

◆ VARIANT_DateFromJulian()

static int VARIANT_DateFromJulian ( int  dateIn)
inlinestatic

Definition at line 1061 of file variant.c.

1062{
1063 int julianDays = dateIn;
1064
1065 julianDays -= 1757585; /* Convert to + days from 1 Jan 100 AD */
1066 julianDays += DATE_MIN; /* Convert to +/- days from 1 Jan 1899 AD */
1067 return julianDays;
1068}
#define DATE_MIN
Definition: variant.h:70

Referenced by VarDateFromUdateEx().

◆ VARIANT_DMYFromJulian()

static void VARIANT_DMYFromJulian ( int  jd,
USHORT year,
USHORT month,
USHORT day 
)
inlinestatic

Definition at line 1071 of file variant.c.

1072{
1073 int j, i, l, n;
1074
1075 l = jd + 68569;
1076 n = l * 4 / 146097;
1077 l -= (n * 146097 + 3) / 4;
1078 i = (4000 * (l + 1)) / 1461001;
1079 l += 31 - (i * 1461) / 4;
1080 j = (l * 80) / 2447;
1081 *day = l - (j * 2447) / 80;
1082 l = j / 11;
1083 *month = (j + 2) - (12 * l);
1084 *year = 100 * (n - 49) + i + l;
1085}
r l[0]
Definition: byte_order.h:167
static DOUBLE day(DOUBLE time)
Definition: date.c:117
static const WCHAR month[12][4]
Definition: session.c:2150
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by VarUdateFromDate().

◆ VARIANT_FetchDispatchValue()

static HRESULT VARIANT_FetchDispatchValue ( LPVARIANT  pvDispatch,
LPVARIANT  pValue 
)
static

Definition at line 515 of file variant.c.

516{
518 static DISPPARAMS emptyParams = { NULL, NULL, 0, 0 };
519
520 if ((V_VT(pvDispatch) & VT_TYPEMASK) == VT_DISPATCH) {
521 if (NULL == V_DISPATCH(pvDispatch)) return DISP_E_TYPEMISMATCH;
522 hres = IDispatch_Invoke(V_DISPATCH(pvDispatch), DISPID_VALUE, &IID_NULL,
524 NULL, NULL);
525 } else {
527 }
528 return hres;
529}
PWCHAR pValue
struct stdole::DISPPARAMS DISPPARAMS
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define IID_NULL
Definition: guiddef.h:98

Referenced by VarAbs(), VarAdd(), VarAnd(), VarCat(), VarDiv(), VarFix(), VarImp(), VarInt(), VarMod(), VarMul(), VarNeg(), VarNot(), VarOr(), VarPow(), VarRound(), VarSub(), and VarXor().

◆ VARIANT_GetLocalisedNumberChars()

static void VARIANT_GetLocalisedNumberChars ( VARIANT_NUMBER_CHARS lpChars,
LCID  lcid,
DWORD  dwFlags 
)
static

Definition at line 1518 of file variant.c.

1519{
1520 static const VARIANT_NUMBER_CHARS defaultChars = { '-','+','.',',','$',0,'.',',' };
1521 static VARIANT_NUMBER_CHARS lastChars;
1522 static LCID lastLcid = -1;
1523 static DWORD lastFlags = 0;
1525 WCHAR buff[4];
1526
1527 /* To make caching thread-safe, a critical section is needed */
1529
1530 /* Asking for default locale entries is very expensive: It is a registry
1531 server call. So cache one locally, as Microsoft does it too */
1532 if(lcid == lastLcid && dwFlags == lastFlags)
1533 {
1534 memcpy(lpChars, &lastChars, sizeof(defaultChars));
1536 return;
1537 }
1538
1539 memcpy(lpChars, &defaultChars, sizeof(defaultChars));
1540 GET_NUMBER_TEXT(LOCALE_SNEGATIVESIGN, cNegativeSymbol);
1541 GET_NUMBER_TEXT(LOCALE_SPOSITIVESIGN, cPositiveSymbol);
1542 GET_NUMBER_TEXT(LOCALE_SDECIMAL, cDecimalPoint);
1543 GET_NUMBER_TEXT(LOCALE_STHOUSAND, cDigitSeparator);
1544 GET_NUMBER_TEXT(LOCALE_SMONDECIMALSEP, cCurrencyDecimalPoint);
1545 GET_NUMBER_TEXT(LOCALE_SMONTHOUSANDSEP, cCurrencyDigitSeparator);
1546
1547 /* Local currency symbols are often 2 characters */
1548 lpChars->cCurrencyLocal2 = '\0';
1549 switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, ARRAY_SIZE(buff)))
1550 {
1551 case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */
1552 case 2: lpChars->cCurrencyLocal = buff[0];
1553 break;
1554 default: WARN("buffer too small for LOCALE_SCURRENCY\n");
1555 }
1556 TRACE("lcid 0x%x, cCurrencyLocal =%d,%d '%c','%c'\n", lcid, lpChars->cCurrencyLocal,
1557 lpChars->cCurrencyLocal2, lpChars->cCurrencyLocal, lpChars->cCurrencyLocal2);
1558
1559 memcpy(&lastChars, lpChars, sizeof(defaultChars));
1560 lastLcid = lcid;
1561 lastFlags = dwFlags;
1563}
#define ARRAY_SIZE(a)
Definition: main.h:24
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static CRITICAL_SECTION cache_cs
Definition: variant.c:45
#define GET_NUMBER_TEXT(fld, name)
Definition: variant.c:1509
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_SPOSITIVESIGN
Definition: winnls.h:117
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:51
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:52
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_SNEGATIVESIGN
Definition: winnls.h:118
DWORD LCTYPE
Definition: winnls.h:517
#define LOCALE_SCURRENCY
Definition: winnls.h:49
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by VarParseNumFromStr().

◆ VARIANT_JulianFromDate()

static int VARIANT_JulianFromDate ( int  dateIn)
inlinestatic

Definition at line 1051 of file variant.c.

1052{
1053 int julianDays = dateIn;
1054
1055 julianDays -= DATE_MIN; /* Convert to + days from 1 Jan 100 AD */
1056 julianDays += 1757585; /* Convert to + days from 23 Nov 4713 BC (Julian) */
1057 return julianDays;
1058}

Referenced by VarUdateFromDate().

◆ VARIANT_JulianFromDMY()

static double VARIANT_JulianFromDMY ( USHORT  year,
USHORT  month,
USHORT  day 
)
inlinestatic

Definition at line 1088 of file variant.c.

1089{
1090 int m12 = (month - 14) / 12;
1091
1092 return ((1461 * (year + 4800 + m12)) / 4 + (367 * (month - 2 - 12 * m12)) / 12 -
1093 (3 * ((year + 4900 + m12) / 100)) / 4 + day - 32075);
1094}
#define m12

Referenced by VarDateFromUdateEx().

◆ VARIANT_RollUdate()

static HRESULT VARIANT_RollUdate ( UDATE lpUd)
static

Definition at line 1108 of file variant.c.

1109{
1110 static const BYTE days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
1111 short iYear, iMonth, iDay, iHour, iMinute, iSecond;
1112
1113 /* interpret values signed */
1114 iYear = lpUd->st.wYear;
1115 iMonth = lpUd->st.wMonth;
1116 iDay = lpUd->st.wDay;
1117 iHour = lpUd->st.wHour;
1118 iMinute = lpUd->st.wMinute;
1119 iSecond = lpUd->st.wSecond;
1120
1121 TRACE("Raw date: %d/%d/%d %d:%d:%d\n", iDay, iMonth,
1122 iYear, iHour, iMinute, iSecond);
1123
1124 if (iYear > 9999 || iYear < -9999)
1125 return E_INVALIDARG; /* Invalid value */
1126 /* Year 0 to 29 are treated as 2000 + year */
1127 if (iYear >= 0 && iYear < 30)
1128 iYear += 2000;
1129 /* Remaining years < 100 are treated as 1900 + year */
1130 else if (iYear >= 30 && iYear < 100)
1131 iYear += 1900;
1132
1133 iMinute += iSecond / 60;
1134 iSecond = iSecond % 60;
1135 iHour += iMinute / 60;
1136 iMinute = iMinute % 60;
1137 iDay += iHour / 24;
1138 iHour = iHour % 24;
1139 iYear += iMonth / 12;
1140 iMonth = iMonth % 12;
1141 if (iMonth<=0) {iMonth+=12; iYear--;}
1142 while (iDay > days[iMonth])
1143 {
1144 if (iMonth == 2 && IsLeapYear(iYear))
1145 iDay -= 29;
1146 else
1147 iDay -= days[iMonth];
1148 iMonth++;
1149 iYear += iMonth / 12;
1150 iMonth = iMonth % 12;
1151 }
1152 while (iDay <= 0)
1153 {
1154 iMonth--;
1155 if (iMonth<=0) {iMonth+=12; iYear--;}
1156 if (iMonth == 2 && IsLeapYear(iYear))
1157 iDay += 29;
1158 else
1159 iDay += days[iMonth];
1160 }
1161
1162 if (iSecond<0){iSecond+=60; iMinute--;}
1163 if (iMinute<0){iMinute+=60; iHour--;}
1164 if (iHour<0) {iHour+=24; iDay--;}
1165 if (iYear<=0) iYear+=2000;
1166
1167 lpUd->st.wYear = iYear;
1168 lpUd->st.wMonth = iMonth;
1169 lpUd->st.wDay = iDay;
1170 lpUd->st.wHour = iHour;
1171 lpUd->st.wMinute = iMinute;
1172 lpUd->st.wSecond = iSecond;
1173
1174 TRACE("Rolled date: %d/%d/%d %d:%d:%d\n", lpUd->st.wDay, lpUd->st.wMonth,
1175 lpUd->st.wYear, lpUd->st.wHour, lpUd->st.wMinute, lpUd->st.wSecond);
1176 return S_OK;
1177}
#define IsLeapYear(y)
Definition: variant.c:1048

Referenced by VarDateFromUdateEx(), and VarUdateFromDate().

◆ VARIANT_ValidateType()

static HRESULT VARIANT_ValidateType ( VARTYPE  vt)
inlinestatic

Definition at line 534 of file variant.c.

535{
536 VARTYPE vtExtra = vt & VT_EXTRA_TYPE;
537
538 vt &= VT_TYPEMASK;
539
540 if (!(vtExtra & (VT_VECTOR|VT_RESERVED)))
541 {
542 if (vt < VT_VOID || vt == VT_RECORD || vt == VT_CLSID)
543 {
544 if ((vtExtra & (VT_BYREF|VT_ARRAY)) && vt <= VT_NULL)
545 return DISP_E_BADVARTYPE;
546 if (vt != (VARTYPE)15)
547 return S_OK;
548 }
549 }
550 return DISP_E_BADVARTYPE;
551}
@ VT_VECTOR
Definition: compat.h:2340
#define VT_EXTRA_TYPE
Definition: variant.h:33

Referenced by VarFix(), VARIANT_ClearInd(), VariantChangeTypeEx(), VariantClear(), VariantCopy(), VarNeg(), and VarNot().

◆ VariantChangeType()

◆ VariantChangeTypeEx()

HRESULT WINAPI VariantChangeTypeEx ( VARIANTARG pvargDest,
VARIANTARG pvargSrc,
LCID  lcid,
USHORT  wFlags,
VARTYPE  vt 
)

Definition at line 988 of file variant.c.

990{
991 HRESULT res = S_OK;
992
993 TRACE("(%s,%s,0x%08x,0x%04x,%s)\n", debugstr_variant(pvargDest),
994 debugstr_variant(pvargSrc), lcid, wFlags, debugstr_vt(vt));
995
996 if (vt == VT_CLSID)
998 else
999 {
1000 res = VARIANT_ValidateType(V_VT(pvargSrc));
1001
1002 if (SUCCEEDED(res))
1003 {
1005
1006 if (SUCCEEDED(res))
1007 {
1008 VARIANTARG vTmp, vSrcDeref;
1009
1010 if(V_ISBYREF(pvargSrc) && !V_BYREF(pvargSrc))
1012 else
1013 {
1014 V_VT(&vTmp) = VT_EMPTY;
1015 V_VT(&vSrcDeref) = VT_EMPTY;
1016 VariantClear(&vTmp);
1017 VariantClear(&vSrcDeref);
1018 }
1019
1020 if (SUCCEEDED(res))
1021 {
1022 res = VariantCopyInd(&vSrcDeref, pvargSrc);
1023 if (SUCCEEDED(res))
1024 {
1025 if (V_ISARRAY(&vSrcDeref) || (vt & VT_ARRAY))
1026 res = VARIANT_CoerceArray(&vTmp, &vSrcDeref, vt);
1027 else
1028 res = VARIANT_Coerce(&vTmp, lcid, wFlags, &vSrcDeref, vt);
1029
1030 if (SUCCEEDED(res)) {
1031 V_VT(&vTmp) = vt;
1032 res = VariantCopy(pvargDest, &vTmp);
1033 }
1034 VariantClear(&vTmp);
1035 VariantClear(&vSrcDeref);
1036 }
1037 }
1038 }
1039 }
1040 }
1041
1042 TRACE("returning 0x%08x, %s\n", res, debugstr_variant(pvargDest));
1043 return res;
1044}
#define V_BYREF(A)
Definition: oleauto.h:228
static HRESULT VARIANT_Coerce(VARIANTARG *pd, LCID lcid, USHORT wFlags, VARIANTARG *ps, VARTYPE vt)
Definition: variant.c:55
static HRESULT VARIANT_CoerceArray(VARIANTARG *pd, VARIANTARG *ps, VARTYPE vt)
Definition: variant.c:501
HRESULT WINAPI VariantCopyInd(VARIANT *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:847

Referenced by _VarChangeTypeExWrap(), document_write(), double_to_string(), invoke(), OLEFontImpl_Invoke(), OLEPictureImpl_Invoke(), RegistryPropertyBag_IPropertyBag_Read(), test_ChangeType_keep_dst(), test_EmptyChangeTypeEx(), test_ErrorChangeTypeEx(), test_IDispatchChangeTypeEx(), test_IUnknownChangeTypeEx(), test_nodeTypedValue(), test_NullByRef(), test_NullChangeTypeEx(), test_safearray(), test_SafeArrayChangeTypeEx(), test_UintChangeTypeEx(), test_VarDateChangeTypeEx(), test_VarUI1FromDisp(), VarCat(), VarCmp(), VarFormatCurrency(), VarFormatFromTokens(), VarFormatNumber(), VarFormatPercent(), VARIANT_FormatDate(), VARIANT_FormatNumber(), VARIANT_FormatString(), VARIANT_FromDisp(), and VariantChangeType().

◆ VariantClear()

HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear ( VARIANTARG pVarg)

Definition at line 648 of file variant.c.

649{
651
652 TRACE("(%s)\n", debugstr_variant(pVarg));
653
655
656 if (SUCCEEDED(hres))
657 {
658 if (!V_ISBYREF(pVarg))
659 {
660 if (V_ISARRAY(pVarg) || V_VT(pVarg) == VT_SAFEARRAY)
661 {
662 hres = SafeArrayDestroy(V_ARRAY(pVarg));
663 }
664 else if (V_VT(pVarg) == VT_BSTR)
665 {
666 SysFreeString(V_BSTR(pVarg));
667 }
668 else if (V_VT(pVarg) == VT_RECORD)
669 {
670 struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
671 if (pBr->pRecInfo)
672 {
673 IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord);
674 IRecordInfo_Release(pBr->pRecInfo);
675 }
676 }
677 else if (V_VT(pVarg) == VT_DISPATCH ||
678 V_VT(pVarg) == VT_UNKNOWN)
679 {
680 if (V_UNKNOWN(pVarg))
681 IUnknown_Release(V_UNKNOWN(pVarg));
682 }
683 }
684 V_VT(pVarg) = VT_EMPTY;
685 }
686 return hres;
687}

Referenced by _check_default_props(), _check_property(), _check_set_props(), _create_img_elem(), _create_option_elem(), _set_framebase_marginheight(), _set_framebase_marginwidth(), _set_iframe_height(), _set_iframe_width(), _set_props(), _test_border_styles(), _test_clone(), _test_disp_value(), _test_elem_attr(), _test_framebase_marginheight(), _test_framebase_marginwidth(), _test_iframe_height(), _test_iframe_width(), _test_node_get_value_str(), _test_node_put_value_str(), _test_readyState(), _test_table_cell_padding(), _test_table_cell_spacing(), _test_tr_possess(), _unset_props(), add_keyitem_pair(), assign_value(), AutomationObject_Invoke(), AVICompressorPropertyBag_Load(), build_directshowfilters_tree(), builtin_propput(), call_event_handlers(), call_script(), call_timer_disp(), clean_props(), SEALED_::CleanupEventArgumentsCallback(), ClearCustData(), Client_EnumVARIANT_Next(), Compartment_Destructor(), Compartment_SetValue(), create_enumerator(), create_signature_columns_and_data(), create_xmlhttprequest(), database_invoke(), disp_call(), disp_call_value(), disp_propget(), disp_propput(), DispatchEx_InvokeEx(), dispex_unlink(), document_write(), enum_find_filter(), enumvar_get_next_item(), exec_assoc_view(), exec_query(), fill_filter_container(), fill_processor_information(), FilterGraph2_Connect(), FilterGraph2_Render(), FilterMapper3_EnumMatchingFilters(), FilterMapper_EnumMatchingFilters(), free_keyitem_pair(), free_property_information(), free_request(), get_attribute_value(), get_diskdrivetodiskpartition_pairs(), get_doc_ready_state(), get_fixed_drive(), get_logicaldisktopartition_pairs(), get_owner(), GetFilterInfo(), GetSplitter(), Global_Abs(), Global_CBool(), Global_CByte(), Global_CCur(), Global_Fix(), Global_Int(), Global_InvokeEx(), HTMLDocument_execCommand(), HTMLElement3_put_disabled(), HTMLElement_populate_props(), HTMLElement_put_title(), IDispatch_Invoke_Proxy(), IDispatch_Invoke_Stub(), iframe_onreadystatechange(), Installer_ProductInfo(), Installer_ProductState(), Installer_RegistryValue(), Installer_RegistryValueE(), Installer_RegistryValueI(), Installer_RegistryValueW(), Installer_VersionGet(), InstallerImpl_InstallProduct(), InstallerImpl_OpenDatabase(), InstallerImpl_OpenPackage(), InstallerImpl_OpenProduct(), InstallerImpl_ProductInfo(), InstallerImpl_ProductState(), InstallerImpl_RegistryValue(), InstallerImpl_RelatedProducts(), InstallerImpl_SummaryInformation(), interp_enumnext(), interp_incc(), interp_newenum(), interp_retval(), invoke(), invoke_builtin_function(), invoke_builtin_prop(), invoke_vbdisp(), IPropertyBag_Read_Stub(), IRecordInfoImpl_GetField(), IRecordInfoImpl_GetFieldNoCopy(), ITypeInfo2_fnGetCustData(), ITypeInfo_fnInvoke(), ITypeInfoImpl_Destroy(), jsval_release(), list_free(), MatchCollectionEnum_Next(), navigate_javascript_proc(), navigate_url(), notif_enabled(), objectset_ItemIndex(), OleCommandTarget_Exec(), OLEFont_SendNotify(), OLEFontImpl_Invoke(), OLEFontImpl_IPersistPropertyBag_Load(), OLEPictureImpl_Invoke(), prepare_for_binding(), process_get_owner(), PropertyBag_Release(), propertyset_Item(), query_prop(), read_property_names(), Record_FieldCountGet(), Record_IntegerDataGet(), record_invoke(), Record_StringDataGet(), refresh_document(), reg_create_key(), reg_enum_key(), reg_enum_values(), reg_get_stringvalue(), register_avicap_devices(), register_codec(), register_dsound_devices(), register_midiout_devices(), register_vfw_codecs(), register_wavein_devices(), register_waveout_devices(), release_dispex(), release_dynamic_vars(), release_exec(), release_val(), remove_attribute(), remove_event_handler(), reset_request(), run_script(), SAFEARRAY_DestroyData(), security_get_sd(), service_pause_service(), service_resume_service(), service_start_service(), service_stop_service(), Session_DoAction(), Session_EvaluateCondition(), Session_FeatureCurrentState(), Session_FeatureRequestStateGet(), session_invoke(), Session_LanguageGet(), Session_ModeGet(), Session_PropertyGet(), set_status_text(), stack_pop_disp(), stack_popn(), stack_push(), StringList_Count(), StringList_Item(), summaryinfo_invoke(), SummaryInfo_PropertyCountGet(), super_navigate(), test_attr(), test_attr_collection(), test_attr_collection_disp(), test_body_funs(), test_body_style(), test_BstrCopy(), test_change_type(), test_child_col_disp(), test_cloneNode(), test_codec(), test_container_properties(), test_create(), test_CreateTypeLib(), test_current_style(), test_default_body(), test_default_client_accessible_object(), test_default_properties(), test_default_value(), test_devenum(), test_directshow_filter(), test_dispatch(), test_DispCallFunc(), test_DispGetParam(), test_dmo(), test_dom_implementation(), test_domdoc(), test_domnode(), test_DriveCollection(), test_dsound(), test_EmptyChangeTypeEx(), test_exec_fontname(), test_exec_script(), test_FileCollection(), test_focus(), test_FolderCollection(), test_font_events_disp(), test_frames_collection(), test_func(), test_get_childNodes(), test_get_dataType(), test_get_namespaces(), test_get_set_attr(), test_get_xml(), test_getAttribute(), test_global_id(), test_hash_value(), test_IDispatchClear(), test_imgload(), test_InitPropVariantFromBuffer(), test_InitPropVariantFromGUIDAsString(), test_Installer_Products(), test_Installer_RegistryValue(), test_interfaces(), test_invokeex(), test_isexpression(), test_items(), test_ITextDocument_Open(), test_IUnknownClear(), test_IWinHttpRequest(), test_IXMLDOMDocument2(), test_Keys(), test_legacy_filter(), test_load(), test_locator(), test_marshal_variant(), test_midiout(), test_mxnamespacemanager(), test_mxwriter_cdata(), test_mxwriter_characters(), test_mxwriter_comment(), test_mxwriter_dtd(), test_mxwriter_encoding(), test_mxwriter_flush(), test_mxwriter_ignorablespaces(), test_mxwriter_indent(), test_mxwriter_pi(), test_mxwriter_properties(), test_mxwriter_startenddocument(), test_mxwriter_startendelement(), test_mxwriter_startendelement_batch(), test_mxwriter_startendelement_batch2(), test_mxwriter_stream(), test_namedmap_newenum(), test_namespace(), test_nodeTypedValue(), test_nodeValue(), test_NullByRef(), test_object_elem(), test_OleLoadPicturePath(), test_onclick(), test_ParseDisplayName(), test_ParseName(), test_procedures(), test_propertybag_read(), test_propertybag_write(), test_PropVariantToGUID(), test_put_nodeTypedValue(), test_put_nodeValue(), test_RegExp(), test_registry(), test_safearray(), test_SafeArrayChangeTypeEx(), test_SafeArrayClear(), test_saxreader(), test_saxreader_properties(), test_schema_refs(), test_script_dispatch(), test_script_run(), test_selection(), test_set_csstext(), test_specific_encoder_properties(), test_StaticWidget(), test_StdRegProv(), test_style2(), test_style3(), test_style4(), test_style5(), test_stylesheets(), test_SummaryInfo(), test_SystemSecurity(), test_table_elem(), test_td_elem(), test_tr_elem(), test_type_info(), test_TypeInfo(), test_typelibmarshal(), test_var_call1(), test_var_call2(), test_VarAdd(), test_VarCat(), test_VarDateChangeTypeEx(), test_VarFormatFromTokens(), test_VariantClear(), test_VariantCopy(), test_VariantCopyInd(), test_Verbs(), test_vfw(), test_wavein(), test_waveout(), test_Win32_Baseboard(), test_Win32_Bios(), test_Win32_ComputerSystem(), test_Win32_OperatingSystem(), test_Win32_PnPEntity(), test_Win32_Printer(), test_Win32_Process(), test_Win32_Service(), test_Win32_SystemEnclosure(), test_Win32_VideoController(), test_wshshell(), test_XDR_datatypes(), test_XDR_schemas(), test_xmlelem(), test_xmlelem_collection(), test_XMLHTTP(), test_xmlhttprequest(), test_xmlTypes(), test_XPath(), test_xsltemplate(), TLB_AllocAndInitVarDesc(), TLB_FreeCustData(), TLB_FreeElemDesc(), TLB_FreeVarDesc(), TLB_set_custdata(), update_readystate(), validate_regex_document(), VarAbs(), VarAdd(), VarAnd(), VarCat(), VarCmp(), VarDiv(), VarFix(), VARIANT_ClearInd(), VARIANT_Coerce(), VARIANT_FormatNumber(), VARIANT_FormatString(), VARIANT_FromDisp(), VARIANT_UserFree(), VARIANT_UserUnmarshal(), VariantChangeType_ChangeType(), VariantChangeTypeEx(), VariantCopy(), VariantCopyInd(), VarIdiv(), VarImp(), VarInt(), VarMod(), VarMul(), VarNeg(), VarNot(), VarOr(), VarPow(), VarRound(), VarSub(), VarXor(), VBArray_getItem(), view_invoke(), Widget_variant(), winhttp_request_Send(), write_filter_data(), WshShell3_Popup(), WshShell3_RegWrite(), and xslprocessor_transform().

◆ VariantCopy()

HRESULT WINAPI VariantCopy ( VARIANTARG pvargDest,
VARIANTARG pvargSrc 
)

Definition at line 748 of file variant.c.

749{
750 HRESULT hres = S_OK;
751
752 TRACE("(%s,%s)\n", debugstr_variant(pvargDest), debugstr_variant(pvargSrc));
753
754 if (V_TYPE(pvargSrc) == VT_CLSID || /* VT_CLSID is a special case */
755 FAILED(VARIANT_ValidateType(V_VT(pvargSrc))))
756 return DISP_E_BADVARTYPE;
757
758 if (pvargSrc != pvargDest &&
759 SUCCEEDED(hres = VariantClear(pvargDest)))
760 {
761 *pvargDest = *pvargSrc; /* Shallow copy the value */
762
763 if (!V_ISBYREF(pvargSrc))
764 {
765 switch (V_VT(pvargSrc))
766 {
767 case VT_BSTR:
768 V_BSTR(pvargDest) = SysAllocStringByteLen((char*)V_BSTR(pvargSrc), SysStringByteLen(V_BSTR(pvargSrc)));
769 if (!V_BSTR(pvargDest))
771 break;
772 case VT_RECORD:
773 hres = VARIANT_CopyIRecordInfo(pvargDest, pvargSrc);
774 break;
775 case VT_DISPATCH:
776 case VT_UNKNOWN:
777 V_UNKNOWN(pvargDest) = V_UNKNOWN(pvargSrc);
778 if (V_UNKNOWN(pvargSrc))
779 IUnknown_AddRef(V_UNKNOWN(pvargSrc));
780 break;
781 default:
782 if (V_ISARRAY(pvargSrc))
783 hres = SafeArrayCopy(V_ARRAY(pvargSrc), &V_ARRAY(pvargDest));
784 }
785 }
786 }
787 return hres;
788}
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:215
BSTR WINAPI DECLSPEC_HOTPATCH SysAllocStringByteLen(LPCSTR str, UINT len)
Definition: oleaut.c:428
static HRESULT VARIANT_CopyIRecordInfo(VARIANT *dest, VARIANT *src)
Definition: variant.c:692

Referenced by Compartment_GetValue(), dict_enum_Next(), dictionary_get_Item(), dictionary_Items(), dictionary_Keys(), function_invoke(), get_event_handler(), HTMLEventObj_get_returnValue(), HTMLStyle3_get_zoom(), IDispatch_Invoke_Proxy(), IDispatch_Invoke_Stub(), IDxDiagContainerImpl_GetProp(), Installer_RegistryValue(), interp_retval(), interp_val(), ITypeInfo2_fnGetCustData(), ITypeInfo2_fnGetFuncCustData(), ITypeInfo2_fnGetImplTypeCustData(), ITypeInfo2_fnGetParamCustData(), ITypeInfo2_fnGetVarCustData(), ITypeInfo_fnInvoke(), ITypeLib2_fnGetCustData(), jsval_to_variant(), jsval_variant(), list_invoke(), ListEnumerator_Next(), PropertyBag_Read(), PropertyBag_Write(), SAFEARRAY_CopyData(), safearray_iter_IEnumVARIANT_Next(), SafeArrayGetElement(), SafeArrayPutElement(), stack_assume_val(), test_BstrCopy(), test_IDispatchCopy(), test_IUnknownCopy(), test_SafeArrayCopy(), test_VarI8Copy(), test_VariantCopy(), test_VarUI8Copy(), TLB_AllocAndInitVarDesc(), TLB_copy_all_custdata(), TLB_CopyElemDesc(), TLB_set_custdata(), VarAdd(), VarAnd(), VARIANT_Coerce(), variant_copy(), VariantChangeTypeEx(), VariantCopyInd(), VarImp(), VarMul(), VarOr(), and VarXor().

◆ VariantCopyInd()

HRESULT WINAPI VariantCopyInd ( VARIANT pvargDest,
VARIANTARG pvargSrc 
)

Definition at line 847 of file variant.c.

848{
849 VARIANTARG vTmp, *pSrc = pvargSrc;
850 VARTYPE vt;
851 HRESULT hres = S_OK;
852
853 TRACE("(%s,%s)\n", debugstr_variant(pvargDest), debugstr_variant(pvargSrc));
854
855 if (!V_ISBYREF(pvargSrc))
856 return VariantCopy(pvargDest, pvargSrc);
857
858 /* Argument checking is more lax than VariantCopy()... */
859 vt = V_TYPE(pvargSrc);
860 if (V_ISARRAY(pvargSrc) || (V_VT(pvargSrc) == (VT_RECORD|VT_BYREF)) ||
861 (vt > VT_NULL && vt != (VARTYPE)15 && vt < VT_VOID &&
862 !(V_VT(pvargSrc) & (VT_VECTOR|VT_RESERVED))))
863 {
864 /* OK */
865 }
866 else
867 return E_INVALIDARG; /* ...And the return value for invalid types differs too */
868
869 if (pvargSrc == pvargDest)
870 {
871 /* In place copy. Use a shallow copy of pvargSrc & init pvargDest.
872 * This avoids an expensive VariantCopy() call - e.g. SafeArrayCopy().
873 */
874 vTmp = *pvargSrc;
875 pSrc = &vTmp;
876 V_VT(pvargDest) = VT_EMPTY;
877 }
878 else
879 {
880 /* Copy into another variant. Free the variant in pvargDest */
881 if (FAILED(hres = VariantClear(pvargDest)))
882 {
883 TRACE("VariantClear() of destination failed\n");
884 return hres;
885 }
886 }
887
888 if (V_ISARRAY(pSrc))
889 {
890 /* Native doesn't check that *V_ARRAYREF(pSrc) is valid */
891 hres = SafeArrayCopy(*V_ARRAYREF(pSrc), &V_ARRAY(pvargDest));
892 }
893 else if (V_VT(pSrc) == (VT_BSTR|VT_BYREF))
894 {
895 /* Native doesn't check that *V_BSTRREF(pSrc) is valid */
896 V_BSTR(pvargDest) = SysAllocStringByteLen((char*)*V_BSTRREF(pSrc), SysStringByteLen(*V_BSTRREF(pSrc)));
897 }
898 else if (V_VT(pSrc) == (VT_RECORD|VT_BYREF))
899 {
900 hres = VARIANT_CopyIRecordInfo(pvargDest, pvargSrc);
901 }
902 else if (V_VT(pSrc) == (VT_DISPATCH|VT_BYREF) ||
903 V_VT(pSrc) == (VT_UNKNOWN|VT_BYREF))
904 {
905 /* Native doesn't check that *V_UNKNOWNREF(pSrc) is valid */
906 V_UNKNOWN(pvargDest) = *V_UNKNOWNREF(pSrc);
907 if (*V_UNKNOWNREF(pSrc))
908 IUnknown_AddRef(*V_UNKNOWNREF(pSrc));
909 }
910 else if (V_VT(pSrc) == (VT_VARIANT|VT_BYREF))
911 {
912 /* Native doesn't check that *V_VARIANTREF(pSrc) is valid */
913 if (V_VT(V_VARIANTREF(pSrc)) == (VT_VARIANT|VT_BYREF))
914 hres = E_INVALIDARG; /* Don't dereference more than one level */
915 else
916 hres = VariantCopyInd(pvargDest, V_VARIANTREF(pSrc));
917
918 /* Use the dereferenced variants type value, not VT_VARIANT */
919 goto VariantCopyInd_Return;
920 }
921 else if (V_VT(pSrc) == (VT_DECIMAL|VT_BYREF))
922 {
923 memcpy(&DEC_SCALE(&V_DECIMAL(pvargDest)), &DEC_SCALE(V_DECIMALREF(pSrc)),
924 sizeof(DECIMAL) - sizeof(USHORT));
925 }
926 else
927 {
928 /* Copy the pointed to data into this variant */
929 memcpy(&V_BYREF(pvargDest), V_BYREF(pSrc), VARIANT_DataSize(pSrc));
930 }
931
932 V_VT(pvargDest) = V_VT(pSrc) & ~VT_BYREF;
933
934VariantCopyInd_Return:
935
936 if (pSrc != pvargSrc)
937 VariantClear(pSrc);
938
939 TRACE("returning 0x%08x, %s\n", hres, debugstr_variant(pvargDest));
940 return hres;
941}
#define V_DECIMALREF(A)
Definition: oleauto.h:238
unsigned short USHORT
Definition: pedump.c:61
static size_t VARIANT_DataSize(const VARIANT *pv)
Definition: variant.c:791
#define DEC_SCALE(d)
Definition: variant.h:92

Referenced by add_keyitem_pair(), assign_value(), dictionary_put_Item(), DispGetParam_CopyOnly(), exec_script(), Global_Array(), invoke_variant_prop(), CFolderItems::Item(), ITypeInfo_fnInvoke(), SummaryInfo_PropertyPut(), test_IDispatchCopy(), test_IUnknownCopy(), test_VarI8Copy(), test_VariantCopyInd(), test_VarUI8Copy(), VarFormatCurrency(), VarFormatNumber(), VarFormatPercent(), VariantChangeTypeEx(), VariantCopyInd(), and winhttp_request_Send().

◆ VariantInit()

void WINAPI VariantInit ( VARIANTARG pVarg)

Definition at line 568 of file variant.c.

569{
570 TRACE("(%p)\n", pVarg);
571
572 /* Win8.1 zeroes whole struct. Previous implementations don't set any other fields. */
573 V_VT(pVarg) = VT_EMPTY;
574}

Referenced by _call_change_type(), _check_default_props(), _check_property(), _check_set_props(), _set_props(), _test_clone(), _test_elem_attr(), _test_readyState(), _unset_props(), AccessibleChildren(), add_keyitem_pair(), AutomationObject_Invoke(), call_docview_84(), call_explorer_69(), ATL::CComVariant::CComVariant(), Compartment_Constructor(), Compartment_GetValue(), create_enumerator(), create_xmlhttprequest(), database_invoke(), Database_OpenView(), Database_SummaryInformation(), DatabaseImpl_LastErrorRecord(), DEVENUM_IMediaCatMoniker_BindToObject(), dictionary_get_Item(), dictionary_put_Key(), enum_find_filter(), enumvar_get_next_item(), fill_filter_container(), FilterMapper3_EnumMatchingFilters(), FilterMapper_EnumMatchingFilters(), get_client_disp_property(), get_dynamic_prop(), GetFilterInfo(), IDispatch_Invoke_Proxy(), IDispatch_Invoke_Stub(), IDxDiagContainerImpl_GetProp(), initialize_request(), Installer_CreateRecord(), Installer_InstallProduct(), Installer_OpenDatabase(), Installer_OpenPackage(), Installer_ProductInfo(), Installer_ProductState(), Installer_RegistryValue(), Installer_RegistryValueE(), Installer_RegistryValueI(), Installer_RegistryValueW(), Installer_RelatedProducts(), Installer_SummaryInformation(), Installer_UILevelPut(), InstallerImpl_CreateRecord(), InstallerImpl_EnableLog(), InstallerImpl_Environment(), InstallerImpl_FileAttributes(), InstallerImpl_FileSize(), InstallerImpl_FileVersion(), InstallerImpl_InstallProduct(), InstallerImpl_LastErrorRecord(), InstallerImpl_OpenDatabase(), InstallerImpl_OpenPackage(), InstallerImpl_OpenProduct(), InstallerImpl_ProductInfo(), InstallerImpl_ProductState(), InstallerImpl_RegistryValue(), InstallerImpl_RelatedProducts(), InstallerImpl_SummaryInformation(), InstallerImpl_UILevel(), invoke(), ITypeInfo2_fnGetCustData(), ITypeInfo2_fnGetFuncCustData(), ITypeInfo2_fnGetImplTypeCustData(), ITypeInfo2_fnGetParamCustData(), ITypeInfo2_fnGetVarCustData(), ITypeInfo_fnInvoke(), ITypeLib2_fnGetCustData(), list_invoke(), ListEnumerator_Next(), load_manifest(), OLEFont_SendNotify(), OLEFontImpl_Invoke(), OLEFontImpl_IPersistPropertyBag_Load(), OLEPictureImpl_Invoke(), parse_elem_text(), process_get_owner(), PropertyBag_Read(), read_property_names(), Record_IntegerDataGet(), Record_IntegerDataPut(), record_invoke(), Record_StringDataGet(), Record_StringDataPut(), reg_enum_key(), reg_enum_values(), reg_get_stringvalue(), request_get_property(), request_send(), security_get_sd(), Session_DoAction(), Session_EvaluateCondition(), Session_FeatureCurrentState(), Session_FeatureRequestStateGet(), Session_FeatureRequestStatePut(), session_invoke(), Session_Message(), Session_ModeGet(), Session_ModePut(), Session_PropertyGet(), Session_PropertyPut(), Session_SetInstallLevel(), StringList_Item(), summaryinfo_invoke(), SummaryInfo_PropertyGet(), SummaryInfo_PropertyPut(), test_attr_collection_disp(), test_ChangeType_keep_dst(), test_child_col_disp(), test_ClearCustData(), test_codec(), test_comparemode(), test_container_properties(), test_CreateTypeLib(), test_devenum(), test_directshow_filter(), test_dispatch(), test_DispCallFunc(), test_DispGetParam(), test_dmo(), test_domdoc(), test_domnode(), test_dsound(), test_EmptyChangeTypeEx(), test_ErrorChangeTypeEx(), test_events(), test_Exists(), test_FileCollection(), test_FolderCollection(), test_func(), test_get_dataType(), test_get_ownerDocument(), test_get_xml(), test_getAttribute(), test_GetNames(), test_GetProp(), test_global_id(), test_hash_value(), test_IDispatchChangeTypeEx(), test_IDispatchCopy(),