ReactOS 0.4.15-dev-8422-g6219a1a
vartype.c File Reference
#include <wchar.h>
#include "wine/debug.h"
#include "winbase.h"
#include "winuser.h"
#include "winnt.h"
#include "variant.h"
#include "resource.h"
Include dependency graph for vartype.c:

Go to the source code of this file.

Classes

struct  DECIMAL_internal
 
union  R4_FIELDS
 
union  R8_FIELDS
 
struct  tagDATEPARSE
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define CY_MULTIPLIER   10000 /* 4 dp of precision */
 
#define CY_MULTIPLIER_F   10000.0
 
#define CY_HALF   (CY_MULTIPLIER/2) /* 0.5 */
 
#define CY_HALF_F   (CY_MULTIPLIER_F/2.0)
 
#define VARIANT_DutchRound(typ, value, res)
 
#define RETTYP   static inline HRESULT
 
#define SIMPLE(dest, src, func)
 
#define NEGTST(dest, src, func)
 
#define POSTST(dest, src, func, tst)
 
#define BOTHTST(dest, src, func, lo, hi)
 
#define DP_TIMESEP   0x01 /* Time separator ( _must_ remain 0x1, used as a bitmask) */
 
#define DP_DATESEP   0x02 /* Date separator */
 
#define DP_MONTH   0x04 /* Month name */
 
#define DP_AM   0x08 /* AM */
 
#define DP_PM   0x10 /* PM */
 
#define TIMEFLAG(i)   ((dp.dwFlags[i] & DP_TIMESEP) << i)
 
#define IsLeapYear(y)   (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
 
#define ORDER_MDY   0x01
 
#define ORDER_YMD   0x02
 
#define ORDER_YDM   0x04
 
#define ORDER_DMY   0x08
 
#define ORDER_MYD   0x10 /* Synthetic order, used only for funky 2 digit dates */
 
#define DATE_SWAP(x, y)   do { dwTemp = x; x = y; y = dwTemp; } while (0)
 

Typedefs

typedef struct DECIMAL_internal VARIANT_DI
 
typedef struct tagDATEPARSE DATEPARSE
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (variant)
 
static void VARIANT_CopyData (const VARIANT *srcVar, VARTYPE vt, void *pOut)
 
static HRESULT VARIANT_NumberFromBstr (OLECHAR *pStrIn, LCID lcid, ULONG ulFlags, void *pOut, VARTYPE vt)
 
static HRESULT VARIANT_FromDisp (IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
 
RETTYP _VarR8FromCy (CY i, double *o)
 
HRESULT WINAPI VarI1FromUI1 (BYTE bIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI2 (SHORT sIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI4 (LONG iIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromR4 (FLOAT fltIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromR8 (double dblIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDate (DATE dateIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromCy (CY cyIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDisp (IDispatch *pdispIn, LCID lcid, signed char *pcOut)
 
HRESULT WINAPI VarI1FromBool (VARIANT_BOOL boolIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI2 (USHORT usIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI4 (ULONG ulIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromDec (DECIMAL *pdecIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromI8 (LONG64 llIn, signed char *pcOut)
 
HRESULT WINAPI VarI1FromUI8 (ULONG64 ullIn, signed char *pcOut)
 
HRESULT WINAPI VarUI1FromI2 (SHORT sIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI4 (LONG iIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromR4 (FLOAT fltIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromR8 (double dblIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromCy (CY cyIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDate (DATE dateIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDisp (IDispatch *pdispIn, LCID lcid, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromBool (VARIANT_BOOL boolIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI1 (signed char cIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI2 (USHORT usIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI4 (ULONG ulIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromDec (DECIMAL *pdecIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromI8 (LONG64 llIn, BYTE *pbOut)
 
HRESULT WINAPI VarUI1FromUI8 (ULONG64 ullIn, BYTE *pbOut)
 
HRESULT WINAPI VarI2FromUI1 (BYTE bIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI4 (LONG iIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromR4 (FLOAT fltIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromR8 (double dblIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromCy (CY cyIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDate (DATE dateIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDisp (IDispatch *pdispIn, LCID lcid, SHORT *psOut)
 
HRESULT WINAPI VarI2FromBool (VARIANT_BOOL boolIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI1 (signed char cIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI2 (USHORT usIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI4 (ULONG ulIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromDec (DECIMAL *pdecIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromI8 (LONG64 llIn, SHORT *psOut)
 
HRESULT WINAPI VarI2FromUI8 (ULONG64 ullIn, SHORT *psOut)
 
HRESULT WINAPI VarUI2FromUI1 (BYTE bIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI2 (SHORT sIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI4 (LONG iIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromR4 (FLOAT fltIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromR8 (double dblIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDate (DATE dateIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromCy (CY cyIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDisp (IDispatch *pdispIn, LCID lcid, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromBool (VARIANT_BOOL boolIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI1 (signed char cIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromUI4 (ULONG ulIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromDec (DECIMAL *pdecIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromI8 (LONG64 llIn, USHORT *pusOut)
 
HRESULT WINAPI VarUI2FromUI8 (ULONG64 ullIn, USHORT *pusOut)
 
HRESULT WINAPI VarI4FromUI1 (BYTE bIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI2 (SHORT sIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromR4 (FLOAT fltIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromR8 (double dblIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromCy (CY cyIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromDate (DATE dateIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG *piOut)
 
HRESULT WINAPI VarI4FromDisp (IDispatch *pdispIn, LCID lcid, LONG *piOut)
 
HRESULT WINAPI VarI4FromBool (VARIANT_BOOL boolIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI1 (signed char cIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI2 (USHORT usIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI4 (ULONG ulIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromDec (DECIMAL *pdecIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromI8 (LONG64 llIn, LONG *piOut)
 
HRESULT WINAPI VarI4FromUI8 (ULONG64 ullIn, LONG *piOut)
 
HRESULT WINAPI VarUI4FromUI1 (BYTE bIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI2 (SHORT sIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI4 (LONG iIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromR4 (FLOAT fltIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromR8 (double dblIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDate (DATE dateIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromCy (CY cyIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDisp (IDispatch *pdispIn, LCID lcid, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromBool (VARIANT_BOOL boolIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI1 (signed char cIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromUI2 (USHORT usIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromDec (DECIMAL *pdecIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromI8 (LONG64 llIn, ULONG *pulOut)
 
HRESULT WINAPI VarUI4FromUI8 (ULONG64 ullIn, ULONG *pulOut)
 
HRESULT WINAPI VarI8FromUI1 (BYTE bIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromI2 (SHORT sIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromR4 (FLOAT fltIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromR8 (double dblIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromCy (CY cyIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDate (DATE dateIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDisp (IDispatch *pdispIn, LCID lcid, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromBool (VARIANT_BOOL boolIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromI1 (signed char cIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI2 (USHORT usIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI4 (ULONG ulIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromDec (DECIMAL *pdecIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarI8FromUI8 (ULONG64 ullIn, LONG64 *pi64Out)
 
HRESULT WINAPI VarUI8FromI8 (LONG64 llIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI1 (BYTE bIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromI2 (SHORT sIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromR4 (FLOAT fltIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromR8 (double dblIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromCy (CY cyIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDate (DATE dateIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDisp (IDispatch *pdispIn, LCID lcid, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromBool (VARIANT_BOOL boolIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromI1 (signed char cIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI2 (USHORT usIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromUI4 (ULONG ulIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarUI8FromDec (DECIMAL *pdecIn, ULONG64 *pui64Out)
 
HRESULT WINAPI VarR4FromUI1 (BYTE bIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI2 (SHORT sIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI4 (LONG lIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromR8 (double dblIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromCy (CY cyIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromDate (DATE dateIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, float *pFltOut)
 
HRESULT WINAPI VarR4FromDisp (IDispatch *pdispIn, LCID lcid, float *pFltOut)
 
HRESULT WINAPI VarR4FromBool (VARIANT_BOOL boolIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI1 (signed char cIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI2 (USHORT usIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI4 (ULONG ulIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromDec (DECIMAL *pDecIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromI8 (LONG64 llIn, float *pFltOut)
 
HRESULT WINAPI VarR4FromUI8 (ULONG64 ullIn, float *pFltOut)
 
HRESULT WINAPI VarR4CmpR8 (float fltLeft, double dblRight)
 
HRESULT WINAPI VarR8FromUI1 (BYTE bIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI2 (SHORT sIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI4 (LONG lIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromR4 (FLOAT fltIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromCy (CY cyIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromDate (DATE dateIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
 
HRESULT WINAPI VarR8FromDisp (IDispatch *pdispIn, LCID lcid, double *pDblOut)
 
HRESULT WINAPI VarR8FromBool (VARIANT_BOOL boolIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI1 (signed char cIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI2 (USHORT usIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI4 (ULONG ulIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromDec (const DECIMAL *pDecIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromI8 (LONG64 llIn, double *pDblOut)
 
HRESULT WINAPI VarR8FromUI8 (ULONG64 ullIn, double *pDblOut)
 
HRESULT WINAPI VarR8Pow (double dblLeft, double dblPow, double *pDblOut)
 
HRESULT WINAPI VarR8Round (double dblIn, int nDig, double *pDblOut)
 
HRESULT WINAPI VarCyFromUI1 (BYTE bIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI2 (SHORT sIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI4 (LONG lIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromR4 (FLOAT fltIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromR8 (double dblIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDate (DATE dateIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDisp (IDispatch *pdispIn, LCID lcid, CY *pCyOut)
 
HRESULT WINAPI VarCyFromBool (VARIANT_BOOL boolIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI1 (signed char cIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI2 (USHORT usIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI4 (ULONG ulIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromDec (DECIMAL *pdecIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromI8 (LONG64 llIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFromUI8 (ULONG64 ullIn, CY *pCyOut)
 
HRESULT WINAPI VarCyAdd (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyMul (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyMulI4 (CY cyLeft, LONG lRight, CY *pCyOut)
 
HRESULT WINAPI VarCySub (CY cyLeft, CY cyRight, CY *pCyOut)
 
HRESULT WINAPI VarCyAbs (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyFix (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyInt (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyNeg (CY cyIn, CY *pCyOut)
 
HRESULT WINAPI VarCyRound (CY cyIn, int cDecimals, CY *pCyOut)
 
HRESULT WINAPI VarCyCmp (CY cyLeft, CY cyRight)
 
HRESULT WINAPI VarCyCmpR8 (CY cyLeft, double dblRight)
 
HRESULT WINAPI VarCyMulI8 (CY cyLeft, LONG64 llRight, CY *pCyOut)
 
HRESULT WINAPI VarDecFromUI1 (BYTE bIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI2 (SHORT sIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI4 (LONG lIn, DECIMAL *pDecOut)
 
static HRESULT VARIANT_DI_FromR4 (float source, VARIANT_DI *dest)
 
static HRESULT VARIANT_DI_FromR8 (double source, VARIANT_DI *dest)
 
static void VARIANT_DIFromDec (const DECIMAL *from, VARIANT_DI *to)
 
static void VARIANT_DecFromDI (const VARIANT_DI *from, DECIMAL *to)
 
static unsigned char VARIANT_int_divbychar (DWORD *p, unsigned int n, unsigned char divisor)
 
static BOOL VARIANT_int_iszero (const DWORD *p, unsigned int n)
 
HRESULT WINAPI VarDecFromR4 (FLOAT fltIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromR8 (double dblIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromDate (DATE dateIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromCy (CY cyIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromDisp (IDispatch *pdispIn, LCID lcid, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromBool (VARIANT_BOOL bIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI1 (signed char cIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI2 (USHORT usIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI4 (ULONG ulIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromI8 (LONG64 llIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFromUI8 (ULONG64 ullIn, DECIMAL *pDecOut)
 
static HRESULT VARIANT_DecScale (const DECIMAL **ppDecLeft, const DECIMAL **ppDecRight, DECIMAL pDecOut[2])
 
static ULONG VARIANT_Add (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static ULONG VARIANT_Sub (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static ULONG VARIANT_Mul (ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
 
static int VARIANT_DecCmp (const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
 
HRESULT WINAPI VarDecAdd (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
static void VARIANT_DI_clear (VARIANT_DI *i)
 
static int VARIANT_DI_mul (const VARIANT_DI *a, const VARIANT_DI *b, VARIANT_DI *result)
 
static BOOL VARIANT_DI_tostringW (const VARIANT_DI *a, WCHAR *s, unsigned int n)
 
static void VARIANT_int_shiftleft (DWORD *p, unsigned int n, unsigned int shift)
 
static unsigned char VARIANT_int_add (DWORD *v, unsigned int nv, const DWORD *p, unsigned int np)
 
static void VARIANT_int_div (DWORD *p, unsigned int n, const DWORD *divisor, unsigned int dn)
 
static unsigned char VARIANT_int_mulbychar (DWORD *p, unsigned int n, unsigned char m)
 
static int VARIANT_int_addlossy (DWORD *a, int *ascale, unsigned int an, DWORD *b, int *bscale, unsigned int bn)
 
static HRESULT VARIANT_DI_div (const VARIANT_DI *dividend, const VARIANT_DI *divisor, VARIANT_DI *quotient, BOOL round_remainder)
 
static HRESULT VARIANT_DI_normalize (VARIANT_DI *val, int exponent2, BOOL isDouble)
 
static HRESULT VARIANT_do_division (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut, BOOL round)
 
HRESULT WINAPI VarDecDiv (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecMul (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecSub (const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecAbs (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecFix (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecInt (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecNeg (const DECIMAL *pDecIn, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecRound (const DECIMAL *pDecIn, int cDecimals, DECIMAL *pDecOut)
 
HRESULT WINAPI VarDecCmp (const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
 
HRESULT WINAPI VarDecCmpR8 (const DECIMAL *pDecLeft, double dblRight)
 
HRESULT WINAPI VarBoolFromUI1 (BYTE bIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI2 (SHORT sIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI4 (LONG lIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromR4 (FLOAT fltIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromR8 (double dblIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDate (DATE dateIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromCy (CY cyIn, VARIANT_BOOL *pBoolOut)
 
static BOOL VARIANT_GetLocalisedText (LANGID langId, DWORD dwId, WCHAR *lpszDest)
 
HRESULT WINAPI VarBoolFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDisp (IDispatch *pdispIn, LCID lcid, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI1 (signed char cIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI2 (USHORT usIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI4 (ULONG ulIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromDec (DECIMAL *pDecIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromI8 (LONG64 llIn, VARIANT_BOOL *pBoolOut)
 
HRESULT WINAPI VarBoolFromUI8 (ULONG64 ullIn, VARIANT_BOOL *pBoolOut)
 
static WCHARVARIANT_WriteNumber (ULONG64 ulVal, WCHAR *szOut)
 
static BSTR VARIANT_MakeBstr (LCID lcid, DWORD dwFlags, WCHAR *szOut)
 
static HRESULT VARIANT_BstrFromUInt (ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI1 (BYTE bIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI2 (short sIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI4 (LONG lIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
static BSTR VARIANT_BstrReplaceDecimal (const WCHAR *buff, LCID lcid, ULONG dwFlags)
 
static HRESULT VARIANT_BstrFromReal (DOUBLE dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut, LPCWSTR lpszFormat)
 
HRESULT WINAPI VarBstrFromR4 (FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromR8 (double dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromCy (CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
static int output_int_len (int o, int min_len, WCHAR *date, int date_len)
 
BOOL get_date_format (LCID lcid, DWORD flags, const SYSTEMTIME *st, const WCHAR *fmt, WCHAR *date, int date_len)
 
HRESULT WINAPI VarBstrFromDate (DATE dateIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromBool (VARIANT_BOOL boolIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI1 (signed char cIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI2 (USHORT usIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI4 (ULONG ulIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromDec (DECIMAL *pDecIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromI8 (LONG64 llIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromUI8 (ULONG64 ullIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrFromDisp (IDispatch *pdispIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrCat (BSTR pbstrLeft, BSTR pbstrRight, BSTR *pbstrOut)
 
HRESULT WINAPI VarBstrCmp (BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFlags)
 
HRESULT WINAPI VarDateFromUI1 (BYTE bIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI2 (short sIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI4 (LONG lIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromR4 (FLOAT fltIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromR8 (double dblIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromDisp (IDispatch *pdispIn, LCID lcid, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromBool (VARIANT_BOOL boolIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromCy (CY cyIn, DATE *pdateOut)
 
static BOOL VARIANT_IsValidMonthDay (DWORD day, DWORD month, DWORD year)
 
static HRESULT VARIANT_MakeDate (DATEPARSE *dp, DWORD iDate, DWORD offset, SYSTEMTIME *st)
 
HRESULT WINAPI VarDateFromStr (OLECHAR *strIn, LCID lcid, ULONG dwFlags, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI1 (signed char cIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI2 (USHORT uiIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI4 (ULONG ulIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromDec (DECIMAL *pdecIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromI8 (LONG64 llIn, DATE *pdateOut)
 
HRESULT WINAPI VarDateFromUI8 (ULONG64 ullIn, DATE *pdateOut)
 

Variables

HMODULE hProxyDll DECLSPEC_HIDDEN
 
static const WCHAR szFloatFormatW [] = { '%','.','7','G','\0' }
 
static const WCHAR szDoubleFormatW [] = { '%','.','1','5','G','\0' }
 
static const int CY_Divisors [5]
 

Macro Definition Documentation

◆ BOTHTST

#define BOTHTST (   dest,
  src,
  func,
  lo,
  hi 
)
Value:
if (in < (dest)lo || in > hi) return DISP_E_OVERFLOW; *out = in; return S_OK; }
#define RETTYP
Definition: vartype.c:146
GLenum func
Definition: glext.h:6028
GLenum src
Definition: glext.h:6340
GLuint in
Definition: glext.h:9616
#define _(X)
Definition: i386-dis.c:35
#define S_OK
Definition: intsafe.h:52
static char * dest
Definition: rtl.c:135
static FILE * out
Definition: regtests2xml.c:44
#define DISP_E_OVERFLOW
Definition: winerror.h:2519

Definition at line 162 of file vartype.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file vartype.c.

◆ CY_HALF

#define CY_HALF   (CY_MULTIPLIER/2) /* 0.5 */

Definition at line 40 of file vartype.c.

◆ CY_HALF_F

#define CY_HALF_F   (CY_MULTIPLIER_F/2.0)

Definition at line 41 of file vartype.c.

◆ CY_MULTIPLIER

#define CY_MULTIPLIER   10000 /* 4 dp of precision */

Definition at line 38 of file vartype.c.

◆ CY_MULTIPLIER_F

#define CY_MULTIPLIER_F   10000.0

Definition at line 39 of file vartype.c.

◆ DATE_SWAP

#define DATE_SWAP (   x,
  y 
)    do { dwTemp = x; x = y; y = dwTemp; } while (0)

◆ DP_AM

#define DP_AM   0x08 /* AM */

Definition at line 7358 of file vartype.c.

◆ DP_DATESEP

#define DP_DATESEP   0x02 /* Date separator */

Definition at line 7356 of file vartype.c.

◆ DP_MONTH

#define DP_MONTH   0x04 /* Month name */

Definition at line 7357 of file vartype.c.

◆ DP_PM

#define DP_PM   0x10 /* PM */

Definition at line 7359 of file vartype.c.

◆ DP_TIMESEP

#define DP_TIMESEP   0x01 /* Time separator ( _must_ remain 0x1, used as a bitmask) */

Definition at line 7355 of file vartype.c.

◆ IsLeapYear

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

Definition at line 7371 of file vartype.c.

◆ NEGTST

#define NEGTST (   dest,
  src,
  func 
)
Value:
return
Definition: dirsup.c:529

Definition at line 154 of file vartype.c.

◆ NONAMELESSSTRUCT

#define NONAMELESSSTRUCT

Definition at line 23 of file vartype.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 22 of file vartype.c.

◆ ORDER_DMY

#define ORDER_DMY   0x08

Definition at line 7390 of file vartype.c.

◆ ORDER_MDY

#define ORDER_MDY   0x01

Definition at line 7387 of file vartype.c.

◆ ORDER_MYD

#define ORDER_MYD   0x10 /* Synthetic order, used only for funky 2 digit dates */

Definition at line 7391 of file vartype.c.

◆ ORDER_YDM

#define ORDER_YDM   0x04

Definition at line 7389 of file vartype.c.

◆ ORDER_YMD

#define ORDER_YMD   0x02

Definition at line 7388 of file vartype.c.

◆ POSTST

#define POSTST (   dest,
  src,
  func,
  tst 
)
Value:
if (in > (dest)tst) return DISP_E_OVERFLOW; *out = in; return S_OK; }

Definition at line 158 of file vartype.c.

◆ RETTYP

#define RETTYP   static inline HRESULT

Definition at line 146 of file vartype.c.

◆ SIMPLE

#define SIMPLE (   dest,
  src,
  func 
)
Value:
*out = in; return S_OK; }

Definition at line 150 of file vartype.c.

◆ TIMEFLAG

#define TIMEFLAG (   i)    ((dp.dwFlags[i] & DP_TIMESEP) << i)

Definition at line 7369 of file vartype.c.

◆ VARIANT_DutchRound

#define VARIANT_DutchRound (   typ,
  value,
  res 
)
Value:
do { \
double whole = value < 0 ? ceil(value) : floor(value); \
double fract = value - whole; \
if (fract > 0.5) res = (typ)whole + (typ)1; \
else if (fract == 0.5) { typ is_odd = (typ)whole & 1; res = whole + is_odd; } \
else if (fract >= 0.0) res = (typ)whole; \
else if (fract == -0.5) { typ is_odd = (typ)whole & 1; res = whole - is_odd; } \
else if (fract > -0.5) res = (typ)whole; \
else res = (typ)whole - (typ)1; \
} while(0)
GLuint res
Definition: glext.h:9613
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
if(dx< 0)
Definition: linetemp.h:194
else
Definition: tritemp.h:161
Definition: pdh_main.c:94

Definition at line 77 of file vartype.c.

Typedef Documentation

◆ DATEPARSE

◆ VARIANT_DI

Function Documentation

◆ _VarR8FromCy()

RETTYP _VarR8FromCy ( CY  i,
double o 
)

Definition at line 255 of file vartype.c.

255{ *o = (double)i.int64 / CY_MULTIPLIER_F; return S_OK; }
#define CY_MULTIPLIER_F
Definition: vartype.c:39
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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80

Referenced by VarCyAdd(), VarCyMul(), VarCyMulI4(), VarCyMulI8(), VarCyRound(), VarCySub(), and VarR8FromCy().

◆ get_date_format()

BOOL get_date_format ( LCID  lcid,
DWORD  flags,
const SYSTEMTIME st,
const WCHAR fmt,
WCHAR date,
int  date_len 
)

Definition at line 6668 of file vartype.c.

6670{
6671 static const LCTYPE dayname[] = {
6674 };
6675 static const LCTYPE sdayname[] = {
6679 };
6680 static const LCTYPE monthname[] = {
6684 };
6685 static const LCTYPE smonthname[] = {
6690 };
6691
6693 FIXME("ignoring flags %x\n", flags);
6695
6696 while(*fmt && date_len) {
6697 int count = 1;
6698
6699 switch(*fmt) {
6700 case 'd':
6701 case 'M':
6702 case 'y':
6703 case 'g':
6704 while(*fmt == *(fmt+count))
6705 count++;
6706 fmt += count-1;
6707 }
6708
6709 switch(*fmt) {
6710 case 'd':
6711 if(count >= 4)
6712 count = GetLocaleInfoW(lcid, dayname[st->wDayOfWeek] | flags, date, date_len)-1;
6713 else if(count == 3)
6714 count = GetLocaleInfoW(lcid, sdayname[st->wDayOfWeek] | flags, date, date_len)-1;
6715 else
6716 count = output_int_len(st->wDay, count, date, date_len);
6717 break;
6718 case 'M':
6719 if(count >= 4)
6720 count = GetLocaleInfoW(lcid, monthname[st->wMonth-1] | flags, date, date_len)-1;
6721 else if(count == 3)
6722 count = GetLocaleInfoW(lcid, smonthname[st->wMonth-1] | flags, date, date_len)-1;
6723 else
6724 count = output_int_len(st->wMonth, count, date, date_len);
6725 break;
6726 case 'y':
6727 if(count >= 3)
6728 count = output_int_len(st->wYear, 0, date, date_len);
6729 else
6730 count = output_int_len(st->wYear%100, count, date, date_len);
6731 break;
6732 case 'g':
6733 if(count == 2) {
6734 FIXME("Should be using GetCalendarInfo(CAL_SERASTRING), defaulting to 'AD'\n");
6735
6736 *date++ = 'A';
6737 date_len--;
6738 if(date_len)
6739 *date = 'D';
6740 else
6741 count = -1;
6742 break;
6743 }
6744 /* fall through */
6745 default:
6746 *date = *fmt;
6747 }
6748
6749 if(count < 0)
6750 break;
6751 fmt++;
6752 date += count;
6753 date_len -= count;
6754 }
6755
6756 if(!date_len)
6757 return FALSE;
6758 *date++ = 0;
6759 return TRUE;
6760}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1665
static int output_int_len(int o, int min_len, WCHAR *date, int date_len)
Definition: vartype.c:6648
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
__u16 date
Definition: mkdosfs.c:8
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
WORD wYear
Definition: winbase.h:905
WORD wMonth
Definition: winbase.h:906
WORD wDay
Definition: winbase.h:908
WORD wDayOfWeek
Definition: winbase.h:907
Definition: dsound.c:943
#define LOCALE_SABBREVMONTHNAME10
Definition: winnls.h:113
#define LOCALE_SMONTHNAME12
Definition: winnls.h:102
#define LOCALE_SMONTHNAME5
Definition: winnls.h:95
#define LOCALE_SDAYNAME5
Definition: winnls.h:81
#define LOCALE_SABBREVMONTHNAME9
Definition: winnls.h:112
#define LOCALE_SABBREVMONTHNAME11
Definition: winnls.h:114
#define LOCALE_SABBREVDAYNAME5
Definition: winnls.h:88
#define LOCALE_SABBREVDAYNAME2
Definition: winnls.h:85
#define LOCALE_SABBREVMONTHNAME2
Definition: winnls.h:105
#define LOCALE_SMONTHNAME3
Definition: winnls.h:93
#define LOCALE_SMONTHNAME11
Definition: winnls.h:101
#define LOCALE_SMONTHNAME8
Definition: winnls.h:98
#define LOCALE_SMONTHNAME4
Definition: winnls.h:94
#define LOCALE_SDAYNAME1
Definition: winnls.h:77
#define LOCALE_SMONTHNAME7
Definition: winnls.h:97
#define LOCALE_SABBREVMONTHNAME4
Definition: winnls.h:107
#define LOCALE_SABBREVDAYNAME4
Definition: winnls.h:87
#define LOCALE_SMONTHNAME1
Definition: winnls.h:91
#define LOCALE_SABBREVMONTHNAME3
Definition: winnls.h:106
#define LOCALE_SDAYNAME7
Definition: winnls.h:83
#define LOCALE_SDAYNAME2
Definition: winnls.h:78
#define LOCALE_SABBREVMONTHNAME1
Definition: winnls.h:104
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVDAYNAME6
Definition: winnls.h:89
#define LOCALE_SMONTHNAME2
Definition: winnls.h:92
#define LOCALE_SABBREVDAYNAME1
Definition: winnls.h:84
#define LOCALE_SABBREVMONTHNAME6
Definition: winnls.h:109
#define LOCALE_SMONTHNAME6
Definition: winnls.h:96
DWORD LCTYPE
Definition: winnls.h:517
#define LOCALE_SDAYNAME3
Definition: winnls.h:79
#define LOCALE_SABBREVDAYNAME3
Definition: winnls.h:86
#define LOCALE_SABBREVMONTHNAME5
Definition: winnls.h:108
#define LOCALE_SABBREVMONTHNAME7
Definition: winnls.h:110
#define LOCALE_SABBREVMONTHNAME8
Definition: winnls.h:111
#define LOCALE_SDAYNAME4
Definition: winnls.h:80
#define LOCALE_SMONTHNAME10
Definition: winnls.h:100
#define LOCALE_SMONTHNAME9
Definition: winnls.h:99
#define LOCALE_SABBREVMONTHNAME12
Definition: winnls.h:115
#define LOCALE_SDAYNAME6
Definition: winnls.h:82
#define LOCALE_SABBREVDAYNAME7
Definition: winnls.h:90

Referenced by VarBstrFromDate(), and VARIANT_FormatDate().

◆ output_int_len()

static int output_int_len ( int  o,
int  min_len,
WCHAR date,
int  date_len 
)
inlinestatic

Definition at line 6648 of file vartype.c.

6649{
6650 int len, tmp;
6651
6652 if(min_len >= date_len)
6653 return -1;
6654
6655 for(len=0, tmp=o; tmp; tmp/=10) len++;
6656 if(!len) len++;
6657 if(len >= date_len)
6658 return -1;
6659
6660 for(tmp=min_len-len; tmp>0; tmp--)
6661 *date++ = '0';
6662 for(tmp=len; tmp>0; tmp--, o/=10)
6663 date[tmp-1] = '0' + o%10;
6664 return min_len>len ? min_len : len;
6665}
GLenum GLsizei len
Definition: glext.h:6722

Referenced by get_date_format().

◆ VarBoolFromCy()

HRESULT WINAPI VarBoolFromCy ( CY  cyIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6048 of file vartype.c.

6049{
6050 *pBoolOut = cyIn.int64 ? VARIANT_TRUE : VARIANT_FALSE;
6051 return S_OK;
6052}
LONGLONG int64
Definition: compat.h:2265

Referenced by test_VarBoolFromCy(), and VARIANT_Coerce().

◆ VarBoolFromDate()

HRESULT WINAPI VarBoolFromDate ( DATE  dateIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6030 of file vartype.c.

6031{
6032 *pBoolOut = dateIn ? VARIANT_TRUE : VARIANT_FALSE;
6033 return S_OK;
6034}

Referenced by test_VarBoolFromDate(), and VARIANT_Coerce().

◆ VarBoolFromDec()

HRESULT WINAPI VarBoolFromDec ( DECIMAL pDecIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6278 of file vartype.c.

6279{
6280 if (DEC_SCALE(pDecIn) > DEC_MAX_SCALE || (DEC_SIGN(pDecIn) & ~DECIMAL_NEG))
6281 return E_INVALIDARG;
6282
6283 if (DEC_HI32(pDecIn) || DEC_MID32(pDecIn) || DEC_LO32(pDecIn))
6284 *pBoolOut = VARIANT_TRUE;
6285 else
6286 *pBoolOut = VARIANT_FALSE;
6287 return S_OK;
6288}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DEC_LO32(d)
Definition: variant.h:96
#define DEC_MID32(d)
Definition: variant.h:95
#define DEC_SIGN(d)
Definition: variant.h:91
#define DEC_SCALE(d)
Definition: variant.h:92
#define DEC_HI32(d)
Definition: variant.h:94
#define DEC_MAX_SCALE
Definition: variant.h:99

Referenced by test_VarBoolFromDec(), and VARIANT_Coerce().

◆ VarBoolFromDisp()

HRESULT WINAPI VarBoolFromDisp ( IDispatch pdispIn,
LCID  lcid,
VARIANT_BOOL pBoolOut 
)

Definition at line 6206 of file vartype.c.

6207{
6208 return VARIANT_FromDisp(pdispIn, lcid, pBoolOut, VT_BOOL, 0);
6209}
@ VT_BOOL
Definition: compat.h:2306
static HRESULT VARIANT_FromDisp(IDispatch *pdispIn, LCID lcid, void *pOut, VARTYPE vt, DWORD dwFlags)
Definition: vartype.c:115

Referenced by VARIANT_Coerce().

◆ VarBoolFromI1()

HRESULT WINAPI VarBoolFromI1 ( signed char  cIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6223 of file vartype.c.

6224{
6225 *pBoolOut = cIn ? VARIANT_TRUE : VARIANT_FALSE;
6226 return S_OK;
6227}

Referenced by test_VarBoolFromI1(), and VARIANT_Coerce().

◆ VarBoolFromI2()

HRESULT WINAPI VarBoolFromI2 ( SHORT  sIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5958 of file vartype.c.

5959{
5960 *pBoolOut = sIn ? VARIANT_TRUE : VARIANT_FALSE;
5961 return S_OK;
5962}

Referenced by test_VarBoolFromI2(), and VARIANT_Coerce().

◆ VarBoolFromI4()

HRESULT WINAPI VarBoolFromI4 ( LONG  lIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5976 of file vartype.c.

5977{
5978 *pBoolOut = lIn ? VARIANT_TRUE : VARIANT_FALSE;
5979 return S_OK;
5980}

Referenced by test_VarBoolFromI4(), test_VarBoolFromUI4(), and VARIANT_Coerce().

◆ VarBoolFromI8()

HRESULT WINAPI VarBoolFromI8 ( LONG64  llIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6302 of file vartype.c.

6303{
6304 *pBoolOut = llIn ? VARIANT_TRUE : VARIANT_FALSE;
6305 return S_OK;
6306}

Referenced by test_VarBoolFromI8(), and VARIANT_Coerce().

◆ VarBoolFromR4()

HRESULT WINAPI VarBoolFromR4 ( FLOAT  fltIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5994 of file vartype.c.

5995{
5996 *pBoolOut = fltIn ? VARIANT_TRUE : VARIANT_FALSE;
5997 return S_OK;
5998}

Referenced by test_VarBoolFromR4(), and VARIANT_Coerce().

◆ VarBoolFromR8()

HRESULT WINAPI VarBoolFromR8 ( double  dblIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6012 of file vartype.c.

6013{
6014 *pBoolOut = dblIn ? VARIANT_TRUE : VARIANT_FALSE;
6015 return S_OK;
6016}

Referenced by test_VarBoolFromR8(), and VARIANT_Coerce().

◆ VarBoolFromStr()

HRESULT WINAPI VarBoolFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
VARIANT_BOOL pBoolOut 
)

Definition at line 6114 of file vartype.c.

6115{
6116 /* Any VB/VBA programmers out there should recognise these strings... */
6117 static const WCHAR szFalse[] = { '#','F','A','L','S','E','#','\0' };
6118 static const WCHAR szTrue[] = { '#','T','R','U','E','#','\0' };
6119 WCHAR szBuff[64];
6121 HRESULT hRes = S_OK;
6122
6123 if (!strIn || !pBoolOut)
6124 return DISP_E_TYPEMISMATCH;
6125
6126 /* Check if we should be comparing against localised text */
6127 if (dwFlags & VAR_LOCALBOOL)
6128 {
6129 /* Convert our LCID into a usable value */
6130 lcid = ConvertDefaultLocale(lcid);
6131
6132 langId = LANGIDFROMLCID(lcid);
6133
6134 if (PRIMARYLANGID(langId) == LANG_NEUTRAL)
6136
6137 /* Note: Native oleaut32 always copies strIn and maps halfwidth characters.
6138 * I don't think this is needed unless any of the localised text strings
6139 * contain characters that can be so mapped. In the event that this is
6140 * true for a given language (possibly some Asian languages), then strIn
6141 * should be mapped here _only_ if langId is an Id for which this can occur.
6142 */
6143 }
6144
6145 /* Note that if we are not comparing against localised strings, langId
6146 * will have its default value of LANG_ENGLISH. This allows us to mimic
6147 * the native behaviour of always checking against English strings even
6148 * after we've checked for localised ones.
6149 */
6150VarBoolFromStr_CheckLocalised:
6151 if (VARIANT_GetLocalisedText(langId, IDS_TRUE, szBuff))
6152 {
6153 /* Compare against localised strings, ignoring case */
6154 if (!wcsicmp(strIn, szBuff))
6155 {
6156 *pBoolOut = VARIANT_TRUE; /* Matched localised 'true' text */
6157 return hRes;
6158 }
6159 VARIANT_GetLocalisedText(langId, IDS_FALSE, szBuff);
6160 if (!wcsicmp(strIn, szBuff))
6161 {
6162 *pBoolOut = VARIANT_FALSE; /* Matched localised 'false' text */
6163 return hRes;
6164 }
6165 }
6166
6167 if (langId != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT))
6168 {
6169 /* We have checked the localised text, now check English */
6171 goto VarBoolFromStr_CheckLocalised;
6172 }
6173
6174 /* All checks against localised text have failed, try #TRUE#/#FALSE# */
6175 if (!wcscmp(strIn, szFalse))
6176 *pBoolOut = VARIANT_FALSE;
6177 else if (!wcscmp(strIn, szTrue))
6178 *pBoolOut = VARIANT_TRUE;
6179 else
6180 {
6181 double d;
6182
6183 /* If this string is a number, convert it as one */
6184 hRes = VarR8FromStr(strIn, lcid, dwFlags, &d);
6185 if (SUCCEEDED(hRes)) *pBoolOut = d ? VARIANT_TRUE : VARIANT_FALSE;
6186 }
6187 return hRes;
6188}
#define wcsicmp
Definition: compat.h:15
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: locale.c:2876
#define IDS_TRUE
Definition: resource.h:26
#define IDS_FALSE
Definition: resource.h:27
HRESULT WINAPI VarR8FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, double *pDblOut)
Definition: vartype.c:3151
static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest)
Definition: vartype.c:6060
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define d
Definition: ke_i.h:81
USHORT LANGID
Definition: mui.h:9
#define VAR_LOCALBOOL
Definition: oleauto.h:330
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_ENGLISH
Definition: nls.h:52
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define PRIMARYLANGID(l)
Definition: nls.h:16
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_VarBoolFromStr(), VarAnd(), VARIANT_Coerce(), VarImp(), VarNot(), and VarOr().

◆ VarBoolFromUI1()

HRESULT WINAPI VarBoolFromUI1 ( BYTE  bIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 5940 of file vartype.c.

5941{
5942 *pBoolOut = bIn ? VARIANT_TRUE : VARIANT_FALSE;
5943 return S_OK;
5944}

Referenced by test_VarBoolFromUI1(), and VARIANT_Coerce().

◆ VarBoolFromUI2()

HRESULT WINAPI VarBoolFromUI2 ( USHORT  usIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6241 of file vartype.c.

6242{
6243 *pBoolOut = usIn ? VARIANT_TRUE : VARIANT_FALSE;
6244 return S_OK;
6245}

Referenced by test_VarBoolFromUI2(), and VARIANT_Coerce().

◆ VarBoolFromUI4()

HRESULT WINAPI VarBoolFromUI4 ( ULONG  ulIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6259 of file vartype.c.

6260{
6261 *pBoolOut = ulIn ? VARIANT_TRUE : VARIANT_FALSE;
6262 return S_OK;
6263}

Referenced by VARIANT_Coerce().

◆ VarBoolFromUI8()

HRESULT WINAPI VarBoolFromUI8 ( ULONG64  ullIn,
VARIANT_BOOL pBoolOut 
)

Definition at line 6320 of file vartype.c.

6321{
6322 *pBoolOut = ullIn ? VARIANT_TRUE : VARIANT_FALSE;
6323 return S_OK;
6324}

Referenced by test_VarBoolFromUI8(), and VARIANT_Coerce().

◆ VarBstrCat()

HRESULT WINAPI VarBstrCat ( BSTR  pbstrLeft,
BSTR  pbstrRight,
BSTR pbstrOut 
)

Definition at line 7107 of file vartype.c.

7108{
7109 unsigned int lenLeft, lenRight;
7110
7111 TRACE("%s,%s,%p\n",
7112 debugstr_wn(pbstrLeft, SysStringLen(pbstrLeft)),
7113 debugstr_wn(pbstrRight, SysStringLen(pbstrRight)), pbstrOut);
7114
7115 if (!pbstrOut)
7116 return E_INVALIDARG;
7117
7118 /* use byte length here to properly handle ansi-allocated BSTRs */
7119 lenLeft = pbstrLeft ? SysStringByteLen(pbstrLeft) : 0;
7120 lenRight = pbstrRight ? SysStringByteLen(pbstrRight) : 0;
7121
7122 *pbstrOut = SysAllocStringByteLen(NULL, lenLeft + lenRight);
7123 if (!*pbstrOut)
7124 return E_OUTOFMEMORY;
7125
7126 (*pbstrOut)[0] = '\0';
7127
7128 if (pbstrLeft)
7129 memcpy(*pbstrOut, pbstrLeft, lenLeft);
7130
7131 if (pbstrRight)
7132 memcpy((CHAR*)*pbstrOut + lenLeft, pbstrRight, lenRight);
7133
7134 TRACE("%s\n", debugstr_wn(*pbstrOut, SysStringLen(*pbstrOut)));
7135 return S_OK;
7136}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define debugstr_wn
Definition: kernel32.h:33
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UINT WINAPI SysStringByteLen(BSTR str)
Definition: oleaut.c:215
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
BSTR WINAPI DECLSPEC_HOTPATCH SysAllocStringByteLen(LPCSTR str, UINT len)
Definition: oleaut.c:428
#define TRACE(s)
Definition: solgame.cpp:4
char CHAR
Definition: xmlstorage.h:175

Referenced by test_VarBstrCat(), VarAdd(), and VarCat().

◆ VarBstrCmp()

HRESULT WINAPI VarBstrCmp ( BSTR  pbstrLeft,
BSTR  pbstrRight,
LCID  lcid,
DWORD  dwFlags 
)

Definition at line 7158 of file vartype.c.

7159{
7160 HRESULT hres;
7161 int ret;
7162
7163 TRACE("%s,%s,%d,%08x\n",
7164 debugstr_wn(pbstrLeft, SysStringLen(pbstrLeft)),
7165 debugstr_wn(pbstrRight, SysStringLen(pbstrRight)), lcid, dwFlags);
7166
7167 if (!pbstrLeft || !*pbstrLeft)
7168 {
7169 if (pbstrRight && *pbstrRight)
7170 return VARCMP_LT;
7171 }
7172 else if (!pbstrRight || !*pbstrRight)
7173 return VARCMP_GT;
7174
7175 if (lcid == 0)
7176 {
7177 unsigned int lenLeft = SysStringByteLen(pbstrLeft);
7178 unsigned int lenRight = SysStringByteLen(pbstrRight);
7179 ret = memcmp(pbstrLeft, pbstrRight, min(lenLeft, lenRight));
7180 if (ret < 0)
7181 return VARCMP_LT;
7182 if (ret > 0)
7183 return VARCMP_GT;
7184 if (lenLeft < lenRight)
7185 return VARCMP_LT;
7186 if (lenLeft > lenRight)
7187 return VARCMP_GT;
7188 return VARCMP_EQ;
7189 }
7190 else
7191 {
7192 unsigned int lenLeft = SysStringLen(pbstrLeft);
7193 unsigned int lenRight = SysStringLen(pbstrRight);
7194
7195 if (lenLeft == 0 || lenRight == 0)
7196 {
7197 if (lenLeft == 0 && lenRight == 0) return VARCMP_EQ;
7198 return lenLeft < lenRight ? VARCMP_LT : VARCMP_GT;
7199 }
7200
7201 hres = CompareStringW(lcid, dwFlags, pbstrLeft, lenLeft,
7202 pbstrRight, lenRight) - CSTR_LESS_THAN;
7203 TRACE("%d\n", hres);
7204 return hres;
7205 }
7206}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4013
HRESULT hres
Definition: protocol.c:465
#define min(a, b)
Definition: monoChain.cc:55
#define VARCMP_LT
Definition: oleauto.h:657
#define VARCMP_EQ
Definition: oleauto.h:658
#define VARCMP_GT
Definition: oleauto.h:659
int ret
#define CSTR_LESS_THAN
Definition: winnls.h:455

Referenced by START_TEST(), and VarCmp().

◆ VarBstrFromBool()

HRESULT WINAPI VarBstrFromBool ( VARIANT_BOOL  boolIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6852 of file vartype.c.

6853{
6854 WCHAR szBuff[64];
6855 DWORD dwResId = IDS_TRUE;
6856 LANGID langId;
6857
6858 TRACE("%d,0x%08x,0x%08x,%p\n", boolIn, lcid, dwFlags, pbstrOut);
6859
6860 if (!pbstrOut)
6861 return E_INVALIDARG;
6862
6863 /* VAR_BOOLONOFF and VAR_BOOLYESNO are internal flags used
6864 * for variant formatting */
6866 {
6867 case VAR_BOOLONOFF:
6868 dwResId = IDS_ON;
6869 break;
6870 case VAR_BOOLYESNO:
6871 dwResId = IDS_YES;
6872 break;
6873 case VAR_LOCALBOOL:
6874 break;
6875 default:
6877 }
6878
6879 lcid = ConvertDefaultLocale(lcid);
6880 langId = LANGIDFROMLCID(lcid);
6881 if (PRIMARYLANGID(langId) == LANG_NEUTRAL)
6883
6884 if (boolIn == VARIANT_FALSE)
6885 dwResId++; /* Use negative form */
6886
6887VarBstrFromBool_GetLocalised:
6888 if (VARIANT_GetLocalisedText(langId, dwResId, szBuff))
6889 {
6890 *pbstrOut = SysAllocString(szBuff);
6891 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6892 }
6893
6894 if (langId != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT))
6895 {
6897 goto VarBstrFromBool_GetLocalised;
6898 }
6899
6900 /* Should never get here */
6901 WARN("Failed to load bool text!\n");
6902 return E_OUTOFMEMORY;
6903}
#define IDS_YES
Definition: resource.h:16
#define WARN(fmt,...)
Definition: precomp.h:61
#define IDS_ON
Definition: resource.h:30
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define VAR_BOOLONOFF
Definition: variant.h:102
#define VAR_BOOLYESNO
Definition: variant.h:103

Referenced by init(), VARIANT_Coerce(), and VARIANT_FormatNumber().

◆ VarBstrFromCy()

HRESULT WINAPI VarBstrFromCy ( CY  cyIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6608 of file vartype.c.

6609{
6610 WCHAR buff[256];
6611 VARIANT_DI decVal;
6612
6613 if (!pbstrOut)
6614 return E_INVALIDARG;
6615
6616 decVal.scale = 4;
6617 decVal.sign = 0;
6618 decVal.bitsnum[0] = cyIn.s.Lo;
6619 decVal.bitsnum[1] = cyIn.s.Hi;
6620 if (cyIn.s.Hi & 0x80000000UL) {
6621 DWORD one = 1;
6622
6623 /* Negative number! */
6624 decVal.sign = 1;
6625 decVal.bitsnum[0] = ~decVal.bitsnum[0];
6626 decVal.bitsnum[1] = ~decVal.bitsnum[1];
6627 VARIANT_int_add(decVal.bitsnum, 3, &one, 1);
6628 }
6629 decVal.bitsnum[2] = 0;
6631
6632 if (dwFlags & LOCALE_USE_NLS)
6633 {
6634 WCHAR cybuff[256];
6635
6636 /* Format the currency for the locale */
6637 cybuff[0] = '\0';
6639 buff, NULL, cybuff, ARRAY_SIZE(cybuff));
6640 *pbstrOut = SysAllocString(cybuff);
6641 }
6642 else
6643 *pbstrOut = VARIANT_BstrReplaceDecimal(buff,lcid,dwFlags);
6644
6645 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6646}
#define ARRAY_SIZE(A)
Definition: main.h:33
static BSTR VARIANT_BstrReplaceDecimal(const WCHAR *buff, LCID lcid, ULONG dwFlags)
Definition: vartype.c:6457
static unsigned char VARIANT_int_add(DWORD *v, unsigned int nv, const DWORD *p, unsigned int np)
Definition: vartype.c:4932
static BOOL VARIANT_DI_tostringW(const VARIANT_DI *a, WCHAR *s, unsigned int n)
Definition: vartype.c:4825
static unsigned char buff[32768]
Definition: fatten.c:17
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1578
#define LOCALE_USE_NLS
Definition: oleauto.h:338
int one
Definition: sehframes.cpp:28
unsigned int sign
Definition: vartype.c:4156
DWORD bitsnum[3]
Definition: vartype.c:4154
unsigned char scale
Definition: vartype.c:4155
ULONG Lo
Definition: compat.h:2261
LONG Hi
Definition: compat.h:2262

Referenced by _BSTR_CY(), and VARIANT_Coerce().

◆ VarBstrFromDate()

HRESULT WINAPI VarBstrFromDate ( DATE  dateIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6778 of file vartype.c.

6779{
6780 SYSTEMTIME st;
6782 WCHAR date[128], fmt_buff[80], *time;
6783
6784 TRACE("(%g,0x%08x,0x%08x,%p)\n", dateIn, lcid, dwFlags, pbstrOut);
6785
6786 if (!pbstrOut || !VariantTimeToSystemTime(dateIn, &st))
6787 return E_INVALIDARG;
6788
6789 *pbstrOut = NULL;
6790
6792 st.wYear += 553; /* Use the Thai buddhist calendar year */
6794 FIXME("VAR_CALENDAR_HIJRI/VAR_CALENDAR_GREGORIAN not handled\n");
6795
6796 if (dwFlags & LOCALE_USE_NLS)
6798 else
6799 {
6800 double whole = dateIn < 0 ? ceil(dateIn) : floor(dateIn);
6801 double partial = dateIn - whole;
6802
6803 if (whole == 0.0)
6805 else if (partial > -1e-12 && partial < 1e-12)
6807 }
6808
6810 date[0] = '\0';
6811 else
6812 if (!GetLocaleInfoW(lcid, LOCALE_SSHORTDATE, fmt_buff, ARRAY_SIZE(fmt_buff)) ||
6813 !get_date_format(lcid, dwFlags, &st, fmt_buff, date, ARRAY_SIZE(date)))
6814 return E_INVALIDARG;
6815
6816 if (!(dwFlags & VAR_DATEVALUEONLY))
6817 {
6818 time = date + lstrlenW(date);
6819 if (time != date)
6820 *time++ = ' ';
6822 return E_INVALIDARG;
6823 }
6824
6825 *pbstrOut = SysAllocString(date);
6826 if (*pbstrOut)
6827 TRACE("returning %s\n", debugstr_w(*pbstrOut));
6828 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6829}
#define lstrlenW
Definition: compat.h:750
BOOL get_date_format(LCID lcid, DWORD flags, const SYSTEMTIME *st, const WCHAR *fmt, WCHAR *date, int date_len)
Definition: vartype.c:6668
#define e
Definition: ke_i.h:82
#define debugstr_w
Definition: kernel32.h:32
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
__u16 time
Definition: mkdosfs.c:8
#define VAR_CALENDAR_GREGORIAN
Definition: oleauto.h:334
#define VAR_CALENDAR_THAI
Definition: oleauto.h:333
#define VAR_CALENDAR_HIJRI
Definition: oleauto.h:329
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
DWORD dwFormatFlags
Definition: trayclock.cpp:31
INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
Definition: variant.c:1317
#define LOCALE_SSHORTDATE
Definition: winnls.h:60

Referenced by _BSTR_DATE(), VARIANT_Coerce(), and VARIANT_FormatDate().

◆ VarBstrFromDec()

HRESULT WINAPI VarBstrFromDec ( DECIMAL pDecIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6991 of file vartype.c.

6992{
6993 WCHAR buff[256];
6995
6996 if (!pbstrOut)
6997 return E_INVALIDARG;
6998
6999 VARIANT_DIFromDec(pDecIn, &temp);
7001
7002 if (dwFlags & LOCALE_USE_NLS)
7003 {
7004 WCHAR numbuff[256];
7005
7006 /* Format the number for the locale */
7007 numbuff[0] = '\0';
7009 buff, NULL, numbuff, ARRAY_SIZE(numbuff));
7010 TRACE("created NLS string %s\n", debugstr_w(numbuff));
7011 *pbstrOut = SysAllocString(numbuff);
7012 }
7013 else
7014 {
7015 *pbstrOut = VARIANT_BstrReplaceDecimal(buff, lcid, dwFlags);
7016 }
7017
7018 TRACE("returning %s\n", debugstr_w(*pbstrOut));
7019 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
7020}
static void VARIANT_DIFromDec(const DECIMAL *from, VARIANT_DI *to)
Definition: vartype.c:4661
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by _BSTR_DEC(), and VARIANT_Coerce().

◆ VarBstrFromDisp()

HRESULT WINAPI VarBstrFromDisp ( IDispatch pdispIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7087 of file vartype.c.

7088{
7089 return VARIANT_FromDisp(pdispIn, lcid, pbstrOut, VT_BSTR, dwFlags);
7090}
@ VT_BSTR
Definition: compat.h:2303

Referenced by VARIANT_Coerce().

◆ VarBstrFromI1()

HRESULT WINAPI VarBstrFromI1 ( signed char  cIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6921 of file vartype.c.

6922{
6923 ULONG64 ul64 = cIn;
6924
6925 if (cIn < 0)
6926 {
6927 ul64 = -cIn;
6929 }
6930 return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6931}
static HRESULT VARIANT_BstrFromUInt(ULONG64 ulVal, LCID lcid, DWORD dwFlags, BSTR *pbstrOut)
Definition: vartype.c:6364
unsigned __int64 ULONG64
Definition: imports.h:198
#define VAR_NEGATIVE
Definition: variant.h:104

Referenced by VARIANT_Coerce().

◆ VarBstrFromI2()

HRESULT WINAPI VarBstrFromI2 ( short  sIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6417 of file vartype.c.

6418{
6419 ULONG64 ul64 = sIn;
6420
6421 if (sIn < 0)
6422 {
6423 ul64 = -sIn;
6425 }
6426 return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6427}

Referenced by VARIANT_Coerce().

◆ VarBstrFromI4()

HRESULT WINAPI VarBstrFromI4 ( LONG  lIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6445 of file vartype.c.

6446{
6447 ULONG64 ul64 = lIn;
6448
6449 if (lIn < 0)
6450 {
6451 ul64 = -(LONG64)lIn;
6453 }
6454 return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
6455}
int64_t LONG64
Definition: typedefs.h:68

Referenced by test_VarBstrFromI4(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromI8()

HRESULT WINAPI VarBstrFromI8 ( LONG64  llIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7038 of file vartype.c.

7039{
7040 ULONG64 ul64 = llIn;
7041
7042 if (llIn < 0)
7043 {
7044 ul64 = -llIn;
7046 }
7047 return VARIANT_BstrFromUInt(ul64, lcid, dwFlags, pbstrOut);
7048}

Referenced by VARIANT_Coerce().

◆ VarBstrFromR4()

HRESULT WINAPI VarBstrFromR4 ( FLOAT  fltIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6566 of file vartype.c.

6567{
6568 return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, szFloatFormatW);
6569}
static const WCHAR szFloatFormatW[]
Definition: vartype.c:43
static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut, LPCWSTR lpszFormat)
Definition: vartype.c:6509

Referenced by test_VarBstrFromR4(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromR8()

HRESULT WINAPI VarBstrFromR8 ( double  dblIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6587 of file vartype.c.

6588{
6589 return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, szDoubleFormatW);
6590}
static const WCHAR szDoubleFormatW[]
Definition: vartype.c:44

Referenced by Global_InvokeEx(), var2str(), and VARIANT_Coerce().

◆ VarBstrFromUI1()

HRESULT WINAPI VarBstrFromUI1 ( BYTE  bIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6396 of file vartype.c.

6397{
6398 return VARIANT_BstrFromUInt(bIn, lcid, dwFlags, pbstrOut);
6399}

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI2()

HRESULT WINAPI VarBstrFromUI2 ( USHORT  usIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6949 of file vartype.c.

6950{
6951 return VARIANT_BstrFromUInt(usIn, lcid, dwFlags, pbstrOut);
6952}

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI4()

HRESULT WINAPI VarBstrFromUI4 ( ULONG  ulIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 6970 of file vartype.c.

6971{
6972 return VARIANT_BstrFromUInt(ulIn, lcid, dwFlags, pbstrOut);
6973}

Referenced by VARIANT_Coerce().

◆ VarBstrFromUI8()

HRESULT WINAPI VarBstrFromUI8 ( ULONG64  ullIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut 
)

Definition at line 7066 of file vartype.c.

7067{
7068 return VARIANT_BstrFromUInt(ullIn, lcid, dwFlags, pbstrOut);
7069}

Referenced by VARIANT_Coerce().

◆ VarCyAbs()

HRESULT WINAPI VarCyAbs ( CY  cyIn,
CY pCyOut 
)

Definition at line 3876 of file vartype.c.

3877{
3878 if (cyIn.s.Hi == (int)0x80000000 && !cyIn.s.Lo)
3879 return DISP_E_OVERFLOW;
3880
3881 pCyOut->int64 = cyIn.int64 < 0 ? -cyIn.int64 : cyIn.int64;
3882 return S_OK;
3883}

Referenced by test_VarCyAbs(), and VarAbs().

◆ VarCyAdd()

HRESULT WINAPI VarCyAdd ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3785 of file vartype.c.

3786{
3787 double l,r;
3788 _VarR8FromCy(cyLeft, &l);
3789 _VarR8FromCy(cyRight, &r);
3790 l = l + r;
3791 return VarCyFromR8(l, pCyOut);
3792}
r l[0]
Definition: byte_order.h:168
HRESULT WINAPI VarCyFromR8(double dblIn, CY *pCyOut)
Definition: vartype.c:3503
RETTYP _VarR8FromCy(CY i, double *o)
Definition: vartype.c:255
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by test_VarCyAdd(), and VarAdd().

◆ VarCyCmp()

HRESULT WINAPI VarCyCmp ( CY  cyLeft,
CY  cyRight 
)

Definition at line 4012 of file vartype.c.

4013{
4014 HRESULT hRet;
4015 CY result;
4016
4017 /* Subtract right from left, and compare the result to 0 */
4018 hRet = VarCySub(cyLeft, cyRight, &result);
4019
4020 if (SUCCEEDED(hRet))
4021 {
4022 if (result.int64 < 0)
4023 hRet = (HRESULT)VARCMP_LT;
4024 else if (result.int64 > 0)
4025 hRet = (HRESULT)VARCMP_GT;
4026 else
4027 hRet = (HRESULT)VARCMP_EQ;
4028 }
4029 return hRet;
4030}
HRESULT WINAPI VarCySub(CY cyLeft, CY cyRight, CY *pCyOut)
Definition: vartype.c:3854
GLuint64EXT * result
Definition: glext.h:11304
Definition: compat.h:2255
#define HRESULT
Definition: msvc.h:7

Referenced by VarCmp(), and VarCyCmpR8().

◆ VarCyCmpR8()

HRESULT WINAPI VarCyCmpR8 ( CY  cyLeft,
double  dblRight 
)

Definition at line 4046 of file vartype.c.

4047{
4048 HRESULT hRet;
4049 CY cyRight;
4050
4051 hRet = VarCyFromR8(dblRight, &cyRight);
4052
4053 if (SUCCEEDED(hRet))
4054 hRet = VarCyCmp(cyLeft, cyRight);
4055
4056 return hRet;
4057}
HRESULT WINAPI VarCyCmp(CY cyLeft, CY cyRight)
Definition: vartype.c:4012

◆ VarCyFix()

HRESULT WINAPI VarCyFix ( CY  cyIn,
CY pCyOut 
)

Definition at line 3902 of file vartype.c.

3903{
3904 pCyOut->int64 = cyIn.int64 / CY_MULTIPLIER;
3905 pCyOut->int64 *= CY_MULTIPLIER;
3906 return S_OK;
3907}
#define CY_MULTIPLIER
Definition: vartype.c:38

Referenced by VarFix().

◆ VarCyFromBool()

HRESULT WINAPI VarCyFromBool ( VARIANT_BOOL  boolIn,
CY pCyOut 
)

Definition at line 3620 of file vartype.c.

3621{
3622 pCyOut->int64 = (LONG64)boolIn * CY_MULTIPLIER;
3623 return S_OK;
3624}

Referenced by test_VarCyFromBool(), and VARIANT_Coerce().

◆ VarCyFromDate()

HRESULT WINAPI VarCyFromDate ( DATE  dateIn,
CY pCyOut 
)

Definition at line 3553 of file vartype.c.

3554{
3555 return VarCyFromR8(dateIn, pCyOut);
3556}

Referenced by test_VarCyFromDate(), and VARIANT_Coerce().

◆ VarCyFromDec()

HRESULT WINAPI VarCyFromDec ( DECIMAL pdecIn,
CY pCyOut 
)

Definition at line 3704 of file vartype.c.

3705{
3706 DECIMAL rounded;
3707 HRESULT hRet;
3708
3709 hRet = VarDecRound(pdecIn, 4, &rounded);
3710
3711 if (SUCCEEDED(hRet))
3712 {
3713 double d;
3714
3715 if (DEC_HI32(&rounded))
3716 return DISP_E_OVERFLOW;
3717
3718 /* Note: Without the casts this promotes to int64 which loses precision */
3719 d = (double)DEC_LO64(&rounded) / (double)CY_Divisors[DEC_SCALE(&rounded)];
3720 if (DEC_SIGN(&rounded))
3721 d = -d;
3722 return VarCyFromR8(d, pCyOut);
3723 }
3724 return hRet;
3725}
HRESULT WINAPI VarDecRound(const DECIMAL *pDecIn, int cDecimals, DECIMAL *pDecOut)
Definition: vartype.c:5815
static const int CY_Divisors[5]
Definition: vartype.c:3402
#define DEC_LO64(d)
Definition: variant.h:97

Referenced by test_VarCyFromDec(), and VARIANT_Coerce().

◆ VarCyFromDisp()

HRESULT WINAPI VarCyFromDisp ( IDispatch pdispIn,
LCID  lcid,
CY pCyOut 
)

Definition at line 3596 of file vartype.c.

3597{
3598 return VARIANT_FromDisp(pdispIn, lcid, pCyOut, VT_CY, 0);
3599}
@ VT_CY
Definition: compat.h:2301

Referenced by VARIANT_Coerce().

◆ VarCyFromI1()

HRESULT WINAPI VarCyFromI1 ( signed char  cIn,
CY pCyOut 
)

Definition at line 3641 of file vartype.c.

3642{
3643 pCyOut->int64 = (LONG64)cIn * CY_MULTIPLIER;
3644 return S_OK;
3645}

Referenced by test_VarCyFromI1(), and VARIANT_Coerce().

◆ VarCyFromI2()

HRESULT WINAPI VarCyFromI2 ( SHORT  sIn,
CY pCyOut 
)

Definition at line 3441 of file vartype.c.

3442{
3443 pCyOut->int64 = (LONG64)sIn * CY_MULTIPLIER;
3444 return S_OK;
3445}

Referenced by test_VarCyFromI2(), and VARIANT_Coerce().

◆ VarCyFromI4()

HRESULT WINAPI VarCyFromI4 ( LONG  lIn,
CY pCyOut 
)

Definition at line 3462 of file vartype.c.

3463{
3464 pCyOut->int64 = (LONG64)lIn * CY_MULTIPLIER;
3465 return S_OK;
3466}

Referenced by test_VarAdd(), test_VarCyFromI4(), test_VarDiv(), test_VarIdiv(), test_VarImp(), test_VarMul(), test_VarPow(), test_VarSub(), and VARIANT_Coerce().

◆ VarCyFromI8()

HRESULT WINAPI VarCyFromI8 ( LONG64  llIn,
CY pCyOut 
)

Definition at line 3742 of file vartype.c.

3743{
3744 if (llIn <= (I8_MIN/CY_MULTIPLIER) || llIn >= (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW;
3745 pCyOut->int64 = llIn * CY_MULTIPLIER;
3746 return S_OK;
3747}
#define I8_MAX
Definition: variant.h:65
#define I8_MIN
Definition: variant.h:66

Referenced by test_VarCyFromI8(), and VARIANT_Coerce().

◆ VarCyFromR4()

HRESULT WINAPI VarCyFromR4 ( FLOAT  fltIn,
CY pCyOut 
)

Definition at line 3483 of file vartype.c.

3484{
3485 return VarCyFromR8(fltIn, pCyOut);
3486}

Referenced by test_VarCyFromR4(), and VARIANT_Coerce().

◆ VarCyFromR8()

HRESULT WINAPI VarCyFromR8 ( double  dblIn,
CY pCyOut 
)

Definition at line 3503 of file vartype.c.

3504{
3505#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
3506 /* This code gives identical results to Win32 on Intel.
3507 * Here we use fp exceptions to catch overflows when storing the value.
3508 */
3509 static const unsigned short r8_fpcontrol = 0x137f;
3510 static const double r8_multiplier = CY_MULTIPLIER_F;
3511 unsigned short old_fpcontrol, result_fpstatus;
3512
3513 /* Clear exceptions, save the old fp state and load the new state */
3514 __asm__ __volatile__( "fnclex" );
3515 __asm__ __volatile__( "fstcw %0" : "=m" (old_fpcontrol) : );
3516 __asm__ __volatile__( "fldcw %0" : : "m" (r8_fpcontrol) );
3517 /* Perform the conversion. */
3518 __asm__ __volatile__( "fldl %0" : : "m" (dblIn) );
3519 __asm__ __volatile__( "fmull %0" : : "m" (r8_multiplier) );
3520 __asm__ __volatile__( "fistpll %0" : : "m" (*pCyOut) );
3521 /* Save the resulting fp state, load the old state and clear exceptions */
3522 __asm__ __volatile__( "fstsw %0" : "=m" (result_fpstatus) : );
3523 __asm__ __volatile__( "fnclex" );
3524 __asm__ __volatile__( "fldcw %0" : : "m" (old_fpcontrol) );
3525
3526 if (result_fpstatus & 0x9) /* Overflow | Invalid */
3527 return DISP_E_OVERFLOW;
3528#else
3529 /* This version produces slightly different results for boundary cases */
3530 if (dblIn < -922337203685477.5807 || dblIn >= 922337203685477.5807)
3531 return DISP_E_OVERFLOW;
3532 dblIn *= CY_MULTIPLIER_F;
3533 VARIANT_DutchRound(LONG64, dblIn, pCyOut->int64);
3534#endif
3535 return S_OK;
3536}
#define VARIANT_DutchRound(typ, value, res)
Definition: vartype.c:77
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")

Referenced by test_VarCyFromDate(), test_VarCyFromR8(), VarCyAdd(), VarCyCmpR8(), VarCyFromDate(), VarCyFromDec(), VarCyFromR4(), VarCyMul(), VarCyMulI4(), VarCyMulI8(), VarCySub(), VARIANT_Coerce(), and VarNumFromParseNum().

◆ VarCyFromStr()

HRESULT WINAPI VarCyFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
CY pCyOut 
)

Definition at line 3575 of file vartype.c.

3576{
3577 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pCyOut, VT_CY);
3578}
static HRESULT VARIANT_NumberFromBstr(OLECHAR *pStrIn, LCID lcid, ULONG ulFlags, void *pOut, VARTYPE vt)
Definition: vartype.c:90

Referenced by VARIANT_Coerce().

◆ VarCyFromUI1()

HRESULT WINAPI VarCyFromUI1 ( BYTE  bIn,
CY pCyOut 
)

Definition at line 3420 of file vartype.c.

3421{
3422 pCyOut->int64 = (ULONG64)bIn * CY_MULTIPLIER;
3423 return S_OK;
3424}

Referenced by test_VarCyFromUI1(), and VARIANT_Coerce().

◆ VarCyFromUI2()

HRESULT WINAPI VarCyFromUI2 ( USHORT  usIn,
CY pCyOut 
)

Definition at line 3662 of file vartype.c.

3663{
3664 pCyOut->int64 = (ULONG64)usIn * CY_MULTIPLIER;
3665 return S_OK;
3666}

Referenced by test_VarCyFromUI2(), and VARIANT_Coerce().

◆ VarCyFromUI4()

HRESULT WINAPI VarCyFromUI4 ( ULONG  ulIn,
CY pCyOut 
)

Definition at line 3683 of file vartype.c.

3684{
3685 pCyOut->int64 = (ULONG64)ulIn * CY_MULTIPLIER;
3686 return S_OK;
3687}

Referenced by test_VarCyFromUI4(), and VARIANT_Coerce().

◆ VarCyFromUI8()

HRESULT WINAPI VarCyFromUI8 ( ULONG64  ullIn,
CY pCyOut 
)

Definition at line 3764 of file vartype.c.

3765{
3766 if (ullIn > (I8_MAX/CY_MULTIPLIER)) return DISP_E_OVERFLOW;
3767 pCyOut->int64 = ullIn * CY_MULTIPLIER;
3768 return S_OK;
3769}

Referenced by test_VarCyFromUI8(), and VARIANT_Coerce().

◆ VarCyInt()

HRESULT WINAPI VarCyInt ( CY  cyIn,
CY pCyOut 
)

Definition at line 3926 of file vartype.c.

3927{
3928 pCyOut->int64 = cyIn.int64 / CY_MULTIPLIER;
3929 pCyOut->int64 *= CY_MULTIPLIER;
3930
3931 if (cyIn.int64 < 0 && cyIn.int64 % CY_MULTIPLIER != 0)
3932 {
3933 pCyOut->int64 -= CY_MULTIPLIER;
3934 }
3935 return S_OK;
3936}

Referenced by VarInt().

◆ VarCyMul()

HRESULT WINAPI VarCyMul ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3808 of file vartype.c.

3809{
3810 double l,r;
3811 _VarR8FromCy(cyLeft, &l);
3812 _VarR8FromCy(cyRight, &r);
3813 l = l * r;
3814 return VarCyFromR8(l, pCyOut);
3815}

Referenced by test_VarCyMul(), and VarMul().

◆ VarCyMulI4()

HRESULT WINAPI VarCyMulI4 ( CY  cyLeft,
LONG  lRight,
CY pCyOut 
)

Definition at line 3831 of file vartype.c.

3832{
3833 double d;
3834
3835 _VarR8FromCy(cyLeft, &d);
3836 d = d * lRight;
3837 return VarCyFromR8(d, pCyOut);
3838}

◆ VarCyMulI8()

HRESULT WINAPI VarCyMulI8 ( CY  cyLeft,
LONG64  llRight,
CY pCyOut 
)

Definition at line 4073 of file vartype.c.

4074{
4075 double d;
4076
4077 _VarR8FromCy(cyLeft, &d);
4078 d = d * (double)llRight;
4079 return VarCyFromR8(d, pCyOut);
4080}

◆ VarCyNeg()

HRESULT WINAPI VarCyNeg ( CY  cyIn,
CY pCyOut 
)

Definition at line 3951 of file vartype.c.

3952{
3953 if (cyIn.s.Hi == (int)0x80000000 && !cyIn.s.Lo)
3954 return DISP_E_OVERFLOW;
3955
3956 pCyOut->int64 = -cyIn.int64;
3957 return S_OK;
3958}

Referenced by test_VarCyNeg(), and VarNeg().

◆ VarCyRound()

HRESULT WINAPI VarCyRound ( CY  cyIn,
int  cDecimals,
CY pCyOut 
)

Definition at line 3974 of file vartype.c.

3975{
3976 if (cDecimals < 0)
3977 return E_INVALIDARG;
3978
3979 if (cDecimals > 3)
3980 {
3981 /* Rounding to more precision than we have */
3982 *pCyOut = cyIn;
3983 return S_OK;
3984 }
3985 else
3986 {
3987 double d, div = CY_Divisors[cDecimals];
3988
3989 _VarR8FromCy(cyIn, &d);
3990 d = d * div;
3992 d = (double)pCyOut->int64 / div * CY_MULTIPLIER_F;
3994 return S_OK;
3995 }
3996}
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
int64_t LONGLONG
Definition: typedefs.h:68

◆ VarCySub()

HRESULT WINAPI VarCySub ( CY  cyLeft,
CY  cyRight,
CY pCyOut 
)

Definition at line 3854 of file vartype.c.

3855{
3856 double l,r;
3857 _VarR8FromCy(cyLeft, &l);
3858 _VarR8FromCy(cyRight, &r);
3859 l = l - r;
3860 return VarCyFromR8(l, pCyOut);
3861}

Referenced by test_VarCySub(), VarCyCmp(), and VarSub().

◆ VarDateFromBool()

HRESULT WINAPI VarDateFromBool ( VARIANT_BOOL  boolIn,
DATE pdateOut 
)

Definition at line 7332 of file vartype.c.

7333{
7334 return VarR8FromBool(boolIn, pdateOut);
7335}
HRESULT WINAPI VarR8FromBool(VARIANT_BOOL boolIn, double *pDblOut)
Definition: vartype.c:3189

Referenced by test_VarDateFromBool(), and VARIANT_Coerce().

◆ VarDateFromCy()

HRESULT WINAPI VarDateFromCy ( CY  cyIn,
DATE pdateOut 
)

Definition at line 7349 of file vartype.c.

7350{
7351 return VarR8FromCy(cyIn, pdateOut);
7352}
HRESULT WINAPI VarR8FromCy(CY cyIn, double *pDblOut)
Definition: vartype.c:3113

Referenced by test_VarDateFromCy(), and VARIANT_Coerce().

◆ VarDateFromDec()

HRESULT WINAPI VarDateFromDec ( DECIMAL pdecIn,
DATE pdateOut 
)

Definition at line 8005 of file vartype.c.

8006{
8007 return VarR8FromDec(pdecIn, pdateOut);
8008}
HRESULT WINAPI VarR8FromDec(const DECIMAL *pDecIn, double *pDblOut)
Definition: vartype.c:3267

Referenced by test_VarDateFromDec(), and VARIANT_Coerce().

◆ VarDateFromDisp()

HRESULT WINAPI VarDateFromDisp ( IDispatch pdispIn,
LCID  lcid,
DATE pdateOut 
)

Definition at line 7315 of file vartype.c.

7316{
7317 return VARIANT_FromDisp(pdispIn, lcid, pdateOut, VT_DATE, 0);
7318}
@ VT_DATE
Definition: compat.h:2302

Referenced by VARIANT_Coerce().

◆ VarDateFromI1()

HRESULT WINAPI VarDateFromI1 ( signed char  cIn,
DATE pdateOut 
)

Definition at line 7954 of file vartype.c.

7955{
7956 return VarR8FromI1(cIn, pdateOut);
7957}
HRESULT WINAPI VarR8FromI1(signed char cIn, double *pDblOut)
Definition: vartype.c:3209

Referenced by test_VarDateFromI1(), and VARIANT_Coerce().

◆ VarDateFromI2()

HRESULT WINAPI VarDateFromI2 ( short  sIn,
DATE pdateOut 
)

Definition at line 7241 of file vartype.c.

7242{
7243 return VarR8FromI2(sIn, pdateOut);
7244}
HRESULT WINAPI VarR8FromI2(SHORT sIn, double *pDblOut)
Definition: vartype.c:3062

Referenced by test_VarDateFromI2(), and VARIANT_Coerce().

◆ VarDateFromI4()

HRESULT WINAPI VarDateFromI4 ( LONG  lIn,
DATE pdateOut 
)

Definition at line 7258 of file vartype.c.

7259{
7260 return VarDateFromR8(lIn, pdateOut);
7261}
HRESULT WINAPI VarDateFromR8(double dblIn, DATE *pdateOut)
Definition: vartype.c:7292

Referenced by test_VarDateFromI4(), and VARIANT_Coerce().

◆ VarDateFromI8()

HRESULT WINAPI VarDateFromI8 ( LONG64  llIn,
DATE pdateOut 
)

Definition at line 8023 of file vartype.c.

8024{
8025 if (llIn < DATE_MIN || llIn > DATE_MAX) return DISP_E_OVERFLOW;
8026 *pdateOut = (DATE)llIn;
8027 return S_OK;
8028}
double DATE
Definition: compat.h:2253
#define DATE_MAX
Definition: variant.h:69

Referenced by test_VarDateFromI8(), and VARIANT_Coerce().

◆ VarDateFromR4()

HRESULT WINAPI VarDateFromR4 ( FLOAT  fltIn,
DATE pdateOut 
)

Definition at line 7275 of file vartype.c.

7276{
7277 return VarR8FromR4(fltIn, pdateOut);
7278}
HRESULT WINAPI VarR8FromR4(FLOAT fltIn, double *pDblOut)
Definition: vartype.c:3096

Referenced by test_VarDateFromR4(), and VARIANT_Coerce().

◆ VarDateFromR8()

HRESULT WINAPI VarDateFromR8 ( double  dblIn,
DATE pdateOut 
)

Definition at line 7292 of file vartype.c.

7293{
7294 if (dblIn <= (DATE_MIN - 1.0) || dblIn >= (DATE_MAX + 1.0)) return DISP_E_OVERFLOW;
7295 *pdateOut = (DATE)dblIn;
7296 return S_OK;
7297}
#define DATE_MIN
Definition: variant.h:70

Referenced by test_VarDateFromR8(), VarDateFromI4(), VarDateFromUI4(), and VARIANT_Coerce().

◆ VarDateFromStr()

HRESULT WINAPI VarDateFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
DATE pdateOut 
)

Definition at line 7595 of file vartype.c.

7596{
7597 static const USHORT ParseDateTokens[] =
7598 {
7615 };
7616 static const BYTE ParseDateMonths[] =
7617 {
7618 1,2,3,4,5,6,7,8,9,10,11,12,13,
7619 1,2,3,4,5,6,7,8,9,10,11,12,13
7620 };
7621 unsigned int i;
7622 BSTR tokens[ARRAY_SIZE(ParseDateTokens)];
7623 DATEPARSE dp;
7624 DWORD dwDateSeps = 0, iDate = 0;
7625 HRESULT hRet = S_OK;
7626
7629 return E_INVALIDARG;
7630
7631 if (!strIn)
7632 return DISP_E_TYPEMISMATCH;
7633
7634 *pdateOut = 0.0;
7635
7636 TRACE("(%s,0x%08x,0x%08x,%p)\n", debugstr_w(strIn), lcid, dwFlags, pdateOut);
7637
7638 memset(&dp, 0, sizeof(dp));
7639
7640 GetLocaleInfoW(lcid, LOCALE_IDATE|LOCALE_RETURN_NUMBER|(dwFlags & LOCALE_NOUSEROVERRIDE),
7641 (LPWSTR)&iDate, sizeof(iDate)/sizeof(WCHAR));
7642 TRACE("iDate is %d\n", iDate);
7643
7644 /* Get the month/day/am/pm tokens for this locale */
7645 for (i = 0; i < ARRAY_SIZE(tokens); i++)
7646 {
7647 WCHAR buff[128];
7648 LCTYPE lctype = ParseDateTokens[i] | (dwFlags & LOCALE_NOUSEROVERRIDE);
7649
7650 /* FIXME: Alternate calendars - should use GetCalendarInfo() and/or
7651 * GetAltMonthNames(). We should really cache these strings too.
7652 */
7653 buff[0] = '\0';
7654 GetLocaleInfoW(lcid, lctype, buff, ARRAY_SIZE(buff));
7655 tokens[i] = SysAllocString(buff);
7656 TRACE("token %d is %s\n", i, debugstr_w(tokens[i]));
7657 }
7658
7659 /* Parse the string into our structure */
7660 while (*strIn)
7661 {
7662 if (iswdigit(*strIn))
7663 {
7664 if (dp.dwCount >= 6)
7665 {
7666 hRet = DISP_E_TYPEMISMATCH;
7667 break;
7668 }
7669 dp.dwValues[dp.dwCount] = wcstoul(strIn, &strIn, 10);
7670 dp.dwCount++;
7671 strIn--;
7672 }
7673 else if (iswalpha(*strIn))
7674 {
7675 BOOL bFound = FALSE;
7676
7677 for (i = 0; i < ARRAY_SIZE(tokens); i++)
7678 {
7679 DWORD dwLen = lstrlenW(tokens[i]);
7680 if (dwLen && !_wcsnicmp(strIn, tokens[i], dwLen))
7681 {
7682 if (i <= 25)
7683 {
7684 if (dp.dwCount >= 6)
7685 hRet = DISP_E_TYPEMISMATCH;
7686 else
7687 {
7688 dp.dwValues[dp.dwCount] = ParseDateMonths[i];
7689 dp.dwFlags[dp.dwCount] |= (DP_MONTH|DP_DATESEP);
7690 dp.dwCount++;
7691 }
7692 }
7693 else if (i > 39 && i < 42)
7694 {
7695 if (!dp.dwCount || dp.dwParseFlags & (DP_AM|DP_PM))
7696 hRet = DISP_E_TYPEMISMATCH;
7697 else
7698 {
7699 dp.dwFlags[dp.dwCount - 1] |= (i == 40 ? DP_AM : DP_PM);
7700 dp.dwParseFlags |= (i == 40 ? DP_AM : DP_PM);
7701 }
7702 }
7703 strIn += (dwLen - 1);
7704 bFound = TRUE;
7705 break;
7706 }
7707 }
7708
7709 if (!bFound)
7710 {
7711 if ((*strIn == 'a' || *strIn == 'A' || *strIn == 'p' || *strIn == 'P') &&
7712 (dp.dwCount && !(dp.dwParseFlags & (DP_AM|DP_PM))))
7713 {
7714 /* Special case - 'a' and 'p' are recognised as short for am/pm */
7715 if (*strIn == 'a' || *strIn == 'A')
7716 {
7717 dp.dwFlags[dp.dwCount - 1] |= DP_AM;
7718 dp.dwParseFlags |= DP_AM;
7719 }
7720 else
7721 {
7722 dp.dwFlags[dp.dwCount - 1] |= DP_PM;
7723 dp.dwParseFlags |= DP_PM;
7724 }
7725 strIn++;
7726 }
7727 else
7728 {
7729 TRACE("No matching token for %s\n", debugstr_w(strIn));
7730 hRet = DISP_E_TYPEMISMATCH;
7731 break;
7732 }
7733 }
7734 }
7735 else if (*strIn == ':' || *strIn == '.')
7736 {
7737 if (!dp.dwCount || !strIn[1])
7738 hRet = DISP_E_TYPEMISMATCH;
7739 else
7740 if (tokens[42][0] == *strIn)
7741 {
7742 dwDateSeps++;
7743 if (dwDateSeps > 2)
7744 hRet = DISP_E_TYPEMISMATCH;
7745 else
7746 dp.dwFlags[dp.dwCount - 1] |= DP_DATESEP;
7747 }
7748 else
7749 dp.dwFlags[dp.dwCount - 1] |= DP_TIMESEP;
7750 }
7751 else if (*strIn == '-' || *strIn == '/')
7752 {
7753 dwDateSeps++;
7754 if (dwDateSeps > 2 || !dp.dwCount || !strIn[1])
7755 hRet = DISP_E_TYPEMISMATCH;
7756 else
7757 dp.dwFlags[dp.dwCount - 1] |= DP_DATESEP;
7758 }
7759 else if (*strIn == ',' || iswspace(*strIn))
7760 {
7761 if (*strIn == ',' && !strIn[1])
7762 hRet = DISP_E_TYPEMISMATCH;
7763 }
7764 else
7765 {
7766 hRet = DISP_E_TYPEMISMATCH;
7767 }
7768 strIn++;
7769 }
7770
7771 if (!dp.dwCount || dp.dwCount > 6 ||
7772 (dp.dwCount == 1 && !(dp.dwParseFlags & (DP_AM|DP_PM))))
7773 hRet = DISP_E_TYPEMISMATCH;
7774
7775 if (SUCCEEDED(hRet))
7776 {
7777 SYSTEMTIME st;
7778 DWORD dwOffset = 0; /* Start of date fields in dp.dwValues */
7779
7780 st.wDayOfWeek = st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0;
7781
7782 /* Figure out which numbers correspond to which fields.
7783 *
7784 * This switch statement works based on the fact that native interprets any
7785 * fields that are not joined with a time separator ('.' or ':') as date
7786 * fields. Thus we construct a value from 0-32 where each set bit indicates
7787 * a time field. This encapsulates the hundreds of permutations of 2-6 fields.
7788 * For valid permutations, we set dwOffset to point to the first date field
7789 * and shorten dp.dwCount by the number of time fields found. The real
7790 * magic here occurs in VARIANT_MakeDate() above, where we determine what
7791 * each date number must represent in the context of iDate.
7792 */
7793 TRACE("0x%08x\n", TIMEFLAG(0)|TIMEFLAG(1)|TIMEFLAG(2)|TIMEFLAG(3)|TIMEFLAG(4));
7794
7795 switch (TIMEFLAG(0)|TIMEFLAG(1)|TIMEFLAG(2)|TIMEFLAG(3)|TIMEFLAG(4))
7796 {
7797 case 0x1: /* TT TTDD TTDDD */
7798 if (dp.dwCount > 3 &&
7799 ((dp.dwFlags[2] & (DP_AM|DP_PM)) || (dp.dwFlags[3] & (DP_AM|DP_PM)) ||
7800 (dp.dwFlags[4] & (DP_AM|DP_PM))))
7801 hRet = DISP_E_TYPEMISMATCH;
7802 else if (dp.dwCount != 2 && dp.dwCount != 4 && dp.dwCount != 5)
7803 hRet = DISP_E_TYPEMISMATCH;
7804 st.wHour = dp.dwValues[0];
7805 st.wMinute = dp.dwValues[1];
7806 dp.dwCount -= 2;
7807 dwOffset = 2;
7808 break;
7809
7810 case 0x3: /* TTT TTTDD TTTDDD */
7811 if (dp.dwCount > 4 &&
7812 ((dp.dwFlags[3] & (DP_AM|DP_PM)) || (dp.dwFlags[4] & (DP_AM|DP_PM)) ||
7813 (dp.dwFlags[5] & (DP_AM|DP_PM))))
7814 hRet = DISP_E_TYPEMISMATCH;
7815 else if (dp.dwCount != 3 && dp.dwCount != 5 && dp.dwCount != 6)
7816 hRet = DISP_E_TYPEMISMATCH;
7817 st.wHour = dp.dwValues[0];
7818 st.wMinute = dp.dwValues[1];
7819 st.wSecond = dp.dwValues[2];
7820 dwOffset = 3;
7821 dp.dwCount -= 3;
7822 break;
7823
7824 case 0x4: /* DDTT */
7825 if (dp.dwCount != 4 ||
7826 (dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)))
7827 hRet = DISP_E_TYPEMISMATCH;
7828
7829 st.wHour = dp.dwValues[2];
7830 st.wMinute = dp.dwValues[3];
7831 dp.dwCount -= 2;
7832 break;
7833
7834 case 0x0: /* T DD DDD TDDD TDDD */
7835 if (dp.dwCount == 1 && (dp.dwParseFlags & (DP_AM|DP_PM)))
7836 {
7837 st.wHour = dp.dwValues[0]; /* T */
7838 dp.dwCount = 0;
7839 break;
7840 }
7841 else if (dp.dwCount > 4 || (dp.dwCount < 3 && dp.dwParseFlags & (DP_AM|DP_PM)))
7842 {
7843 hRet = DISP_E_TYPEMISMATCH;
7844 }
7845 else if (dp.dwCount == 3)
7846 {
7847 if (dp.dwFlags[0] & (DP_AM|DP_PM)) /* TDD */
7848 {
7849 dp.dwCount = 2;
7850 st.wHour = dp.dwValues[0];
7851 dwOffset = 1;
7852 break;
7853 }
7854 if (dp.dwFlags[2] & (DP_AM|DP_PM)) /* DDT */
7855 {
7856 dp.dwCount = 2;
7857 st.wHour = dp.dwValues[2];
7858 break;
7859 }
7860 else if (dp.dwParseFlags & (DP_AM|DP_PM))
7861 hRet = DISP_E_TYPEMISMATCH;
7862 }
7863 else if (dp.dwCount == 4)
7864 {
7865 dp.dwCount = 3;
7866 if (dp.dwFlags[0] & (DP_AM|DP_PM)) /* TDDD */
7867 {
7868 st.wHour = dp.dwValues[0];
7869 dwOffset = 1;
7870 }
7871 else if (dp.dwFlags[3] & (DP_AM|DP_PM)) /* DDDT */
7872 {
7873 st.wHour = dp.dwValues[3];
7874 }
7875 else
7876 hRet = DISP_E_TYPEMISMATCH;
7877 break;
7878 }
7879 /* .. fall through .. */
7880
7881 case 0x8: /* DDDTT */
7882 if ((dp.dwCount == 2 && (dp.dwParseFlags & (DP_AM|DP_PM))) ||
7883 (dp.dwCount == 5 && ((dp.dwFlags[0] & (DP_AM|DP_PM)) ||
7884 (dp.dwFlags[1] & (DP_AM|DP_PM)) || (dp.dwFlags[2] & (DP_AM|DP_PM)))) ||
7885 dp.dwCount == 4 || dp.dwCount == 6)
7886 hRet = DISP_E_TYPEMISMATCH;
7887 st.wHour = dp.dwValues[3];
7888 st.wMinute = dp.dwValues[4];
7889 if (dp.dwCount == 5)
7890 dp.dwCount -= 2;
7891 break;
7892
7893 case 0xC: /* DDTTT */
7894 if (dp.dwCount != 5 ||
7895 (dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)))
7896 hRet = DISP_E_TYPEMISMATCH;
7897 st.wHour = dp.dwValues[2];
7898 st.wMinute = dp.dwValues[3];
7899 st.wSecond = dp.dwValues[4];
7900 dp.dwCount -= 3;
7901 break;
7902
7903 case 0x18: /* DDDTTT */
7904 if ((dp.dwFlags[0] & (DP_AM|DP_PM)) || (dp.dwFlags[1] & (DP_AM|DP_PM)) ||
7905 (dp.dwFlags[2] & (DP_AM|DP_PM)))
7906 hRet = DISP_E_TYPEMISMATCH;
7907 st.wHour = dp.dwValues[3];
7908 st.wMinute = dp.dwValues[4];
7909 st.wSecond = dp.dwValues[5];
7910 dp.dwCount -= 3;
7911 break;
7912
7913 default:
7914 hRet = DISP_E_TYPEMISMATCH;
7915 break;
7916 }
7917
7918 if (SUCCEEDED(hRet))
7919 {
7920 hRet = VARIANT_MakeDate(&dp, iDate, dwOffset, &st);
7921
7923 {
7924 st.wYear = 1899;
7925 st.wMonth = 12;
7926 st.wDay = 30;
7927 }
7928 else if (dwFlags & VAR_DATEVALUEONLY)
7929 st.wHour = st.wMinute = st.wSecond = 0;
7930
7931 /* Finally, convert the value to a VT_DATE */
7932 if (SUCCEEDED(hRet))
7933 hRet = SystemTimeToVariantTime(&st, pdateOut) ? S_OK : DISP_E_TYPEMISMATCH;
7934 }
7935 }
7936
7937 for (i = 0; i < ARRAY_SIZE(tokens); i++)
7938 SysFreeString(tokens[i]);
7939 return hRet;
7940}
OLECHAR * BSTR
Definition: compat.h:2293
#define DP_TIMESEP
Definition: vartype.c:7355
#define DP_DATESEP
Definition: vartype.c:7356
#define DP_AM
Definition: vartype.c:7358
static HRESULT VARIANT_MakeDate(DATEPARSE *dp, DWORD iDate, DWORD offset, SYSTEMTIME *st)
Definition: vartype.c:7394
#define DP_PM
Definition: vartype.c:7359
#define TIMEFLAG(i)
Definition: vartype.c:7369
#define DP_MONTH
Definition: vartype.c:7357
unsigned int BOOL
Definition: ntddk_ex.h:94
#define iswspace(_c)
Definition: ctype.h:669
#define iswdigit(_c)
Definition: ctype.h:667
#define iswalpha(_c)
Definition: ctype.h:664
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2033
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define memset(x, y, z)
Definition: compat.h:39
WORD wMilliseconds
Definition: winbase.h:912
WORD wHour
Definition: winbase.h:909
WORD wSecond
Definition: winbase.h:911
WORD wMinute
Definition: winbase.h:910
DWORD dwParseFlags
Definition: vartype.c:7364
DWORD dwCount
Definition: vartype.c:7363
DWORD dwFlags[6]
Definition: vartype.c:7365
DWORD dwValues[6]
Definition: vartype.c:7366
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
Definition: variant.c:1286
#define LOCALE_SDATE
Definition: winnls.h:58
#define LOCALE_SMONTHNAME13
Definition: winnls.h:103
#define LOCALE_IDATE
Definition: winnls.h:63
#define LOCALE_SABBREVMONTHNAME13
Definition: winnls.h:116
#define LOCALE_S1159
Definition: winnls.h:71
#define LOCALE_S2359
Definition: winnls.h:72
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_VarDateFromStr(), and VARIANT_Coerce().

◆ VarDateFromUI1()

HRESULT WINAPI VarDateFromUI1 ( BYTE  bIn,
DATE pdateOut 
)

Definition at line 7224 of file vartype.c.

7225{
7226 return VarR8FromUI1(bIn, pdateOut);
7227}
HRESULT WINAPI VarR8FromUI1(BYTE bIn, double *pDblOut)
Definition: vartype.c:3045

Referenced by test_VarDateFromUI1(), and VARIANT_Coerce().

◆ VarDateFromUI2()

HRESULT WINAPI VarDateFromUI2 ( USHORT  uiIn,
DATE pdateOut 
)

Definition at line 7971 of file vartype.c.

7972{
7973 return VarR8FromUI2(uiIn, pdateOut);
7974}
HRESULT WINAPI VarR8FromUI2(USHORT usIn, double *pDblOut)
Definition: vartype.c:3229

Referenced by test_VarDateFromUI2(), and VARIANT_Coerce().

◆ VarDateFromUI4()

HRESULT WINAPI VarDateFromUI4 ( ULONG  ulIn,
DATE pdateOut 
)

Definition at line 7988 of file vartype.c.

7989{
7990 return VarDateFromR8(ulIn, pdateOut);
7991}

Referenced by test_VarDateFromUI4(), and VARIANT_Coerce().

◆ VarDateFromUI8()

HRESULT WINAPI VarDateFromUI8 ( ULONG64  ullIn,
DATE pdateOut 
)

Definition at line 8043 of file vartype.c.

8044{
8045 if (ullIn > DATE_MAX) return DISP_E_OVERFLOW;
8046 *pdateOut = (DATE)ullIn;
8047 return S_OK;
8048}

Referenced by test_VarDateFromUI8(), and VARIANT_Coerce().

◆ VarDecAbs()

HRESULT WINAPI VarDecAbs ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5698 of file vartype.c.

5699{
5700 *pDecOut = *pDecIn;
5701 DEC_SIGN(pDecOut) &= ~DECIMAL_NEG;
5702 return S_OK;
5703}

Referenced by test_VarDecAbs().

◆ VarDecAdd()

HRESULT WINAPI VarDecAdd ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 4588 of file vartype.c.

4589{
4590 HRESULT hRet;
4591 DECIMAL scaled[2];
4592
4593 hRet = VARIANT_DecScale(&pDecLeft, &pDecRight, scaled);
4594
4595 if (SUCCEEDED(hRet))
4596 {
4597 /* Our decimals now have the same scale, we can add them as 96 bit integers */
4598 ULONG overflow = 0;
4600 int cmp;
4601
4602 /* Correct for the sign of the result */
4603 if (DEC_SIGN(pDecLeft) && DEC_SIGN(pDecRight))
4604 {
4605 /* -x + -y : Negative */
4606 sign = DECIMAL_NEG;
4607 goto VarDecAdd_AsPositive;
4608 }
4609 else if (DEC_SIGN(pDecLeft) && !DEC_SIGN(pDecRight))
4610 {
4611 cmp = VARIANT_DecCmp(pDecLeft, pDecRight);
4612
4613 /* -x + y : Negative if x > y */
4614 if (cmp > 0)
4615 {
4616 sign = DECIMAL_NEG;
4617VarDecAdd_AsNegative:
4618 DEC_LO32(pDecOut) = VARIANT_Sub(DEC_LO32(pDecLeft), DEC_LO32(pDecRight), &overflow);
4619 DEC_MID32(pDecOut) = VARIANT_Sub(DEC_MID32(pDecLeft), DEC_MID32(pDecRight), &overflow);
4620 DEC_HI32(pDecOut) = VARIANT_Sub(DEC_HI32(pDecLeft), DEC_HI32(pDecRight), &overflow);
4621 }
4622 else
4623 {
4624VarDecAdd_AsInvertedNegative:
4625 DEC_LO32(pDecOut) = VARIANT_Sub(DEC_LO32(pDecRight), DEC_LO32(pDecLeft), &overflow);
4626 DEC_MID32(pDecOut) = VARIANT_Sub(DEC_MID32(pDecRight), DEC_MID32(pDecLeft), &overflow);
4627 DEC_HI32(pDecOut) = VARIANT_Sub(DEC_HI32(pDecRight), DEC_HI32(pDecLeft), &overflow);
4628 }
4629 }
4630 else if (!DEC_SIGN(pDecLeft) && DEC_SIGN(pDecRight))
4631 {
4632 cmp = VARIANT_DecCmp(pDecLeft, pDecRight);
4633
4634 /* x + -y : Negative if x <= y */
4635 if (cmp <= 0)
4636 {
4637 sign = DECIMAL_NEG;
4638 goto VarDecAdd_AsInvertedNegative;
4639 }
4640 goto VarDecAdd_AsNegative;
4641 }
4642 else
4643 {
4644 /* x + y : Positive */
4645VarDecAdd_AsPositive:
4646 DEC_LO32(pDecOut) = VARIANT_Add(DEC_LO32(pDecLeft), DEC_LO32(pDecRight), &overflow);
4647 DEC_MID32(pDecOut) = VARIANT_Add(DEC_MID32(pDecLeft), DEC_MID32(pDecRight), &overflow);
4648 DEC_HI32(pDecOut) = VARIANT_Add(DEC_HI32(pDecLeft), DEC_HI32(pDecRight), &overflow);
4649 }
4650
4651 if (overflow)
4652 return DISP_E_OVERFLOW; /* overflowed */
4653
4654 DEC_SCALE(pDecOut) = DEC_SCALE(pDecLeft);
4655 DEC_SIGN(pDecOut) = sign;
4656 }
4657 return hRet;
4658}
static ULONG VARIANT_Add(ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
Definition: vartype.c:4520
static int VARIANT_DecCmp(const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
Definition: vartype.c:4564
static ULONG VARIANT_Sub(ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
Definition: vartype.c:4530
static HRESULT VARIANT_DecScale(const DECIMAL **ppDecLeft, const DECIMAL **ppDecRight, DECIMAL pDecOut[2])
Definition: vartype.c:4438
#define sign(x)
Definition: mapdesc.cc:613
#define cmp(status, error)
Definition: error.c:114
uint32_t ULONG
Definition: typedefs.h:59
#define DECIMAL_POS
Definition: variant.h:77

Referenced by test_VarDecAdd(), VarAdd(), and VarDecSub().

◆ VarDecCmp()

HRESULT WINAPI VarDecCmp ( const DECIMAL pDecLeft,
const DECIMAL pDecRight 
)

Definition at line 5866 of file vartype.c.

5867{
5868 HRESULT hRet;
5870
5871 if (!pDecLeft || !pDecRight)
5872 return VARCMP_NULL;
5873
5874 if ((!(DEC_SIGN(pDecLeft) & DECIMAL_NEG)) && (DEC_SIGN(pDecRight) & DECIMAL_NEG) &&
5875 (DEC_HI32(pDecLeft) | DEC_MID32(pDecLeft) | DEC_LO32(pDecLeft)))
5876 return VARCMP_GT;
5877 else if ((DEC_SIGN(pDecLeft) & DECIMAL_NEG) && (!(DEC_SIGN(pDecRight) & DECIMAL_NEG)) &&
5878 (DEC_HI32(pDecLeft) | DEC_MID32(pDecLeft) | DEC_LO32(pDecLeft)))
5879 return VARCMP_LT;
5880
5881 /* Subtract right from left, and compare the result to 0 */
5882 hRet = VarDecSub(pDecLeft, pDecRight, &result);
5883
5884 if (SUCCEEDED(hRet))
5885 {
5886 int non_zero = DEC_HI32(&result) | DEC_MID32(&result) | DEC_LO32(&result);
5887
5888 if ((DEC_SIGN(&result) & DECIMAL_NEG) && non_zero)
5889 hRet = (HRESULT)VARCMP_LT;
5890 else if (non_zero)
5891 hRet = (HRESULT)VARCMP_GT;
5892 else
5893 hRet = (HRESULT)VARCMP_EQ;
5894 }
5895 return hRet;
5896}
HRESULT WINAPI VarDecSub(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:5677
#define VARCMP_NULL
Definition: oleauto.h:660

Referenced by test_VarDecCmp(), VarCmp(), and VarDecCmpR8().

◆ VarDecCmpR8()

HRESULT WINAPI VarDecCmpR8 ( const DECIMAL pDecLeft,
double  dblRight 
)

Definition at line 5912 of file vartype.c.

5913{
5914 HRESULT hRet;
5915 DECIMAL decRight;
5916
5917 hRet = VarDecFromR8(dblRight, &decRight);
5918
5919 if (SUCCEEDED(hRet))
5920 hRet = VarDecCmp(pDecLeft, &decRight);
5921
5922 return hRet;
5923}
HRESULT WINAPI VarDecCmp(const DECIMAL *pDecLeft, const DECIMAL *pDecRight)
Definition: vartype.c:5866
HRESULT WINAPI VarDecFromR8(double dblIn, DECIMAL *pDecOut)
Definition: vartype.c:4200

Referenced by test_VarDecCmpR8().

◆ VarDecDiv()

HRESULT WINAPI VarDecDiv ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 5601 of file vartype.c.

5602{
5603 if (!pDecLeft || !pDecRight || !pDecOut) return E_INVALIDARG;
5604
5605 return VARIANT_do_division(pDecLeft, pDecRight, pDecOut, FALSE);
5606}
static HRESULT VARIANT_do_division(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut, BOOL round)
Definition: vartype.c:5531

Referenced by test_VarDecDiv(), and VarDiv().

◆ VarDecFix()

HRESULT WINAPI VarDecFix ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5722 of file vartype.c.

5723{
5724 double dbl;
5725 HRESULT hr;
5726
5727 if (DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
5728 return E_INVALIDARG;
5729
5730 if (!DEC_SCALE(pDecIn))
5731 {
5732 *pDecOut = *pDecIn; /* Already an integer */
5733 return S_OK;
5734 }
5735
5736 hr = VarR8FromDec(pDecIn, &dbl);
5737 if (SUCCEEDED(hr)) {
5738 LONGLONG rounded = dbl;
5739
5740 hr = VarDecFromI8(rounded, pDecOut);
5741 }
5742 return hr;
5743}
HRESULT WINAPI VarDecFromI8(LONG64 llIn, DECIMAL *pDecOut)
Definition: vartype.c:4396
HRESULT hr
Definition: shlfolder.c:183

Referenced by VarDecInt(), and VarFix().

◆ VarDecFromBool()

HRESULT WINAPI VarDecFromBool ( VARIANT_BOOL  bIn,
DECIMAL pDecOut 
)

Definition at line 4312 of file vartype.c.

4313{
4314 DEC_HI32(pDecOut) = 0;
4315 DEC_MID32(pDecOut) = 0;
4316 if (bIn)
4317 {
4318 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4319 DEC_LO32(pDecOut) = 1;
4320 }
4321 else
4322 {
4323 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4324 DEC_LO32(pDecOut) = 0;
4325 }
4326 return S_OK;
4327}
#define SIGNSCALE(sign, scale)
Definition: variant.h:87
#define DEC_SIGNSCALE(d)
Definition: variant.h:93

Referenced by test_VarDecFromBool().

◆ VarDecFromCy()

HRESULT WINAPI VarDecFromCy ( CY  cyIn,
DECIMAL pDecOut 
)

Definition at line 4239 of file vartype.c.

4240{
4241 DEC_HI32(pDecOut) = 0;
4242
4243 /* Note: This assumes 2s complement integer representation */
4244 if (cyIn.s.Hi & 0x80000000)
4245 {
4246 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,4);
4247 DEC_LO64(pDecOut) = -cyIn.int64;
4248 }
4249 else
4250 {
4251 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,4);
4252 DEC_MID32(pDecOut) = cyIn.s.Hi;
4253 DEC_LO32(pDecOut) = cyIn.s.Lo;
4254 }
4255 return S_OK;
4256}

Referenced by test_VarDecFromCy(), and VARIANT_Coerce().

◆ VarDecFromDate()

HRESULT WINAPI VarDecFromDate ( DATE  dateIn,
DECIMAL pDecOut 
)

Definition at line 4222 of file vartype.c.

4223{
4224 return VarDecFromR8(dateIn, pDecOut);
4225}

Referenced by test_VarDecFromDate(), and VARIANT_Coerce().

◆ VarDecFromDisp()

HRESULT WINAPI VarDecFromDisp ( IDispatch pdispIn,
LCID  lcid,
DECIMAL pDecOut 
)

Definition at line 4292 of file vartype.c.

4293{
4294 return VARIANT_FromDisp(pdispIn, lcid, pDecOut, VT_DECIMAL, 0);
4295}
@ VT_DECIMAL
Definition: compat.h:2309

Referenced by VARIANT_Coerce().

◆ VarDecFromI1()

HRESULT WINAPI VarDecFromI1 ( signed char  cIn,
DECIMAL pDecOut 
)

Definition at line 4341 of file vartype.c.

4342{
4343 return VarDecFromI4(cIn, pDecOut);
4344}
HRESULT WINAPI VarDecFromI4(LONG lIn, DECIMAL *pDecOut)
Definition: vartype.c:4131

Referenced by test_VarDecFromI1(), and VARIANT_Coerce().

◆ VarDecFromI2()

HRESULT WINAPI VarDecFromI2 ( SHORT  sIn,
DECIMAL pDecOut 
)

Definition at line 4114 of file vartype.c.

4115{
4116 return VarDecFromI4(sIn, pDecOut);
4117}

Referenced by test_VarDecFromI2(), and VARIANT_Coerce().

◆ VarDecFromI4()

HRESULT WINAPI VarDecFromI4 ( LONG  lIn,
DECIMAL pDecOut 
)

Definition at line 4131 of file vartype.c.

4132{
4133 DEC_HI32(pDecOut) = 0;
4134 DEC_MID32(pDecOut) = 0;
4135
4136 if (lIn < 0)
4137 {
4138 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4139 DEC_LO32(pDecOut) = -lIn;
4140 }
4141 else
4142 {
4143 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4144 DEC_LO32(pDecOut) = lIn;
4145 }
4146 return S_OK;
4147}

Referenced by test_marshal_VARIANT(), test_VarDecFromI4(), test_VarMod(), VarDecFromI1(), VarDecFromI2(), and VARIANT_Coerce().

◆ VarDecFromI8()

HRESULT WINAPI VarDecFromI8 ( LONG64  llIn,
DECIMAL pDecOut 
)

Definition at line 4396 of file vartype.c.

4397{
4398 PULARGE_INTEGER pLi = (PULARGE_INTEGER)&llIn;
4399
4400 DEC_HI32(pDecOut) = 0;
4401
4402 /* Note: This assumes 2s complement integer representation */
4403 if (pLi->u.HighPart & 0x80000000)
4404 {
4405 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_NEG,0);
4406 DEC_LO64(pDecOut) = -pLi->QuadPart;
4407 }
4408 else
4409 {
4410 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4411 DEC_MID32(pDecOut) = pLi->u.HighPart;
4412 DEC_LO32(pDecOut) = pLi->u.LowPart;
4413 }
4414 return S_OK;
4415}
struct _ULARGE_INTEGER * PULARGE_INTEGER
Definition: drive.c:28
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
struct _ULARGE_INTEGER::@4138 u

Referenced by test_VarDecFromI8(), VarDecFix(), VarDecInt(), and VARIANT_Coerce().

◆ VarDecFromR4()

HRESULT WINAPI VarDecFromR4 ( FLOAT  fltIn,
DECIMAL pDecOut 
)

Definition at line 4178 of file vartype.c.

4179{
4180 VARIANT_DI di;
4181 HRESULT hres;
4182
4183 hres = VARIANT_DI_FromR4(fltIn, &di);
4184 if (hres == S_OK) VARIANT_DecFromDI(&di, pDecOut);
4185 return hres;
4186}
static HRESULT VARIANT_DI_FromR4(float source, VARIANT_DI *dest)
Definition: vartype.c:5424
static void VARIANT_DecFromDI(const VARIANT_DI *from, DECIMAL *to)
Definition: vartype.c:4671

Referenced by test_VarDecFromR4(), and VARIANT_Coerce().

◆ VarDecFromR8()

HRESULT WINAPI VarDecFromR8 ( double  dblIn,
DECIMAL pDecOut 
)

Definition at line 4200 of file vartype.c.

4201{
4202 VARIANT_DI di;
4203 HRESULT hres;
4204
4205 hres = VARIANT_DI_FromR8(dblIn, &di);
4206 if (hres == S_OK) VARIANT_DecFromDI(&di, pDecOut);
4207 return hres;
4208}
static HRESULT VARIANT_DI_FromR8(double source, VARIANT_DI *dest)
Definition: vartype.c:5484

Referenced by test_VarAdd(), test_VarCat(), test_VarDecFromR8(), test_VarDiv(), test_VarIdiv(), test_VarImp(), test_VarMul(), test_VarPow(), test_VarSub(), VarDecCmpR8(), VarDecFromDate(), VARIANT_Coerce(), and VarRound().

◆ VarDecFromStr()

HRESULT WINAPI VarDecFromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
DECIMAL pDecOut 
)

Definition at line 4273 of file vartype.c.

4274{
4275 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pDecOut, VT_DECIMAL);
4276}

Referenced by test_VarDecFromStr(), and VARIANT_Coerce().

◆ VarDecFromUI1()

HRESULT WINAPI VarDecFromUI1 ( BYTE  bIn,
DECIMAL pDecOut 
)

Definition at line 4097 of file vartype.c.

4098{
4099 return VarDecFromUI4(bIn, pDecOut);
4100}
HRESULT WINAPI VarDecFromUI4(ULONG ulIn, DECIMAL *pDecOut)
Definition: vartype.c:4375

Referenced by test_VarDecFromUI1(), and VARIANT_Coerce().

◆ VarDecFromUI2()

HRESULT WINAPI VarDecFromUI2 ( USHORT  usIn,
DECIMAL pDecOut 
)

Definition at line 4358 of file vartype.c.

4359{
4360 return VarDecFromUI4(usIn, pDecOut);
4361}

Referenced by test_VarDecFromUI2(), and VARIANT_Coerce().

◆ VarDecFromUI4()

HRESULT WINAPI VarDecFromUI4 ( ULONG  ulIn,
DECIMAL pDecOut 
)

Definition at line 4375 of file vartype.c.

4376{
4377 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4378 DEC_HI32(pDecOut) = 0;
4379 DEC_MID32(pDecOut) = 0;
4380 DEC_LO32(pDecOut) = ulIn;
4381 return S_OK;
4382}

Referenced by test_VarDecFromUI4(), VarDecFromUI1(), VarDecFromUI2(), and VARIANT_Coerce().

◆ VarDecFromUI8()

HRESULT WINAPI VarDecFromUI8 ( ULONG64  ullIn,
DECIMAL pDecOut 
)

Definition at line 4429 of file vartype.c.

4430{
4431 DEC_SIGNSCALE(pDecOut) = SIGNSCALE(DECIMAL_POS,0);
4432 DEC_HI32(pDecOut) = 0;
4433 DEC_LO64(pDecOut) = ullIn;
4434 return S_OK;
4435}

Referenced by test_VarDecFromUI8(), and VARIANT_Coerce().

◆ VarDecInt()

HRESULT WINAPI VarDecInt ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5762 of file vartype.c.

5763{
5764 double dbl;
5765 HRESULT hr;
5766
5767 if (DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
5768 return E_INVALIDARG;
5769
5770 if (!(DEC_SIGN(pDecIn) & DECIMAL_NEG) || !DEC_SCALE(pDecIn))
5771 return VarDecFix(pDecIn, pDecOut); /* The same, if +ve or no fractionals */
5772
5773 hr = VarR8FromDec(pDecIn, &dbl);
5774 if (SUCCEEDED(hr)) {
5775 LONGLONG rounded = dbl >= 0.0 ? dbl + 0.5 : dbl - 0.5;
5776
5777 hr = VarDecFromI8(rounded, pDecOut);
5778 }
5779 return hr;
5780}
HRESULT WINAPI VarDecFix(const DECIMAL *pDecIn, DECIMAL *pDecOut)
Definition: vartype.c:5722

Referenced by VarInt().

◆ VarDecMul()

HRESULT WINAPI VarDecMul ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 5622 of file vartype.c.

5623{
5624 HRESULT hRet = S_OK;
5625 VARIANT_DI di_left, di_right, di_result;
5626 int mulresult;
5627
5628 VARIANT_DIFromDec(pDecLeft, &di_left);
5629 VARIANT_DIFromDec(pDecRight, &di_right);
5630 mulresult = VARIANT_DI_mul(&di_left, &di_right, &di_result);
5631 if (mulresult)
5632 {
5633 /* multiplication actually overflowed */
5634 hRet = DISP_E_OVERFLOW;
5635 }
5636 else
5637 {
5638 if (di_result.scale > DEC_MAX_SCALE)
5639 {
5640 /* multiplication underflowed. In order to comply with the MSDN
5641 specifications for DECIMAL ranges, some significant digits
5642 must be removed
5643 */
5644 WARN("result scale is %u, scaling (with loss of significant digits)...\n",
5645 di_result.scale);
5646 while (di_result.scale > DEC_MAX_SCALE &&
5647 !VARIANT_int_iszero(di_result.bitsnum, ARRAY_SIZE(di_result.bitsnum)))
5648 {
5649 VARIANT_int_divbychar(di_result.bitsnum, ARRAY_SIZE(di_result.bitsnum), 10);
5650 di_result.scale--;
5651 }
5652 if (di_result.scale > DEC_MAX_SCALE)
5653 {
5654 WARN("result underflowed, setting to 0\n");
5655 di_result.scale = 0;
5656 di_result.sign = 0;
5657 }
5658 }
5659 VARIANT_DecFromDI(&di_result, pDecOut);
5660 }
5661 return hRet;
5662}
static BOOL VARIANT_int_iszero(const DWORD *p, unsigned int n)
Definition: vartype.c:4720
static int VARIANT_DI_mul(const VARIANT_DI *a, const VARIANT_DI *b, VARIANT_DI *result)
Definition: vartype.c:4731
static unsigned char VARIANT_int_divbychar(DWORD *p, unsigned int n, unsigned char divisor)
Definition: vartype.c:4695

Referenced by test_VarDecMul(), VarDecRound(), VARIANT_DecScale(), and VarMul().

◆ VarDecNeg()

HRESULT WINAPI VarDecNeg ( const DECIMAL pDecIn,
DECIMAL pDecOut 
)

Definition at line 5794 of file vartype.c.

5795{
5796 *pDecOut = *pDecIn;
5797 DEC_SIGN(pDecOut) ^= DECIMAL_NEG;
5798 return S_OK;
5799}

Referenced by test_VarDecNeg(), VarDecSub(), and VarNeg().

◆ VarDecRound()

HRESULT WINAPI VarDecRound ( const DECIMAL pDecIn,
int  cDecimals,
DECIMAL pDecOut 
)

Definition at line 5815 of file vartype.c.

5816{
5817 DECIMAL divisor, tmp;
5818 HRESULT hr;
5819 unsigned int i;
5820
5821 if (cDecimals < 0 || (DEC_SIGN(pDecIn) & ~DECIMAL_NEG) || DEC_SCALE(pDecIn) > DEC_MAX_SCALE)
5822 return E_INVALIDARG;
5823
5824 if (cDecimals >= DEC_SCALE(pDecIn))
5825 {
5826 *pDecOut = *pDecIn; /* More precision than we have */
5827 return S_OK;
5828 }
5829
5830 /* truncate significant digits and rescale */
5831 memset(&divisor, 0, sizeof(divisor));
5832 DEC_LO64(&divisor) = 1;
5833
5834 memset(&tmp, 0, sizeof(tmp));
5835 DEC_LO64(&tmp) = 10;
5836 for (i = 0; i < DEC_SCALE(pDecIn) - cDecimals; ++i)
5837 {
5838 hr = VarDecMul(&divisor, &tmp, &divisor);
5839 if (FAILED(hr))
5840 return hr;
5841 }
5842
5843 hr = VARIANT_do_division(pDecIn, &divisor, pDecOut, TRUE);
5844 if (FAILED(hr))
5845 return hr;
5846
5847 DEC_SCALE(pDecOut) = cDecimals;
5848
5849 return S_OK;
5850}
HRESULT WINAPI VarDecMul(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:5622
GLuint divisor
Definition: glext.h:6313
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by test_VarDecRound(), and VarCyFromDec().

◆ VarDecSub()

HRESULT WINAPI VarDecSub ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut 
)

Definition at line 5677 of file vartype.c.

5678{
5679 DECIMAL decRight;
5680
5681 /* Implement as addition of the negative */
5682 VarDecNeg(pDecRight, &decRight);
5683 return VarDecAdd(pDecLeft, &decRight, pDecOut);
5684}
HRESULT WINAPI VarDecAdd(const DECIMAL *pDecLeft, const DECIMAL *pDecRight, DECIMAL *pDecOut)
Definition: vartype.c:4588
HRESULT WINAPI VarDecNeg(const DECIMAL *pDecIn, DECIMAL *pDecOut)
Definition: vartype.c:5794

Referenced by test_VarDecSub(), VarDecCmp(), and VarSub().

◆ VarI1FromBool()

HRESULT WINAPI VarI1FromBool ( VARIANT_BOOL  boolIn,
signed char pcOut 
)

Definition at line 465 of file vartype.c.

466{
467 return _VarI1FromBool(boolIn, pcOut);
468}

Referenced by test_VarI1FromBool(), and VARIANT_Coerce().

◆ VarI1FromCy()

HRESULT WINAPI VarI1FromCy ( CY  cyIn,
signed char pcOut 
)

Definition at line 402 of file vartype.c.

403{
404 LONG i = I1_MAX + 1;
405
406 VarI4FromCy(cyIn, &i);
407 return _VarI1FromI4(i, pcOut);
408}
HRESULT WINAPI VarI4FromCy(CY cyIn, LONG *piOut)
Definition: vartype.c:1570
long LONG
Definition: pedump.c:60
#define I1_MAX
Definition: variant.h:53

Referenced by test_VarI1FromCy(), and VARIANT_Coerce().

◆ VarI1FromDate()

HRESULT WINAPI VarI1FromDate ( DATE  dateIn,
signed char pcOut 
)

Definition at line 383 of file vartype.c.

384{
385 return VarI1FromR8(dateIn, pcOut);
386}
HRESULT WINAPI VarI1FromR8(double dblIn, signed char *pcOut)
Definition: vartype.c:361

Referenced by test_VarI1FromDate(), and VARIANT_Coerce().

◆ VarI1FromDec()

HRESULT WINAPI VarI1FromDec ( DECIMAL pdecIn,
signed char pcOut 
)

Definition at line 523 of file vartype.c.

524{
525 LONG64 i64;
526 HRESULT hRet;
527
528 hRet = VarI8FromDec(pdecIn, &i64);
529
530 if (SUCCEEDED(hRet))
531 hRet = _VarI1FromI8(i64, pcOut);
532 return hRet;
533}
HRESULT WINAPI VarI8FromDec(DECIMAL *pdecIn, LONG64 *pi64Out)
Definition: vartype.c:2335

Referenced by test_VarI1FromDec(), and VARIANT_Coerce().

◆ VarI1FromDisp()

HRESULT WINAPI VarI1FromDisp ( IDispatch pdispIn,
LCID  lcid,
signed char pcOut 
)

Definition at line 448 of file vartype.c.

449{
450 return VARIANT_FromDisp(pdispIn, lcid, pcOut, VT_I1, 0);
451}
@ VT_I1
Definition: compat.h:2310

Referenced by VARIANT_Coerce().

◆ VarI1FromI2()

HRESULT WINAPI VarI1FromI2 ( SHORT  sIn,
signed char pcOut 
)

Definition at line 301 of file vartype.c.

302{
303 return _VarI1FromI2(sIn, pcOut);
304}

Referenced by test_VarI1FromI2(), and VARIANT_Coerce().

◆ VarI1FromI4()

HRESULT WINAPI VarI1FromI4 ( LONG  iIn,
signed char pcOut 
)

Definition at line 320 of file vartype.c.

321{
322 return _VarI1FromI4(iIn, pcOut);
323}

Referenced by test_VarI1FromI4(), and VARIANT_Coerce().

◆ VarI1FromI8()

HRESULT WINAPI VarI1FromI8 ( LONG64  llIn,
signed char pcOut 
)

Definition at line 549 of file vartype.c.

550{
551 return _VarI1FromI8(llIn, pcOut);
552}

Referenced by test_VarI1FromI8(), and VARIANT_Coerce().

◆ VarI1FromR4()

HRESULT WINAPI VarI1FromR4 ( FLOAT  fltIn,
signed char pcOut 
)

Definition at line 339 of file vartype.c.

340{
341 return VarI1FromR8(fltIn, pcOut);
342}

Referenced by test_VarI1FromR4(), and VARIANT_Coerce().

◆ VarI1FromR8()

HRESULT WINAPI VarI1FromR8 ( double  dblIn,
signed char pcOut 
)

Definition at line 361 of file vartype.c.

362{
363 if (dblIn < I1_MIN - 0.5 || dblIn >= I1_MAX + 0.5)
364 return DISP_E_OVERFLOW;
365 VARIANT_DutchRound(CHAR, dblIn, *pcOut);
366 return S_OK;
367}

Referenced by test_VarI1FromR8(), VarI1FromDate(), VarI1FromR4(), and VARIANT_Coerce().

◆ VarI1FromStr()

HRESULT WINAPI VarI1FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
signed char pcOut 
)

Definition at line 427 of file vartype.c.

428{
429 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pcOut, VT_I1);
430}

Referenced by test_VarI1FromStr(), and VARIANT_Coerce().

◆ VarI1FromUI1()

HRESULT WINAPI VarI1FromUI1 ( BYTE  bIn,
signed char pcOut 
)

Definition at line 282 of file vartype.c.

283{
284 return _VarI1FromUI1(bIn, pcOut);
285}

Referenced by test_VarI1FromUI1().

◆ VarI1FromUI2()

HRESULT WINAPI VarI1FromUI2 ( USHORT  usIn,
signed char pcOut 
)

Definition at line 484 of file vartype.c.

485{
486 return _VarI1FromUI2(usIn, pcOut);
487}

Referenced by test_VarI1FromUI2(), and VARIANT_Coerce().

◆ VarI1FromUI4()

HRESULT WINAPI VarI1FromUI4 ( ULONG  ulIn,
signed char pcOut 
)

Definition at line 504 of file vartype.c.

505{
506 return _VarI1FromUI4(ulIn, pcOut);
507}

Referenced by test_VarI1FromUI4(), and VARIANT_Coerce().

◆ VarI1FromUI8()

HRESULT WINAPI VarI1FromUI8 ( ULONG64  ullIn,
signed char pcOut 
)

Definition at line 568 of file vartype.c.

569{
570 return _VarI1FromUI8(ullIn, pcOut);
571}

Referenced by test_VarI1FromUI8(), and VARIANT_Coerce().

◆ VarI2FromBool()

HRESULT WINAPI VarI2FromBool ( VARIANT_BOOL  boolIn,
SHORT psOut 
)

Definition at line 1059 of file vartype.c.

1060{
1061 return _VarI2FromBool(boolIn, psOut);
1062}

Referenced by test_VarI2FromBool(), and VARIANT_Coerce().

◆ VarI2FromCy()

HRESULT WINAPI VarI2FromCy ( CY  cyIn,
SHORT psOut 
)

Definition at line 978 of file vartype.c.

979{
980 LONG i = I2_MAX + 1;
981
982 VarI4FromCy(cyIn, &i);
983 return _VarI2FromI4(i, psOut);
984}
#define I2_MAX
Definition: variant.h:57

Referenced by test_VarI2FromCy(), and VARIANT_Coerce().

◆ VarI2FromDate()

HRESULT WINAPI VarI2FromDate ( DATE  dateIn,
SHORT psOut 
)

Definition at line 999 of file vartype.c.

1000{
1001 return VarI2FromR8(dateIn, psOut);
1002}
HRESULT WINAPI VarI2FromR8(double dblIn, SHORT *psOut)
Definition: vartype.c:957

Referenced by test_VarI2FromDate(), and VARIANT_Coerce().

◆ VarI2FromDec()

HRESULT WINAPI VarI2FromDec ( DECIMAL pdecIn,
SHORT psOut 
)

Definition at line 1131 of file vartype.c.

1132{
1133 LONG64 i64;
1134 HRESULT hRet;
1135
1136 hRet = VarI8FromDec(pdecIn, &i64);
1137
1138 if (SUCCEEDED(hRet))
1139 hRet = _VarI2FromI8(i64, psOut);
1140 return hRet;
1141}

Referenced by test_VarI2FromDec(), and VARIANT_Coerce().

◆ VarI2FromDisp()

HRESULT WINAPI VarI2FromDisp ( IDispatch pdispIn,
LCID  lcid,
SHORT psOut 
)

Definition at line 1042 of file vartype.c.

1043{
1044 return VARIANT_FromDisp(pdispIn, lcid, psOut, VT_I2, 0);
1045}
@ VT_I2
Definition: compat.h:2297

Referenced by VARIANT_Coerce().

◆ VarI2FromI1()

HRESULT WINAPI VarI2FromI1 ( signed char  cIn,
SHORT psOut 
)

Definition at line 1076 of file vartype.c.

1077{
1078 return _VarI2FromI1(cIn, psOut);
1079}

Referenced by test_VarI2FromI1(), and VARIANT_Coerce().

◆ VarI2FromI4()

HRESULT WINAPI VarI2FromI4 ( LONG  iIn,
SHORT psOut 
)

Definition at line 918 of file vartype.c.

919{
920 return _VarI2FromI4(iIn, psOut);
921}

Referenced by test_VarI2FromI4(), and VARIANT_Coerce().

◆ VarI2FromI8()

HRESULT WINAPI VarI2FromI8 ( LONG64  llIn,
SHORT psOut 
)

Definition at line 1156 of file vartype.c.

1157{
1158 return _VarI2FromI8(llIn, psOut);
1159}

Referenced by test_VarI2FromI8(), and VARIANT_Coerce().

◆ VarI2FromR4()

HRESULT WINAPI VarI2FromR4 ( FLOAT  fltIn,
SHORT psOut 
)

Definition at line 936 of file vartype.c.

937{
938 return VarI2FromR8(fltIn, psOut);
939}

Referenced by test_VarI2FromR4(), and VARIANT_Coerce().

◆ VarI2FromR8()

HRESULT WINAPI VarI2FromR8 ( double  dblIn,
SHORT psOut 
)

Definition at line 957 of file vartype.c.

958{
959 if (dblIn < I2_MIN - 0.5 || dblIn >= I2_MAX + 0.5)
960 return DISP_E_OVERFLOW;
961 VARIANT_DutchRound(SHORT, dblIn, *psOut);
962 return S_OK;
963}
short SHORT
Definition: pedump.c:59

Referenced by test_VarI2FromR8(), VarI2FromDate(), VarI2FromR4(), and VARIANT_Coerce().

◆ VarI2FromStr()

HRESULT WINAPI VarI2FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
SHORT psOut 
)

Definition at line 1021 of file vartype.c.

1022{
1023 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, psOut, VT_I2);
1024}

Referenced by test_VarI2FromStr(), and VARIANT_Coerce().

◆ VarI2FromUI1()

HRESULT WINAPI VarI2FromUI1 ( BYTE  bIn,
SHORT psOut 
)

Definition at line 900 of file vartype.c.

901{
902 return _VarI2FromUI1(bIn, psOut);
903}

Referenced by test_VarI2FromUI1(), and VARIANT_Coerce().

◆ VarI2FromUI2()

HRESULT WINAPI VarI2FromUI2 ( USHORT  usIn,
SHORT psOut 
)

Definition at line 1094 of file vartype.c.

1095{
1096 return _VarI2FromUI2(usIn, psOut);
1097}

Referenced by test_VarI2FromUI2().

◆ VarI2FromUI4()

HRESULT WINAPI VarI2FromUI4 ( ULONG  ulIn,
SHORT psOut 
)

Definition at line 1112 of file vartype.c.

1113{
1114 return _VarI2FromUI4(ulIn, psOut);
1115}

Referenced by test_VarI2FromUI4(), and VARIANT_Coerce().

◆ VarI2FromUI8()

HRESULT WINAPI VarI2FromUI8 ( ULONG64  ullIn,
SHORT psOut 
)

Definition at line 1174 of file vartype.c.

1175{
1176 return _VarI2FromUI8(ullIn, psOut);
1177}

Referenced by test_VarI2FromUI8(), and VARIANT_Coerce().

◆ VarI4FromBool()

HRESULT WINAPI VarI4FromBool ( VARIANT_BOOL  boolIn,
LONG piOut 
)

Definition at line 1649 of file vartype.c.

1650{
1651 return _VarI4FromBool(boolIn, piOut);
1652}

Referenced by test_VarI4FromBool(), and VARIANT_Coerce().

◆ VarI4FromCy()

HRESULT WINAPI VarI4FromCy ( CY  cyIn,
LONG piOut 
)

Definition at line 1570 of file vartype.c.

1571{
1572 double d = cyIn.int64 / CY_MULTIPLIER_F;
1573 return VarI4FromR8(d, piOut);
1574}
HRESULT WINAPI VarI4FromR8(double dblIn, LONG *piOut)
Definition: vartype.c:1549

Referenced by test_VarI4FromCy(), VarI1FromCy(), VarI2FromCy(), VARIANT_Coerce(), and VarNot().

◆ VarI4FromDate()

HRESULT WINAPI VarI4FromDate ( DATE  dateIn,
LONG piOut 
)

Definition at line 1589 of file vartype.c.

1590{
1591 return VarI4FromR8(dateIn, piOut);
1592}

Referenced by test_VarI4FromDate(), and VARIANT_Coerce().

◆ VarI4FromDec()

HRESULT WINAPI VarI4FromDec ( DECIMAL pdecIn,
LONG piOut 
)

Definition at line 1720 of file vartype.c.

1721{
1722 LONG64 i64;
1723 HRESULT hRet;
1724
1725 hRet = VarI8FromDec(pdecIn, &i64);
1726
1727 if (SUCCEEDED(hRet))
1728 hRet = _VarI4FromI8(i64, piOut);
1729 return hRet;
1730}

Referenced by test_VarI4FromDec(), VARIANT_Coerce(), and VarNot().

◆ VarI4FromDisp()

HRESULT WINAPI VarI4FromDisp ( IDispatch pdispIn,
LCID  lcid,
LONG piOut 
)

Definition at line 1632 of file vartype.c.

1633{
1634 return VARIANT_FromDisp(pdispIn, lcid, piOut, VT_I4, 0);
1635}
@ VT_I4
Definition: compat.h:2298

Referenced by VARIANT_Coerce().

◆ VarI4FromI1()

HRESULT WINAPI VarI4FromI1 ( signed char  cIn,
LONG piOut 
)

Definition at line 1666 of file vartype.c.

1667{
1668 return _VarI4FromI1(cIn, piOut);
1669}

Referenced by test_VarI4FromI1(), and VARIANT_Coerce().

◆ VarI4FromI2()

HRESULT WINAPI VarI4FromI2 ( SHORT  sIn,
LONG piOut 
)

Definition at line 1510 of file vartype.c.

1511{
1512 return _VarI4FromI2(sIn, piOut);
1513}

Referenced by test_VarI4FromI2(), and VARIANT_Coerce().

◆ VarI4FromI8()

HRESULT WINAPI VarI4FromI8 ( LONG64  llIn,
LONG piOut 
)

Definition at line 1745 of file vartype.c.

1746{
1747 return _VarI4FromI8(llIn, piOut);
1748}

Referenced by test_VarI4FromI8(), and VARIANT_Coerce().

◆ VarI4FromR4()

HRESULT WINAPI VarI4FromR4 ( FLOAT  fltIn,
LONG piOut 
)

Definition at line 1528 of file vartype.c.

1529{
1530 return VarI4FromR8(fltIn, piOut);
1531}

Referenced by test_VarI4FromR4(), VARIANT_Coerce(), and VarNot().

◆ VarI4FromR8()

HRESULT WINAPI VarI4FromR8 ( double  dblIn,
LONG piOut 
)

Definition at line 1549 of file vartype.c.

1550{
1551 if (dblIn < I4_MIN - 0.5 || dblIn >= I4_MAX + 0.5)
1552 return DISP_E_OVERFLOW;
1553 VARIANT_DutchRound(LONG, dblIn, *piOut);
1554 return S_OK;
1555}
#define I4_MAX
Definition: variant.h:61

Referenced by test_VarI4FromR8(), VarI4FromCy(), VarI4FromDate(), VarI4FromR4(), VARIANT_Coerce(), and VarNot().

◆ VarI4FromStr()

HRESULT WINAPI VarI4FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
LONG piOut 
)