ReactOS  0.4.14-dev-98-gb0d4763
variant.c File Reference
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wine/unicode.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 1571 of file variant.c.

◆ B_INEXACT_ZEROS

#define B_INEXACT_ZEROS   0x8

Definition at line 1572 of file variant.c.

◆ B_LEADING_ZERO

#define B_LEADING_ZERO   0x10

Definition at line 1573 of file variant.c.

◆ B_NEGATIVE_EXPONENT

#define B_NEGATIVE_EXPONENT   0x2

Definition at line 1570 of file variant.c.

◆ B_PROCESSING_EXPONENT

#define B_PROCESSING_EXPONENT   0x1

Definition at line 1569 of file variant.c.

◆ B_PROCESSING_HEX

#define B_PROCESSING_HEX   0x20

Definition at line 1574 of file variant.c.

◆ B_PROCESSING_OCT

#define B_PROCESSING_OCT   0x40

Definition at line 1575 of file variant.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 34 of file variant.c.

◆ DOS_DATE

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

Definition at line 1107 of file variant.c.

◆ DOS_DAY

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

Definition at line 1102 of file variant.c.

◆ DOS_HOUR

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

Definition at line 1103 of file variant.c.

◆ DOS_MINUTE

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

Definition at line 1104 of file variant.c.

◆ DOS_MONTH

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

Definition at line 1101 of file variant.c.

◆ DOS_SECOND

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

Definition at line 1105 of file variant.c.

◆ DOS_TIME

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

Definition at line 1108 of file variant.c.

◆ DOS_YEAR

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

Definition at line 1100 of file variant.c.

◆ FITS_AS_I1

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

Definition at line 1967 of file variant.c.

◆ FITS_AS_I2

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

Definition at line 1968 of file variant.c.

◆ FITS_AS_I4

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

Definition at line 1969 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"); \
if (buff[0]) lpChars->name = buff[0]; \
TRACE("lcid 0x%x, " #name "=%d '%c'\n", lcid, lpChars->name, lpChars->name)
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
if(!(yy_init))
Definition: macro.lex.yy.c:714
Definition: name.c:36
static unsigned char buff[32768]
Definition: fatten.c:17
WCHAR * name
Definition: name.c:40

Definition at line 1512 of file variant.c.

◆ INTEGER_VTBITS

Definition at line 1962 of file variant.c.

◆ IsLeapYear

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

Definition at line 1051 of file variant.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 36 of file variant.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 35 of file variant.c.

◆ REAL_VTBITS

#define REAL_VTBITS   (VTBIT_R4|VTBIT_R8|VTBIT_CY)

Definition at line 1964 of file variant.c.

Function Documentation

◆ _VarChangeTypeExWrap()

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

Definition at line 2662 of file variant.c.

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

Referenced by VarCmp().

◆ DosDateTimeToVariantTime()

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

Definition at line 1214 of file variant.c.

1216 {
1217  UDATE ud;
1218 
1219  TRACE("(0x%x(%d/%d/%d),0x%x(%d:%d:%d),%p)\n",
1220  wDosDate, DOS_YEAR(wDosDate), DOS_MONTH(wDosDate), DOS_DAY(wDosDate),
1221  wDosTime, DOS_HOUR(wDosTime), DOS_MINUTE(wDosTime), DOS_SECOND(wDosTime),
1222  pDateOut);
1223 
1224  ud.st.wYear = DOS_YEAR(wDosDate);
1225  ud.st.wMonth = DOS_MONTH(wDosDate);
1226  if (ud.st.wYear > 2099 || ud.st.wMonth > 12)
1227  return FALSE;
1228  ud.st.wDay = DOS_DAY(wDosDate);
1229  ud.st.wHour = DOS_HOUR(wDosTime);
1230  ud.st.wMinute = DOS_MINUTE(wDosTime);
1231  ud.st.wSecond = DOS_SECOND(wDosTime);
1232  ud.st.wDayOfWeek = ud.st.wMilliseconds = 0;
1233  if (ud.st.wHour > 23 || ud.st.wMinute > 59 || ud.st.wSecond > 59)
1234  return FALSE; /* Invalid values in Dos*/
1235 
1236  return VarDateFromUdate(&ud, 0, pDateOut) == S_OK;
1237 }
#define DOS_MONTH(x)
Definition: variant.c:1101
SYSTEMTIME st
Definition: oleauto.h:721
WORD wMonth
Definition: winbase.h:878
WORD wDayOfWeek
Definition: winbase.h:879
HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1409
WORD wYear
Definition: winbase.h:877
WORD wMinute
Definition: winbase.h:882
#define TRACE(s)
Definition: solgame.cpp:4
#define DOS_SECOND(x)
Definition: variant.c:1105
WORD wSecond
Definition: winbase.h:883
WORD wMilliseconds
Definition: winbase.h:884
Definition: oleauto.h:720
WORD wDay
Definition: winbase.h:880
#define S_OK
Definition: intsafe.h:59
#define DOS_MINUTE(x)
Definition: variant.c:1104
WORD wHour
Definition: winbase.h:881
#define DOS_HOUR(x)
Definition: variant.c:1103
#define DOS_YEAR(x)
Definition: variant.c:1100
#define DOS_DAY(x)
Definition: variant.c:1102

Referenced by test_DosDateTimeToVariantTime().

◆ SystemTimeToVariantTime()

INT WINAPI SystemTimeToVariantTime ( LPSYSTEMTIME  lpSt,
double pDateOut 
)

Definition at line 1289 of file variant.c.

1290 {
1291  UDATE ud;
1292 
1293  TRACE("(%p->%d/%d/%d %d:%d:%d,%p)\n", lpSt, lpSt->wDay, lpSt->wMonth,
1294  lpSt->wYear, lpSt->wHour, lpSt->wMinute, lpSt->wSecond, pDateOut);
1295 
1296  if (lpSt->wMonth > 12)
1297  return FALSE;
1298  if (lpSt->wDay > 31)
1299  return FALSE;
1300  if ((short)lpSt->wYear < 0)
1301  return FALSE;
1302 
1303  ud.st = *lpSt;
1304  return VarDateFromUdate(&ud, 0, pDateOut) == S_OK;
1305 }
SYSTEMTIME st
Definition: oleauto.h:721
WORD wMonth
Definition: winbase.h:878
HRESULT WINAPI VarDateFromUdate(UDATE *pUdateIn, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1409
WORD wYear
Definition: winbase.h:877
WORD wMinute
Definition: winbase.h:882
#define TRACE(s)
Definition: solgame.cpp:4
WORD wSecond
Definition: winbase.h:883
Definition: oleauto.h:720
WORD wDay
Definition: winbase.h:880
#define S_OK
Definition: intsafe.h:59
WORD wHour
Definition: winbase.h:881

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 4266 of file variant.c.

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

Referenced by Global_Abs(), and test_VarAbs().

◆ VarAdd()

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

Definition at line 3133 of file variant.c.

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

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

◆ VarAnd()

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

Definition at line 2896 of file variant.c.

2897 {
2898  HRESULT hres = S_OK;
2899  VARTYPE resvt = VT_EMPTY;
2900  VARTYPE leftvt,rightvt;
2901  VARTYPE rightExtraFlags,leftExtraFlags,ExtraFlags;
2902  VARIANT varLeft, varRight;
2903  VARIANT tempLeft, tempRight;
2904 
2905  VariantInit(&varLeft);
2906  VariantInit(&varRight);
2907  VariantInit(&tempLeft);
2908  VariantInit(&tempRight);
2909 
2910  TRACE("(%s,%s,%p)\n", debugstr_variant(left), debugstr_variant(right), result);
2911 
2912  /* Handle VT_DISPATCH by storing and taking address of returned value */
2913  if ((V_VT(left) & VT_TYPEMASK) == VT_DISPATCH)
2914  {
2915  hres = VARIANT_FetchDispatchValue(left, &tempLeft);
2916  if (FAILED(hres)) goto VarAnd_Exit;
2917  left = &tempLeft;
2918  }
2919  if ((V_VT(right) & VT_TYPEMASK) == VT_DISPATCH)
2920  {
2921  hres = VARIANT_FetchDispatchValue(right, &tempRight);
2922  if (FAILED(hres)) goto VarAnd_Exit;
2923  right = &tempRight;
2924  }
2925 
2926  leftvt = V_VT(left)&VT_TYPEMASK;
2927  rightvt = V_VT(right)&VT_TYPEMASK;
2928  leftExtraFlags = V_VT(left)&(~VT_TYPEMASK);
2929  rightExtraFlags = V_VT(right)&(~VT_TYPEMASK);
2930 
2931  if (leftExtraFlags != rightExtraFlags)
2932  {
2934  goto VarAnd_Exit;
2935  }
2936  ExtraFlags = leftExtraFlags;
2937 
2938  /* Native VarAnd always returns an error when using extra
2939  * flags or if the variant combination is I8 and INT.
2940  */
2941  if ((leftvt == VT_I8 && rightvt == VT_INT) ||
2942  (leftvt == VT_INT && rightvt == VT_I8) ||
2943  ExtraFlags != 0)
2944  {
2946  goto VarAnd_Exit;
2947  }
2948 
2949  /* Determine return type */
2950  else if (leftvt == VT_I8 || rightvt == VT_I8)
2951  resvt = VT_I8;
2952  else if (leftvt == VT_I4 || rightvt == VT_I4 ||
2953  leftvt == VT_UINT || rightvt == VT_UINT ||
2954  leftvt == VT_INT || rightvt == VT_INT ||
2955  leftvt == VT_R4 || rightvt == VT_R4 ||
2956  leftvt == VT_R8 || rightvt == VT_R8 ||
2957  leftvt == VT_CY || rightvt == VT_CY ||
2958  leftvt == VT_DATE || rightvt == VT_DATE ||
2959  leftvt == VT_I1 || rightvt == VT_I1 ||
2960  leftvt == VT_UI2 || rightvt == VT_UI2 ||
2961  leftvt == VT_UI4 || rightvt == VT_UI4 ||
2962  leftvt == VT_UI8 || rightvt == VT_UI8 ||
2963  leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
2964  resvt = VT_I4;
2965  else if (leftvt == VT_UI1 || rightvt == VT_UI1 ||
2966  leftvt == VT_I2 || rightvt == VT_I2 ||
2967  leftvt == VT_EMPTY || rightvt == VT_EMPTY)
2968  if ((leftvt == VT_NULL && rightvt == VT_UI1) ||
2969  (leftvt == VT_UI1 && rightvt == VT_NULL) ||
2970  (leftvt == VT_UI1 && rightvt == VT_UI1))
2971  resvt = VT_UI1;
2972  else
2973  resvt = VT_I2;
2974  else if (leftvt == VT_BOOL || rightvt == VT_BOOL ||
2975  (leftvt == VT_BSTR && rightvt == VT_BSTR))
2976  resvt = VT_BOOL;
2977  else if (leftvt == VT_NULL || rightvt == VT_NULL ||
2978  leftvt == VT_BSTR || rightvt == VT_BSTR)
2979  resvt = VT_NULL;
2980  else
2981  {
2983  goto VarAnd_Exit;
2984  }
2985 
2986  if (leftvt == VT_NULL || rightvt == VT_NULL)
2987  {
2988  /*
2989  * Special cases for when left variant is VT_NULL
2990  * (VT_NULL & 0 = VT_NULL, VT_NULL & value = value)
2991  */
2992  if (leftvt == VT_NULL)
2993  {
2994  VARIANT_BOOL b;
2995  switch(rightvt)
2996  {
2997  case VT_I1: if (V_I1(right)) resvt = VT_NULL; break;
2998  case VT_UI1: if (V_UI1(right)) resvt = VT_NULL; break;
2999  case VT_I2: if (V_I2(right)) resvt = VT_NULL; break;
3000  case VT_UI2: if (V_UI2(right)) resvt = VT_NULL; break;
3001  case VT_I4: if (V_I4(right)) resvt = VT_NULL; break;
3002  case VT_UI4: if (V_UI4(right)) resvt = VT_NULL; break;
3003  case VT_I8: if (V_I8(right)) resvt = VT_NULL; break;
3004  case VT_UI8: if (V_UI8(right)) resvt = VT_NULL; break;
3005  case VT_INT: if (V_INT(right)) resvt = VT_NULL; break;
3006  case VT_UINT: if (V_UINT(right)) resvt = VT_NULL; break;
3007  case VT_BOOL: if (V_BOOL(right)) resvt = VT_NULL; break;
3008  case VT_R4: if (V_R4(right)) resvt = VT_NULL; break;
3009  case VT_R8: if (V_R8(right)) resvt = VT_NULL; break;
3010  case VT_CY:
3011  if(V_CY(right).int64)
3012  resvt = VT_NULL;
3013  break;
3014  case VT_DECIMAL:
3015  if (DEC_HI32(&V_DECIMAL(right)) ||
3017  resvt = VT_NULL;
3018  break;
3019  case VT_BSTR:
3022  if (FAILED(hres))
3023  return hres;
3024  else if (b)
3025  V_VT(result) = VT_NULL;
3026  else
3027  {
3028  V_VT(result) = VT_BOOL;
3029  V_BOOL(result) = b;
3030  }
3031  goto VarAnd_Exit;
3032  }
3033  }
3034  V_VT(result) = resvt;
3035  goto VarAnd_Exit;
3036  }
3037 
3038  hres = VariantCopy(&varLeft, left);
3039  if (FAILED(hres)) goto VarAnd_Exit;
3040 
3041  hres = VariantCopy(&varRight, right);
3042  if (FAILED(hres)) goto VarAnd_Exit;
3043 
3044  if (resvt == VT_I4 && V_VT(&varLeft) == VT_UI4)
3045  V_VT(&varLeft) = VT_I4; /* Don't overflow */
3046  else
3047  {
3048  double d;
3049 
3050  if (V_VT(&varLeft) == VT_BSTR &&
3051  FAILED(VarR8FromStr(V_BSTR(&varLeft),
3052  LOCALE_USER_DEFAULT, 0, &d)))
3053  hres = VariantChangeType(&varLeft,&varLeft,
3055  if (SUCCEEDED(hres) && V_VT(&varLeft) != resvt)
3056  hres = VariantChangeType(&varLeft,&varLeft,0,resvt);
3057  if (FAILED(hres)) goto VarAnd_Exit;
3058  }
3059 
3060  if (resvt == VT_I4 && V_VT(&varRight) == VT_UI4)
3061  V_VT(&varRight) = VT_I4; /* Don't overflow */
3062  else
3063  {
3064  double d;
3065 
3066  if (V_VT(&varRight) == VT_BSTR &&
3067  FAILED(VarR8FromStr(V_BSTR(&varRight),
3068  LOCALE_USER_DEFAULT, 0, &d)))
3069  hres = VariantChangeType(&varRight, &varRight,
3071  if (SUCCEEDED(hres) && V_VT(&varRight) != resvt)
3072  hres = VariantChangeType(&varRight, &varRight, 0, resvt);
3073  if (FAILED(hres)) goto VarAnd_Exit;
3074  }
3075 
3076  V_VT(result) = resvt;
3077  switch(resvt)
3078  {
3079  case VT_I8:
3080  V_I8(result) = V_I8(&varLeft) & V_I8(&varRight);
3081  break;
3082  case VT_I4:
3083  V_I4(result) = V_I4(&varLeft) & V_I4(&varRight);
3084  break;
3085  case VT_I2:
3086  V_I2(result) = V_I2(&varLeft) & V_I2(&varRight);
3087  break;
3088  case VT_UI1:
3089  V_UI1(result) = V_UI1(&varLeft) & V_UI1(&varRight);
3090  break;
3091  case VT_BOOL:
3092  V_BOOL(result) = V_BOOL(&varLeft) & V_BOOL(&varRight);
3093  break;
3094  default:
3095  FIXME("Couldn't bitwise AND variant types %d,%d\n",
3096  leftvt,rightvt);
3097  }
3098 
3099 VarAnd_Exit:
3100  VariantClear(&varLeft);
3101  VariantClear(&varRight);
3102  VariantClear(&tempLeft);
3103  VariantClear(&tempRight);
3104 
3105  return hres;
3106 }
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
Definition: compat.h:1939
Definition: compat.h:1955
Definition: compat.h:1951
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
#define LOCALE_USER_DEFAULT
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2(A)
Definition: oleauto.h:245
HRESULT WINAPI VarBoolFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6113
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3150
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
short VARIANT_BOOL
Definition: compat.h:1931
#define V_UI8(A)
Definition: oleauto.h:272
#define V_I4(A)
Definition: oleauto.h:247
#define V_CY(A)
Definition: oleauto.h:229
#define FIXME(fmt,...)
Definition: debug.h:110
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
#define b
Definition: ke_i.h:79
#define V_I8(A)
Definition: oleauto.h:249
#define V_DECIMAL(A)
Definition: oleauto.h:236
#define V_R4(A)
Definition: oleauto.h:260
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
#define V_UI1(A)
Definition: oleauto.h:266
#define V_BOOL(A)
Definition: oleauto.h:224
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static const VARTYPE ExtraFlags[16]
Definition: vartest.c:689
#define V_UI4(A)
Definition: oleauto.h:270
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
#define DEC_HI32(d)
Definition: variant.h:94
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
Definition: compat.h:1940
#define V_VT(A)
Definition: oleauto.h:211
#define VAR_LOCALBOOL
Definition: oleauto.h:330
Definition: compat.h:1942
#define V_BSTR(A)
Definition: oleauto.h:226
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define S_OK
Definition: intsafe.h:59
#define V_INT(x)
Definition: webchild.h:78
unsigned short VARTYPE
Definition: compat.h:1895
#define DEC_LO64(d)
Definition: variant.h:97
static HRESULT VARIANT_FetchDispatchValue(LPVARIANT pvDispatch, LPVARIANT pValue)
Definition: variant.c:518
#define V_UINT(A)
Definition: oleauto.h:264
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:751
GLuint64EXT * result
Definition: glext.h:11304
Definition: compat.h:1941
Definition: compat.h:1938
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by interp_and(), and test_VarAnd().

◆ VarCat()

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

Definition at line 2518 of file variant.c.

2519 {
2520  BSTR left_str = NULL, right_str = NULL;
2521  VARTYPE leftvt, rightvt;
2522  HRESULT hres;
2523 
2524  TRACE("%s,%s,%p)\n", debugstr_variant(left), debugstr_variant(right), out);
2525 
2526  leftvt = V_VT(left);
2527  rightvt = V_VT(right);
2528 
2529  /* when both left and right are NULL the result is NULL */
2530  if (leftvt == VT_NULL && rightvt == VT_NULL)
2531  {
2532  V_VT(out) = VT_NULL;
2533  return S_OK;
2534  }
2535 
2536  /* There are many special case for errors and return types */
2537  if (leftvt == VT_VARIANT && (rightvt == VT_ERROR ||
2538  rightvt == VT_DATE || rightvt == VT_DECIMAL))
2540  else if ((leftvt == VT_I2 || leftvt == VT_I4 ||
2541  leftvt == VT_R4 || leftvt == VT_R8 ||
2542  leftvt == VT_CY || leftvt == VT_BOOL ||
2543  leftvt == VT_BSTR || leftvt == VT_I1 ||
2544  leftvt == VT_UI1 || leftvt == VT_UI2 ||
2545  leftvt == VT_UI4 || leftvt == VT_I8 ||
2546  leftvt == VT_UI8 || leftvt == VT_INT ||
2547  leftvt == VT_UINT || leftvt == VT_EMPTY ||
2548  leftvt == VT_NULL || leftvt == VT_DATE ||
2549  leftvt == VT_DECIMAL || leftvt == VT_DISPATCH)
2550  &&
2551  (rightvt == VT_I2 || rightvt == VT_I4 ||
2552  rightvt == VT_R4 || rightvt == VT_R8 ||
2553  rightvt == VT_CY || rightvt == VT_BOOL ||
2554  rightvt == VT_BSTR || rightvt == VT_I1 ||
2555  rightvt == VT_UI1 || rightvt == VT_UI2 ||
2556  rightvt == VT_UI4 || rightvt == VT_I8 ||
2557  rightvt == VT_UI8 || rightvt == VT_INT ||
2558  rightvt == VT_UINT || rightvt == VT_EMPTY ||
2559  rightvt == VT_NULL || rightvt == VT_DATE ||
2560  rightvt == VT_DECIMAL || rightvt == VT_DISPATCH))
2561  hres = S_OK;
2562  else if (rightvt == VT_ERROR && leftvt < VT_VOID)
2564  else if (leftvt == VT_ERROR && (rightvt == VT_DATE ||
2565  rightvt == VT_ERROR || rightvt == VT_DECIMAL))
2567  else if (rightvt == VT_DATE || rightvt == VT_ERROR ||
2568  rightvt == VT_DECIMAL)
2570  else if (leftvt == VT_ERROR || rightvt == VT_ERROR)
2572  else if (leftvt == VT_VARIANT)
2574  else if (rightvt == VT_VARIANT && (leftvt == VT_EMPTY ||
2575  leftvt == VT_NULL || leftvt == VT_I2 ||
2576  leftvt == VT_I4 || leftvt == VT_R4 ||
2577  leftvt == VT_R8 || leftvt == VT_CY ||
2578  leftvt == VT_DATE || leftvt == VT_BSTR ||
2579  leftvt == VT_BOOL || leftvt == VT_DECIMAL ||
2580  leftvt == VT_I1 || leftvt == VT_UI1 ||
2581  leftvt == VT_UI2 || leftvt == VT_UI4 ||
2582  leftvt == VT_I8 || leftvt == VT_UI8 ||
2583  leftvt == VT_INT || leftvt == VT_UINT))
2585  else
2587 
2588  /* if result type is not S_OK, then no need to go further */
2589  if (hres != S_OK)
2590  {
2591  V_VT(out) = VT_EMPTY;
2592  return hres;
2593  }
2594 
2595  if (leftvt == VT_BSTR)
2596  left_str = V_BSTR(left);
2597  else
2598  {
2599  VARIANT converted, *tmp = left;
2600 
2601  VariantInit(&converted);
2602  if(leftvt == VT_DISPATCH)
2603  {
2604  hres = VARIANT_FetchDispatchValue(left, &converted);
2605  if(FAILED(hres))
2606  goto failed;
2607 
2608  tmp = &converted;
2609  }
2610 
2612  if (SUCCEEDED(hres))
2613  left_str = V_BSTR(&converted);
2614  else if (hres != DISP_E_TYPEMISMATCH)
2615  {
2616  VariantClear(&converted);
2617  goto failed;
2618  }
2619  }
2620 
2621  if (rightvt == VT_BSTR)
2622  right_str = V_BSTR(right);
2623  else
2624  {
2625  VARIANT converted, *tmp = right;
2626 
2627  VariantInit(&converted);
2628  if(rightvt == VT_DISPATCH)
2629  {
2630  hres = VARIANT_FetchDispatchValue(right, &converted);
2631  if(FAILED(hres))
2632  goto failed;
2633 
2634  tmp = &converted;
2635  }
2636 
2638  if (SUCCEEDED(hres))
2639  right_str = V_BSTR(&converted);
2640  else if (hres != DISP_E_TYPEMISMATCH)
2641  {
2642  VariantClear(&converted);
2643  goto failed;
2644  }
2645  }
2646 
2647 
2648  V_VT(out) = VT_BSTR;
2649  hres = VarBstrCat(left_str, right_str, &V_BSTR(out));
2650 
2651 failed:
2652  if(V_VT(left) != VT_BSTR)
2653  SysFreeString(left_str);
2654  if(V_VT(right) != VT_BSTR)
2655  SysFreeString(right_str);
2656  return hres;
2657 }
Definition: compat.h:1939
Definition: compat.h:1955
Definition: compat.h:1951
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
#define VARIANT_ALPHABOOL
Definition: oleauto.h:311
HRESULT WINAPI VarBstrCat(BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
Definition: vartype.c:7106
OLECHAR * BSTR
Definition: compat.h:1934
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
smooth NULL
Definition: ftsmooth.c:416
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static FILE * out
Definition: regtests2xml.c:44
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
Definition: compat.h:1940
#define V_VT(A)
Definition: oleauto.h:211
Definition: compat.h:1942
#define V_BSTR(A)
Definition: oleauto.h:226
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define S_OK
Definition: intsafe.h:59
unsigned short VARTYPE
Definition: compat.h:1895
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
static HRESULT VARIANT_FetchDispatchValue(LPVARIANT pvDispatch, LPVARIANT pValue)
Definition: variant.c:518
Definition: compat.h:1941
Definition: compat.h:1938
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:991

Referenced by interp_concat(), and test_VarCat().

◆ VarCmp()

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

Definition at line 2715 of file variant.c.

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

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 1409 of file variant.c.

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

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

◆ VarDateFromUdateEx()

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

Definition at line 1348 of file variant.c.

1349 {
1350  UDATE ud;
1351  double dateVal = 0;
1352 
1353  TRACE("(%p->%d/%d/%d %d:%d:%d:%d %d %d,0x%08x,0x%08x,%p)\n", pUdateIn,
1354  pUdateIn->st.wMonth, pUdateIn->st.wDay, pUdateIn->st.wYear,
1355  pUdateIn->st.wHour, pUdateIn->st.wMinute, pUdateIn->st.wSecond,
1356  pUdateIn->st.wMilliseconds, pUdateIn->st.wDayOfWeek,
1357  pUdateIn->wDayOfYear, lcid, dwFlags, pDateOut);
1358 
1360  FIXME("lcid possibly not handled, treating as en-us\n");
1362  FIXME("unsupported flags: %x\n", dwFlags);
1363 
1364  ud = *pUdateIn;
1365 
1366  if (dwFlags & VAR_VALIDDATE)
1367  WARN("Ignoring VAR_VALIDDATE\n");
1368 
1369  if (FAILED(VARIANT_RollUdate(&ud)))
1370  return E_INVALIDARG;
1371 
1372  /* Date */
1373  if (!(dwFlags & VAR_TIMEVALUEONLY))
1375 
1377  {
1378  double dateSign = (dateVal < 0.0) ? -1.0 : 1.0;
1379 
1380  /* Time */
1381  dateVal += ud.st.wHour / 24.0 * dateSign;
1382  dateVal += ud.st.wMinute / 1440.0 * dateSign;
1383  dateVal += ud.st.wSecond / 86400.0 * dateSign;
1384  }
1385 
1386  TRACE("Returning %g\n", dateVal);
1387  *pDateOut = dateVal;
1388  return S_OK;
1389 }
#define MAKELCID(lgid, srtid)
SYSTEMTIME st
Definition: oleauto.h:721
WORD wMonth
Definition: winbase.h:878
WORD wDayOfWeek
Definition: winbase.h:879
#define WARN(fmt,...)
Definition: debug.h:111
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
static HRESULT VARIANT_RollUdate(UDATE *lpUd)
Definition: variant.c:1111
static int VARIANT_DateFromJulian(int dateIn)
Definition: variant.c:1064
WORD wYear
Definition: winbase.h:877
static double VARIANT_JulianFromDMY(USHORT year, USHORT month, USHORT day)
Definition: variant.c:1091
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
WORD wMinute
Definition: winbase.h:882
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define TRACE(s)
Definition: solgame.cpp:4
#define SORT_DEFAULT
WORD wSecond
Definition: winbase.h:883
#define LANG_ENGLISH
Definition: nls.h:52
WORD wMilliseconds
Definition: winbase.h:884
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: oleauto.h:720
WORD wDay
Definition: winbase.h:880
#define S_OK
Definition: intsafe.h:59
WORD wHour
Definition: winbase.h:881
#define MAKELANGID(p, s)
Definition: nls.h:15
#define VAR_VALIDDATE
Definition: oleauto.h:328
USHORT wDayOfYear
Definition: oleauto.h:722

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

◆ VarDiv()

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

Definition at line 3524 of file variant.c.

3525 {
3526  HRESULT hres = S_OK;
3527  VARTYPE resvt = VT_EMPTY;
3528  VARTYPE leftvt,rightvt;
3529  VARTYPE rightExtraFlags,leftExtraFlags,ExtraFlags;
3530  VARIANT lv,rv;
3531  VARIANT tempLeft, tempRight;
3532 
3533  VariantInit(&tempLeft);
3534  VariantInit(&tempRight);
3535  VariantInit(&lv);
3536  VariantInit(&rv);
3537 
3538  TRACE("(%s,%s,%p)\n", debugstr_variant(left), debugstr_variant(right), result);
3539 
3540  /* Handle VT_DISPATCH by storing and taking address of returned value */
3541  if ((V_VT(left) & VT_TYPEMASK) == VT_DISPATCH)
3542  {
3543  hres = VARIANT_FetchDispatchValue(left, &tempLeft);
3544  if (FAILED(hres)) goto end;
3545  left = &tempLeft;
3546  }
3547  if ((V_VT(right) & VT_TYPEMASK) == VT_DISPATCH)
3548  {
3549  hres = VARIANT_FetchDispatchValue(right, &tempRight);
3550  if (FAILED(hres)) goto end;
3551  right = &tempRight;
3552  }
3553 
3554  leftvt = V_VT(left)&VT_TYPEMASK;
3555  rightvt = V_VT(right)&VT_TYPEMASK;
3556  leftExtraFlags = V_VT(left)&(~VT_TYPEMASK);
3557  rightExtraFlags = V_VT(right)&(~VT_TYPEMASK);
3558 
3559  if (leftExtraFlags != rightExtraFlags)
3560  {
3562  goto end;
3563  }
3564  ExtraFlags = leftExtraFlags;
3565 
3566  /* Native VarDiv always returns an error when using extra flags */
3567  if (ExtraFlags != 0)
3568  {
3570  goto end;
3571  }
3572 
3573  /* Determine return type */
3574  if (rightvt != VT_EMPTY)
3575  {
3576  if (leftvt == VT_NULL || rightvt == VT_NULL)
3577  {
3578  V_VT(result) = VT_NULL;
3579  hres = S_OK;
3580  goto end;
3581  }
3582  else if (leftvt == VT_DECIMAL || rightvt == VT_DECIMAL)
3583  resvt = VT_DECIMAL;
3584  else if (leftvt == VT_I8 || rightvt == VT_I8 ||
3585  leftvt == VT_CY || rightvt == VT_CY ||
3586  leftvt == VT_DATE || rightvt == VT_DATE ||
3587  leftvt == VT_I4 || rightvt == VT_I4 ||
3588  leftvt == VT_BSTR || rightvt == VT_BSTR ||
3589  leftvt == VT_I2 || rightvt == VT_I2 ||
3590  leftvt == VT_BOOL || rightvt == VT_BOOL ||
3591  leftvt == VT_R8 || rightvt == VT_R8 ||
3592  leftvt == VT_UI1 || rightvt == VT_UI1)
3593  {
3594  if ((leftvt == VT_UI1 && rightvt == VT_R4) ||
3595  (leftvt == VT_R4 && rightvt == VT_UI1))
3596  resvt = VT_R4;
3597  else if ((leftvt == VT_R4 && (rightvt == VT_BOOL ||
3598  rightvt == VT_I2)) || (rightvt == VT_R4 &&
3599  (leftvt == VT_BOOL || leftvt == VT_I2)))
3600  resvt = VT_R4;
3601  else
3602  resvt = VT_R8;
3603  }
3604  else if (leftvt == VT_R4 || rightvt == VT_R4)
3605  resvt = VT_R4;
3606  }
3607  else if (leftvt == VT_NULL)
3608  {
3609  V_VT(result) = VT_NULL;
3610  hres = S_OK;
3611  goto end;
3612  }
3613  else
3614  {
3616  goto end;
3617  }
3618 
3619  /* coerce to the result type */
3620  hres = VariantChangeType(&lv, left, 0, resvt);
3621  if (hres != S_OK) goto end;
3622 
3623  hres = VariantChangeType(&rv, right, 0, resvt);
3624  if (hres != S_OK) goto end;
3625 
3626  /* do the math */
3627  V_VT(result) = resvt;
3628  switch (resvt)
3629  {
3630  case VT_R4:
3631  if (V_R4(&lv) == 0.0 && V_R4(&rv) == 0.0)
3632  {
3634  V_VT(result) = VT_EMPTY;
3635  }
3636  else if (V_R4(&rv) == 0.0)
3637  {
3639  V_VT(result) = VT_EMPTY;
3640  }
3641  else
3642  V_R4(result) = V_R4(&lv) / V_R4(&rv);
3643  break;
3644  case VT_R8:
3645  if (V_R8(&lv) == 0.0 && V_R8(&rv) == 0.0)
3646  {
3648  V_VT(result) = VT_EMPTY;
3649  }
3650  else if (V_R8(&rv) == 0.0)
3651  {
3653  V_VT(result) = VT_EMPTY;
3654  }
3655  else
3656  V_R8(result) = V_R8(&lv) / V_R8(&rv);
3657  break;
3658  case VT_DECIMAL:
3659  hres = VarDecDiv(&(V_DECIMAL(&lv)), &(V_DECIMAL(&rv)), &(V_DECIMAL(result)));
3660  break;
3661  }
3662 
3663 end:
3664  VariantClear(&lv);
3665  VariantClear(&rv);
3666  VariantClear(&tempLeft);
3667  VariantClear(&tempRight);
3668  TRACE("returning 0x%8x %s\n", hres, debugstr_variant(result));
3669  return hres;
3670 }
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:965
Definition: compat.h:1939
Definition: compat.h:1955
#define V_R8(A)
Definition: oleauto.h:262
GLuint GLuint end
Definition: gl.h:1545
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
HRESULT WINAPI VarDecDiv(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:5600
#define V_DECIMAL(A)
Definition: oleauto.h:236
#define V_R4(A)
Definition: oleauto.h:260
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static const VARTYPE ExtraFlags[16]
Definition: vartest.c:689
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
Definition: compat.h:1940
#define V_VT(A)
Definition: oleauto.h:211
Definition: compat.h:1942
#define DISP_E_DIVBYZERO
Definition: winerror.h:2527
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define S_OK
Definition: intsafe.h:59
unsigned short VARTYPE
Definition: compat.h:1895
static HRESULT VARIANT_FetchDispatchValue(LPVARIANT pvDispatch, LPVARIANT pValue)
Definition: variant.c:518
GLuint64EXT * result
Definition: glext.h:11304
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
Definition: compat.h:1941
Definition: compat.h:1938

Referenced by interp_div(), and test_VarDiv().

◆ VarEqv()

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

Definition at line 4730 of file variant.c.

4731 {
4732  HRESULT hRet;
4733 
4734  TRACE("(%s,%s,%p)\n", debugstr_variant(pVarLeft), debugstr_variant(pVarRight), pVarOut);
4735 
4736  hRet = VarXor(pVarLeft, pVarRight, pVarOut);
4737  if (SUCCEEDED(hRet))
4738  {
4739  if (V_VT(pVarOut) == VT_I8)
4740  V_I8(pVarOut) = ~V_I8(pVarOut);
4741  else
4742  V_UI4(pVarOut) = ~V_UI4(pVarOut);
4743  }
4744  return hRet;
4745 }
Definition: compat.h:1955
#define V_I8(A)
Definition: oleauto.h:249
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define V_UI4(A)
Definition: oleauto.h:270
#define V_VT(A)
Definition: oleauto.h:211
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
HRESULT WINAPI VarXor(LPVARIANT pVarLeft, LPVARIANT pVarRight, LPVARIANT pVarOut)
Definition: variant.c:4549
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by interp_eqv(), and test_VarEqv().

◆ VarFix()

HRESULT WINAPI VarFix ( LPVARIANT  pVarIn,
LPVARIANT  pVarOut 
)

Definition at line 4370 of file variant.c.

4371 {
4372  HRESULT hRet = S_OK;
4373  VARIANT temp;
4374 
4375  VariantInit(&temp);
4376 
4377  TRACE("(%s,%p)\n", debugstr_variant(pVarIn), pVarOut);
4378 
4379  /* Handle VT_DISPATCH by storing and taking address of returned value */
4380  if ((V_VT(pVarIn) & VT_TYPEMASK) == VT_DISPATCH && ((V_VT(pVarIn) & ~VT_TYPEMASK) == 0))
4381  {
4382  hRet = VARIANT_FetchDispatchValue(pVarIn, &temp);
4383  if (FAILED(hRet)) goto VarFix_Exit;
4384  pVarIn = &temp;
4385  }
4386  V_VT(pVarOut) = V_VT(pVarIn);
4387 
4388  switch (V_VT(pVarIn))
4389  {
4390  case VT_UI1:
4391  V_UI1(pVarOut) = V_UI1(pVarIn);
4392  break;
4393  case VT_BOOL:
4394  V_VT(pVarOut) = VT_I2;
4395  /* Fall through */
4396  case VT_I2:
4397  V_I2(pVarOut) = V_I2(pVarIn);
4398  break;
4399  case VT_I4:
4400  V_I4(pVarOut) = V_I4(pVarIn);
4401  break;
4402  case VT_I8:
4403  V_I8(pVarOut) = V_I8(pVarIn);
4404  break;
4405  case VT_R4:
4406  if (V_R4(pVarIn) < 0.0f)
4407  V_R4(pVarOut) = (float)ceil(V_R4(pVarIn));
4408  else
4409  V_R4(pVarOut) = (float)floor(V_R4(pVarIn));
4410  break;
4411  case VT_BSTR:
4412  V_VT(pVarOut) = VT_R8;
4413  hRet = VarR8FromStr(V_BSTR(pVarIn), LOCALE_USER_DEFAULT, 0, &V_R8(pVarOut));
4414  pVarIn = pVarOut;
4415  /* Fall through */
4416  case VT_DATE:
4417  case VT_R8:
4418  if (V_R8(pVarIn) < 0.0)
4419  V_R8(pVarOut) = ceil(V_R8(pVarIn));
4420  else
4421  V_R8(pVarOut) = floor(V_R8(pVarIn));
4422  break;
4423  case VT_CY:
4424  hRet = VarCyFix(V_CY(pVarIn), &V_CY(pVarOut));
4425  break;
4426  case VT_DECIMAL:
4427  hRet = VarDecFix(&V_DECIMAL(pVarIn), &V_DECIMAL(pVarOut));
4428  break;
4429  case VT_EMPTY:
4430  V_VT(pVarOut) = VT_I2;
4431  V_I2(pVarOut) = 0;
4432  break;
4433  case VT_NULL:
4434  /* No-Op */
4435  break;
4436  default:
4437  if (V_TYPE(pVarIn) == VT_CLSID || /* VT_CLSID is a special case */
4438  FAILED(VARIANT_ValidateType(V_VT(pVarIn))))
4439  hRet = DISP_E_BADVARTYPE;
4440  else
4441  hRet = DISP_E_TYPEMISMATCH;
4442  }
4443 VarFix_Exit:
4444  if (FAILED(hRet))
4445  V_VT(pVarOut) = VT_EMPTY;
4446  VariantClear(&temp);
4447 
4448  return hRet;
4449 }
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
Definition: compat.h:1939
Definition: compat.h:1955
#define LOCALE_USER_DEFAULT
#define V_R8(A)
Definition: oleauto.h:262
#define V_I2(A)
Definition: oleauto.h:245
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3150
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
#define V_I4(A)
Definition: oleauto.h:247
#define V_CY(A)
Definition: oleauto.h:229
#define V_I8(A)
Definition: oleauto.h:249
#define V_DECIMAL(A)
Definition: oleauto.h:236
GLfloat f
Definition: glext.h:7540
#define V_R4(A)
Definition: oleauto.h:260
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define V_UI1(A)
Definition: oleauto.h:266
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
Definition: compat.h:1940
#define V_VT(A)
Definition: oleauto.h:211
Definition: compat.h:1942
#define V_BSTR(A)
Definition: oleauto.h:226
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define S_OK
Definition: intsafe.h:59
static calc_node_t temp
Definition: rpn_ieee.c:38
#define V_TYPE(v)
Definition: variant.h:30
HRESULT WINAPI VarDecFix(const DECIMAL *pDecIn, DECIMAL *pDecOut)
Definition: vartype.c:5721
static HRESULT VARIANT_FetchDispatchValue(LPVARIANT pvDispatch, LPVARIANT pValue)
Definition: variant.c:518
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
static HRESULT VARIANT_ValidateType(VARTYPE vt)
Definition: variant.c:537
HRESULT WINAPI VarCyFix(CY cyIn, CY *pCyOut)
Definition: vartype.c:3901
Definition: compat.h:1941
Definition: compat.h:1938

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

◆ VARIANT_ClearInd()

HRESULT VARIANT_ClearInd ( VARIANTARG pVarg)

Definition at line 579 of file variant.c.

580 {
581  HRESULT hres;
582 
583  TRACE("(%s)\n", debugstr_variant(pVarg));
584 
585  hres = VARIANT_ValidateType(V_VT(pVarg));
586  if (FAILED(hres))
587  return hres;
588 
589  switch (V_VT(pVarg))
590  {
591  case VT_DISPATCH:
592  case VT_UNKNOWN:
593  if (V_UNKNOWN(pVarg))
594  IUnknown_Release(V_UNKNOWN(pVarg));
595  break;
596  case VT_UNKNOWN | VT_BYREF:
597  case VT_DISPATCH | VT_BYREF:
598  if(*V_UNKNOWNREF(pVarg))
599  IUnknown_Release(*V_UNKNOWNREF(pVarg));
600  break;
601  case VT_BSTR:
602  SysFreeString(V_BSTR(pVarg));
603  break;
604  case VT_BSTR | VT_BYREF:
605  SysFreeString(*V_BSTRREF(pVarg));
606  break;
607  case VT_VARIANT | VT_BYREF:
608  VariantClear(V_VARIANTREF(pVarg));
609  break;
610  case VT_RECORD:
611  case VT_RECORD | VT_BYREF:
612  {
613  struct __tagBRECORD* pBr = &V_UNION(pVarg,brecVal);
614  if (pBr->pRecInfo)
615  {
616  IRecordInfo_RecordClear(pBr->pRecInfo, pBr->pvRecord);
617  IRecordInfo_Release(pBr->pRecInfo);
618  }
619  break;
620  }
621  default:
622  if (V_ISARRAY(pVarg) || (V_VT(pVarg) & ~VT_BYREF) == VT_SAFEARRAY)
623  {
624  if (V_ISBYREF(pVarg))
625  {
626  if (*V_ARRAYREF(pVarg))
627  hres = SafeArrayDestroy(*V_ARRAYREF(pVarg));
628  }
629  else if (V_ARRAY(pVarg))
630  hres = SafeArrayDestroy(V_ARRAY(pVarg));
631  }
632  break;
633  }
634 
635  V_VT(pVarg) = VT_EMPTY;
636  return hres;
637 }
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_ISBYREF(A)
Definition: oleauto.h:217
#define V_UNKNOWNREF(A)
Definition: oleauto.h:282
#define V_ISARRAY(A)
Definition: oleauto.h:218
#define V_ARRAYREF(A)
Definition: oleauto.h:223
#define __tagBRECORD
Definition: compat.h:2015
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1349
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
#define V_VT(A)
Definition: oleauto.h:211
#define V_UNKNOWN(A)
Definition: oleauto.h:281
#define V_BSTR(A)
Definition: oleauto.h:226
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define V_UNION(A, B)
Definition: oleauto.h:212
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
#define V_VARIANTREF(A)
Definition: oleauto.h:283
static HRESULT VARIANT_ValidateType(VARTYPE vt)
Definition: variant.c:537
#define V_BSTRREF(A)
Definition: oleauto.h:227

Referenced by ITypeInfo_fnInvoke().

◆ VARIANT_Coerce()

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

Definition at line 58 of file variant.c.

60 {
62  VARTYPE vtFrom = V_TYPE(ps);
63  DWORD dwFlags = 0;
64 
65  TRACE("(%s,0x%08x,0x%04x,%s,%s)\n", debugstr_variant(pd), lcid, wFlags,
66  debugstr_variant(ps), debugstr_vt(vt));
67 
68  if (vt == VT_BSTR || vtFrom == VT_BSTR)
69  {
70  /* All flags passed to low level function are only used for
71  * changing to or from strings. Map these here.
72  */
83  if (wFlags & VARIANT_USE_NLS)
85  }
86 
87  /* Map int/uint to i4/ui4 */
88  if (vt == VT_INT)
89  vt = VT_I4;
90  else if (vt == VT_UINT)
91  vt = VT_UI4;
92 
93  if (vtFrom == VT_INT)
94  vtFrom = VT_I4;
95  else if (vtFrom == VT_UINT)
96  vtFrom = VT_UI4;
97 
98  if (vt == vtFrom)
99  return VariantCopy(pd, ps);
100 
101  if (wFlags & VARIANT_NOVALUEPROP && vtFrom == VT_DISPATCH && vt != VT_UNKNOWN)
102  {
103  /* VARIANT_NOVALUEPROP prevents IDispatch objects from being coerced by
104  * accessing the default object property.
105  */
106  return DISP_E_TYPEMISMATCH;
107  }
108 
109  switch (vt)
110  {
111  case VT_EMPTY:
112  if (vtFrom == VT_NULL)
113  return DISP_E_TYPEMISMATCH;
114  /* ... Fall through */
115  case VT_NULL:
116  if (vtFrom <= VT_UINT && vtFrom != (VARTYPE)15 && vtFrom != VT_ERROR)
117  {
118  res = VariantClear( pd );
119  if (vt == VT_NULL && SUCCEEDED(res))
120  V_VT(pd) = VT_NULL;
121  }
122  return res;
123 
124  case VT_I1:
125  switch (vtFrom)
126  {
127  case VT_EMPTY: V_I1(pd) = 0; return S_OK;
128  case VT_I2: return VarI1FromI2(V_I2(ps), &V_I1(pd));
129  case VT_I4: return VarI1FromI4(V_I4(ps), &V_I1(pd));
130  case VT_UI1: V_I1(pd) = V_UI1(ps); return S_OK;
131  case VT_UI2: return VarI1FromUI2(V_UI2(ps), &V_I1(pd));
132  case VT_UI4: return VarI1FromUI4(V_UI4(ps), &V_I1(pd));
133  case VT_I8: return VarI1FromI8(V_I8(ps), &V_I1(pd));
134  case VT_UI8: return VarI1FromUI8(V_UI8(ps), &V_I1(pd));
135  case VT_R4: return VarI1FromR4(V_R4(ps), &V_I1(pd));
136  case VT_R8: return VarI1FromR8(V_R8(ps), &V_I1(pd));
137  case VT_DATE: return VarI1FromDate(V_DATE(ps), &V_I1(pd));
138  case VT_BOOL: return VarI1FromBool(V_BOOL(ps), &V_I1(pd));
139  case VT_CY: return VarI1FromCy(V_CY(ps), &V_I1(pd));
140  case VT_DECIMAL: return VarI1FromDec(&V_DECIMAL(ps), &V_I1(pd) );
141  case VT_DISPATCH: return VarI1FromDisp(V_DISPATCH(ps), lcid, &V_I1(pd) );
142  case VT_BSTR: return VarI1FromStr(V_BSTR(ps), lcid, dwFlags, &V_I1(pd) );
143  }
144  break;
145 
146  case VT_I2:
147  switch (vtFrom)
148  {
149  case VT_EMPTY: V_I2(pd) = 0; return S_OK;
150  case VT_I1: return VarI2FromI1(V_I1(ps), &V_I2(pd));
151  case VT_I4: return VarI2FromI4(V_I4(ps), &V_I2(pd));
152  case VT_UI1: return VarI2FromUI1(V_UI1(ps), &V_I2(pd));
153  case VT_UI2: V_I2(pd) = V_UI2(ps); return S_OK;
154  case VT_UI4: return VarI2FromUI4(V_UI4(ps), &V_I2(pd));
155  case VT_I8: return VarI2FromI8(V_I8(ps), &V_I2(pd));
156  case VT_UI8: return VarI2FromUI8(V_UI8(ps), &V_I2(pd));
157  case VT_R4: return VarI2FromR4(V_R4(ps), &V_I2(pd));
158  case VT_R8: return VarI2FromR8(V_R8(ps), &V_I2(pd));
159  case VT_DATE: return VarI2FromDate(V_DATE(ps), &V_I2(pd));
160  case VT_BOOL: return VarI2FromBool(V_BOOL(ps), &V_I2(pd));
161  case VT_CY: return VarI2FromCy(V_CY(ps), &V_I2(pd));
162  case VT_DECIMAL: return VarI2FromDec(&V_DECIMAL(ps), &V_I2(pd));
163  case VT_DISPATCH: return VarI2FromDisp(V_DISPATCH(ps), lcid, &V_I2(pd));
164  case VT_BSTR: return VarI2FromStr(V_BSTR(ps), lcid, dwFlags, &V_I2(pd));
165  }
166  break;
167 
168  case VT_I4:
169  switch (vtFrom)
170  {
171  case VT_EMPTY: V_I4(pd) = 0; return S_OK;
172  case VT_I1: return VarI4FromI1(V_I1(ps), &V_I4(pd));
173  case VT_I2: return VarI4FromI2(V_I2(ps), &V_I4(pd));
174  case VT_UI1: return VarI4FromUI1(V_UI1(ps), &V_I4(pd));
175  case VT_UI2: return VarI4FromUI2(V_UI2(ps), &V_I4(pd));
176  case VT_UI4: V_I4(pd) = V_UI4(ps); return S_OK;
177  case VT_I8: return VarI4FromI8(V_I8(ps), &V_I4(pd));
178  case VT_UI8: return VarI4FromUI8(V_UI8(ps), &V_I4(pd));
179  case VT_R4: return VarI4FromR4(V_R4(ps), &V_I4(pd));
180  case VT_R8: return VarI4FromR8(V_R8(ps), &V_I4(pd));
181  case VT_DATE: return VarI4FromDate(V_DATE(ps), &V_I4(pd));
182  case VT_BOOL: return VarI4FromBool(V_BOOL(ps), &V_I4(pd));
183  case VT_CY: return VarI4FromCy(V_CY(ps), &V_I4(pd));
184  case VT_DECIMAL: return VarI4FromDec(&V_DECIMAL(ps), &V_I4(pd));
185  case VT_DISPATCH: return VarI4FromDisp(V_DISPATCH(ps), lcid, &V_I4(pd));
186  case VT_BSTR: return VarI4FromStr(V_BSTR(ps), lcid, dwFlags, &V_I4(pd));
187  }
188  break;
189 
190  case VT_UI1:
191  switch (vtFrom)
192  {
193  case VT_EMPTY: V_UI1(pd) = 0; return S_OK;
194  case VT_I1: V_UI1(pd) = V_I1(ps); return S_OK;
195  case VT_I2: return VarUI1FromI2(V_I2(ps), &V_UI1(pd));
196  case VT_I4: return VarUI1FromI4(V_I4(ps), &V_UI1(pd));
197  case VT_UI2: return VarUI1FromUI2(V_UI2(ps), &V_UI1(pd));
198  case VT_UI4: return VarUI1FromUI4(V_UI4(ps), &V_UI1(pd));
199  case VT_I8: return VarUI1FromI8(V_I8(ps), &V_UI1(pd));
200  case VT_UI8: return VarUI1FromUI8(V_UI8(ps), &V_UI1(pd));
201  case VT_R4: return VarUI1FromR4(V_R4(ps), &V_UI1(pd));
202  case VT_R8: return VarUI1FromR8(V_R8(ps), &V_UI1(pd));
203  case VT_DATE: return VarUI1FromDate(V_DATE(ps), &V_UI1(pd));
204  case VT_BOOL: return VarUI1FromBool(V_BOOL(ps), &V_UI1(pd));
205  case VT_CY: return VarUI1FromCy(V_CY(ps), &V_UI1(pd));
206  case VT_DECIMAL: return VarUI1FromDec(&V_DECIMAL(ps), &V_UI1(pd));
207  case VT_DISPATCH: return VarUI1FromDisp(V_DISPATCH(ps), lcid, &V_UI1(pd));
208  case VT_BSTR: return VarUI1FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI1(pd));
209  }
210  break;
211 
212  case VT_UI2:
213  switch (vtFrom)
214  {
215  case VT_EMPTY: V_UI2(pd) = 0; return S_OK;
216  case VT_I1: return VarUI2FromI1(V_I1(ps), &V_UI2(pd));
217  case VT_I2: V_UI2(pd) = V_I2(ps); return S_OK;
218  case VT_I4: return VarUI2FromI4(V_I4(ps), &V_UI2(pd));
219  case VT_UI1: return VarUI2FromUI1(V_UI1(ps), &V_UI2(pd));
220  case VT_UI4: return VarUI2FromUI4(V_UI4(ps), &V_UI2(pd));
221  case VT_I8: return VarUI4FromI8(V_I8(ps), &V_UI4(pd));
222  case VT_UI8: return VarUI4FromUI8(V_UI8(ps), &V_UI4(pd));
223  case VT_R4: return VarUI2FromR4(V_R4(ps), &V_UI2(pd));
224  case VT_R8: return VarUI2FromR8(V_R8(ps), &V_UI2(pd));
225  case VT_DATE: return VarUI2FromDate(V_DATE(ps), &V_UI2(pd));
226  case VT_BOOL: return VarUI2FromBool(V_BOOL(ps), &V_UI2(pd));
227  case VT_CY: return VarUI2FromCy(V_CY(ps), &V_UI2(pd));
228  case VT_DECIMAL: return VarUI2FromDec(&V_DECIMAL(ps), &V_UI2(pd));
229  case VT_DISPATCH: return VarUI2FromDisp(V_DISPATCH(ps), lcid, &V_UI2(pd));
230  case VT_BSTR: return VarUI2FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI2(pd));
231  }
232  break;
233 
234  case VT_UI4:
235  switch (vtFrom)
236  {
237  case VT_EMPTY: V_UI4(pd) = 0; return S_OK;
238  case VT_I1: return VarUI4FromI1(V_I1(ps), &V_UI4(pd));
239  case VT_I2: return VarUI4FromI2(V_I2(ps), &V_UI4(pd));
240  case VT_I4: V_UI4(pd) = V_I4(ps); return S_OK;
241  case VT_UI1: return VarUI4FromUI1(V_UI1(ps), &V_UI4(pd));
242  case VT_UI2: return VarUI4FromUI2(V_UI2(ps), &V_UI4(pd));
243  case VT_I8: return VarUI4FromI8(V_I8(ps), &V_UI4(pd));
244  case VT_UI8: return VarUI4FromUI8(V_UI8(ps), &V_UI4(pd));
245  case VT_R4: return VarUI4FromR4(V_R4(ps), &V_UI4(pd));
246  case VT_R8: return VarUI4FromR8(V_R8(ps), &V_UI4(pd));
247  case VT_DATE: return VarUI4FromDate(V_DATE(ps), &V_UI4(pd));
248  case VT_BOOL: return VarUI4FromBool(V_BOOL(ps), &V_UI4(pd));
249  case VT_CY: return VarUI4FromCy(V_CY(ps), &V_UI4(pd));
250  case VT_DECIMAL: return VarUI4FromDec(&V_DECIMAL(ps), &V_UI4(pd));
251  case VT_DISPATCH: return VarUI4FromDisp(V_DISPATCH(ps), lcid, &V_UI4(pd));
252  case VT_BSTR: return VarUI4FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI4(pd));
253  }
254  break;
255 
256  case VT_UI8:
257  switch (vtFrom)
258  {
259  case VT_EMPTY: V_UI8(pd) = 0; return S_OK;
260  case VT_I4: if (V_I4(ps) < 0) return DISP_E_OVERFLOW; V_UI8(pd) = V_I4(ps); return S_OK;
261  case VT_I1: return VarUI8FromI1(V_I1(ps), &V_UI8(pd));
262  case VT_I2: return VarUI8FromI2(V_I2(ps), &V_UI8(pd));
263  case VT_UI1: return VarUI8FromUI1(V_UI1(ps), &V_UI8(pd));
264  case VT_UI2: return VarUI8FromUI2(V_UI2(ps), &V_UI8(pd));
265  case VT_UI4: return VarUI8FromUI4(V_UI4(ps), &V_UI8(pd));
266  case VT_I8: V_UI8(pd) = V_I8(ps); return S_OK;
267  case VT_R4: return VarUI8FromR4(V_R4(ps), &V_UI8(pd));
268  case VT_R8: return VarUI8FromR8(V_R8(ps), &V_UI8(pd));
269  case VT_DATE: return VarUI8FromDate(V_DATE(ps), &V_UI8(pd));
270  case VT_BOOL: return VarUI8FromBool(V_BOOL(ps), &V_UI8(pd));
271  case VT_CY: return VarUI8FromCy(V_CY(ps), &V_UI8(pd));
272  case VT_DECIMAL: return VarUI8FromDec(&V_DECIMAL(ps), &V_UI8(pd));
273  case VT_DISPATCH: return VarUI8FromDisp(V_DISPATCH(ps), lcid, &V_UI8(pd));
274  case VT_BSTR: return VarUI8FromStr(V_BSTR(ps), lcid, dwFlags, &V_UI8(pd));
275  }
276  break;
277 
278  case VT_I8:
279  switch (vtFrom)
280  {
281  case VT_EMPTY: V_I8(pd) = 0; return S_OK;
282  case VT_I4: V_I8(pd) = V_I4(ps); return S_OK;
283  case VT_I1: return VarI8FromI1(V_I1(ps), &V_I8(pd));
284  case VT_I2: return VarI8FromI2(V_I2(ps), &V_I8(pd));
285  case VT_UI1: return VarI8FromUI1(V_UI1(ps), &V_I8(pd));
286  case VT_UI2: return VarI8FromUI2(V_UI2(ps), &V_I8(pd));
287  case VT_UI4: return VarI8FromUI4(V_UI4(ps), &V_I8(pd));
288  case VT_UI8: V_I8(pd) = V_UI8(ps); return S_OK;
289  case VT_R4: return VarI8FromR4(V_R4(ps), &V_I8(pd));
290  case VT_R8: return VarI8FromR8(V_R8(ps), &V_I8(pd));
291  case VT_DATE: return VarI8FromDate(V_DATE(ps), &V_I8(pd));
292  case VT_BOOL: return VarI8FromBool(V_BOOL(ps), &V_I8(pd));
293  case VT_CY: return VarI8FromCy(V_CY(ps), &V_I8(pd));
294  case VT_DECIMAL: return VarI8FromDec(&V_DECIMAL(ps), &V_I8(pd));
295  case VT_DISPATCH: return VarI8FromDisp(V_DISPATCH(ps), lcid, &V_I8(pd));
296  case VT_BSTR: return VarI8FromStr(V_BSTR(ps), lcid, dwFlags, &V_I8(pd));
297  }
298  break;
299 
300  case VT_R4:
301  switch (vtFrom)
302  {
303  case VT_EMPTY: V_R4(pd) = 0.0f; return S_OK;
304  case VT_I1: return VarR4FromI1(V_I1(ps), &V_R4(pd));
305  case VT_I2: return VarR4FromI2(V_I2(ps), &V_R4(pd));
306  case VT_I4: return VarR4FromI4(V_I4(ps), &V_R4(pd));
307  case VT_UI1: return VarR4FromUI1(V_UI1(ps), &V_R4(pd));
308  case VT_UI2: return VarR4FromUI2(V_UI2(ps), &V_R4(pd));
309  case VT_UI4: return VarR4FromUI4(V_UI4(ps), &V_R4(pd));
310  case VT_I8: return VarR4FromI8(V_I8(ps), &V_R4(pd));
311  case VT_UI8: return VarR4FromUI8(V_UI8(ps), &V_R4(pd));
312  case VT_R8: return VarR4FromR8(V_R8(ps), &V_R4(pd));
313  case VT_DATE: return VarR4FromDate(V_DATE(ps), &V_R4(pd));
314  case VT_BOOL: return VarR4FromBool(V_BOOL(ps), &V_R4(pd));
315  case VT_CY: return VarR4FromCy(V_CY(ps), &V_R4(pd));
316  case VT_DECIMAL: return VarR4FromDec(&V_DECIMAL(ps), &V_R4(pd));
317  case VT_DISPATCH: return VarR4FromDisp(V_DISPATCH(ps), lcid, &V_R4(pd));
318  case VT_BSTR: return VarR4FromStr(V_BSTR(ps), lcid, dwFlags, &V_R4(pd));
319  }
320  break;
321 
322  case VT_R8:
323  switch (vtFrom)
324  {
325  case VT_EMPTY: V_R8(pd) = 0.0; return S_OK;
326  case VT_I1: return VarR8FromI1(V_I1(ps), &V_R8(pd));
327  case VT_I2: return VarR8FromI2(V_I2(ps), &V_R8(pd));
328  case VT_I4: return VarR8FromI4(V_I4(ps), &V_R8(pd));
329  case VT_UI1: return VarR8FromUI1(V_UI1(ps), &V_R8(pd));
330  case VT_UI2: return VarR8FromUI2(V_UI2(ps), &V_R8(pd));
331  case VT_UI4: return VarR8FromUI4(V_UI4(ps), &V_R8(pd));
332  case VT_I8: return VarR8FromI8(V_I8(ps), &V_R8(pd));
333  case VT_UI8: return VarR8FromUI8(V_UI8(ps), &V_R8(pd));
334  case VT_R4: return VarR8FromR4(V_R4(ps), &V_R8(pd));
335  case VT_DATE: return VarR8FromDate(V_DATE(ps), &V_R8(pd));
336  case VT_BOOL: return VarR8FromBool(V_BOOL(ps), &V_R8(pd));
337  case VT_CY: return VarR8FromCy(V_CY(ps), &V_R8(pd));
338  case VT_DECIMAL: return VarR8FromDec(&V_DECIMAL(ps), &V_R8(pd));
339  case VT_DISPATCH: return VarR8FromDisp(V_DISPATCH(ps), lcid, &V_R8(pd));
340  case VT_BSTR: return VarR8FromStr(V_BSTR(ps), lcid, dwFlags, &V_R8(pd));
341  }
342  break;
343 
344  case VT_DATE:
345  switch (vtFrom)
346  {
347  case VT_EMPTY: V_DATE(pd) = 0.0; return S_OK;
348  case VT_I1: return VarDateFromI1(V_I1(ps), &V_DATE(pd));
349  case VT_I2: return VarDateFromI2(V_I2(ps), &V_DATE(pd));
350  case VT_I4: return VarDateFromI4(V_I4(ps), &V_DATE(pd));
351  case VT_UI1: return VarDateFromUI1(V_UI1(ps), &V_DATE(pd));
352  case VT_UI2: return VarDateFromUI2(V_UI2(ps), &V_DATE(pd));
353  case VT_UI4: return VarDateFromUI4(V_UI4(ps), &V_DATE(pd));
354  case VT_I8: return VarDateFromI8(V_I8(ps), &V_DATE(pd));
355  case VT_UI8: return VarDateFromUI8(V_UI8(ps), &V_DATE(pd));
356  case VT_R4: return VarDateFromR4(V_R4(ps), &V_DATE(pd));
357  case VT_R8: return VarDateFromR8(V_R8(ps), &V_DATE(pd));
358  case VT_BOOL: return VarDateFromBool(V_BOOL(ps), &V_DATE(pd));
359  case VT_CY: return VarDateFromCy(V_CY(ps), &V_DATE(pd));
360  case VT_DECIMAL: return VarDateFromDec(&V_DECIMAL(ps), &V_DATE(pd));
361  case VT_DISPATCH: return VarDateFromDisp(V_DISPATCH(ps), lcid, &V_DATE(pd));
362  case VT_BSTR: return VarDateFromStr(V_BSTR(ps), lcid, dwFlags, &V_DATE(pd));
363  }
364  break;
365 
366  case VT_BOOL:
367  switch (vtFrom)
368  {
369  case VT_EMPTY: V_BOOL(pd) = 0; return S_OK;
370  case VT_I1: return VarBoolFromI1(V_I1(ps), &V_BOOL(pd));
371  case VT_I2: return VarBoolFromI2(V_I2(ps), &V_BOOL(pd));
372  case VT_I4: return VarBoolFromI4(V_I4(ps), &V_BOOL(pd));
373  case VT_UI1: return VarBoolFromUI1(V_UI1(ps), &V_BOOL(pd));
374  case VT_UI2: return VarBoolFromUI2(V_UI2(ps), &V_BOOL(pd));
375  case VT_UI4: return VarBoolFromUI4(V_UI4(ps), &V_BOOL(pd));
376  case VT_I8: return VarBoolFromI8(V_I8(ps), &V_BOOL(pd));
377  case VT_UI8: return VarBoolFromUI8(V_UI8(ps), &V_BOOL(pd));
378  case VT_R4: return VarBoolFromR4(V_R4(ps), &V_BOOL(pd));
379  case VT_R8: return VarBoolFromR8(V_R8(ps), &V_BOOL(pd));
380  case VT_DATE: return VarBoolFromDate(V_DATE(ps), &V_BOOL(pd));
381  case VT_CY: return VarBoolFromCy(V_CY(ps), &V_BOOL(pd));
382  case VT_DECIMAL: return VarBoolFromDec(&V_DECIMAL(ps), &V_BOOL(pd));
383  case VT_DISPATCH: return VarBoolFromDisp(V_DISPATCH(ps), lcid, &V_BOOL(pd));
384  case VT_BSTR: return VarBoolFromStr(V_BSTR(ps), lcid, dwFlags, &V_BOOL(pd));
385  }
386  break;
387 
388  case VT_BSTR:
389  switch (vtFrom)
390  {
391  case VT_EMPTY:
392  V_BSTR(pd) = SysAllocStringLen(NULL, 0);
393  return V_BSTR(pd) ? S_OK : E_OUTOFMEMORY;
394  case VT_BOOL:
396  return VarBstrFromBool(V_BOOL(ps), lcid, dwFlags, &V_BSTR(pd));
397  return VarBstrFromI2(V_BOOL(ps), lcid, dwFlags, &V_BSTR(pd));
398  case VT_I1: return VarBstrFromI1(V_I1(ps), lcid, dwFlags, &V_BSTR(pd));
399  case VT_I2: return VarBstrFromI2(V_I2(ps), lcid, dwFlags, &V_BSTR(pd));
400  case VT_I4: return VarBstrFromI4(V_I4(ps), lcid, dwFlags, &V_BSTR(pd));
401  case VT_UI1: return VarBstrFromUI1(V_UI1(ps), lcid, dwFlags, &V_BSTR(pd));
402  case VT_UI2: return VarBstrFromUI2(V_UI2(ps), lcid, dwFlags, &V_BSTR(pd));
403  case VT_UI4: return VarBstrFromUI4(V_UI4(ps), lcid, dwFlags, &V_BSTR(pd));
404  case VT_I8: return VarBstrFromI8(V_I8(ps), lcid, dwFlags, &V_BSTR(pd));
405  case VT_UI8: return VarBstrFromUI8(V_UI8(ps), lcid, dwFlags, &V_BSTR(pd));
406  case VT_R4: return VarBstrFromR4(V_R4(ps), lcid, dwFlags, &V_BSTR(pd));
407  case VT_R8: return VarBstrFromR8(V_R8(ps), lcid, dwFlags, &V_BSTR(pd));
408  case VT_DATE: return VarBstrFromDate(V_DATE(ps), lcid, dwFlags, &V_BSTR(pd));
409  case VT_CY: return VarBstrFromCy(V_CY(ps), lcid, dwFlags, &V_BSTR(pd));
410  case VT_DECIMAL: return VarBstrFromDec(&V_DECIMAL(ps), lcid, dwFlags, &V_BSTR(pd));
411  case VT_DISPATCH: return VarBstrFromDisp(V_DISPATCH(ps), lcid, dwFlags, &V_BSTR(pd));
412  }
413  break;
414 
415  case VT_CY:
416  switch (vtFrom)
417  {
418  case VT_EMPTY: V_CY(pd).int64 = 0; return S_OK;
419  case VT_I1: return VarCyFromI1(V_I1(ps), &V_CY(pd));
420  case VT_I2: return VarCyFromI2(V_I2(ps), &V_CY(pd));
421  case VT_I4: return VarCyFromI4(V_I4(ps), &V_CY(pd));
422  case VT_UI1: return VarCyFromUI1(V_UI1(ps), &V_CY(pd));
423  case VT_UI2: return VarCyFromUI2(V_UI2(ps), &V_CY(pd));
424  case VT_UI4: return VarCyFromUI4(V_UI4(ps), &V_CY(pd));
425  case VT_I8: return VarCyFromI8(V_I8(ps), &V_CY(pd));
426  case VT_UI8: return VarCyFromUI8(V_UI8(ps), &V_CY(pd));
427  case VT_R4: return VarCyFromR4(V_R4(ps), &V_CY(pd));
428  case VT_R8: return VarCyFromR8(V_R8(ps), &V_CY(pd));
429  case VT_DATE: return VarCyFromDate(V_DATE(ps), &V_CY(pd));
430  case VT_BOOL: return VarCyFromBool(V_BOOL(ps), &V_CY(pd));
431  case VT_DECIMAL: return VarCyFromDec(&V_DECIMAL(ps), &V_CY(pd));
432  case VT_DISPATCH: return VarCyFromDisp(V_DISPATCH(ps), lcid, &V_CY(pd));
433  case VT_BSTR: return VarCyFromStr(V_BSTR(ps), lcid, dwFlags, &V_CY(pd));
434  }
435  break;
436 
437  case VT_DECIMAL:
438  switch (vtFrom)
439  {
440  case VT_EMPTY:
441  case VT_BOOL:
443  DEC_HI32(&V_DECIMAL(pd)) = 0;
444  DEC_MID32(&V_DECIMAL(pd)) = 0;
445  /* VarDecFromBool() coerces to -1/0, ChangeTypeEx() coerces to 1/0.
446  * VT_NULL and VT_EMPTY always give a 0 value.
447  */
448  DEC_LO32(&V_DECIMAL(pd)) = vtFrom == VT_BOOL && V_BOOL(ps) ? 1 : 0;
449  return S_OK;
450  case VT_I1: return VarDecFromI1(V_I1(ps), &V_DECIMAL(pd));
451  case VT_I2: return VarDecFromI2(V_I2(ps), &V_DECIMAL(pd));
452  case VT_I4: return VarDecFromI4(V_I4(ps), &V_DECIMAL(pd));
453  case VT_UI1: return VarDecFromUI1(V_UI1(ps), &V_DECIMAL(pd));
454  case VT_UI2: return VarDecFromUI2(V_UI2(ps), &V_DECIMAL(pd));
455  case VT_UI4: return VarDecFromUI4(V_UI4(ps), &V_DECIMAL(pd));
456  case VT_I8: return VarDecFromI8(V_I8(ps), &V_DECIMAL(pd));
457  case VT_UI8: return VarDecFromUI8(V_UI8(ps), &V_DECIMAL(pd));
458  case VT_R4: return VarDecFromR4(V_R4(ps), &V_DECIMAL(pd));
459  case VT_R8: return VarDecFromR8(V_R8(ps), &V_DECIMAL(pd));
460  case VT_DATE: return VarDecFromDate(V_DATE(ps), &V_DECIMAL(pd));
461  case VT_CY: return VarDecFromCy(V_CY(ps), &V_DECIMAL(pd));
462  case VT_DISPATCH: return VarDecFromDisp(V_DISPATCH(ps), lcid, &V_DECIMAL(pd));
463  case VT_BSTR: return VarDecFromStr(V_BSTR(ps), lcid, dwFlags, &V_DECIMAL(pd));
464  }
465  break;
466 
467  case VT_UNKNOWN:
468  switch (vtFrom)
469  {
470  case VT_DISPATCH:
471  if (V_DISPATCH(ps) == NULL)
472  {
473  V_UNKNOWN(pd) = NULL;
474  res = S_OK;
475  }
476  else
477  res = IDispatch_QueryInterface(V_DISPATCH(ps), &IID_IUnknown, (LPVOID*)&V_UNKNOWN(pd));
478  break;
479  }
480  break;
481 
482  case VT_DISPATCH:
483  switch (vtFrom)
484  {
485  case VT_UNKNOWN:
486  if (V_UNKNOWN(ps) == NULL)
487  {
488  V_DISPATCH(pd) = NULL;
489  res = S_OK;
490  }
491  else
492  res = IUnknown_QueryInterface(V_UNKNOWN(ps), &IID_IDispatch, (LPVOID*)&V_DISPATCH(pd));
493  break;
494  }
495  break;
496 
497  case VT_RECORD:
498  break;
499  }
500  return res;
501 }
HRESULT WINAPI VarUI4FromI2(SHORT sIn, ULONG *pulOut)
Definition: vartype.c:1800
HRESULT WINAPI VarBstrFromUI8(ULONG64 ullIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7065
HRESULT WINAPI VarI2FromDisp(IDispatch *pdispIn, LCID lcid, SHORT *psOut)
Definition: vartype.c:1041
HRESULT WINAPI VarI1FromDisp(IDispatch *pdispIn, LCID lcid, signed char *pcOut)
Definition: vartype.c:447
HRESULT WINAPI VarDateFromDisp(IDispatch *pdispIn, LCID lcid, DATE *pdateOut)
Definition: vartype.c:7314
#define VARIANT_NOVALUEPROP
Definition: oleauto.h:310
HRESULT WINAPI VarUI2FromDec(DECIMAL *pdecIn, USHORT *pusOut)
Definition: vartype.c:1427
#define VARIANT_NOUSEROVERRIDE
Definition: oleauto.h:312
HRESULT WINAPI VarI1FromR8(double dblIn, signed char *pcOut)
Definition: vartype.c:360
HRESULT WINAPI VarUI2FromDate(DATE dateIn, USHORT *pusOut)
Definition: vartype.c:1289
HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG *pulOut)
Definition: vartype.c:1857
HRESULT WINAPI VarI8FromBool(VARIANT_BOOL boolIn, LONG64 *pi64Out)
Definition: vartype.c:2264
HRESULT WINAPI VarUI4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG *pulOut)
Definition: vartype.c:1919
HRESULT WINAPI VarCyFromI8(LONG64 llIn, CY *pCyOut)
Definition: vartype.c:3741
Definition: compat.h:1939
HRESULT WINAPI VarUI8FromUI2(USHORT usIn, ULONG64 *pui64Out)
Definition: vartype.c:2627
HRESULT WINAPI VarDecFromDate(DATE dateIn, DECIMAL *pDecOut)
Definition: vartype.c:4221
HRESULT WINAPI VarBstrFromI2(short sIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6416
HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL *pDecOut)
Definition: vartype.c:4199
HRESULT WINAPI VarR8FromUI4(ULONG ulIn, double *pDblOut)
Definition: vartype.c:3248
Definition: compat.h:1955
HRESULT WINAPI VarUI4FromI8(LONG64 llIn, ULONG *pulOut)
Definition: vartype.c:2036
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
#define VAR_CALENDAR_HIJRI
Definition: oleauto.h:329
Definition: compat.h:1951
HRESULT WINAPI VarBoolFromUI1(BYTE bIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5939
HRESULT WINAPI VarR8FromDate(DATE dateIn, double *pDblOut)
Definition: vartype.c:3129
HRESULT WINAPI VarR8FromUI8(ULONG64 ullIn, double *pDblOut)
Definition: vartype.c:3322
HRESULT WINAPI VarBoolFromUI8(ULONG64 ullIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6319
HRESULT WINAPI VarUI8FromCy(CY cyIn, ULONG64 *pui64Out)
Definition: vartype.c:2497
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
HRESULT WINAPI VarBoolFromDec(DECIMAL *pDecIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6277
HRESULT WINAPI VarBoolFromDate(DATE dateIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6029
HRESULT WINAPI VarI4FromI8(LONG64 llIn, LONG *piOut)
Definition: vartype.c:1744
HRESULT WINAPI VarI2FromUI4(ULONG ulIn, SHORT *psOut)
Definition: vartype.c:1111
HRESULT WINAPI VarUI8FromBool(VARIANT_BOOL boolIn, ULONG64 *pui64Out)
Definition: vartype.c:2593
#define LOCALE_USE_NLS
Definition: oleauto.h:338
HRESULT WINAPI VarBoolFromI2(SHORT sIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5957
#define V_R8(A)
Definition: oleauto.h:262
HRESULT WINAPI VarI4FromR8(double dblIn, LONG *piOut)
Definition: vartype.c:1548
HRESULT WINAPI VarR4FromDisp(IDispatch *pdispIn, LCID lcid, float *pFltOut)
Definition: vartype.c:2850
HRESULT WINAPI VarBoolFromR8(double dblIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6011
HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE *pbOut)
Definition: vartype.c:675
#define VARIANT_ALPHABOOL
Definition: oleauto.h:311
#define V_I2(A)
Definition: oleauto.h:245
HRESULT WINAPI VarR4FromI1(signed char cIn, float *pFltOut)
Definition: vartype.c:2887
HRESULT WINAPI VarI2FromCy(CY cyIn, SHORT *psOut)
Definition: vartype.c:977
#define DEC_LO32(d)
Definition: variant.h:96
HRESULT WINAPI VarI8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG64 *pi64Out)
Definition: vartype.c:2226
HRESULT WINAPI VarI8FromUI2(USHORT usIn, LONG64 *pi64Out)
Definition: vartype.c:2298
HRESULT WINAPI VarUI4FromBool(VARIANT_BOOL boolIn, ULONG *pulOut)
Definition: vartype.c:1957
HRESULT WINAPI VarUI2FromR4(FLOAT fltIn, USHORT *pusOut)
Definition: vartype.c:1247
HRESULT WINAPI VarUI8FromUI4(ULONG ulIn, ULONG64 *pui64Out)
Definition: vartype.c:2644
HRESULT WINAPI VarBoolFromI4(LONG lIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5975
HRESULT WINAPI VarI1FromDate(DATE dateIn, signed char *pcOut)
Definition: vartype.c:382
HRESULT WINAPI VarBoolFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6113
HRESULT WINAPI VarR8FromCy(CY cyIn, double *pDblOut)
Definition: vartype.c:3112
HRESULT WINAPI VarI1FromR4(FLOAT fltIn, signed char *pcOut)
Definition: vartype.c:338
HRESULT WINAPI VarI1FromUI8(ULONG64 ullIn, signed char *pcOut)
Definition: vartype.c:567
HRESULT WINAPI VarUI8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG64 *pui64Out)
Definition: vartype.c:2554
HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT *pusOut)
Definition: vartype.c:1268
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3150
HRESULT WINAPI VarUI2FromDisp(IDispatch *pdispIn, LCID lcid, USHORT *pusOut)
Definition: vartype.c:1355
HRESULT WINAPI VarI8FromR8(double dblIn, LONG64 *pi64Out)
Definition: vartype.c:2147
HRESULT WINAPI VarDecFromCy(CY cyIn, DECIMAL *pDecOut)
Definition: vartype.c:4238
HRESULT WINAPI VarDecFromUI1(BYTE bIn, DECIMAL *pDecOut)
Definition: vartype.c:4096
HRESULT WINAPI VarUI1FromDec(DECIMAL *pdecIn, BYTE *pbOut)
Definition: vartype.c:833
HRESULT WINAPI VarBstrFromUI1(BYTE bIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6395
HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double *pDblOut)
Definition: vartype.c:3095
HRESULT WINAPI VarI1FromUI2(USHORT usIn, signed char *pcOut)
Definition: vartype.c:483
HRESULT WINAPI VarBstrFromDate(DATE dateIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6777
HRESULT WINAPI VarUI4FromDisp(IDispatch *pdispIn, LCID lcid, ULONG *pulOut)
Definition: vartype.c:1940
HRESULT WINAPI VarBoolFromUI4(ULONG ulIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6258
HRESULT WINAPI VarI1FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, signed char *pcOut)
Definition: vartype.c:426
HRESULT WINAPI VarR8FromUI1(BYTE bIn, double *pDblOut)
Definition: vartype.c:3044
#define VARIANT_CALENDAR_THAI
Definition: oleauto.h:315
HRESULT WINAPI VarR8FromI1(signed char cIn, double *pDblOut)
Definition: vartype.c:3208
HRESULT WINAPI VarDateFromR4(FLOAT fltIn, DATE *pdateOut)
Definition: vartype.c:7274
HRESULT WINAPI VarI8FromDisp(IDispatch *pdispIn, LCID lcid, LONG64 *pi64Out)
Definition: vartype.c:2247
HRESULT WINAPI VarCyFromDec(DECIMAL *pdecIn, CY *pCyOut)
Definition: vartype.c:3703
#define V_UI8(A)
Definition: oleauto.h:272
#define V_I4(A)
Definition: oleauto.h:247
HRESULT WINAPI VarDateFromI2(short sIn, DATE *pdateOut)
Definition: vartype.c:7240
HRESULT WINAPI VarI2FromBool(VARIANT_BOOL boolIn, SHORT *psOut)
Definition: vartype.c:1058
#define V_DISPATCH(A)
Definition: oleauto.h:239
HRESULT WINAPI VarI4FromDate(DATE dateIn, LONG *piOut)
Definition: vartype.c:1588
HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG *pulOut)
Definition: vartype.c:1896
HRESULT WINAPI VarUI4FromDec(DECIMAL *pdecIn, ULONG *pulOut)
Definition: vartype.c:2011
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY *pCyOut)
Definition: vartype.c:3419
#define V_CY(A)
Definition: oleauto.h:229
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI VarDecFromUI8(ULONG64 ullIn, DECIMAL *pDecOut)
Definition: vartype.c:4428
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3502
#define VAR_CALENDAR_THAI
Definition: oleauto.h:333
HRESULT WINAPI VarI2FromR4(FLOAT fltIn, SHORT *psOut)
Definition: vartype.c:935
HRESULT WINAPI VarUI8FromUI1(BYTE bIn, ULONG64 *pui64Out)
Definition: vartype.c:2415
HRESULT WINAPI VarDateFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, DATE *pdateOut)
Definition: vartype.c:7594
HRESULT WINAPI VarDateFromUI8(ULONG64 ullIn, DATE *pdateOut)
Definition: vartype.c:8042
HRESULT WINAPI VarR4FromR8(double dblIn, float *pFltOut)
Definition: vartype.c:2769
HRESULT WINAPI VarDateFromI1(signed char cIn, DATE *pdateOut)
Definition: vartype.c:7953
HRESULT WINAPI VarI8FromDate(DATE dateIn, LONG64 *pi64Out)
Definition: vartype.c:2204
HRESULT WINAPI VarR4FromUI8(ULONG64 ullIn, float *pFltOut)
Definition: vartype.c:3002
HRESULT WINAPI VarUI8FromI2(SHORT sIn, ULONG64 *pui64Out)
Definition: vartype.c:2432
HRESULT WINAPI VarUI1FromUI4(ULONG ulIn, BYTE *pbOut)
Definition: vartype.c:814
HRESULT WINAPI VarCyFromI2(SHORT sIn, CY *pCyOut)
Definition: vartype.c:3440
HRESULT WINAPI VarR4FromI4(LONG lIn, float *pFltOut)
Definition: vartype.c:2751
HRESULT WINAPI VarUI4FromUI8(ULONG64 ullIn, ULONG *pulOut)
Definition: vartype.c:2054
HRESULT WINAPI VarR8FromDisp(IDispatch *pdispIn, LCID lcid, double *pDblOut)
Definition: vartype.c:3171
HRESULT WINAPI VarI8FromUI1(BYTE bIn, LONG64 *pi64Out)
Definition: vartype.c:2074
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI VarDecFromI2(SHORT sIn, DECIMAL *pDecOut)
Definition: vartype.c:4113
#define V_UI2(A)
Definition: oleauto.h:268
#define V_I1(A)
Definition: oleauto.h:243
HRESULT WINAPI VarR4FromUI4(ULONG ulIn, float *pFltOut)
Definition: vartype.c:2927
HRESULT WINAPI VarR4FromUI1(BYTE bIn, float *pFltOut)
Definition: vartype.c:2717
HRESULT WINAPI VarI1FromI4(LONG iIn, signed char *pcOut)
Definition: vartype.c:319
HRESULT WINAPI VarUI1FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, BYTE *pbOut)
Definition: vartype.c:719
HRESULT WINAPI VarR4FromDec(DECIMAL *pDecIn, float *pFltOut)
Definition: vartype.c:2945
HRESULT WINAPI VarBoolFromUI2(USHORT usIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6240
HRESULT WINAPI VarR4FromDate(DATE dateIn, float *pFltOut)
Definition: vartype.c:2808
HRESULT WINAPI VarI2FromDec(DECIMAL *pdecIn, SHORT *psOut)
Definition: vartype.c:1130
HRESULT WINAPI VarDecFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, DECIMAL *pDecOut)
Definition: vartype.c:4272
HRESULT WINAPI VarI2FromI8(LONG64 llIn, SHORT *psOut)
Definition: vartype.c:1155
#define V_I8(A)
Definition: oleauto.h:249
HRESULT WINAPI VarR8FromI8(LONG64 llIn, double *pDblOut)
Definition: vartype.c:3305
#define V_DECIMAL(A)
Definition: oleauto.h:236
HRESULT WINAPI VarI4FromUI2(USHORT usIn, LONG *piOut)
Definition: vartype.c:1682
HRESULT WINAPI VarI2FromI1(signed char cIn, SHORT *psOut)
Definition: vartype.c:1075
HRESULT WINAPI VarBstrFromI4(LONG lIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6444
#define V_R4(A)
Definition: oleauto.h:260
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI VarI2FromDate(DATE dateIn, SHORT *psOut)
Definition: vartype.c:998
HRESULT WINAPI VarUI8FromI1(signed char cIn, ULONG64 *pui64Out)
Definition: vartype.c:2610
HRESULT WINAPI VarI8FromCy(CY cyIn, LONG64 *pi64Out)
Definition: vartype.c:2173
HRESULT WINAPI VarDecFromUI4(ULONG ulIn, DECIMAL *pDecOut)
Definition: vartype.c:4374
HRESULT WINAPI VarUI8FromR4(FLOAT fltIn, ULONG64 *pui64Out)
Definition: vartype.c:2450
HRESULT WINAPI VarBstrFromDec(DECIMAL *pDecIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6990
HRESULT WINAPI VarI1FromUI4(ULONG ulIn, signed char *pcOut)
Definition: vartype.c:503
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI VarI8FromI1(signed char cIn, LONG64 *pi64Out)
Definition: vartype.c:2281
HRESULT WINAPI VarR8FromI2(SHORT sIn, double *pDblOut)
Definition: vartype.c:3061
HRESULT WINAPI VarUI2FromBool(VARIANT_BOOL boolIn, USHORT *pusOut)
Definition: vartype.c:1372
HRESULT WINAPI VarI4FromBool(VARIANT_BOOL boolIn, LONG *piOut)
Definition: vartype.c:1648
HRESULT WINAPI VarI2FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, SHORT *psOut)
Definition: vartype.c:1020
const GUID IID_IUnknown
HRESULT WINAPI VarDecFromI1(signed char cIn, DECIMAL *pDecOut)
Definition: vartype.c:4340
HRESULT WINAPI VarI2FromR8(double dblIn, SHORT *psOut)
Definition: vartype.c:956
#define V_UI1(A)
Definition: oleauto.h:266
HRESULT WINAPI VarI2FromI4(LONG iIn, SHORT *psOut)
Definition: vartype.c:917
HRESULT WINAPI VarUI4FromR4(FLOAT fltIn, ULONG *pulOut)
Definition: vartype.c:1836
HRESULT WINAPI VarI4FromI2(SHORT sIn, LONG *piOut)
Definition: vartype.c:1509
#define V_BOOL(A)
Definition: oleauto.h:224
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI VarBstrFromDisp(IDispatch *pdispIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7086
HRESULT WINAPI VarDecFromI8(LONG64 llIn, DECIMAL *pDecOut)
Definition: vartype.c:4395
HRESULT WINAPI VarI4FromUI8(ULONG64 ullIn, LONG *piOut)
Definition: vartype.c:1762
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
HRESULT WINAPI VarDateFromDec(DECIMAL *pdecIn, DATE *pdateOut)
Definition: vartype.c:8004
HRESULT WINAPI VarR4FromCy(CY cyIn, float *pFltOut)
Definition: vartype.c:2789
HRESULT WINAPI VarUI1FromI2(SHORT sIn, BYTE *pbOut)
Definition: vartype.c:589
#define V_UI4(A)
Definition: oleauto.h:270
const GUID IID_IDispatch
HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6586
HRESULT WINAPI VarR8FromUI2(USHORT usIn, double *pDblOut)
Definition: vartype.c:3228
HRESULT WINAPI VarDateFromUI1(BYTE bIn, DATE *pdateOut)
Definition: vartype.c:7223
#define DEC_HI32(d)
Definition: variant.h:94
HRESULT WINAPI VarI1FromI8(LONG64 llIn, signed char *pcOut)
Definition: vartype.c:548
HRESULT WINAPI VarCyFromUI2(USHORT usIn, CY *pCyOut)
Definition: vartype.c:3661
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:651
Definition: compat.h:1940
HRESULT WINAPI VarR4FromI2(SHORT sIn, float *pFltOut)
Definition: vartype.c:2734
HRESULT WINAPI VarDateFromI8(LONG64 llIn, DATE *pdateOut)
Definition: vartype.c:8022
HRESULT WINAPI VarDateFromBool(VARIANT_BOOL boolIn, DATE *pdateOut)
Definition: vartype.c:7331
HRESULT WINAPI VarBstrFromUI2(USHORT usIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6948
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
HRESULT WINAPI VarI4FromDisp(IDispatch *pdispIn, LCID lcid, LONG *piOut)
Definition: vartype.c:1631
#define V_VT(A)
Definition: oleauto.h:211
HRESULT WINAPI VarI2FromUI1(BYTE bIn, SHORT *psOut)
Definition: vartype.c:899
HRESULT WINAPI VarBoolFromI1(signed char cIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6222
#define VARIANT_CALENDAR_GREGORIAN
Definition: oleauto.h:316
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
HRESULT WINAPI VarR4FromBool(VARIANT_BOOL boolIn, float *pFltOut)
Definition: vartype.c:2867
HRESULT WINAPI VarUI1FromUI8(ULONG64 ullIn, BYTE *pbOut)
Definition: vartype.c:878
#define VAR_LOCALBOOL
Definition: oleauto.h:330
HRESULT WINAPI VarR4FromI8(LONG64 llIn, float *pFltOut)
Definition: vartype.c:2985
Definition: compat.h:1942
#define V_UNKNOWN(A)
Definition: oleauto.h:281
HRESULT WINAPI VarI8FromUI4(ULONG ulIn, LONG64 *pi64Out)
Definition: vartype.c:2315
HRESULT WINAPI VarUI4FromI1(signed char cIn, ULONG *pulOut)
Definition: vartype.c:1975
HRESULT WINAPI VarUI4FromUI1(BYTE bIn, ULONG *pulOut)
Definition: vartype.c:1782
#define V_BSTR(A)
Definition: oleauto.h:226
HRESULT WINAPI VarUI2FromI4(LONG iIn, USHORT *pusOut)
Definition: vartype.c:1229
HRESULT WINAPI VarDecFromR4(FLOAT fltIn, DECIMAL *pDecOut)
Definition: vartype.c:4177
HRESULT WINAPI VarUI2FromI1(signed char cIn, USHORT *pusOut)
Definition: vartype.c:1390
HRESULT WINAPI VarI4FromI1(signed char cIn, LONG *piOut)
Definition: vartype.c:1665
HRESULT WINAPI VarCyFromUI4(ULONG ulIn, CY *pCyOut)
Definition: vartype.c:3682
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:519
HRESULT WINAPI VarI8FromR4(FLOAT fltIn, LONG64 *pi64Out)
Definition: vartype.c:2111
HRESULT WINAPI VarBstrFromUI4(ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6969
HRESULT WINAPI VarR4FromUI2(USHORT usIn, float *pFltOut)
Definition: vartype.c:2907
HRESULT WINAPI VarCyFromBool(VARIANT_BOOL boolIn, CY *pCyOut)
Definition: vartype.c:3619
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
HRESULT WINAPI VarUI2FromUI4(ULONG ulIn, USHORT *pusOut)
Definition: vartype.c:1408
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI VarUI8FromDisp(IDispatch *pdispIn, LCID lcid, ULONG64 *pui64Out)
Definition: vartype.c:2575
HRESULT WINAPI VarUI1FromUI2(USHORT usIn, BYTE *pbOut)
Definition: vartype.c:795
HRESULT WINAPI VarR8FromDec(const DECIMAL *pDecIn, double *pDblOut)
Definition: vartype.c:3266
HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT *pusOut)
Definition: vartype.c:1310
#define DECIMAL_POS
Definition: variant.h:77
HRESULT WINAPI VarBoolFromDisp(IDispatch *pdispIn, LCID lcid, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6205
HRESULT WINAPI VarDateFromI4(LONG lIn, DATE *pdateOut)
Definition: vartype.c:7257
HRESULT WINAPI VarI4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG *piOut)
Definition: vartype.c:1610
HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE *pbOut)
Definition: vartype.c:650
HRESULT WINAPI VarUI1FromDate(DATE dateIn, BYTE *pbOut)
Definition: vartype.c:697
HRESULT WINAPI VarUI2FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, USHORT *pusOut)
Definition: vartype.c:1334
unsigned short VARTYPE
Definition: compat.h:1895
HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6047
HRESULT WINAPI VarI1FromDec(DECIMAL *pdecIn, signed char *pcOut)
Definition: vartype.c:522
#define V_TYPE(v)
Definition: variant.h:30
HRESULT WINAPI VarUI4FromDate(DATE dateIn, ULONG *pulOut)
Definition: vartype.c:1878
#define VARIANT_USE_NLS
Definition: oleauto.h:317
HRESULT WINAPI VarCyFromDisp(IDispatch *pdispIn, LCID lcid, CY *pCyOut)
Definition: vartype.c:3595
HRESULT WINAPI VarCyFromI1(signed char cIn, CY *pCyOut)
Definition: vartype.c:3640
#define VARIANT_CALENDAR_HIJRI
Definition: oleauto.h:313
HRESULT WINAPI VarDateFromCy(CY cyIn, DATE *pdateOut)
Definition: vartype.c:7348
HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double *pDblOut)
Definition: vartype.c:3188
#define DEC_SIGNSCALE(d)
Definition: variant.h:93
HRESULT WINAPI VarUI2FromUI1(BYTE bIn, USHORT *pusOut)
Definition: vartype.c:1193
HRESULT WINAPI VarDecFromI4(LONG lIn, DECIMAL *pDecOut)
Definition: vartype.c:4130
HRESULT WINAPI VarBstrFromBool(VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6851
HRESULT WINAPI VarUI1FromI4(LONG iIn, BYTE *pbOut)
Definition: vartype.c:608
HRESULT WINAPI VarUI1FromBool(VARIANT_BOOL boolIn, BYTE *pbOut)
Definition: vartype.c:757
HRESULT WINAPI VarR8FromI4(LONG lIn, double *pDblOut)
Definition: vartype.c:3078
HRESULT WINAPI VarDecFromDisp(IDispatch *pdispIn, LCID lcid, DECIMAL *pDecOut)
Definition: vartype.c:4291
HRESULT WINAPI VarDateFromR8(double dblIn, DATE *pdateOut)
Definition: vartype.c:7291
GLuint res
Definition: glext.h:9613
HRESULT WINAPI VarI1FromCy(CY cyIn, signed char *pcOut)
Definition: vartype.c:401
HRESULT WINAPI VarI1FromBool(VARIANT_BOOL boolIn, signed char *pcOut)
Definition: vartype.c:464
HRESULT WINAPI VarUI8FromDec(DECIMAL *pdecIn, ULONG64 *pui64Out)
Definition: vartype.c:2669
HRESULT WINAPI VarCyFromR4(FLOAT fltIn, CY *pCyOut)
Definition: vartype.c:3482
HRESULT WINAPI VarBstrFromI1(signed char cIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6920
HRESULT WINAPI VarUI1FromDisp(IDispatch *pdispIn, LCID lcid, BYTE *pbOut)
Definition: vartype.c:740
HRESULT WINAPI VarDateFromUI2(USHORT uiIn, DATE *pdateOut)
Definition: vartype.c:7970
HRESULT WINAPI VarI4FromCy(CY cyIn, LONG *piOut)
Definition: vartype.c:1569
HRESULT WINAPI VarUI4FromUI2(USHORT usIn, ULONG *pulOut)
Definition: vartype.c:1992
#define VAR_CALENDAR_GREGORIAN
Definition: oleauto.h:334
HRESULT WINAPI VarBoolFromI8(LONG64 llIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:6301
HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pCyOut)
Definition: vartype.c:3574
HRESULT WINAPI VarI4FromDec(DECIMAL *pdecIn, LONG *piOut)
Definition: vartype.c:1719
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:751
HRESULT WINAPI VarR4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, float *pFltOut)
Definition: vartype.c:2829
#define DEC_MID32(d)
Definition: variant.h:95
HRESULT WINAPI VarCyFromI4(LONG lIn, CY *pCyOut)
Definition: vartype.c:3461
HRESULT WINAPI VarDecFromUI2(USHORT usIn, DECIMAL *pDecOut)
Definition: vartype.c:4357
HRESULT WINAPI VarUI1FromI8(LONG64 llIn, BYTE *pbOut)
Definition: vartype.c:859
#define DISP_E_OVERFLOW
Definition: winerror.h:2519
HRESULT WINAPI VarUI1FromR4(FLOAT fltIn, BYTE *pbOut)
Definition: vartype.c:628
HRESULT WINAPI VarCyFromDate(DATE dateIn, CY *pCyOut)
Definition: vartype.c:3552
HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6565
HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6607
HRESULT WINAPI VarUI8FromDate(DATE dateIn, ULONG64 *pui64Out)
Definition: vartype.c:2532
HRESULT WINAPI VarI4FromUI1(BYTE bIn, LONG *piOut)
Definition: vartype.c:1490
HRESULT WINAPI VarI1FromI2(SHORT sIn, signed char *pcOut)
Definition: vartype.c:300
Definition: compat.h:1941
Definition: compat.h:1938
HRESULT WINAPI VarI4FromR4(FLOAT fltIn, LONG *piOut)
Definition: vartype.c:1527
#define V_DATE(A)
Definition: oleauto.h:231
HRESULT WINAPI VarDateFromUI4(ULONG ulIn, DATE *pdateOut)
Definition: vartype.c:7987
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI VarBoolFromR4(FLOAT fltIn, VARIANT_BOOL *pBoolOut)
Definition: vartype.c:5993
HRESULT WINAPI VarI8FromI2(SHORT sIn, LONG64 *pi64Out)
Definition: vartype.c:2092
HRESULT WINAPI VarBstrFromI8(LONG64 llIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
Definition: vartype.c:7037
HRESULT WINAPI VarI2FromUI8(ULONG64 ullIn, SHORT *psOut)
Definition: vartype.c:1173
HRESULT WINAPI VarCyFromUI8(ULONG64 ullIn, CY *pCyOut)
Definition: vartype.c:3763
HRESULT WINAPI VarUI8FromR8(double dblIn, ULONG64 *pui64Out)
Definition: vartype.c:2472
HRESULT WINAPI VarI8FromDec(DECIMAL *pdecIn, LONG64 *pi64Out)
Definition: vartype.c:2334

Referenced by VariantChangeTypeEx().

◆ VARIANT_CoerceArray()

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

Definition at line 504 of file variant.c.

505 {
506  if (vt == VT_BSTR && V_VT(ps) == (VT_ARRAY|VT_UI1))
507  return BstrFromVector(V_ARRAY(ps), &V_BSTR(pd));
508 
509  if (V_VT(ps) == VT_BSTR && vt == (VT_ARRAY|VT_UI1))
510  return VectorFromBstr(V_BSTR(ps), &V_ARRAY(pd));
511 
512  if (V_VT(ps) == vt)
513  return SafeArrayCopy(V_ARRAY(ps), &V_ARRAY(pd));
514 
515  return DISP_E_TYPEMISMATCH;
516 }
#define V_ARRAY(A)
Definition: oleauto.h:222
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
HRESULT WINAPI SafeArrayCopy(SAFEARRAY *psa, SAFEARRAY **ppsaOut)
Definition: safearray.c:1381
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
HRESULT WINAPI BstrFromVector(SAFEARRAY *psa, BSTR *pbstr)
Definition: safearray.c:1742
HRESULT WINAPI VectorFromBstr(BSTR bstr, SAFEARRAY **ppsa)
Definition: safearray.c:1701
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226

Referenced by VariantChangeTypeEx().

◆ VARIANT_CopyIRecordInfo()

static HRESULT VARIANT_CopyIRecordInfo ( VARIANT dest,
VARIANT src 
)
static

Definition at line 695 of file variant.c.

696 {
697  struct __tagBRECORD *dest_rec = &V_UNION(dest, brecVal);
698  struct __tagBRECORD *src_rec = &V_UNION(src, brecVal);
699  HRESULT hr = S_OK;
700  ULONG size;
701 
702  if (!src_rec->pRecInfo)
703  {
704  if (src_rec->pvRecord) return E_INVALIDARG;
705  return S_OK;
706  }
707 
708  hr = IRecordInfo_GetSize(src_rec->pRecInfo, &size);
709  if (FAILED(hr)) return hr;
710 
711  /* This could look cleaner if only RecordCreate() was used, but native doesn't use it.
712  Memory should be allocated in a same way as RecordCreate() does, so RecordDestroy()
713  could free it later. */
714  dest_rec->pvRecord = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
715  if (!dest_rec->pvRecord) return E_OUTOFMEMORY;
716 
717  dest_rec->pRecInfo = src_rec->pRecInfo;
718  IRecordInfo_AddRef(src_rec->pRecInfo);
719 
720  return IRecordInfo_RecordCopy(src_rec->pRecInfo, src_rec->pvRecord, dest_rec->pvRecord);
721 }
HRESULT hr
Definition: shlfolder.c:183
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define __tagBRECORD
Definition: compat.h:2015
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
GLenum src
Definition: glext.h:6340
#define S_OK
Definition: intsafe.h:59
#define V_UNION(A, B)
Definition: oleauto.h:212
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
static char * dest
Definition: rtl.c:135

Referenced by VariantCopy(), and VariantCopyInd().

◆ VARIANT_DataSize()

static size_t VARIANT_DataSize ( const VARIANT pv)
inlinestatic

Definition at line 794 of file variant.c.

795 {
796  switch (V_TYPE(pv))
797  {
798  case VT_I1:
799  case VT_UI1: return sizeof(BYTE);
800  case VT_I2:
801  case VT_UI2: return sizeof(SHORT);
802  case VT_INT:
803  case VT_UINT:
804  case VT_I4:
805  case VT_UI4: return sizeof(LONG);
806  case VT_I8:
807  case VT_UI8: return sizeof(LONGLONG);
808  case VT_R4: return sizeof(float);
809  case VT_R8: return sizeof(double);
810  case VT_DATE: return sizeof(DATE);
811  case VT_BOOL: return sizeof(VARIANT_BOOL);
812  case VT_DISPATCH:
813  case VT_UNKNOWN:
814  case VT_BSTR: return sizeof(void*);
815  case VT_CY: return sizeof(CY);
816  case VT_ERROR: return sizeof(SCODE);
817  }
818  TRACE("Shouldn't be called for variant %s!\n", debugstr_variant(pv));
819  return 0;
820 }
Definition: compat.h:1939
Definition: compat.h:1955
Definition: compat.h:1951
double DATE
Definition: compat.h:1894
short VARIANT_BOOL
Definition: compat.h:1931
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
LONG SCODE
Definition: compat.h:1893
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
union tagCY CY
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
Definition: compat.h:1940
unsigned char BYTE
Definition: mem.h:68
Definition: compat.h:1942
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
#define V_TYPE(v)
Definition: variant.h:30
Definition: compat.h:1941
Definition: compat.h:1938

Referenced by VariantCopyInd().

◆ VARIANT_DateFromJulian()

static int VARIANT_DateFromJulian ( int  dateIn)
inlinestatic

Definition at line 1064 of file variant.c.

1065 {
1066  int julianDays = dateIn;
1067 
1068  julianDays -= 1757585; /* Convert to + days from 1 Jan 100 AD */
1069  julianDays += DATE_MIN; /* Convert to +/- days from 1 Jan 1899 AD */
1070  return julianDays;
1071 }
#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 1074 of file variant.c.

1075 {
1076  int j, i, l, n;
1077 
1078  l = jd + 68569;
1079  n = l * 4 / 146097;
1080  l -= (n * 146097 + 3) / 4;
1081  i = (4000 * (l + 1)) / 1461001;
1082  l += 31 - (i * 1461) / 4;
1083  j = (l * 80) / 2447;
1084  *day = l - (j * 2447) / 80;
1085  l = j / 11;
1086  *month = (j + 2) - (12 * l);
1087  *year = 100 * (n - 49) + i + l;
1088 }
static DOUBLE day(DOUBLE time)
Definition: date.c:115
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
r l[0]
Definition: byte_order.h:167
int month[12]
Definition: systime.c:13

Referenced by VarUdateFromDate().

◆ VARIANT_FetchDispatchValue()

static HRESULT VARIANT_FetchDispatchValue ( LPVARIANT  pvDispatch,
LPVARIANT  pValue 
)
static

Definition at line 518 of file variant.c.

519 {
520  HRESULT hres;
521  static DISPPARAMS emptyParams = { NULL, NULL, 0, 0 };
522 
523  if ((V_VT(pvDispatch) & VT_TYPEMASK) == VT_DISPATCH) {
524  if (NULL == V_DISPATCH(pvDispatch)) return DISP_E_TYPEMISMATCH;
525  hres = IDispatch_Invoke(V_DISPATCH(pvDispatch), DISPID_VALUE, &IID_NULL,
526  LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &emptyParams, pValue,
527  NULL, NULL);
528  } else {
530  }
531  return hres;
532 }
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define LOCALE_USER_DEFAULT
#define V_DISPATCH(A)
Definition: oleauto.h:239
smooth NULL
Definition: ftsmooth.c:416
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
#define IID_NULL
Definition: guiddef.h:98
#define V_VT(A)
Definition: oleauto.h:211
struct stdole::DISPPARAMS DISPPARAMS

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 1521 of file variant.c.

1522 {
1523  static const VARIANT_NUMBER_CHARS defaultChars = { '-','+','.',',','$',0,'.',',' };
1524  static VARIANT_NUMBER_CHARS lastChars;
1525  static LCID lastLcid = -1;
1526  static DWORD lastFlags = 0;
1528  WCHAR buff[4];
1529 
1530  /* To make caching thread-safe, a critical section is needed */
1532 
1533  /* Asking for default locale entries is very expensive: It is a registry
1534  server call. So cache one locally, as Microsoft does it too */
1535  if(lcid == lastLcid && dwFlags == lastFlags)
1536  {
1537  memcpy(lpChars, &lastChars, sizeof(defaultChars));
1539  return;
1540  }
1541 
1542  memcpy(lpChars, &defaultChars, sizeof(defaultChars));
1543  GET_NUMBER_TEXT(LOCALE_SNEGATIVESIGN, cNegativeSymbol);
1544  GET_NUMBER_TEXT(LOCALE_SPOSITIVESIGN, cPositiveSymbol);
1545  GET_NUMBER_TEXT(LOCALE_SDECIMAL, cDecimalPoint);
1546  GET_NUMBER_TEXT(LOCALE_STHOUSAND, cDigitSeparator);
1547  GET_NUMBER_TEXT(LOCALE_SMONDECIMALSEP, cCurrencyDecimalPoint);
1548  GET_NUMBER_TEXT(LOCALE_SMONTHOUSANDSEP, cCurrencyDigitSeparator);
1549 
1550  /* Local currency symbols are often 2 characters */
1551  lpChars->cCurrencyLocal2 = '\0';
1552  switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, ARRAY_SIZE(buff)))
1553  {
1554  case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */
1555  case 2: lpChars->cCurrencyLocal = buff[0];
1556  break;
1557  default: WARN("buffer too small for LOCALE_SCURRENCY\n");
1558  }
1559  TRACE("lcid 0x%x, cCurrencyLocal =%d,%d '%c','%c'\n", lcid, lpChars->cCurrencyLocal,
1560  lpChars->cCurrencyLocal2, lpChars->cCurrencyLocal, lpChars->cCurrencyLocal2);
1561 
1562  memcpy(&lastChars, lpChars, sizeof(defaultChars));
1563  lastLcid = lcid;
1564  lastFlags = dwFlags;
1566 }
#define WARN(fmt,...)
Definition: debug.h:111
DWORD LCID
Definition: nls.h:13
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define LOCALE_SCURRENCY
Definition: winnls.h:49
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
DWORD LCTYPE
Definition: winnls.h:514
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_SMONDECIMALSEP
Definition: winnls.h:51
#define TRACE(s)
Definition: solgame.cpp:4
#define LOCALE_SMONTHOUSANDSEP
Definition: winnls.h:52
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LOCALE_SPOSITIVESIGN
Definition: winnls.h:117
unsigned long DWORD
Definition: