ReactOS 0.4.15-dev-7918-g2a2556c
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: debug.h:111
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
__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
#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
LCID WINAPI ConvertDefaultLocale(LCID lcid)
Definition: lang.c:1512
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: lang.c:2671
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: debug.h:112
#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" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tmov %rdx, %rbp\n" "\tjmp *%rax\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
struct _ULARGE_INTEGER::@4140 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

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 
)

Definition at line 1611 of file vartype.c.

1612{
1613 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, piOut, VT_I4);
1614}

Referenced by test_VarI4FromStr(), var_to_size(), and VARIANT_Coerce().

◆ VarI4FromUI1()

HRESULT WINAPI VarI4FromUI1 ( BYTE  bIn,
LONG piOut 
)

Definition at line 1491 of file vartype.c.

1492{
1493 return _VarI4FromUI1(bIn, piOut);
1494}

Referenced by test_VarI4FromUI1(), and VARIANT_Coerce().

◆ VarI4FromUI2()

HRESULT WINAPI VarI4FromUI2 ( USHORT  usIn,
LONG piOut 
)

Definition at line 1683 of file vartype.c.

1684{
1685 return _VarI4FromUI2(usIn, piOut);
1686}

Referenced by test_VarI4FromUI2(), and VARIANT_Coerce().

◆ VarI4FromUI4()

HRESULT WINAPI VarI4FromUI4 ( ULONG  ulIn,
LONG piOut 
)

Definition at line 1701 of file vartype.c.

1702{
1703 return _VarI4FromUI4(ulIn, piOut);
1704}

Referenced by test_VarI4FromUI4().

◆ VarI4FromUI8()

HRESULT WINAPI VarI4FromUI8 ( ULONG64  ullIn,
LONG piOut 
)

Definition at line 1763 of file vartype.c.

1764{
1765 return _VarI4FromUI8(ullIn, piOut);
1766}

Referenced by test_VarI4FromUI8(), and VARIANT_Coerce().

◆ VarI8FromBool()

HRESULT WINAPI VarI8FromBool ( VARIANT_BOOL  boolIn,
LONG64 pi64Out 
)

Definition at line 2265 of file vartype.c.

2266{
2267 return VarI8FromI2(boolIn, pi64Out);
2268}
HRESULT WINAPI VarI8FromI2(SHORT sIn, LONG64 *pi64Out)
Definition: vartype.c:2093

Referenced by test_VarI8FromBool(), and VARIANT_Coerce().

◆ VarI8FromCy()

HRESULT WINAPI VarI8FromCy ( CY  cyIn,
LONG64 pi64Out 
)

Definition at line 2174 of file vartype.c.

2175{
2176 *pi64Out = cyIn.int64 / CY_MULTIPLIER;
2177
2178 if (cyIn.int64 < 0)
2179 (*pi64Out)--; /* Mimic Win32 bug */
2180 else
2181 {
2182 cyIn.int64 -= *pi64Out * CY_MULTIPLIER; /* cyIn.s.Lo now holds fractional remainder */
2183
2184 if (cyIn.s.Lo > CY_HALF || (cyIn.s.Lo == CY_HALF && (*pi64Out & 0x1)))
2185 (*pi64Out)++;
2186 }
2187 return S_OK;
2188}
#define CY_HALF
Definition: vartype.c:40

Referenced by test_VarI8FromCy(), and VARIANT_Coerce().

◆ VarI8FromDate()

HRESULT WINAPI VarI8FromDate ( DATE  dateIn,
LONG64 pi64Out 
)

Definition at line 2205 of file vartype.c.

2206{
2207 return VarI8FromR8(dateIn, pi64Out);
2208}
HRESULT WINAPI VarI8FromR8(double dblIn, LONG64 *pi64Out)
Definition: vartype.c:2148

Referenced by test_VarI8FromDate(), and VARIANT_Coerce().

◆ VarI8FromDec()

HRESULT WINAPI VarI8FromDec ( DECIMAL pdecIn,
LONG64 pi64Out 
)

Definition at line 2335 of file vartype.c.

2336{
2337 if (!DEC_SCALE(pdecIn))
2338 {
2339 /* This decimal is just a 96 bit integer */
2340 if (DEC_SIGN(pdecIn) & ~DECIMAL_NEG)
2341 return E_INVALIDARG;
2342
2343 if (DEC_HI32(pdecIn) || DEC_MID32(pdecIn) & 0x80000000)
2344 return DISP_E_OVERFLOW;
2345
2346 if (DEC_SIGN(pdecIn))
2347 *pi64Out = -DEC_LO64(pdecIn);
2348 else
2349 *pi64Out = DEC_LO64(pdecIn);
2350 return S_OK;
2351 }
2352 else
2353 {
2354 /* Decimal contains a floating point number */
2355 HRESULT hRet;
2356 double dbl;
2357
2358 hRet = VarR8FromDec(pdecIn, &dbl);
2359 if (SUCCEEDED(hRet))
2360 hRet = VarI8FromR8(dbl, pi64Out);
2361 return hRet;
2362 }
2363}

Referenced by test_VarI8FromDec(), VarI1FromDec(), VarI2FromDec(), VarI4FromDec(), VARIANT_Coerce(), VarUI1FromDec(), VarUI2FromDec(), and VarUI4FromDec().

◆ VarI8FromDisp()

HRESULT WINAPI VarI8FromDisp ( IDispatch pdispIn,
LCID  lcid,
LONG64 pi64Out 
)

Definition at line 2248 of file vartype.c.

2249{
2250 return VARIANT_FromDisp(pdispIn, lcid, pi64Out, VT_I8, 0);
2251}
@ VT_I8
Definition: compat.h:2314

Referenced by VARIANT_Coerce().

◆ VarI8FromI1()

HRESULT WINAPI VarI8FromI1 ( signed char  cIn,
LONG64 pi64Out 
)

Definition at line 2282 of file vartype.c.

2283{
2284 return _VarI8FromI1(cIn, pi64Out);
2285}

Referenced by test_VarI8FromI1(), and VARIANT_Coerce().

◆ VarI8FromI2()

HRESULT WINAPI VarI8FromI2 ( SHORT  sIn,
LONG64 pi64Out 
)

Definition at line 2093 of file vartype.c.

2094{
2095 return _VarI8FromI2(sIn, pi64Out);
2096}

Referenced by test_VarI8FromI2(), VarI8FromBool(), VARIANT_Coerce(), and VarUI8FromBool().

◆ VarI8FromR4()

HRESULT WINAPI VarI8FromR4 ( FLOAT  fltIn,
LONG64 pi64Out 
)

Definition at line 2112 of file vartype.c.

2113{
2114 return VarI8FromR8(fltIn, pi64Out);
2115}

Referenced by test_VarI8FromR4(), and VARIANT_Coerce().

◆ VarI8FromR8()

HRESULT WINAPI VarI8FromR8 ( double  dblIn,
LONG64 pi64Out 
)

Definition at line 2148 of file vartype.c.

2149{
2150 if ( dblIn < -4611686018427387904.0 || dblIn >= 4611686018427387904.0)
2151 return DISP_E_OVERFLOW;
2152 VARIANT_DutchRound(LONG64, dblIn, *pi64Out);
2153 return S_OK;
2154}

Referenced by test_VarI8FromR8(), VarI8FromDate(), VarI8FromDec(), VarI8FromR4(), and VARIANT_Coerce().

◆ VarI8FromStr()

HRESULT WINAPI VarI8FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
LONG64 pi64Out 
)

Definition at line 2227 of file vartype.c.

2228{
2229 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pi64Out, VT_I8);
2230}

Referenced by test_VarI8FromStr(), and VARIANT_Coerce().

◆ VarI8FromUI1()

HRESULT WINAPI VarI8FromUI1 ( BYTE  bIn,
LONG64 pi64Out 
)

Definition at line 2075 of file vartype.c.

2076{
2077 return _VarI8FromUI1(bIn, pi64Out);
2078}

Referenced by test_VarI8FromUI1(), and VARIANT_Coerce().

◆ VarI8FromUI2()

HRESULT WINAPI VarI8FromUI2 ( USHORT  usIn,
LONG64 pi64Out 
)

Definition at line 2299 of file vartype.c.

2300{
2301 return _VarI8FromUI2(usIn, pi64Out);
2302}

Referenced by test_VarI8FromUI2(), and VARIANT_Coerce().

◆ VarI8FromUI4()

HRESULT WINAPI VarI8FromUI4 ( ULONG  ulIn,
LONG64 pi64Out 
)

Definition at line 2316 of file vartype.c.

2317{
2318 return _VarI8FromUI4(ulIn, pi64Out);
2319}

Referenced by test_VarI8FromUI4(), and VARIANT_Coerce().

◆ VarI8FromUI8()

HRESULT WINAPI VarI8FromUI8 ( ULONG64  ullIn,
LONG64 pi64Out 
)

Definition at line 2378 of file vartype.c.

2379{
2380 return _VarI8FromUI8(ullIn, pi64Out);
2381}

Referenced by test_VarI8FromUI8().

◆ VARIANT_Add()

static ULONG VARIANT_Add ( ULONG  ulLeft,
ULONG  ulRight,
ULONG pulHigh 
)
static

Definition at line 4520 of file vartype.c.

4521{
4522 ULARGE_INTEGER ul64;
4523
4524 ul64.QuadPart = (ULONG64)ulLeft + (ULONG64)ulRight + (ULONG64)*pulHigh;
4525 *pulHigh = ul64.u.HighPart;
4526 return ul64.u.LowPart;
4527}

Referenced by VarDecAdd(), and VARIANT_DI_mul().

◆ VARIANT_BstrFromReal()

static HRESULT VARIANT_BstrFromReal ( DOUBLE  dblIn,
LCID  lcid,
ULONG  dwFlags,
BSTR pbstrOut,
LPCWSTR  lpszFormat 
)
static

Definition at line 6509 of file vartype.c.

6511{
6512 WCHAR buff[256];
6513
6514 if (!pbstrOut)
6515 return E_INVALIDARG;
6516
6517 swprintf( buff, lpszFormat, dblIn );
6518
6519 /* Negative zeroes are disallowed (some applications depend on this).
6520 If buff starts with a minus, and then nothing follows but zeroes
6521 and/or a period, it is a negative zero and is replaced with a
6522 canonical zero. This duplicates native oleaut32 behavior.
6523 */
6524 if (buff[0] == '-')
6525 {
6526 static const WCHAR szAccept[] = {'0', '.', '\0'};
6527 if (lstrlenW(buff + 1) == wcsspn(buff + 1, szAccept))
6528 { buff[0] = '0'; buff[1] = '\0'; }
6529 }
6530
6531 TRACE("created string %s\n", debugstr_w(buff));
6532 if (dwFlags & LOCALE_USE_NLS)
6533 {
6534 WCHAR numbuff[256];
6535
6536 /* Format the number for the locale */
6537 numbuff[0] = '\0';
6539 buff, NULL, numbuff, ARRAY_SIZE(numbuff));
6540 TRACE("created NLS string %s\n", debugstr_w(numbuff));
6541 *pbstrOut = SysAllocString(numbuff);
6542 }
6543 else
6544 {
6545 *pbstrOut = VARIANT_BstrReplaceDecimal(buff, lcid, dwFlags);
6546 }
6547 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6548}
#define swprintf
Definition: precomp.h:40
_Check_return_ _CRTIMP size_t __cdecl wcsspn(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)

Referenced by VarBstrFromR4(), and VarBstrFromR8().

◆ VARIANT_BstrFromUInt()

static HRESULT VARIANT_BstrFromUInt ( ULONG64  ulVal,
LCID  lcid,
DWORD  dwFlags,
BSTR pbstrOut 
)
static

Definition at line 6364 of file vartype.c.

6365{
6366 WCHAR szBuff[64], *szOut = szBuff + ARRAY_SIZE(szBuff) - 1;
6367
6368 if (!pbstrOut)
6369 return E_INVALIDARG;
6370
6371 /* Create the basic number string */
6372 *szOut-- = '\0';
6373 szOut = VARIANT_WriteNumber(ulVal, szOut);
6374
6375 *pbstrOut = VARIANT_MakeBstr(lcid, dwFlags, szOut);
6376 TRACE("returning %s\n", debugstr_w(*pbstrOut));
6377 return *pbstrOut ? S_OK : E_OUTOFMEMORY;
6378}
static WCHAR * VARIANT_WriteNumber(ULONG64 ulVal, WCHAR *szOut)
Definition: vartype.c:6330
static BSTR VARIANT_MakeBstr(LCID lcid, DWORD dwFlags, WCHAR *szOut)
Definition: vartype.c:6345

Referenced by VarBstrFromI1(), VarBstrFromI2(), VarBstrFromI4(), VarBstrFromI8(), VarBstrFromUI1(), VarBstrFromUI2(), VarBstrFromUI4(), and VarBstrFromUI8().

◆ VARIANT_BstrReplaceDecimal()

static BSTR VARIANT_BstrReplaceDecimal ( const WCHAR buff,
LCID  lcid,
ULONG  dwFlags 
)
static

Definition at line 6457 of file vartype.c.

6458{
6459 BSTR bstrOut;
6460 WCHAR lpDecimalSep[16];
6461
6462 /* Native oleaut32 uses the locale-specific decimal separator even in the
6463 absence of the LOCALE_USE_NLS flag. For example, the Spanish/Latin
6464 American locales will see "one thousand and one tenth" as "1000,1"
6465 instead of "1000.1" (notice the comma). The following code checks for
6466 the need to replace the decimal separator, and if so, will prepare an
6467 appropriate NUMBERFMTW structure to do the job via GetNumberFormatW().
6468 */
6470 lpDecimalSep, ARRAY_SIZE(lpDecimalSep));
6471 if (lpDecimalSep[0] == '.' && lpDecimalSep[1] == '\0')
6472 {
6473 /* locale is compatible with English - return original string */
6474 bstrOut = SysAllocString(buff);
6475 }
6476 else
6477 {
6478 WCHAR *p;
6479 WCHAR numbuff[256];
6480 WCHAR empty[] = {'\0'};
6481 NUMBERFMTW minFormat;
6482
6483 minFormat.NumDigits = 0;
6484 minFormat.LeadingZero = 0;
6485 minFormat.Grouping = 0;
6486 minFormat.lpDecimalSep = lpDecimalSep;
6487 minFormat.lpThousandSep = empty;
6488 minFormat.NegativeOrder = 1; /* NLS_NEG_LEFT */
6489
6490 /* count number of decimal digits in string */
6491 p = wcschr( buff, '.' );
6492 if (p) minFormat.NumDigits = lstrlenW(p + 1);
6493
6494 numbuff[0] = '\0';
6495 if (!GetNumberFormatW(lcid, 0, buff, &minFormat, numbuff, ARRAY_SIZE(numbuff)))
6496 {
6497 WARN("GetNumberFormatW() failed, returning raw number string instead\n");
6498 bstrOut = SysAllocString(buff);
6499 }
6500 else
6501 {
6502 TRACE("created minimal NLS string %s\n", debugstr_w(numbuff));
6503 bstrOut = SysAllocString(numbuff);
6504 }
6505 }
6506 return bstrOut;
6507}
static const WCHAR empty[]
Definition: main.c:47
#define wcschr
Definition: compat.h:17
GLfloat GLfloat p
Definition: glext.h:8902
UINT NumDigits
Definition: winnls.h:642
LPWSTR lpDecimalSep
Definition: winnls.h:645
UINT Grouping
Definition: winnls.h:644
UINT NegativeOrder
Definition: winnls.h:647
LPWSTR lpThousandSep
Definition: winnls.h:646
UINT LeadingZero
Definition: winnls.h:643
#define LOCALE_SDECIMAL
Definition: winnls.h:42

Referenced by VarBstrFromCy(), VarBstrFromDec(), and VARIANT_BstrFromReal().

◆ VARIANT_CopyData()

static void VARIANT_CopyData ( const VARIANT srcVar,
VARTYPE  vt,
void pOut 
)
inlinestatic

Definition at line 47 of file vartype.c.

48{
49 switch (vt)
50 {
51 case VT_I1:
52 case VT_UI1: memcpy(pOut, &V_UI1(srcVar), sizeof(BYTE)); break;
53 case VT_BOOL:
54 case VT_I2:
55 case VT_UI2: memcpy(pOut, &V_UI2(srcVar), sizeof(SHORT)); break;
56 case VT_R4:
57 case VT_INT:
58 case VT_I4:
59 case VT_UINT:
60 case VT_UI4: memcpy(pOut, &V_UI4(srcVar), sizeof (LONG)); break;
61 case VT_R8:
62 case VT_DATE:
63 case VT_CY:
64 case VT_I8:
65 case VT_UI8: memcpy(pOut, &V_UI8(srcVar), sizeof (LONG64)); break;
66 case VT_INT_PTR: memcpy(pOut, &V_INT_PTR(srcVar), sizeof (INT_PTR)); break;
67 case VT_DECIMAL: memcpy(pOut, &V_DECIMAL(srcVar), sizeof (DECIMAL)); break;
68 case VT_BSTR: memcpy(pOut, &V_BSTR(srcVar), sizeof(BSTR)); break;
69 default:
70 FIXME("VT_ type %d unhandled, please report!\n", vt);
71 }
72}
@ VT_UI8
Definition: compat.h:2315
@ VT_INT
Definition: compat.h:2316
@ VT_R4
Definition: compat.h:2299
@ VT_UI2
Definition: compat.h:2312
@ VT_R8
Definition: compat.h:2300
@ VT_INT_PTR
Definition: compat.h:2327
@ VT_UI4
Definition: compat.h:2313
@ VT_UINT
Definition: compat.h:2317
@ VT_UI1
Definition: compat.h:2311
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:86
#define V_UI1(A)
Definition: oleauto.h:266
#define V_UI2(A)
Definition: oleauto.h:268
#define V_INT_PTR(A)
Definition: oleauto.h:257
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_DECIMAL(A)
Definition: oleauto.h:236
#define V_UI4(A)
Definition: oleauto.h:270
#define V_UI8(A)
Definition: oleauto.h:272
int32_t INT_PTR
Definition: typedefs.h:64

Referenced by VARIANT_FromDisp(), and VARIANT_NumberFromBstr().

◆ VARIANT_DecCmp()

static int VARIANT_DecCmp ( const DECIMAL pDecLeft,
const DECIMAL pDecRight 
)
inlinestatic

Definition at line 4564 of file vartype.c.

4565{
4566 if ( DEC_HI32(pDecLeft) < DEC_HI32(pDecRight) ||
4567 (DEC_HI32(pDecLeft) <= DEC_HI32(pDecRight) && DEC_LO64(pDecLeft) < DEC_LO64(pDecRight)))
4568 return -1;
4569 else if (DEC_HI32(pDecLeft) == DEC_HI32(pDecRight) && DEC_LO64(pDecLeft) == DEC_LO64(pDecRight))
4570 return 0;
4571 return 1;
4572}

Referenced by VarDecAdd().

◆ VARIANT_DecFromDI()

static void VARIANT_DecFromDI ( const VARIANT_DI from,
DECIMAL to 
)
static

Definition at line 4671 of file vartype.c.

4672{
4673 if (from->sign) {
4674 DEC_SIGNSCALE(to) = SIGNSCALE(DECIMAL_NEG, from->scale);
4675 } else {
4676 DEC_SIGNSCALE(to) = SIGNSCALE(DECIMAL_POS, from->scale);
4677 }
4678
4679 DEC_LO32(to) = from->bitsnum[0];
4680 DEC_MID32(to) = from->bitsnum[1];
4681 DEC_HI32(to) = from->bitsnum[2];
4682}
CardRegion * from
Definition: spigame.cpp:19

Referenced by VarDecFromR4(), VarDecFromR8(), VarDecMul(), VARIANT_DecScale(), and VARIANT_do_division().

◆ VARIANT_DecScale()

static HRESULT VARIANT_DecScale ( const DECIMAL **  ppDecLeft,
const DECIMAL **  ppDecRight,
DECIMAL  pDecOut[2] 
)
static

Definition at line 4438 of file vartype.c.

4441{
4442 static DECIMAL scaleFactor;
4443 unsigned char remainder;
4444 DECIMAL decTemp;
4445 VARIANT_DI di;
4446 int scaleAmount, i;
4447
4448 if (DEC_SIGN(*ppDecLeft) & ~DECIMAL_NEG || DEC_SIGN(*ppDecRight) & ~DECIMAL_NEG)
4449 return E_INVALIDARG;
4450
4451 DEC_LO32(&scaleFactor) = 10;
4452
4453 i = scaleAmount = DEC_SCALE(*ppDecLeft) - DEC_SCALE(*ppDecRight);
4454
4455 if (!scaleAmount)
4456 return S_OK; /* Same scale */
4457
4458 if (scaleAmount > 0)
4459 {
4460 decTemp = *(*ppDecRight); /* Left is bigger - scale the right hand side */
4461 *ppDecRight = &pDecOut[0];
4462 }
4463 else
4464 {
4465 decTemp = *(*ppDecLeft); /* Right is bigger - scale the left hand side */
4466 *ppDecLeft = &pDecOut[0];
4467 i = -scaleAmount;
4468 }
4469
4470 /* Multiply up the value to be scaled by the correct amount (if possible) */
4471 while (i > 0 && SUCCEEDED(VarDecMul(&decTemp, &scaleFactor, &pDecOut[0])))
4472 {
4473 decTemp = pDecOut[0];
4474 i--;
4475 }
4476
4477 if (!i)
4478 {
4479 DEC_SCALE(&pDecOut[0]) += (scaleAmount > 0) ? scaleAmount : (-scaleAmount);
4480 return S_OK; /* Same scale */
4481 }
4482
4483 /* Scaling further not possible, reduce accuracy of other argument */
4484 pDecOut[0] = decTemp;
4485 if (scaleAmount > 0)
4486 {
4487 DEC_SCALE(&pDecOut[0]) += scaleAmount - i;
4488 VARIANT_DIFromDec(*ppDecLeft, &di);
4489 *ppDecLeft = &pDecOut[1];
4490 }
4491 else
4492 {
4493 DEC_SCALE(&pDecOut[0]) += (-scaleAmount) - i;
4494 VARIANT_DIFromDec(*ppDecRight, &di);
4495 *ppDecRight = &pDecOut[1];
4496 }
4497
4498 di.scale -= i;
4499 remainder = 0;
4500 while (i-- > 0 && !VARIANT_int_iszero(di.bitsnum, ARRAY_SIZE(di.bitsnum)))
4501 {
4503 if (remainder > 0) WARN("losing significant digits (remainder %u)...\n", remainder);
4504 }
4505
4506 /* round up the result - native oleaut32 does this */
4507 if (remainder >= 5) {
4508 for (remainder = 1, i = 0; i < ARRAY_SIZE(di.bitsnum) && remainder; i++) {
4509 ULONGLONG digit = di.bitsnum[i] + 1;
4510 remainder = (digit > 0xFFFFFFFF) ? 1 : 0;
4511 di.bitsnum[i] = digit & 0xFFFFFFFF;
4512 }
4513 }
4514
4515 VARIANT_DecFromDI(&di, &pDecOut[1]);
4516 return S_OK;
4517}
double __cdecl remainder(double, double)
Definition: remainder.c:75
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by VarDecAdd().

◆ VARIANT_DI_clear()

static void VARIANT_DI_clear ( VARIANT_DI i)
static

Definition at line 4685 of file vartype.c.

4686{
4687 memset(i, 0, sizeof(VARIANT_DI));
4688}

Referenced by VARIANT_DI_div(), VARIANT_DI_FromR4(), VARIANT_DI_FromR8(), and VARIANT_DI_mul().

◆ VARIANT_DI_div()

static HRESULT VARIANT_DI_div ( const VARIANT_DI dividend,
const VARIANT_DI divisor,
VARIANT_DI quotient,
BOOL  round_remainder 
)
static

Definition at line 5172 of file vartype.c.

5174{
5175 HRESULT r_overflow = S_OK;
5176
5177 if (VARIANT_int_iszero(divisor->bitsnum, ARRAY_SIZE(divisor->bitsnum))) {
5178 /* division by 0 */
5179 r_overflow = DISP_E_DIVBYZERO;
5180 } else if (VARIANT_int_iszero(dividend->bitsnum, ARRAY_SIZE(dividend->bitsnum))) {
5181 VARIANT_DI_clear(quotient);
5182 } else {
5183 int quotientscale, remainderscale, tempquotientscale;
5184 DWORD remainderplusquotient[8];
5185 int underflow;
5186
5187 quotientscale = remainderscale = (int)dividend->scale - (int)divisor->scale;
5188 tempquotientscale = quotientscale;
5189 VARIANT_DI_clear(quotient);
5190 quotient->sign = (dividend->sign ^ divisor->sign) ? 1 : 0;
5191
5192 /* The following strategy is used for division
5193 1) if there was a nonzero remainder from previous iteration, use it as
5194 dividend for this iteration, else (for first iteration) use intended
5195 dividend
5196 2) perform integer division in temporary buffer, develop quotient in
5197 low-order part, remainder in high-order part
5198 3) add quotient from step 2 to final result, with possible loss of
5199 significant digits
5200 4) multiply integer part of remainder by 10, while incrementing the
5201 scale of the remainder. This operation preserves the intended value
5202 of the remainder.
5203 5) loop to step 1 until one of the following is true:
5204 a) remainder is zero (exact division achieved)
5205 b) addition in step 3 fails to modify bits in quotient (remainder underflow)
5206 */
5207 memset(remainderplusquotient, 0, sizeof(remainderplusquotient));
5208 memcpy(remainderplusquotient, dividend->bitsnum, sizeof(dividend->bitsnum));
5209 do {
5210 VARIANT_int_div(remainderplusquotient, 4, divisor->bitsnum, ARRAY_SIZE(divisor->bitsnum));
5211 underflow = VARIANT_int_addlossy( quotient->bitsnum, &quotientscale,
5212 ARRAY_SIZE(quotient->bitsnum), remainderplusquotient, &tempquotientscale, 4);
5213 if (round_remainder) {
5214 if(remainderplusquotient[4] >= 5){
5215 unsigned int i;
5216 unsigned char remainder = 1;
5217 for (i = 0; i < ARRAY_SIZE(quotient->bitsnum) && remainder; i++) {
5218 ULONGLONG digit = quotient->bitsnum[i] + 1;
5219 remainder = (digit > 0xFFFFFFFF) ? 1 : 0;
5220 quotient->bitsnum[i] = digit & 0xFFFFFFFF;
5221 }
5222 }
5223 memset(remainderplusquotient, 0, sizeof(remainderplusquotient));
5224 } else {
5225 VARIANT_int_mulbychar(remainderplusquotient + 4, 4, 10);
5226 memcpy(remainderplusquotient, remainderplusquotient + 4, 4 * sizeof(DWORD));
5227 }
5228 tempquotientscale = ++remainderscale;
5229 } while (!underflow && !VARIANT_int_iszero(remainderplusquotient + 4, 4));
5230
5231 /* quotient scale might now be negative (extremely big number). If, so, try
5232 to multiply quotient by 10 (without overflowing), while adjusting the scale,
5233 until scale is 0. If this cannot be done, it is a real overflow.
5234 */
5235 while (r_overflow == S_OK && quotientscale < 0) {
5236 memset(remainderplusquotient, 0, sizeof(remainderplusquotient));
5237 memcpy(remainderplusquotient, quotient->bitsnum, sizeof(quotient->bitsnum));
5238 VARIANT_int_mulbychar(remainderplusquotient, ARRAY_SIZE(remainderplusquotient), 10);
5239 if (VARIANT_int_iszero(remainderplusquotient + ARRAY_SIZE(quotient->bitsnum),
5240 ARRAY_SIZE(remainderplusquotient) - ARRAY_SIZE(quotient->bitsnum))) {
5241 quotientscale++;
5242 memcpy(quotient->bitsnum, remainderplusquotient, sizeof(quotient->bitsnum));
5243 } else r_overflow = DISP_E_OVERFLOW;
5244 }
5245 if (r_overflow == S_OK) {
5246 if (quotientscale <= 255) quotient->scale = quotientscale;
5247 else VARIANT_DI_clear(quotient);
5248 }
5249 }
5250 return r_overflow;
5251}
static void VARIANT_DI_clear(VARIANT_DI *i)
Definition: vartype.c:4685
static void VARIANT_int_div(DWORD *p, unsigned int n, const DWORD *divisor, unsigned int dn)
Definition: vartype.c:4971
static unsigned char VARIANT_int_mulbychar(DWORD *p, unsigned int n, unsigned char m)
Definition: vartype.c:5003
static int VARIANT_int_addlossy(DWORD *a, int *ascale, unsigned int an, DWORD *b, int *bscale, unsigned int bn)
Definition: vartype.c:5018
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define DISP_E_DIVBYZERO
Definition: winerror.h:2527

Referenced by VARIANT_do_division().

◆ VARIANT_DI_FromR4()

static HRESULT VARIANT_DI_FromR4 ( float  source,
VARIANT_DI dest 
)
static

Definition at line 5424 of file vartype.c.

5425{
5426 HRESULT hres = S_OK;
5427 R4_FIELDS fx;
5428
5429 fx.f = source;
5430
5431 /* Detect special cases */
5432 if (fx.i.m == 0 && fx.i.exp_bias == 0) {
5433 /* Floating-point zero */
5435 } else if (fx.i.m == 0 && fx.i.exp_bias == 0xFF) {
5436 /* Floating-point infinity */
5438 } else if (fx.i.exp_bias == 0xFF) {
5439 /* Floating-point NaN */
5441 } else {
5442 int exponent2;
5444
5445 exponent2 = fx.i.exp_bias - 127; /* Get unbiased exponent */
5446 dest->sign = fx.i.sign; /* Sign is simply copied */
5447
5448 /* Copy significant bits to VARIANT_DI mantissa */
5449 dest->bitsnum[0] = fx.i.m;
5450 dest->bitsnum[0] &= 0x007FFFFF;
5451 if (fx.i.exp_bias == 0) {
5452 /* Denormalized number - correct exponent */
5453 exponent2++;
5454 } else {
5455 /* Add hidden bit to mantissa */
5456 dest->bitsnum[0] |= 0x00800000;
5457 }
5458
5459 /* The act of copying a FP mantissa as integer bits is equivalent to
5460 shifting left the mantissa 23 bits. The exponent2 is reduced to
5461 compensate. */
5462 exponent2 -= 23;
5463
5464 hres = VARIANT_DI_normalize(dest, exponent2, FALSE);
5465 }
5466
5467 return hres;
5468}
static HRESULT VARIANT_DI_normalize(VARIANT_DI *val, int exponent2, BOOL isDouble)
Definition: vartype.c:5260
GLfixed fx
Definition: tritemp.h:484
#define DISP_E_BADVARTYPE
Definition: winerror.h:2517

Referenced by VarDecFromR4().

◆ VARIANT_DI_FromR8()

static HRESULT VARIANT_DI_FromR8 ( double  source,
VARIANT_DI dest 
)
static

Definition at line 5484 of file vartype.c.

5485{
5486 HRESULT hres = S_OK;
5487 R8_FIELDS fx;
5488
5489 fx.d = source;
5490
5491 /* Detect special cases */
5492 if (fx.i.m_lo == 0 && fx.i.m_hi == 0 && fx.i.exp_bias == 0) {
5493 /* Floating-point zero */
5495 } else if (fx.i.m_lo == 0 && fx.i.m_hi == 0 && fx.i.exp_bias == 0x7FF) {
5496 /* Floating-point infinity */
5498 } else if (fx.i.exp_bias == 0x7FF) {
5499 /* Floating-point NaN */
5501 } else {
5502 int exponent2;
5504
5505 exponent2 = fx.i.exp_bias - 1023; /* Get unbiased exponent */
5506 dest->sign = fx.i.sign; /* Sign is simply copied */
5507
5508 /* Copy significant bits to VARIANT_DI mantissa */
5509 dest->bitsnum[0] = fx.i.m_lo;
5510 dest->bitsnum[1] = fx.i.m_hi;
5511 dest->bitsnum[1] &= 0x000FFFFF;
5512 if (fx.i.exp_bias == 0) {
5513 /* Denormalized number - correct exponent */
5514 exponent2++;
5515 } else {
5516 /* Add hidden bit to mantissa */
5517 dest->bitsnum[1] |= 0x00100000;
5518 }
5519
5520 /* The act of copying a FP mantissa as integer bits is equivalent to
5521 shifting left the mantissa 52 bits. The exponent2 is reduced to
5522 compensate. */
5523 exponent2 -= 52;
5524
5525 hres = VARIANT_DI_normalize(dest, exponent2, TRUE);
5526 }
5527
5528 return hres;
5529}

Referenced by VarDecFromR8().

◆ VARIANT_DI_mul()

static int VARIANT_DI_mul ( const VARIANT_DI a,
const VARIANT_DI b,
VARIANT_DI result 
)
static

Definition at line 4731 of file vartype.c.

4732{
4733 BOOL r_overflow = FALSE;
4734 DWORD running[6];
4735 signed int mulstart;
4736
4738 result->sign = (a->sign ^ b->sign) ? 1 : 0;
4739
4740 /* Multiply 128-bit operands into a (max) 256-bit result. The scale
4741 of the result is formed by adding the scales of the operands.
4742 */
4743 result->scale = a->scale + b->scale;
4744 memset(running, 0, sizeof(running));
4745
4746 /* count number of leading zero-bytes in operand A */
4747 for (mulstart = ARRAY_SIZE(a->bitsnum) - 1; mulstart >= 0 && !a->bitsnum[mulstart]; mulstart--);
4748 if (mulstart < 0) {
4749 /* result is 0, because operand A is 0 */
4750 result->scale = 0;
4751 result->sign = 0;
4752 } else {
4753 unsigned char remainder = 0;
4754 int iA;
4755
4756 /* perform actual multiplication */
4757 for (iA = 0; iA <= mulstart; iA++) {
4758 ULONG iOverflowMul;
4759 int iB;
4760
4761 for (iOverflowMul = 0, iB = 0; iB < ARRAY_SIZE(b->bitsnum); iB++) {
4762 ULONG iRV;
4763 int iR;
4764
4765 iRV = VARIANT_Mul(b->bitsnum[iB], a->bitsnum[iA], &iOverflowMul);
4766 iR = iA + iB;
4767 do {
4768 running[iR] = VARIANT_Add(running[iR], 0, &iRV);
4769 iR++;
4770 } while (iRV);
4771 }
4772 }
4773
4774/* Too bad - native oleaut does not do this, so we should not either */
4775#if 0
4776 /* While the result is divisible by 10, and the scale > 0, divide by 10.
4777 This operation should not lose significant digits, and gives an
4778 opportunity to reduce the possibility of overflows in future
4779 operations issued by the application.
4780 */
4781 while (result->scale > 0) {
4782 memcpy(quotient, running, sizeof(quotient));
4783 remainder = VARIANT_int_divbychar(quotient, sizeof(quotient) / sizeof(DWORD), 10);
4784 if (remainder > 0) break;
4785 memcpy(running, quotient, sizeof(quotient));
4786 result->scale--;
4787 }
4788#endif
4789 /* While the 256-bit result overflows, and the scale > 0, divide by 10.
4790 This operation *will* lose significant digits of the result because
4791 all the factors of 10 were consumed by the previous operation.
4792 */
4793 while (result->scale > 0 && !VARIANT_int_iszero(running + ARRAY_SIZE(result->bitsnum),
4794 ARRAY_SIZE(running) - ARRAY_SIZE(result->bitsnum))) {
4795
4796 remainder = VARIANT_int_divbychar(running, ARRAY_SIZE(running), 10);
4797 if (remainder > 0) WARN("losing significant digits (remainder %u)...\n", remainder);
4798 result->scale--;
4799 }
4800
4801 /* round up the result - native oleaut32 does this */
4802 if (remainder >= 5) {
4803 unsigned int i;
4804 for (remainder = 1, i = 0; i < ARRAY_SIZE(running) && remainder; i++) {
4805 ULONGLONG digit = running[i] + 1;
4806 remainder = (digit > 0xFFFFFFFF) ? 1 : 0;
4807 running[i] = digit & 0xFFFFFFFF;
4808 }
4809 }
4810
4811 /* Signal overflow if scale == 0 and 256-bit result still overflows,
4812 and copy result bits into result structure
4813 */
4814 r_overflow = !VARIANT_int_iszero(running + ARRAY_SIZE(result->bitsnum),
4815 ARRAY_SIZE(running) - ARRAY_SIZE(result->bitsnum));
4816 memcpy(result->bitsnum, running, sizeof(result->bitsnum));
4817 }
4818 return r_overflow;
4819}
static ULONG VARIANT_Mul(ULONG ulLeft, ULONG ulRight, ULONG *pulHigh)
Definition: vartype.c:4554
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by VarDecMul().

◆ VARIANT_DI_normalize()

static HRESULT VARIANT_DI_normalize ( VARIANT_DI val,
int  exponent2,
BOOL  isDouble 
)
static

Definition at line 5260 of file vartype.c.

5261{
5262 HRESULT hres = S_OK;
5263 int exponent5, exponent10;
5264
5265 /* A factor of 2^exponent2 is equivalent to (10^exponent2)/(5^exponent2), and
5266 thus equal to (5^-exponent2)*(10^exponent2). After all manipulations,
5267 exponent10 might be used to set the VARIANT_DI scale directly. However,
5268 the value of 5^-exponent5 must be assimilated into the VARIANT_DI. */
5269 exponent5 = -exponent2;
5270 exponent10 = exponent2;
5271
5272 /* Handle exponent5 > 0 */
5273 while (exponent5 > 0) {
5274 char bPrevCarryBit;
5275 char bCurrCarryBit;
5276
5277 /* In order to multiply the value represented by the VARIANT_DI by 5, it
5278 is best to multiply by 10/2. Therefore, exponent10 is incremented, and
5279 somehow the mantissa should be divided by 2. */
5280 if ((val->bitsnum[0] & 1) == 0) {
5281 /* The mantissa is divisible by 2. Therefore the division can be done
5282 without losing significant digits. */
5283 exponent10++; exponent5--;
5284
5285 /* Shift right */
5286 bPrevCarryBit = val->bitsnum[2] & 1;
5287 val->bitsnum[2] >>= 1;
5288 bCurrCarryBit = val->bitsnum[1] & 1;
5289 val->bitsnum[1] = (val->bitsnum[1] >> 1) | (bPrevCarryBit ? 0x80000000 : 0);
5290 val->bitsnum[0] = (val->bitsnum[0] >> 1) | (bCurrCarryBit ? 0x80000000 : 0);
5291 } else {
5292 /* The mantissa is NOT divisible by 2. Therefore the mantissa should
5293 be multiplied by 5, unless the multiplication overflows. */
5294 DWORD temp_bitsnum[3];
5295
5296 exponent5--;
5297
5298 memcpy(temp_bitsnum, val->bitsnum, 3 * sizeof(DWORD));
5299 if (0 == VARIANT_int_mulbychar(temp_bitsnum, 3, 5)) {
5300 /* Multiplication succeeded without overflow, so copy result back
5301 into VARIANT_DI */
5302 memcpy(val->bitsnum, temp_bitsnum, 3 * sizeof(DWORD));
5303
5304 /* Mask out 3 extraneous bits introduced by the multiply */
5305 } else {
5306 /* Multiplication by 5 overflows. The mantissa should be divided
5307 by 2, and therefore will lose significant digits. */
5308 exponent10++;
5309
5310 /* Shift right */
5311 bPrevCarryBit = val->bitsnum[2] & 1;
5312 val->bitsnum[2] >>= 1;
5313 bCurrCarryBit = val->bitsnum[1] & 1;
5314 val->bitsnum[1] = (val->bitsnum[1] >> 1) | (bPrevCarryBit ? 0x80000000 : 0);
5315 val->bitsnum[0] = (val->bitsnum[0] >> 1) | (bCurrCarryBit ? 0x80000000 : 0);
5316 }
5317 }
5318 }
5319
5320 /* Handle exponent5 < 0 */
5321 while (exponent5 < 0) {
5322 /* In order to divide the value represented by the VARIANT_DI by 5, it
5323 is best to multiply by 2/10. Therefore, exponent10 is decremented,
5324 and the mantissa should be multiplied by 2 */
5325 if ((val->bitsnum[2] & 0x80000000) == 0) {
5326 /* The mantissa can withstand a shift-left without overflowing */
5327 exponent10--; exponent5++;
5328 VARIANT_int_shiftleft(val->bitsnum, 3, 1);
5329 } else {
5330 /* The mantissa would overflow if shifted. Therefore it should be
5331 directly divided by 5. This will lose significant digits, unless
5332 by chance the mantissa happens to be divisible by 5 */
5333 exponent5++;
5334 VARIANT_int_divbychar(val->bitsnum, 3, 5);
5335 }
5336 }
5337
5338 /* At this point, the mantissa has assimilated the exponent5, but the
5339 exponent10 might not be suitable for assignment. The exponent10 must be
5340 in the range [-DEC_MAX_SCALE..0], so the mantissa must be scaled up or
5341 down appropriately. */
5342 while (hres == S_OK && exponent10 > 0) {
5343 /* In order to bring exponent10 down to 0, the mantissa should be
5344 multiplied by 10 to compensate. If the exponent10 is too big, this
5345 will cause the mantissa to overflow. */
5346 if (0 == VARIANT_int_mulbychar(val->bitsnum, 3, 10)) {
5347 exponent10--;
5348 } else {
5350 }
5351 }
5352 while (exponent10 < -DEC_MAX_SCALE) {
5353 int rem10;
5354 /* In order to bring exponent up to -DEC_MAX_SCALE, the mantissa should
5355 be divided by 10 to compensate. If the exponent10 is too small, this
5356 will cause the mantissa to underflow and become 0 */
5357 rem10 = VARIANT_int_divbychar(val->bitsnum, 3, 10);
5358 exponent10++;
5359 if (VARIANT_int_iszero(val->bitsnum, 3)) {
5360 /* Underflow, unable to keep dividing */
5361 exponent10 = 0;
5362 } else if (rem10 >= 5) {
5363 DWORD x = 1;
5364 VARIANT_int_add(val->bitsnum, 3, &x, 1);
5365 }
5366 }
5367 /* This step is required in order to remove excess bits of precision from the
5368 end of the bit representation, down to the precision guaranteed by the
5369 floating point number. */
5370 if (isDouble) {
5371 while (exponent10 < 0 && (val->bitsnum[2] != 0 || (val->bitsnum[1] & 0xFFE00000) != 0)) {
5372 int rem10;
5373
5374 rem10 = VARIANT_int_divbychar(val->bitsnum, 3, 10);
5375 exponent10++;
5376 if (rem10 >= 5) {
5377 DWORD x = 1;
5378 VARIANT_int_add(val->bitsnum, 3, &x, 1);
5379 }
5380 }
5381 } else {
5382 while (exponent10 < 0 && (val->bitsnum[2] != 0 || val->bitsnum[1] != 0 ||
5383 (val->bitsnum[2] == 0 && val->bitsnum[1] == 0 && (val->bitsnum[0] & 0xFF000000) != 0))) {
5384 int rem10;
5385
5386 rem10 = VARIANT_int_divbychar(val->bitsnum, 3, 10);
5387 exponent10++;
5388 if (rem10 >= 5) {
5389 DWORD x = 1;
5390 VARIANT_int_add(val->bitsnum, 3, &x, 1);
5391 }
5392 }
5393 }
5394 /* Remove multiples of 10 from the representation */
5395 while (exponent10 < 0) {
5396 DWORD temp_bitsnum[3];
5397
5398 memcpy(temp_bitsnum, val->bitsnum, 3 * sizeof(DWORD));
5399 if (0 == VARIANT_int_divbychar(temp_bitsnum, 3, 10)) {
5400 exponent10++;
5401 memcpy(val->bitsnum, temp_bitsnum, 3 * sizeof(DWORD));
5402 } else break;
5403 }
5404
5405 /* Scale assignment */
5406 if (hres == S_OK) val->scale = -exponent10;
5407
5408 return hres;
5409}
static void VARIANT_int_shiftleft(DWORD *p, unsigned int n, unsigned int shift)
Definition: vartype.c:4905
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by VARIANT_DI_FromR4(), and VARIANT_DI_FromR8().

◆ VARIANT_DI_tostringW()

static BOOL VARIANT_DI_tostringW ( const VARIANT_DI a,
WCHAR s,
unsigned int  n 
)
static

Definition at line 4825 of file vartype.c.

4826{
4827 BOOL overflow = FALSE;
4828 DWORD quotient[3];
4829 unsigned char remainder;
4830 unsigned int i;
4831
4832 /* place negative sign */
4833 if (!VARIANT_int_iszero(a->bitsnum, ARRAY_SIZE(a->bitsnum)) && a->sign) {
4834 if (n > 0) {
4835 *s++ = '-';
4836 n--;
4837 }
4838 else overflow = TRUE;
4839 }
4840
4841 /* prepare initial 0 */
4842 if (!overflow) {
4843 if (n >= 2) {
4844 s[0] = '0';
4845 s[1] = '\0';
4846 } else overflow = TRUE;
4847 }
4848
4849 i = 0;
4850 memcpy(quotient, a->bitsnum, sizeof(a->bitsnum));
4851 while (!overflow && !VARIANT_int_iszero(quotient, ARRAY_SIZE(quotient))) {
4852 remainder = VARIANT_int_divbychar(quotient, ARRAY_SIZE(quotient), 10);
4853 if (i + 2 > n) {
4854 overflow = TRUE;
4855 } else {
4856 s[i++] = '0' + remainder;
4857 s[i] = '\0';
4858 }
4859 }
4860
4861 if (!overflow && !VARIANT_int_iszero(a->bitsnum, ARRAY_SIZE(a->bitsnum))) {
4862
4863 /* reverse order of digits */
4864 WCHAR * x = s; WCHAR * y = s + i - 1;
4865 while (x < y) {
4866 *x ^= *y;
4867 *y ^= *x;
4868 *x++ ^= *y--;
4869 }
4870
4871 /* check for decimal point. "i" now has string length */
4872 if (i <= a->scale) {
4873 unsigned int numzeroes = a->scale + 1 - i;
4874 if (i + 1 + numzeroes >= n) {
4875 overflow = TRUE;
4876 } else {
4877 memmove(s + numzeroes, s, (i + 1) * sizeof(WCHAR));
4878 i += numzeroes;
4879 while (numzeroes > 0) {
4880 s[--numzeroes] = '0';
4881 }
4882 }
4883 }
4884
4885 /* place decimal point */
4886 if (a->scale > 0) {
4887 unsigned int periodpos = i - a->scale;
4888 if (i + 2 >= n) {
4889 overflow = TRUE;
4890 } else {
4891 memmove(s + periodpos + 1, s + periodpos, (i + 1 - periodpos) * sizeof(WCHAR));
4892 s[periodpos] = '.'; i++;
4893
4894 /* remove extra zeros at the end, if any */
4895 while (s[i - 1] == '0') s[--i] = '\0';
4896 if (s[i - 1] == '.') s[--i] = '\0';
4897 }
4898 }
4899 }
4900
4901 return !overflow;
4902}
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

Referenced by VarBstrFromCy(), and VarBstrFromDec().

◆ VARIANT_DIFromDec()

static void VARIANT_DIFromDec ( const DECIMAL from,
VARIANT_DI to 
)
static

Definition at line 4661 of file vartype.c.

4662{
4663 to->scale = DEC_SCALE(from);
4664 to->sign = DEC_SIGN(from) ? 1 : 0;
4665
4666 to->bitsnum[0] = DEC_LO32(from);
4667 to->bitsnum[1] = DEC_MID32(from);
4668 to->bitsnum[2] = DEC_HI32(from);
4669}

Referenced by VarBstrFromDec(), VarDecMul(), VARIANT_DecScale(), and VARIANT_do_division().

◆ VARIANT_do_division()

static HRESULT VARIANT_do_division ( const DECIMAL pDecLeft,
const DECIMAL pDecRight,
DECIMAL pDecOut,
BOOL  round 
)
static

Definition at line 5531 of file vartype.c.

5533{
5534 HRESULT hRet = S_OK;
5535 VARIANT_DI di_left, di_right, di_result;
5536 HRESULT divresult;
5537
5538 VARIANT_DIFromDec(pDecLeft, &di_left);
5539 VARIANT_DIFromDec(pDecRight, &di_right);
5540 divresult = VARIANT_DI_div(&di_left, &di_right, &di_result, round);
5541 if (divresult != S_OK)
5542 {
5543 /* division actually overflowed */
5544 hRet = divresult;
5545 }
5546 else
5547 {
5548 hRet = S_OK;
5549
5550 if (di_result.scale > DEC_MAX_SCALE)
5551 {
5552 unsigned char remainder = 0;
5553
5554 /* division underflowed. In order to comply with the MSDN
5555 specifications for DECIMAL ranges, some significant digits
5556 must be removed
5557 */
5558 WARN("result scale is %u, scaling (with loss of significant digits)...\n",
5559 di_result.scale);
5560 while (di_result.scale > DEC_MAX_SCALE &&
5561 !VARIANT_int_iszero(di_result.bitsnum, ARRAY_SIZE(di_result.bitsnum)))
5562 {
5563 remainder = VARIANT_int_divbychar(di_result.bitsnum, ARRAY_SIZE(di_result.bitsnum), 10);
5564 di_result.scale--;
5565 }
5566 if (di_result.scale > DEC_MAX_SCALE)
5567 {
5568 WARN("result underflowed, setting to 0\n");
5569 di_result.scale = 0;
5570 di_result.sign = 0;
5571 }
5572 else if (remainder >= 5) /* round up result - native oleaut32 does this */
5573 {
5574 unsigned int i;
5575 for (remainder = 1, i = 0; i < ARRAY_SIZE(di_result.bitsnum) && remainder; i++) {
5576 ULONGLONG digit = di_result.bitsnum[i] + 1;
5577 remainder = (digit > 0xFFFFFFFF) ? 1 : 0;
5578 di_result.bitsnum[i] = digit & 0xFFFFFFFF;
5579 }
5580 }
5581 }
5582 VARIANT_DecFromDI(&di_result, pDecOut);
5583 }
5584 return hRet;
5585}
static HRESULT VARIANT_DI_div(const VARIANT_DI *dividend, const VARIANT_DI *divisor, VARIANT_DI *quotient, BOOL round_remainder)
Definition: vartype.c:5172
#define round(x)
Definition: opentype.c:47

Referenced by VarDecDiv(), and VarDecRound().

◆ VARIANT_FromDisp()

static HRESULT VARIANT_FromDisp ( IDispatch pdispIn,
LCID  lcid,
void pOut,
VARTYPE  vt,
DWORD  dwFlags 
)
static

Definition at line 115 of file vartype.c.

117{
118 static DISPPARAMS emptyParams = { NULL, NULL, 0, 0 };
119 VARIANTARG srcVar, dstVar;
120 HRESULT hRet;
121
122 if (!pdispIn)
123 return DISP_E_BADVARTYPE;
124
125 /* Get the default 'value' property from the IDispatch */
126 VariantInit(&srcVar);
127 hRet = IDispatch_Invoke(pdispIn, DISPID_VALUE, &IID_NULL, lcid, DISPATCH_PROPERTYGET,
128 &emptyParams, &srcVar, NULL, NULL);
129
130 if (SUCCEEDED(hRet))
131 {
132 /* Convert the property to the requested type */
133 VariantInit(&dstVar);
134 hRet = VariantChangeTypeEx(&dstVar, &srcVar, lcid, dwFlags, vt);
135 VariantClear(&srcVar);
136
137 if (SUCCEEDED(hRet))
138 VARIANT_CopyData(&dstVar, vt, pOut);
139 }
140 else
141 hRet = DISP_E_TYPEMISMATCH;
142 return hRet;
143}
static void VARIANT_CopyData(const VARIANT *srcVar, VARTYPE vt, void *pOut)
Definition: vartype.c:47
struct stdole::DISPPARAMS DISPPARAMS
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define IID_NULL
Definition: guiddef.h:98
HRESULT WINAPI VariantChangeTypeEx(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, LCID lcid, USHORT wFlags, VARTYPE vt)
Definition: variant.c:988
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

Referenced by VarBoolFromDisp(), VarBstrFromDisp(), VarCyFromDisp(), VarDateFromDisp(), VarDecFromDisp(), VarI1FromDisp(), VarI2FromDisp(), VarI4FromDisp(), VarI8FromDisp(), VarR4FromDisp(), VarR8FromDisp(), VarUI1FromDisp(), VarUI2FromDisp(), VarUI4FromDisp(), and VarUI8FromDisp().

◆ VARIANT_GetLocalisedText()

static BOOL VARIANT_GetLocalisedText ( LANGID  langId,
DWORD  dwId,
WCHAR lpszDest 
)
static

Definition at line 6060 of file vartype.c.

6061{
6062 HRSRC hrsrc;
6063
6064 hrsrc = FindResourceExW( hProxyDll, (LPWSTR)RT_STRING,
6065 MAKEINTRESOURCEW((dwId >> 4) + 1), langId );
6066 if (hrsrc)
6067 {
6068 HGLOBAL hmem = LoadResource( hProxyDll, hrsrc );
6069
6070 if (hmem)
6071 {
6072 const WCHAR *p;
6073 unsigned int i;
6074
6075 p = LockResource( hmem );
6076 for (i = 0; i < (dwId & 0x0f); i++) p += *p + 1;
6077
6078 memcpy( lpszDest, p + 1, *p * sizeof(WCHAR) );
6079 lpszDest[*p] = '\0';
6080 TRACE("got %s for LANGID %08x\n", debugstr_w(lpszDest), langId);
6081 return TRUE;
6082 }
6083 }
6084 return FALSE;
6085}
WCHAR lpszDest[260]
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HRSRC WINAPI FindResourceExW(HMODULE hModule, LPCWSTR type, LPCWSTR name, WORD lang)
Definition: res.c:164
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define RT_STRING
Definition: pedump.c:368
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by VarBoolFromStr(), and VarBstrFromBool().

◆ VARIANT_int_add()

static unsigned char VARIANT_int_add ( DWORD v,
unsigned int  nv,
const DWORD p,
unsigned int  np 
)
static

Definition at line 4932 of file vartype.c.

4934{
4935 unsigned char carry = 0;
4936
4937 if (nv >= np) {
4938 ULONGLONG sum;
4939 unsigned int i;
4940
4941 for (i = 0; i < np; i++) {
4942 sum = (ULONGLONG)v[i]
4943 + (ULONGLONG)p[i]
4944 + (ULONGLONG)carry;
4945 v[i] = sum & 0xffffffff;
4946 carry = sum >> 32;
4947 }
4948 for (; i < nv && carry; i++) {
4949 sum = (ULONGLONG)v[i]
4950 + (ULONGLONG)carry;
4951 v[i] = sum & 0xffffffff;
4952 carry = sum >> 32;
4953 }
4954 }
4955 return carry;
4956}
const GLdouble * v
Definition: gl.h:2040
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35

Referenced by VarBstrFromCy(), VARIANT_DI_normalize(), VARIANT_int_addlossy(), and VARIANT_int_div().

◆ VARIANT_int_addlossy()

static int VARIANT_int_addlossy ( DWORD a,
int ascale,
unsigned int  an,
DWORD b,
int bscale,
unsigned int  bn 
)
static

Definition at line 5018 of file vartype.c.

5021{
5022 int underflow = 0;
5023
5024 if (VARIANT_int_iszero(a, an)) {
5025 /* if A is zero, copy B into A, after removing digits */
5026 while (bn > an && !VARIANT_int_iszero(b + an, bn - an)) {
5027 VARIANT_int_divbychar(b, bn, 10);
5028 (*bscale)--;
5029 }
5030 memcpy(a, b, an * sizeof(DWORD));
5031 *ascale = *bscale;
5032 } else if (!VARIANT_int_iszero(b, bn)) {
5033 unsigned int tn = an + 1;
5034 DWORD t[5];
5035
5036 if (bn + 1 > tn) tn = bn + 1;
5037 if (*ascale != *bscale) {
5038 /* first (optimistic) try - try to scale down the one with the bigger
5039 scale, while this number is divisible by 10 */
5040 DWORD * digitchosen;
5041 unsigned int nchosen;
5042 int * scalechosen;
5043 int targetscale;
5044
5045 if (*ascale < *bscale) {
5046 targetscale = *ascale;
5047 scalechosen = bscale;
5048 digitchosen = b;
5049 nchosen = bn;
5050 } else {
5051 targetscale = *bscale;
5052 scalechosen = ascale;
5053 digitchosen = a;
5054 nchosen = an;
5055 }
5056 memset(t, 0, tn * sizeof(DWORD));
5057 memcpy(t, digitchosen, nchosen * sizeof(DWORD));
5058
5059 /* divide by 10 until target scale is reached */
5060 while (*scalechosen > targetscale) {
5061 unsigned char remainder = VARIANT_int_divbychar(t, tn, 10);
5062 if (!remainder) {
5063 (*scalechosen)--;
5064 memcpy(digitchosen, t, nchosen * sizeof(DWORD));
5065 } else break;
5066 }
5067 }
5068
5069 if (*ascale != *bscale) {
5070 DWORD * digitchosen;
5071 unsigned int nchosen;
5072 int * scalechosen;
5073 int targetscale;
5074
5075 /* try to scale up the one with the smaller scale */
5076 if (*ascale > *bscale) {
5077 targetscale = *ascale;
5078 scalechosen = bscale;
5079 digitchosen = b;
5080 nchosen = bn;
5081 } else {
5082 targetscale = *bscale;
5083 scalechosen = ascale;
5084 digitchosen = a;
5085 nchosen = an;
5086 }
5087 memset(t, 0, tn * sizeof(DWORD));
5088 memcpy(t, digitchosen, nchosen * sizeof(DWORD));
5089
5090 /* multiply by 10 until target scale is reached, or
5091 significant bytes overflow the number
5092 */
5093 while (*scalechosen < targetscale && t[nchosen] == 0) {
5094 VARIANT_int_mulbychar(t, tn, 10);
5095 if (t[nchosen] == 0) {
5096 /* still does not overflow */
5097 (*scalechosen)++;
5098 memcpy(digitchosen, t, nchosen * sizeof(DWORD));
5099 }
5100 }
5101 }
5102
5103 if (*ascale != *bscale) {
5104 /* still different? try to scale down the one with the bigger scale
5105 (this *will* lose significant digits) */
5106 DWORD * digitchosen;
5107 unsigned int nchosen;
5108 int * scalechosen;
5109 int targetscale;
5110
5111 if (*ascale < *bscale) {
5112 targetscale = *ascale;
5113 scalechosen = bscale;
5114 digitchosen = b;
5115 nchosen = bn;
5116 } else {
5117 targetscale = *bscale;
5118 scalechosen = ascale;
5119 digitchosen = a;
5120 nchosen = an;
5121 }
5122 memset(t, 0, tn * sizeof(DWORD));
5123 memcpy(t, digitchosen, nchosen * sizeof(DWORD));
5124
5125 /* divide by 10 until target scale is reached */
5126 while (*scalechosen > targetscale) {
5127 VARIANT_int_divbychar(t, tn, 10);
5128 (*scalechosen)--;
5129 memcpy(digitchosen, t, nchosen * sizeof(DWORD));
5130 }
5131 }
5132
5133 /* check whether any of the operands still has significant digits
5134 (underflow case 1)
5135 */
5136 if (VARIANT_int_iszero(a, an) || VARIANT_int_iszero(b, bn)) {
5137 underflow = 1;
5138 } else {
5139 /* at this step, both numbers have the same scale and can be added
5140 as integers. However, the result might not fit in A, so further
5141 scaling down might be necessary.
5142 */
5143 while (!underflow) {
5144 memset(t, 0, tn * sizeof(DWORD));
5145 memcpy(t, a, an * sizeof(DWORD));
5146
5147 VARIANT_int_add(t, tn, b, bn);
5148 if (VARIANT_int_iszero(t + an, tn - an)) {
5149 /* addition was successful */
5150 memcpy(a, t, an * sizeof(DWORD));
5151 break;
5152 } else {
5153 /* addition overflowed - remove significant digits
5154 from both operands and try again */
5155 VARIANT_int_divbychar(a, an, 10); (*ascale)--;
5156 VARIANT_int_divbychar(b, bn, 10); (*bscale)--;
5157 /* check whether any operand keeps significant digits after
5158 scaledown (underflow case 2)
5159 */
5160 underflow = (VARIANT_int_iszero(a, an) || VARIANT_int_iszero(b, bn));
5161 }
5162 }
5163 }
5164 }
5165 return underflow;
5166}
GLdouble GLdouble t
Definition: gl.h:2047
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79

Referenced by VARIANT_DI_div().

◆ VARIANT_int_div()

static void VARIANT_int_div ( DWORD p,
unsigned int  n,
const DWORD divisor,
unsigned int  dn 
)
static

Definition at line 4971 of file vartype.c.

4973{
4974 unsigned int i;
4975 DWORD tempsub[8];
4976 DWORD * negdivisor = tempsub + n;
4977
4978 /* build 2s-complement of divisor */
4979 for (i = 0; i < n; i++) negdivisor[i] = (i < dn) ? ~divisor[i] : 0xFFFFFFFF;
4980 p[n] = 1;
4981 VARIANT_int_add(negdivisor, n, p + n, 1);
4982 memset(p + n, 0, n * sizeof(DWORD));
4983
4984 /* skip all leading zero DWORDs in quotient */
4985 for (i = 0; i < n && !p[n - 1]; i++) VARIANT_int_shiftleft(p, n, 32);
4986 /* i is now number of DWORDs left to process */
4987 for (i <<= 5; i < (n << 5); i++) {
4988 VARIANT_int_shiftleft(p, n << 1, 1); /* shl quotient+remainder */
4989
4990 /* trial subtraction */
4991 memcpy(tempsub, p + n, n * sizeof(DWORD));
4992 VARIANT_int_add(tempsub, n, negdivisor, n);
4993
4994 /* check whether result of subtraction was negative */
4995 if ((tempsub[n - 1] & 0x80000000) == 0) {
4996 memcpy(p + n, tempsub, n * sizeof(DWORD));
4997 p[0] |= 1;
4998 }
4999 }
5000}

Referenced by VARIANT_DI_div().

◆ VARIANT_int_divbychar()

static unsigned char VARIANT_int_divbychar ( DWORD p,
unsigned int  n,
unsigned char  divisor 
)
static

Definition at line 4695 of file vartype.c.

4696{
4697 if (divisor == 0) {
4698 /* division by 0 */
4699 return 0xFF;
4700 } else if (divisor == 1) {
4701 /* dividend remains unchanged */
4702 return 0;
4703 } else {
4704 unsigned char remainder = 0;
4705 ULONGLONG iTempDividend;
4706 signed int i;
4707
4708 for (i = n - 1; i >= 0 && !p[i]; i--); /* skip leading zeros */
4709 for (; i >= 0; i--) {
4710 iTempDividend = ((ULONGLONG)remainder << 32) + p[i];
4711 remainder = iTempDividend % divisor;
4712 p[i] = iTempDividend / divisor;
4713 }
4714
4715 return remainder;
4716 }
4717}

Referenced by VarDecMul(), VARIANT_DecScale(), VARIANT_DI_mul(), VARIANT_DI_normalize(), VARIANT_DI_tostringW(), VARIANT_do_division(), and VARIANT_int_addlossy().

◆ VARIANT_int_iszero()

static BOOL VARIANT_int_iszero ( const DWORD p,
unsigned int  n 
)
static

Definition at line 4720 of file vartype.c.

4721{
4722 for (; n > 0; n--) if (*p++ != 0) return FALSE;
4723 return TRUE;
4724}

Referenced by VarDecMul(), VARIANT_DecScale(), VARIANT_DI_div(), VARIANT_DI_mul(), VARIANT_DI_normalize(), VARIANT_DI_tostringW(), VARIANT_do_division(), and VARIANT_int_addlossy().

◆ VARIANT_int_mulbychar()

static unsigned char VARIANT_int_mulbychar ( DWORD p,
unsigned int  n,
unsigned char  m 
)
static

Definition at line 5003 of file vartype.c.

5004{
5005 unsigned int i;
5006 ULONG iOverflowMul;
5007
5008 for (iOverflowMul = 0, i = 0; i < n; i++)
5009 p[i] = VARIANT_Mul(p[i], m, &iOverflowMul);
5010 return (unsigned char)iOverflowMul;
5011}
const GLfloat * m
Definition: glext.h:10848

Referenced by VARIANT_DI_div(), VARIANT_DI_normalize(), and VARIANT_int_addlossy().

◆ VARIANT_int_shiftleft()

static void VARIANT_int_shiftleft ( DWORD p,
unsigned int  n,
unsigned int  shift 
)
static

Definition at line 4905 of file vartype.c.

4906{
4907 DWORD shifted;
4908 unsigned int i;
4909
4910 /* shift whole DWORDs to the left */
4911 while (shift >= 32)
4912 {
4913 memmove(p + 1, p, (n - 1) * sizeof(DWORD));
4914 *p = 0; shift -= 32;
4915 }
4916
4917 /* shift remainder (1..31 bits) */
4918 shifted = 0;
4919 if (shift > 0) for (i = 0; i < n; i++)
4920 {
4921 DWORD b;
4922 b = p[i] >> (32 - shift);
4923 p[i] = (p[i] << shift) | shifted;
4924 shifted = b;
4925 }
4926}
#define shift
Definition: input.c:1755

Referenced by VARIANT_DI_normalize(), and VARIANT_int_div().

◆ VARIANT_IsValidMonthDay()

static BOOL VARIANT_IsValidMonthDay ( DWORD  day,
DWORD  month,
DWORD  year 
)
static

Definition at line 7374 of file vartype.c.

7375{
7376 static const BYTE days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
7377
7378 if (day && month && month < 13)
7379 {
7380 if (day <= days[month] || (month == 2 && day == 29 && IsLeapYear(year)))
7381 return TRUE;
7382 }
7383 return FALSE;
7384}
static DOUBLE day(DOUBLE time)
Definition: date.c:117
#define IsLeapYear(y)
Definition: vartype.c:7371
static const WCHAR month[12][4]
Definition: session.c:2150

Referenced by VARIANT_MakeDate().

◆ VARIANT_MakeBstr()

static BSTR VARIANT_MakeBstr ( LCID  lcid,
DWORD  dwFlags,
WCHAR szOut 
)
static

Definition at line 6345 of file vartype.c.

6346{
6347 WCHAR szConverted[256];
6348
6349 if (dwFlags & VAR_NEGATIVE)
6350 *--szOut = '-';
6351
6352 if (dwFlags & LOCALE_USE_NLS)
6353 {
6354 /* Format the number for the locale */
6355 szConverted[0] = '\0';
6357 szOut, NULL, szConverted, ARRAY_SIZE(szConverted));
6358 szOut = szConverted;
6359 }
6360 return SysAllocStringByteLen((LPCSTR)szOut, lstrlenW(szOut) * sizeof(WCHAR));
6361}
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by VARIANT_BstrFromUInt().

◆ VARIANT_MakeDate()

static HRESULT VARIANT_MakeDate ( DATEPARSE dp,
DWORD  iDate,
DWORD  offset,
SYSTEMTIME st 
)
inlinestatic

Definition at line 7394 of file vartype.c.

7396{
7397 DWORD dwAllOrders, dwTry, dwCount = 0, v1, v2, v3;
7398
7399 if (!dp->dwCount)
7400 {
7401 v1 = 30; /* Default to (Variant) 0 date part */
7402 v2 = 12;
7403 v3 = 1899;
7404 goto VARIANT_MakeDate_OK;
7405 }
7406
7407 v1 = dp->dwValues[offset + 0];
7408 v2 = dp->dwValues[offset + 1];
7409 if (dp->dwCount == 2)
7410 {
7413 v3 = current.wYear;
7414 }
7415 else
7416 v3 = dp->dwValues[offset + 2];
7417
7418 TRACE("(%d,%d,%d,%d,%d)\n", v1, v2, v3, iDate, offset);
7419
7420 /* If one number must be a month (Because a month name was given), then only
7421 * consider orders with the month in that position.
7422 * If we took the current year as 'v3', then only allow a year in that position.
7423 */
7424 if (dp->dwFlags[offset + 0] & DP_MONTH)
7425 {
7426 dwAllOrders = ORDER_MDY;
7427 }
7428 else if (dp->dwFlags[offset + 1] & DP_MONTH)
7429 {
7430 dwAllOrders = ORDER_DMY;
7431 if (dp->dwCount > 2)
7432 dwAllOrders |= ORDER_YMD;
7433 }
7434 else if (dp->dwCount > 2 && dp->dwFlags[offset + 2] & DP_MONTH)
7435 {
7436 dwAllOrders = ORDER_YDM;
7437 }
7438 else
7439 {
7440 dwAllOrders = ORDER_MDY|ORDER_DMY;
7441 if (dp->dwCount > 2)
7442 dwAllOrders |= (ORDER_YMD|ORDER_YDM);
7443 }
7444
7445VARIANT_MakeDate_Start:
7446 TRACE("dwAllOrders is 0x%08x\n", dwAllOrders);
7447
7448 while (dwAllOrders)
7449 {
7450 DWORD dwTemp;
7451
7452 if (dwCount == 0)
7453 {
7454 /* First: Try the order given by iDate */
7455 switch (iDate)
7456 {
7457 case 0: dwTry = dwAllOrders & ORDER_MDY; break;
7458 case 1: dwTry = dwAllOrders & ORDER_DMY; break;
7459 default: dwTry = dwAllOrders & ORDER_YMD; break;
7460 }
7461 }
7462 else if (dwCount == 1)
7463 {
7464 /* Second: Try all the orders compatible with iDate */
7465 switch (iDate)
7466 {
7467 case 0: dwTry = dwAllOrders & ~(ORDER_DMY|ORDER_YDM); break;
7468 case 1: dwTry = dwAllOrders & ~(ORDER_MDY|ORDER_YDM|ORDER_MYD); break;
7469 default: dwTry = dwAllOrders & ~(ORDER_DMY|ORDER_YDM); break;
7470 }
7471 }
7472 else
7473 {
7474 /* Finally: Try any remaining orders */
7475 dwTry = dwAllOrders;
7476 }
7477
7478 TRACE("Attempt %d, dwTry is 0x%08x\n", dwCount, dwTry);
7479
7480 dwCount++;
7481 if (!dwTry)
7482 continue;
7483
7484#define DATE_SWAP(x,y) do { dwTemp = x; x = y; y = dwTemp; } while (0)
7485
7486 if (dwTry & ORDER_MDY)
7487 {
7489 {
7490 DATE_SWAP(v1,v2);
7491 goto VARIANT_MakeDate_OK;
7492 }
7493 dwAllOrders &= ~ORDER_MDY;
7494 }
7495 if (dwTry & ORDER_YMD)
7496 {
7498 {
7499 DATE_SWAP(v1,v3);
7500 goto VARIANT_MakeDate_OK;
7501 }
7502 dwAllOrders &= ~ORDER_YMD;
7503 }
7504 if (dwTry & ORDER_YDM)
7505 {
7507 {
7508 DATE_SWAP(v1,v2);
7509 DATE_SWAP(v2,v3);
7510 goto VARIANT_MakeDate_OK;
7511 }
7512 dwAllOrders &= ~ORDER_YDM;
7513 }
7514 if (dwTry & ORDER_DMY)
7515 {
7517 goto VARIANT_MakeDate_OK;
7518 dwAllOrders &= ~ORDER_DMY;
7519 }
7520 if (dwTry & ORDER_MYD)
7521 {
7522 /* Only occurs if we are trying a 2 year date as M/Y not D/M */
7524 {
7525 DATE_SWAP(v1,v3);
7526 DATE_SWAP(v2,v3);
7527 goto VARIANT_MakeDate_OK;
7528 }
7529 dwAllOrders &= ~ORDER_MYD;
7530 }
7531 }
7532
7533 if (dp->dwCount == 2)
7534 {
7535 /* We couldn't make a date as D/M or M/D, so try M/Y or Y/M */
7536 v3 = 1; /* 1st of the month */
7537 dwAllOrders = ORDER_YMD|ORDER_MYD;
7538 dp->dwCount = 0; /* Don't return to this code path again */
7539 dwCount = 0;
7540 goto VARIANT_MakeDate_Start;
7541 }
7542
7543 /* No valid dates were able to be constructed */
7544 return DISP_E_TYPEMISMATCH;
7545
7546VARIANT_MakeDate_OK:
7547
7548 /* Check that the time part is ok */
7549 if (st->wHour > 23 || st->wMinute > 59 || st->wSecond > 59)
7550 return DISP_E_TYPEMISMATCH;
7551
7552 TRACE("Time %d %d %d\n", st->wHour, st->wMinute, st->wSecond);
7553 if (st->wHour < 12 && (dp->dwParseFlags & DP_PM))
7554 st->wHour += 12;
7555 else if (st->wHour == 12 && (dp->dwParseFlags & DP_AM))
7556 st->wHour = 0;
7557 TRACE("Time %d %d %d\n", st->wHour, st->wMinute, st->wSecond);
7558
7559 st->wDay = v1;
7560 st->wMonth = v2;
7561 /* FIXME: For 2 digit dates, I'm not sure if 30 is hard coded or not. It may
7562 * be retrieved from:
7563 * HKCU\Control Panel\International\Calendars\TwoDigitYearMax
7564 * But Wine doesn't have/use that key as at the time of writing.
7565 */
7566 st->wYear = v3 < 30 ? 2000 + v3 : v3 < 100 ? 1900 + v3 : v3;
7567 TRACE("Returning date %d/%d/%d\n", v1, v2, st->wYear);
7568 return S_OK;
7569}
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
static BOOL VARIANT_IsValidMonthDay(DWORD day, DWORD month, DWORD year)
Definition: vartype.c:7374
#define ORDER_MDY
Definition: vartype.c:7387
#define ORDER_YMD
Definition: vartype.c:7388
#define ORDER_DMY
Definition: vartype.c:7390
#define ORDER_MYD
Definition: vartype.c:7391
#define ORDER_YDM
Definition: vartype.c:7389
#define DATE_SWAP(x, y)
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:6064
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLintptr offset
Definition: glext.h:5920
struct task_struct * current
Definition: linux.c:32

Referenced by VarDateFromStr().

◆ VARIANT_Mul()

static ULONG VARIANT_Mul ( ULONG  ulLeft,
ULONG  ulRight,
ULONG pulHigh 
)
static

Definition at line 4554 of file vartype.c.

4555{
4556 ULARGE_INTEGER ul64;
4557
4558 ul64.QuadPart = (ULONG64)ulLeft * (ULONG64)ulRight + (ULONG64)*pulHigh;
4559 *pulHigh = ul64.u.HighPart;
4560 return ul64.u.LowPart;
4561}

Referenced by VARIANT_DI_mul(), and VARIANT_int_mulbychar().

◆ VARIANT_NumberFromBstr()

static HRESULT VARIANT_NumberFromBstr ( OLECHAR pStrIn,
LCID  lcid,
ULONG  ulFlags,
void pOut,
VARTYPE  vt 
)
static

Definition at line 90 of file vartype.c.

92{
93 VARIANTARG dstVar;
94 HRESULT hRet;
95 NUMPARSE np;
96 BYTE rgb[1024];
97
98 /* Use VarParseNumFromStr/VarNumFromParseNum as MSDN indicates */
99 np.cDig = ARRAY_SIZE(rgb);
101
102 hRet = VarParseNumFromStr(pStrIn, lcid, ulFlags, &np, rgb);
103
104 if (SUCCEEDED(hRet))
105 {
106 /* 1 << vt gives us the VTBIT constant for the destination number type */
107 hRet = VarNumFromParseNum(&np, rgb, 1 << vt, &dstVar);
108 if (SUCCEEDED(hRet))
109 VARIANT_CopyData(&dstVar, vt, pOut);
110 }
111 return hRet;
112}
#define NUMPRS_STD
Definition: oleauto.h:748
ULONG dwInFlags
Definition: oleauto.h:728
INT cDig
Definition: oleauto.h:727
HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags, NUMPARSE *pNumprs, BYTE *rgbDig)
Definition: variant.c:1604
HRESULT WINAPI VarNumFromParseNum(NUMPARSE *pNumprs, BYTE *rgbDig, ULONG dwVtBits, VARIANT *pVarDst)
Definition: variant.c:1998
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521

Referenced by VarCyFromStr(), VarDecFromStr(), VarI1FromStr(), VarI2FromStr(), VarI4FromStr(), VarI8FromStr(), VarR4FromStr(), VarR8FromStr(), VarUI1FromStr(), VarUI2FromStr(), VarUI4FromStr(), and VarUI8FromStr().

◆ VARIANT_Sub()

static ULONG VARIANT_Sub ( ULONG  ulLeft,
ULONG  ulRight,
ULONG pulHigh 
)
static

Definition at line 4530 of file vartype.c.

4531{
4532 BOOL invert = FALSE;
4533 ULARGE_INTEGER ul64;
4534
4535 ul64.QuadPart = (LONG64)ulLeft - (ULONG64)ulRight;
4536 if (ulLeft < ulRight)
4537 invert = TRUE;
4538
4539 if (ul64.QuadPart > (ULONG64)*pulHigh)
4540 ul64.QuadPart -= (ULONG64)*pulHigh;
4541 else
4542 {
4543 ul64.QuadPart -= (ULONG64)*pulHigh;
4544 invert = TRUE;
4545 }
4546 if (invert)
4547 ul64.u.HighPart = -ul64.u.HighPart ;
4548
4549 *pulHigh = ul64.u.HighPart;
4550 return ul64.u.LowPart;
4551}
GLboolean invert
Definition: gl.h:1949

Referenced by VarDecAdd().

◆ VARIANT_WriteNumber()

static WCHAR * VARIANT_WriteNumber ( ULONG64  ulVal,
WCHAR szOut 
)
static

Definition at line 6330 of file vartype.c.

6331{
6332 do
6333 {
6334 WCHAR ulNextDigit = ulVal % 10;
6335
6336 *szOut-- = '0' + ulNextDigit;
6337 ulVal = (ulVal - ulNextDigit) / 10;
6338 } while (ulVal);
6339
6340 szOut++;
6341 return szOut;
6342}

Referenced by VARIANT_BstrFromUInt().

◆ VarR4CmpR8()

HRESULT WINAPI VarR4CmpR8 ( float  fltLeft,
double  dblRight 
)

Definition at line 3021 of file vartype.c.

3022{
3023 if (fltLeft < dblRight)
3024 return VARCMP_LT;
3025 else if (fltLeft > dblRight)
3026 return VARCMP_GT;
3027 return VARCMP_EQ;
3028}

◆ VarR4FromBool()

HRESULT WINAPI VarR4FromBool ( VARIANT_BOOL  boolIn,
float pFltOut 
)

Definition at line 2868 of file vartype.c.

2869{
2870 return VarR4FromI2(boolIn, pFltOut);
2871}
HRESULT WINAPI VarR4FromI2(SHORT sIn, float *pFltOut)
Definition: vartype.c:2735

Referenced by test_VarR4FromBool(), and VARIANT_Coerce().

◆ VarR4FromCy()

HRESULT WINAPI VarR4FromCy ( CY  cyIn,
float pFltOut 
)

Definition at line 2790 of file vartype.c.

2791{
2792 *pFltOut = (double)cyIn.int64 / CY_MULTIPLIER_F;
2793 return S_OK;
2794}

Referenced by test_VarR4FromCy(), and VARIANT_Coerce().

◆ VarR4FromDate()

HRESULT WINAPI VarR4FromDate ( DATE  dateIn,
float pFltOut 
)

Definition at line 2809 of file vartype.c.

2810{
2811 return VarR4FromR8(dateIn, pFltOut);
2812}
HRESULT WINAPI VarR4FromR8(double dblIn, float *pFltOut)
Definition: vartype.c:2770

Referenced by test_VarR4FromDate(), and VARIANT_Coerce().

◆ VarR4FromDec()

HRESULT WINAPI VarR4FromDec ( DECIMAL pDecIn,
float pFltOut 
)

Definition at line 2946 of file vartype.c.

2947{
2948 BYTE scale = DEC_SCALE(pDecIn);
2949 double divisor = 1.0;
2950 double highPart;
2951
2952 if (scale > DEC_MAX_SCALE || DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
2953 return E_INVALIDARG;
2954
2955 while (scale--)
2956 divisor *= 10.0;
2957
2958 if (DEC_SIGN(pDecIn))
2959 divisor = -divisor;
2960
2961 if (DEC_HI32(pDecIn))
2962 {
2963 highPart = (double)DEC_HI32(pDecIn) / divisor;
2964 highPart *= 4294967296.0F;
2965 highPart *= 4294967296.0F;
2966 }
2967 else
2968 highPart = 0.0;
2969
2970 *pFltOut = (double)DEC_LO64(pDecIn) / divisor + highPart;
2971 return S_OK;
2972}

Referenced by test_VarR4FromDec(), and VARIANT_Coerce().

◆ VarR4FromDisp()

HRESULT WINAPI VarR4FromDisp ( IDispatch pdispIn,
LCID  lcid,
float pFltOut 
)

Definition at line 2851 of file vartype.c.

2852{
2853 return VARIANT_FromDisp(pdispIn, lcid, pFltOut, VT_R4, 0);
2854}

Referenced by VARIANT_Coerce().

◆ VarR4FromI1()

HRESULT WINAPI VarR4FromI1 ( signed char  cIn,
float pFltOut 
)

Definition at line 2888 of file vartype.c.

2889{
2890 return _VarR4FromI1(cIn, pFltOut);
2891}

Referenced by test_VarR4FromI1(), and VARIANT_Coerce().

◆ VarR4FromI2()

HRESULT WINAPI VarR4FromI2 ( SHORT  sIn,
float pFltOut 
)

Definition at line 2735 of file vartype.c.

2736{
2737 return _VarR4FromI2(sIn, pFltOut);
2738}

Referenced by test_VarR4FromI2(), VARIANT_Coerce(), and VarR4FromBool().

◆ VarR4FromI4()

HRESULT WINAPI VarR4FromI4 ( LONG  lIn,
float pFltOut 
)

Definition at line 2752 of file vartype.c.

2753{
2754 return _VarR4FromI4(lIn, pFltOut);
2755}

Referenced by test_VarR4FromI4(), and VARIANT_Coerce().

◆ VarR4FromI8()

HRESULT WINAPI VarR4FromI8 ( LONG64  llIn,
float pFltOut 
)

Definition at line 2986 of file vartype.c.

2987{
2988 return _VarR4FromI8(llIn, pFltOut);
2989}

Referenced by test_VarR4FromI8(), and VARIANT_Coerce().

◆ VarR4FromR8()

HRESULT WINAPI VarR4FromR8 ( double  dblIn,
float pFltOut 
)

Definition at line 2770 of file vartype.c.

2771{
2772 double d = dblIn < 0.0 ? -dblIn : dblIn;
2773 if (d > R4_MAX) return DISP_E_OVERFLOW;
2774 *pFltOut = dblIn;
2775 return S_OK;
2776}
#define R4_MAX
Definition: variant.h:71

Referenced by test_VarR4FromR8(), VARIANT_Coerce(), and VarR4FromDate().

◆ VarR4FromStr()

HRESULT WINAPI VarR4FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
float pFltOut 
)

Definition at line 2830 of file vartype.c.

2831{
2832 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pFltOut, VT_R4);
2833}

Referenced by test_VarR4FromStr(), and VARIANT_Coerce().

◆ VarR4FromUI1()

HRESULT WINAPI VarR4FromUI1 ( BYTE  bIn,
float pFltOut 
)

Definition at line 2718 of file vartype.c.

2719{
2720 return _VarR4FromUI1(bIn, pFltOut);
2721}

Referenced by test_VarR4FromUI1(), and VARIANT_Coerce().

◆ VarR4FromUI2()

HRESULT WINAPI VarR4FromUI2 ( USHORT  usIn,
float pFltOut 
)

Definition at line 2908 of file vartype.c.

2909{
2910 return _VarR4FromUI2(usIn, pFltOut);
2911}

Referenced by test_VarR4FromUI2(), and VARIANT_Coerce().

◆ VarR4FromUI4()

HRESULT WINAPI VarR4FromUI4 ( ULONG  ulIn,
float pFltOut 
)

Definition at line 2928 of file vartype.c.

2929{
2930 return _VarR4FromUI4(ulIn, pFltOut);
2931}

Referenced by test_VarR4FromUI4(), and VARIANT_Coerce().

◆ VarR4FromUI8()

HRESULT WINAPI VarR4FromUI8 ( ULONG64  ullIn,
float pFltOut 
)

Definition at line 3003 of file vartype.c.

3004{
3005 return _VarR4FromUI8(ullIn, pFltOut);
3006}

Referenced by test_VarR4FromUI8(), and VARIANT_Coerce().

◆ VarR8FromBool()

HRESULT WINAPI VarR8FromBool ( VARIANT_BOOL  boolIn,
double pDblOut 
)

Definition at line 3189 of file vartype.c.

3190{
3191 return VarR8FromI2(boolIn, pDblOut);
3192}

Referenced by test_VarR8FromBool(), VarDateFromBool(), and VARIANT_Coerce().

◆ VarR8FromCy()

HRESULT WINAPI VarR8FromCy ( CY  cyIn,
double pDblOut 
)

Definition at line 3113 of file vartype.c.

3114{
3115 return _VarR8FromCy(cyIn, pDblOut);
3116}

Referenced by test_VarAdd(), test_VarMul(), test_VarR8FromCy(), test_VarSub(), VarDateFromCy(), and VARIANT_Coerce().

◆ VarR8FromDate()

HRESULT WINAPI VarR8FromDate ( DATE  dateIn,
double pDblOut 
)

Definition at line 3130 of file vartype.c.

3131{
3132 return _VarR8FromDate(dateIn, pDblOut);
3133}

Referenced by test_VarR8FromDate(), and VARIANT_Coerce().

◆ VarR8FromDec()

HRESULT WINAPI VarR8FromDec ( const DECIMAL pDecIn,
double pDblOut 
)

Definition at line 3267 of file vartype.c.

3268{
3269 BYTE scale = DEC_SCALE(pDecIn);
3270 double divisor = 1.0, highPart;
3271
3272 if (scale > DEC_MAX_SCALE || DEC_SIGN(pDecIn) & ~DECIMAL_NEG)
3273 return E_INVALIDARG;
3274
3275 while (scale--)
3276 divisor *= 10;
3277
3278 if (DEC_SIGN(pDecIn))
3279 divisor = -divisor;
3280
3281 if (DEC_HI32(pDecIn))
3282 {
3283 highPart = (double)DEC_HI32(pDecIn) / divisor;
3284 highPart *= 4294967296.0F;
3285 highPart *= 4294967296.0F;
3286 }
3287 else
3288 highPart = 0.0;
3289
3290 *pDblOut = (double)DEC_LO64(pDecIn) / divisor + highPart;
3291 return S_OK;
3292}

Referenced by test_VarAdd(), test_VarDiv(), test_VarMul(), test_VarR8FromDec(), test_VarSub(), VarDateFromDec(), VarDecFix(), VarDecInt(), VarI8FromDec(), VARIANT_Coerce(), VarRound(), and VarUI8FromDec().

◆ VarR8FromDisp()

HRESULT WINAPI VarR8FromDisp ( IDispatch pdispIn,
LCID  lcid,
double pDblOut 
)

Definition at line 3172 of file vartype.c.

3173{
3174 return VARIANT_FromDisp(pdispIn, lcid, pDblOut, VT_R8, 0);
3175}

Referenced by VARIANT_Coerce().

◆ VarR8FromI1()

HRESULT WINAPI VarR8FromI1 ( signed char  cIn,
double pDblOut 
)

Definition at line 3209 of file vartype.c.

3210{
3211 return _VarR8FromI1(cIn, pDblOut);
3212}

Referenced by test_VarR8FromI1(), VarDateFromI1(), and VARIANT_Coerce().

◆ VarR8FromI2()

HRESULT WINAPI VarR8FromI2 ( SHORT  sIn,
double pDblOut 
)

Definition at line 3062 of file vartype.c.

3063{
3064 return _VarR8FromI2(sIn, pDblOut);
3065}

Referenced by test_VarR8FromI2(), VarDateFromI2(), VARIANT_Coerce(), and VarR8FromBool().

◆ VarR8FromI4()

HRESULT WINAPI VarR8FromI4 ( LONG  lIn,
double pDblOut 
)

Definition at line 3079 of file vartype.c.

3080{
3081 return _VarR8FromI4(lIn, pDblOut);
3082}

Referenced by test_VarR8FromI4(), and VARIANT_Coerce().

◆ VarR8FromI8()

HRESULT WINAPI VarR8FromI8 ( LONG64  llIn,
double pDblOut 
)

Definition at line 3306 of file vartype.c.

3307{
3308 return _VarR8FromI8(llIn, pDblOut);
3309}

Referenced by test_VarR8FromI8(), VARIANT_Coerce(), and VarNeg().

◆ VarR8FromR4()

HRESULT WINAPI VarR8FromR4 ( FLOAT  fltIn,
double pDblOut 
)

Definition at line 3096 of file vartype.c.

3097{
3098 return _VarR8FromR4(fltIn, pDblOut);
3099}

Referenced by test_VarR8FromR4(), VarDateFromR4(), and VARIANT_Coerce().

◆ VarR8FromStr()

HRESULT WINAPI VarR8FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
double pDblOut 
)

Definition at line 3151 of file vartype.c.

3152{
3153 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pDblOut, VT_R8);
3154}

Referenced by test_VarAdd(), test_VarR8FromStr(), VarAbs(), VarAnd(), VarBoolFromStr(), VarFix(), VARIANT_Coerce(), VarImp(), VarInt(), VarNeg(), VarNot(), VarOr(), VarRound(), and VarXor().

◆ VarR8FromUI1()

HRESULT WINAPI VarR8FromUI1 ( BYTE  bIn,
double pDblOut 
)

Definition at line 3045 of file vartype.c.

3046{
3047 return _VarR8FromUI1(bIn, pDblOut);
3048}

Referenced by test_VarR8FromUI1(), VarDateFromUI1(), and VARIANT_Coerce().

◆ VarR8FromUI2()

HRESULT WINAPI VarR8FromUI2 ( USHORT  usIn,
double pDblOut 
)

Definition at line 3229 of file vartype.c.

3230{
3231 return _VarR8FromUI2(usIn, pDblOut);
3232}

Referenced by test_VarR8FromUI2(), VarDateFromUI2(), and VARIANT_Coerce().

◆ VarR8FromUI4()

HRESULT WINAPI VarR8FromUI4 ( ULONG  ulIn,
double pDblOut 
)

Definition at line 3249 of file vartype.c.

3250{
3251 return _VarR8FromUI4(ulIn, pDblOut);
3252}

Referenced by test_VarR8FromUI4(), and VARIANT_Coerce().

◆ VarR8FromUI8()

HRESULT WINAPI VarR8FromUI8 ( ULONG64  ullIn,
double pDblOut 
)

Definition at line 3323 of file vartype.c.

3324{
3325 return _VarR8FromUI8(ullIn, pDblOut);
3326}

Referenced by test_VarR8FromUI8(), VARIANT_Coerce(), and variant_from_largeint().

◆ VarR8Pow()

HRESULT WINAPI VarR8Pow ( double  dblLeft,
double  dblPow,
double pDblOut 
)

Definition at line 3341 of file vartype.c.

3342{
3343 *pDblOut = pow(dblLeft, dblPow);
3344 return S_OK;
3345}
double pow(double x, double y)
Definition: freeldr.c:112

◆ VarR8Round()

HRESULT WINAPI VarR8Round ( double  dblIn,
int  nDig,
double pDblOut 
)

Definition at line 3368 of file vartype.c.

3369{
3370 double scale, whole, fract;
3371
3372 if (nDig < 0)
3373 return E_INVALIDARG;
3374
3375 scale = pow(10.0, nDig);
3376
3377 dblIn *= scale;
3378 whole = dblIn < 0 ? ceil(dblIn) : floor(dblIn);
3379 fract = dblIn - whole;
3380
3381 if (fract > 0.5)
3382 dblIn = whole + 1.0;
3383 else if (fract == 0.5)
3384 dblIn = whole + fmod(whole, 2.0);
3385 else if (fract >= 0.0)
3386 dblIn = whole;
3387 else if (fract == -0.5)
3388 dblIn = whole - fmod(whole, 2.0);
3389 else if (fract > -0.5)
3390 dblIn = whole;
3391 else
3392 dblIn = whole - 1.0;
3393
3394 *pDblOut = dblIn / scale;
3395 return S_OK;
3396}
_Check_return_ double __cdecl fmod(_In_ double x, _In_ double y)

◆ VarUI1FromBool()

HRESULT WINAPI VarUI1FromBool ( VARIANT_BOOL  boolIn,
BYTE pbOut 
)

Definition at line 758 of file vartype.c.

759{
760 return _VarUI1FromBool(boolIn, pbOut);
761}

Referenced by test_VarUI1FromBool(), and VARIANT_Coerce().

◆ VarUI1FromCy()

HRESULT WINAPI VarUI1FromCy ( CY  cyIn,
BYTE pbOut 
)

Definition at line 676 of file vartype.c.

677{
678 ULONG i = UI1_MAX + 1;
679
680 VarUI4FromCy(cyIn, &i);
681 return _VarUI1FromUI4(i, pbOut);
682}
HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG *pulOut)
Definition: vartype.c:1897
#define UI1_MAX
Definition: variant.h:55

Referenced by test_VarUI1FromCy(), and VARIANT_Coerce().

◆ VarUI1FromDate()

HRESULT WINAPI VarUI1FromDate ( DATE  dateIn,
BYTE pbOut 
)

Definition at line 698 of file vartype.c.

699{
700 return VarUI1FromR8(dateIn, pbOut);
701}
HRESULT WINAPI VarUI1FromR8(double dblIn, BYTE *pbOut)
Definition: vartype.c:651

Referenced by test_VarUI1FromDate(), and VARIANT_Coerce().

◆ VarUI1FromDec()

HRESULT WINAPI VarUI1FromDec ( DECIMAL pdecIn,
BYTE pbOut 
)

Definition at line 834 of file vartype.c.

835{
836 LONG64 i64;
837 HRESULT hRet;
838
839 hRet = VarI8FromDec(pdecIn, &i64);
840
841 if (SUCCEEDED(hRet))
842 hRet = _VarUI1FromI8(i64, pbOut);
843 return hRet;
844}

Referenced by test_VarUI1FromDec(), and VARIANT_Coerce().

◆ VarUI1FromDisp()

HRESULT WINAPI VarUI1FromDisp ( IDispatch pdispIn,
LCID  lcid,
BYTE pbOut 
)

Definition at line 741 of file vartype.c.

742{
743 return VARIANT_FromDisp(pdispIn, lcid, pbOut, VT_UI1, 0);
744}

Referenced by test_VarUI1FromDisp(), and VARIANT_Coerce().

◆ VarUI1FromI1()

HRESULT WINAPI VarUI1FromI1 ( signed char  cIn,
BYTE pbOut 
)

Definition at line 777 of file vartype.c.

778{
779 return _VarUI1FromI1(cIn, pbOut);
780}

Referenced by test_VarUI1FromI1().

◆ VarUI1FromI2()

HRESULT WINAPI VarUI1FromI2 ( SHORT  sIn,
BYTE pbOut 
)

Definition at line 590 of file vartype.c.

591{
592 return _VarUI1FromI2(sIn, pbOut);
593}

Referenced by test_VarUI1FromI2(), and VARIANT_Coerce().

◆ VarUI1FromI4()

HRESULT WINAPI VarUI1FromI4 ( LONG  iIn,
BYTE pbOut 
)

Definition at line 609 of file vartype.c.

610{
611 return _VarUI1FromI4(iIn, pbOut);
612}

Referenced by test_VarUI1FromI4(), and VARIANT_Coerce().

◆ VarUI1FromI8()

HRESULT WINAPI VarUI1FromI8 ( LONG64  llIn,
BYTE pbOut 
)

Definition at line 860 of file vartype.c.

861{
862 return _VarUI1FromI8(llIn, pbOut);
863}

Referenced by test_VarUI1FromI8(), and VARIANT_Coerce().

◆ VarUI1FromR4()

HRESULT WINAPI VarUI1FromR4 ( FLOAT  fltIn,
BYTE pbOut 
)

Definition at line 629 of file vartype.c.

630{
631 return VarUI1FromR8(fltIn, pbOut);
632}

Referenced by test_VarUI1FromR4(), and VARIANT_Coerce().

◆ VarUI1FromR8()

HRESULT WINAPI VarUI1FromR8 ( double  dblIn,
BYTE pbOut 
)

Definition at line 651 of file vartype.c.

652{
653 if (dblIn < -0.5 || dblIn >= UI1_MAX + 0.5)
654 return DISP_E_OVERFLOW;
655 VARIANT_DutchRound(BYTE, dblIn, *pbOut);
656 return S_OK;
657}

Referenced by test_VarUI1FromR8(), VARIANT_Coerce(), VarUI1FromDate(), and VarUI1FromR4().

◆ VarUI1FromStr()

HRESULT WINAPI VarUI1FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
BYTE pbOut 
)

Definition at line 720 of file vartype.c.

721{
722 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pbOut, VT_UI1);
723}

Referenced by test_VarUI1FromStr(), and VARIANT_Coerce().

◆ VarUI1FromUI2()

HRESULT WINAPI VarUI1FromUI2 ( USHORT  usIn,
BYTE pbOut 
)

Definition at line 796 of file vartype.c.

797{
798 return _VarUI1FromUI2(usIn, pbOut);
799}

Referenced by test_VarUI1FromUI2(), and VARIANT_Coerce().

◆ VarUI1FromUI4()

HRESULT WINAPI VarUI1FromUI4 ( ULONG  ulIn,
BYTE pbOut 
)

Definition at line 815 of file vartype.c.

816{
817 return _VarUI1FromUI4(ulIn, pbOut);
818}

Referenced by test_VarUI1FromUI4(), and VARIANT_Coerce().

◆ VarUI1FromUI8()

HRESULT WINAPI VarUI1FromUI8 ( ULONG64  ullIn,
BYTE pbOut 
)

Definition at line 879 of file vartype.c.

880{
881 return _VarUI1FromUI8(ullIn, pbOut);
882}

Referenced by test_VarUI1FromUI8(), and VARIANT_Coerce().

◆ VarUI2FromBool()

HRESULT WINAPI VarUI2FromBool ( VARIANT_BOOL  boolIn,
USHORT pusOut 
)

Definition at line 1373 of file vartype.c.

1374{
1375 return _VarUI2FromBool(boolIn, pusOut);
1376}

Referenced by test_VarUI2FromBool(), and VARIANT_Coerce().

◆ VarUI2FromCy()

HRESULT WINAPI VarUI2FromCy ( CY  cyIn,
USHORT pusOut 
)

Definition at line 1311 of file vartype.c.

1312{
1313 ULONG i = UI2_MAX + 1;
1314
1315 VarUI4FromCy(cyIn, &i);
1316 return _VarUI2FromUI4(i, pusOut);
1317}
#define UI2_MAX
Definition: variant.h:59

Referenced by test_VarUI2FromCy(), and VARIANT_Coerce().

◆ VarUI2FromDate()

HRESULT WINAPI VarUI2FromDate ( DATE  dateIn,
USHORT pusOut 
)

Definition at line 1290 of file vartype.c.

1291{
1292 return VarUI2FromR8(dateIn, pusOut);
1293}
HRESULT WINAPI VarUI2FromR8(double dblIn, USHORT *pusOut)
Definition: vartype.c:1269

Referenced by test_VarUI2FromDate(), and VARIANT_Coerce().

◆ VarUI2FromDec()

HRESULT WINAPI VarUI2FromDec ( DECIMAL pdecIn,
USHORT pusOut 
)

Definition at line 1428 of file vartype.c.

1429{
1430 LONG64 i64;
1431 HRESULT hRet;
1432
1433 hRet = VarI8FromDec(pdecIn, &i64);
1434
1435 if (SUCCEEDED(hRet))
1436 hRet = _VarUI2FromI8(i64, pusOut);
1437 return hRet;
1438}

Referenced by test_VarUI2FromDec(), and VARIANT_Coerce().

◆ VarUI2FromDisp()

HRESULT WINAPI VarUI2FromDisp ( IDispatch pdispIn,
LCID  lcid,
USHORT pusOut 
)

Definition at line 1356 of file vartype.c.

1357{
1358 return VARIANT_FromDisp(pdispIn, lcid, pusOut, VT_UI2, 0);
1359}

Referenced by VARIANT_Coerce().

◆ VarUI2FromI1()

HRESULT WINAPI VarUI2FromI1 ( signed char  cIn,
USHORT pusOut 
)

Definition at line 1391 of file vartype.c.

1392{
1393 return _VarUI2FromI1(cIn, pusOut);
1394}

Referenced by test_VarUI2FromI1(), and VARIANT_Coerce().

◆ VarUI2FromI2()

HRESULT WINAPI VarUI2FromI2 ( SHORT  sIn,
USHORT pusOut 
)

Definition at line 1212 of file vartype.c.

1213{
1214 return _VarUI2FromI2(sIn, pusOut);
1215}

Referenced by test_VarUI2FromI2().

◆ VarUI2FromI4()

HRESULT WINAPI VarUI2FromI4 ( LONG  iIn,
USHORT pusOut 
)

Definition at line 1230 of file vartype.c.

1231{
1232 return _VarUI2FromI4(iIn, pusOut);
1233}

Referenced by test_VarUI2FromI4(), and VARIANT_Coerce().

◆ VarUI2FromI8()

HRESULT WINAPI VarUI2FromI8 ( LONG64  llIn,
USHORT pusOut 
)

Definition at line 1453 of file vartype.c.

1454{
1455 return _VarUI2FromI8(llIn, pusOut);
1456}

Referenced by test_VarUI2FromI8().

◆ VarUI2FromR4()

HRESULT WINAPI VarUI2FromR4 ( FLOAT  fltIn,
USHORT pusOut 
)

Definition at line 1248 of file vartype.c.

1249{
1250 return VarUI2FromR8(fltIn, pusOut);
1251}

Referenced by test_VarUI2FromR4(), and VARIANT_Coerce().

◆ VarUI2FromR8()

HRESULT WINAPI VarUI2FromR8 ( double  dblIn,
USHORT pusOut 
)

Definition at line 1269 of file vartype.c.

1270{
1271 if (dblIn < -0.5 || dblIn >= UI2_MAX + 0.5)
1272 return DISP_E_OVERFLOW;
1273 VARIANT_DutchRound(USHORT, dblIn, *pusOut);
1274 return S_OK;
1275}

Referenced by test_VarUI2FromR8(), VARIANT_Coerce(), VarUI2FromDate(), and VarUI2FromR4().

◆ VarUI2FromStr()

HRESULT WINAPI VarUI2FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
USHORT pusOut 
)

Definition at line 1335 of file vartype.c.

1336{
1337 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pusOut, VT_UI2);
1338}

Referenced by test_VarUI2FromStr(), and VARIANT_Coerce().

◆ VarUI2FromUI1()

HRESULT WINAPI VarUI2FromUI1 ( BYTE  bIn,
USHORT pusOut 
)

Definition at line 1194 of file vartype.c.

1195{
1196 return _VarUI2FromUI1(bIn, pusOut);
1197}

Referenced by test_VarUI2FromUI1(), and VARIANT_Coerce().

◆ VarUI2FromUI4()

HRESULT WINAPI VarUI2FromUI4 ( ULONG  ulIn,
USHORT pusOut 
)

Definition at line 1409 of file vartype.c.

1410{
1411 return _VarUI2FromUI4(ulIn, pusOut);
1412}

Referenced by test_VarUI2FromUI4(), and VARIANT_Coerce().

◆ VarUI2FromUI8()

HRESULT WINAPI VarUI2FromUI8 ( ULONG64  ullIn,
USHORT pusOut 
)

Definition at line 1471 of file vartype.c.

1472{
1473 return _VarUI2FromUI8(ullIn, pusOut);
1474}

Referenced by test_VarUI2FromUI8().

◆ VarUI4FromBool()

HRESULT WINAPI VarUI4FromBool ( VARIANT_BOOL  boolIn,
ULONG pulOut 
)

Definition at line 1958 of file vartype.c.

1959{
1960 return _VarUI4FromBool(boolIn, pulOut);
1961}

Referenced by test_VarUI4FromBool(), and VARIANT_Coerce().

◆ VarUI4FromCy()

HRESULT WINAPI VarUI4FromCy ( CY  cyIn,
ULONG pulOut 
)

Definition at line 1897 of file vartype.c.

1898{
1899 double d = cyIn.int64 / CY_MULTIPLIER_F;
1900 return VarUI4FromR8(d, pulOut);
1901}
HRESULT WINAPI VarUI4FromR8(double dblIn, ULONG *pulOut)
Definition: vartype.c:1858

Referenced by test_VarUI4FromCy(), VARIANT_Coerce(), VarUI1FromCy(), and VarUI2FromCy().

◆ VarUI4FromDate()

HRESULT WINAPI VarUI4FromDate ( DATE  dateIn,
ULONG pulOut 
)

Definition at line 1879 of file vartype.c.

1880{
1881 return VarUI4FromR8(dateIn, pulOut);
1882}

Referenced by test_VarUI4FromDate(), and VARIANT_Coerce().

◆ VarUI4FromDec()

HRESULT WINAPI VarUI4FromDec ( DECIMAL pdecIn,
ULONG pulOut 
)

Definition at line 2012 of file vartype.c.

2013{
2014 LONG64 i64;
2015 HRESULT hRet;
2016
2017 hRet = VarI8FromDec(pdecIn, &i64);
2018
2019 if (SUCCEEDED(hRet))
2020 hRet = _VarUI4FromI8(i64, pulOut);
2021 return hRet;
2022}

Referenced by test_VarUI4FromDec(), and VARIANT_Coerce().

◆ VarUI4FromDisp()

HRESULT WINAPI VarUI4FromDisp ( IDispatch pdispIn,
LCID  lcid,
ULONG pulOut 
)

Definition at line 1941 of file vartype.c.

1942{
1943 return VARIANT_FromDisp(pdispIn, lcid, pulOut, VT_UI4, 0);
1944}

Referenced by VARIANT_Coerce().

◆ VarUI4FromI1()

HRESULT WINAPI VarUI4FromI1 ( signed char  cIn,
ULONG pulOut 
)

Definition at line 1976 of file vartype.c.

1977{
1978 return _VarUI4FromI1(cIn, pulOut);
1979}

Referenced by test_VarUI4FromI1(), and VARIANT_Coerce().

◆ VarUI4FromI2()

HRESULT WINAPI VarUI4FromI2 ( SHORT  sIn,
ULONG pulOut 
)

Definition at line 1801 of file vartype.c.

1802{
1803 return _VarUI4FromI2(sIn, pulOut);
1804}

Referenced by test_VarUI4FromI2(), and VARIANT_Coerce().

◆ VarUI4FromI4()

HRESULT WINAPI VarUI4FromI4 ( LONG  iIn,
ULONG pulOut 
)

Definition at line 1819 of file vartype.c.

1820{
1821 return _VarUI4FromI4(iIn, pulOut);
1822}

Referenced by test_VarUI4FromI4().

◆ VarUI4FromI8()

HRESULT WINAPI VarUI4FromI8 ( LONG64  llIn,
ULONG pulOut 
)

Definition at line 2037 of file vartype.c.

2038{
2039 return _VarUI4FromI8(llIn, pulOut);
2040}

Referenced by test_VarUI4FromI8(), test_VarUI4FromUI8(), and VARIANT_Coerce().

◆ VarUI4FromR4()

HRESULT WINAPI VarUI4FromR4 ( FLOAT  fltIn,
ULONG pulOut 
)

Definition at line 1837 of file vartype.c.

1838{
1839 return VarUI4FromR8(fltIn, pulOut);
1840}

Referenced by test_VarUI4FromR4(), test_VarUI4FromR8(), and VARIANT_Coerce().

◆ VarUI4FromR8()

HRESULT WINAPI VarUI4FromR8 ( double  dblIn,
ULONG pulOut 
)

Definition at line 1858 of file vartype.c.

1859{
1860 if (dblIn < -0.5 || dblIn >= UI4_MAX + 0.5)
1861 return DISP_E_OVERFLOW;
1862 VARIANT_DutchRound(ULONG, dblIn, *pulOut);
1863 return S_OK;
1864}
#define UI4_MAX
Definition: variant.h:63

Referenced by test_VarUI4FromR8(), VARIANT_Coerce(), VarUI4FromCy(), VarUI4FromDate(), and VarUI4FromR4().

◆ VarUI4FromStr()

HRESULT WINAPI VarUI4FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
ULONG pulOut 
)

Definition at line 1920 of file vartype.c.

1921{
1922 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pulOut, VT_UI4);
1923}

Referenced by test_VarUI4FromStr(), and VARIANT_Coerce().

◆ VarUI4FromUI1()

HRESULT WINAPI VarUI4FromUI1 ( BYTE  bIn,
ULONG pulOut 
)

Definition at line 1783 of file vartype.c.

1784{
1785 return _VarUI4FromUI1(bIn, pulOut);
1786}

Referenced by test_VarUI4FromUI1(), and VARIANT_Coerce().

◆ VarUI4FromUI2()

HRESULT WINAPI VarUI4FromUI2 ( USHORT  usIn,
ULONG pulOut 
)

Definition at line 1993 of file vartype.c.

1994{
1995 return _VarUI4FromUI2(usIn, pulOut);
1996}

Referenced by test_VarUI4FromUI2(), and VARIANT_Coerce().

◆ VarUI4FromUI8()

HRESULT WINAPI VarUI4FromUI8 ( ULONG64  ullIn,
ULONG pulOut 
)

Definition at line 2055 of file vartype.c.

2056{
2057 return _VarUI4FromUI8(ullIn, pulOut);
2058}

Referenced by test_VarUI4FromUI8(), and VARIANT_Coerce().

◆ VarUI8FromBool()

HRESULT WINAPI VarUI8FromBool ( VARIANT_BOOL  boolIn,
ULONG64 pui64Out 
)

Definition at line 2594 of file vartype.c.

2595{
2596 return VarI8FromI2(boolIn, (LONG64 *)pui64Out);
2597}

Referenced by test_VarUI8FromBool(), and VARIANT_Coerce().

◆ VarUI8FromCy()

HRESULT WINAPI VarUI8FromCy ( CY  cyIn,
ULONG64 pui64Out 
)

Definition at line 2498 of file vartype.c.

2499{
2500 if (cyIn.int64 < 0)
2501 {
2502 if (cyIn.int64 < -CY_HALF)
2503 return DISP_E_OVERFLOW;
2504 *pui64Out = 0;
2505 }
2506 else
2507 {
2508 *pui64Out = cyIn.int64 / CY_MULTIPLIER;
2509
2510 cyIn.int64 -= *pui64Out * CY_MULTIPLIER; /* cyIn.s.Lo now holds fractional remainder */
2511
2512 if (cyIn.s.Lo > CY_HALF || (cyIn.s.Lo == CY_HALF && (*pui64Out & 0x1)))
2513 (*pui64Out)++;
2514 }
2515 return S_OK;
2516}

Referenced by test_VarUI8FromCy(), and VARIANT_Coerce().

◆ VarUI8FromDate()

HRESULT WINAPI VarUI8FromDate ( DATE  dateIn,
ULONG64 pui64Out 
)

Definition at line 2533 of file vartype.c.

2534{
2535 return VarUI8FromR8(dateIn, pui64Out);
2536}
HRESULT WINAPI VarUI8FromR8(double dblIn, ULONG64 *pui64Out)
Definition: vartype.c:2473

Referenced by test_VarUI8FromDate(), and VARIANT_Coerce().

◆ VarUI8FromDec()

HRESULT WINAPI VarUI8FromDec ( DECIMAL pdecIn,
ULONG64 pui64Out 
)

Definition at line 2670 of file vartype.c.

2671{
2672 if (!DEC_SCALE(pdecIn))
2673 {
2674 /* This decimal is just a 96 bit integer */
2675 if (DEC_SIGN(pdecIn) & ~DECIMAL_NEG)
2676 return E_INVALIDARG;
2677
2678 if (DEC_HI32(pdecIn))
2679 return DISP_E_OVERFLOW;
2680
2681 if (DEC_SIGN(pdecIn))
2682 {
2683 WARN("Sign would be ignored under Win32!\n");
2684 return DISP_E_OVERFLOW;
2685 }
2686
2687 *pui64Out = DEC_LO64(pdecIn);
2688 return S_OK;
2689 }
2690 else
2691 {
2692 /* Decimal contains a floating point number */
2693 HRESULT hRet;
2694 double dbl;
2695
2696 hRet = VarR8FromDec(pdecIn, &dbl);
2697 if (SUCCEEDED(hRet))
2698 hRet = VarUI8FromR8(dbl, pui64Out);
2699 return hRet;
2700 }
2701}

Referenced by test_VarUI8FromDec(), and VARIANT_Coerce().

◆ VarUI8FromDisp()

HRESULT WINAPI VarUI8FromDisp ( IDispatch pdispIn,
LCID  lcid,
ULONG64 pui64Out 
)

Definition at line 2576 of file vartype.c.

2577{
2578 return VARIANT_FromDisp(pdispIn, lcid, pui64Out, VT_UI8, 0);
2579}

Referenced by VARIANT_Coerce().

◆ VarUI8FromI1()

HRESULT WINAPI VarUI8FromI1 ( signed char  cIn,
ULONG64 pui64Out 
)

Definition at line 2611 of file vartype.c.

2612{
2613 return _VarUI8FromI1(cIn, pui64Out);
2614}

Referenced by test_VarUI8FromI1(), and VARIANT_Coerce().

◆ VarUI8FromI2()

HRESULT WINAPI VarUI8FromI2 ( SHORT  sIn,
ULONG64 pui64Out 
)

Definition at line 2433 of file vartype.c.

2434{
2435 return _VarUI8FromI2(sIn, pui64Out);
2436}

Referenced by test_VarUI8FromI2(), and VARIANT_Coerce().

◆ VarUI8FromI8()

HRESULT WINAPI VarUI8FromI8 ( LONG64  llIn,
ULONG64 pui64Out 
)

Definition at line 2399 of file vartype.c.

2400{
2401 return _VarUI8FromI8(llIn, pui64Out);
2402}

Referenced by test_VarUI8FromI8().

◆ VarUI8FromR4()

HRESULT WINAPI VarUI8FromR4 ( FLOAT  fltIn,
ULONG64 pui64Out 
)

Definition at line 2451 of file vartype.c.

2452{
2453 return VarUI8FromR8(fltIn, pui64Out);
2454}

Referenced by test_VarUI8FromR4(), and VARIANT_Coerce().

◆ VarUI8FromR8()

HRESULT WINAPI VarUI8FromR8 ( double  dblIn,
ULONG64 pui64Out 
)

Definition at line 2473 of file vartype.c.

2474{
2475 if (dblIn < -0.5 || dblIn > 1.844674407370955e19)
2476 return DISP_E_OVERFLOW;
2477 VARIANT_DutchRound(ULONG64, dblIn, *pui64Out);
2478 return S_OK;
2479}

Referenced by test_VarUI8FromR8(), VARIANT_Coerce(), VarUI8FromDate(), VarUI8FromDec(), and VarUI8FromR4().

◆ VarUI8FromStr()

HRESULT WINAPI VarUI8FromStr ( OLECHAR strIn,
LCID  lcid,
ULONG  dwFlags,
ULONG64 pui64Out 
)

Definition at line 2555 of file vartype.c.

2556{
2557 return VARIANT_NumberFromBstr(strIn, lcid, dwFlags, pui64Out, VT_UI8);
2558}

Referenced by test_VarUI8FromStr(), and VARIANT_Coerce().

◆ VarUI8FromUI1()

HRESULT WINAPI VarUI8FromUI1 ( BYTE  bIn,
ULONG64 pui64Out 
)

Definition at line 2416 of file vartype.c.

2417{
2418 return _VarUI8FromUI1(bIn, pui64Out);
2419}

Referenced by test_VarUI8FromUI1(), and VARIANT_Coerce().

◆ VarUI8FromUI2()

HRESULT WINAPI VarUI8FromUI2 ( USHORT  usIn,
ULONG64 pui64Out 
)

Definition at line 2628 of file vartype.c.

2629{
2630 return _VarUI8FromUI2(usIn, pui64Out);
2631}

Referenced by test_VarUI8FromUI2(), and VARIANT_Coerce().

◆ VarUI8FromUI4()

HRESULT WINAPI VarUI8FromUI4 ( ULONG  ulIn,
ULONG64 pui64Out 
)

Definition at line 2645 of file vartype.c.

2646{
2647 return _VarUI8FromUI4(ulIn, pui64Out);
2648}

Referenced by test_VarUI8FromUI4(), and VARIANT_Coerce().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( variant  )

Variable Documentation

◆ CY_Divisors

const int CY_Divisors[5]
static
Initial value:

Definition at line 3402 of file vartype.c.

Referenced by VarCyFromDec(), and VarCyRound().

◆ DECLSPEC_HIDDEN

HMODULE hProxyDll DECLSPEC_HIDDEN
extern

Definition at line 289 of file d3dcompiler_private.h.

◆ szDoubleFormatW

const WCHAR szDoubleFormatW[] = { '%','.','1','5','G','\0' }
static

Definition at line 44 of file vartype.c.

Referenced by VarBstrFromR8().

◆ szFloatFormatW

const WCHAR szFloatFormatW[] = { '%','.','7','G','\0' }
static

Definition at line 43 of file vartype.c.

Referenced by VarBstrFromR4().