Jacek Caban : oleaut32: Added debugstr_variant helper for better debug traces.
Alexandre Julliard
julliard at winehq.org
Wed May 14 15:39:07 CDT 2014
Module: wine
Branch: master
Commit: ed41fc1d9b0aabd581dd7f1e0eb9e1939b96b26f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ed41fc1d9b0aabd581dd7f1e0eb9e1939b96b26f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 14 16:55:57 2014 +0200
oleaut32: Added debugstr_variant helper for better debug traces.
---
dlls/oleaut32/varformat.c | 36 +++++++++++++++---------------------
dlls/oleaut32/variant.c | 33 +++++++++++++++++++++++++++++++++
dlls/oleaut32/variant.h | 2 ++
3 files changed, 50 insertions(+), 21 deletions(-)
diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index e72a170..0e1c370 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -1201,9 +1201,8 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
const BYTE* pToken = NULL;
HRESULT hRes = S_OK;
- TRACE("(%p->(%s%s),%s,%p,0x%08x,%p,0x%08x)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), debugstr_w(lpszFormat), rgbTok, dwFlags, pbstrOut,
- lcid);
+ TRACE("(%s,%s,%p,0x%08x,%p,0x%08x)\n", debugstr_variant(pVarIn), debugstr_w(lpszFormat),
+ rgbTok, dwFlags, pbstrOut, lcid);
V_VT(&vString) = VT_EMPTY;
V_VT(&vBool) = VT_BOOL;
@@ -1612,9 +1611,8 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
const BYTE* pToken = NULL;
HRESULT hRes;
- TRACE("(%p->(%s%s),%s,%p,0x%08x,%p,0x%08x)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), debugstr_w(lpszFormat), rgbTok, dwFlags, pbstrOut,
- lcid);
+ TRACE("(%s,%s,%p,0x%08x,%p,0x%08x)\n", debugstr_variant(pVarIn),
+ debugstr_w(lpszFormat), rgbTok, dwFlags, pbstrOut, lcid);
V_VT(&vDate) = VT_EMPTY;
@@ -1954,9 +1952,8 @@ static HRESULT VARIANT_FormatString(LPVARIANT pVarIn, LPOLESTR lpszFormat,
BOOL bUpper = FALSE;
HRESULT hRes = S_OK;
- TRACE("(%p->(%s%s),%s,%p,0x%08x,%p,0x%08x)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), debugstr_w(lpszFormat), rgbTok, dwFlags, pbstrOut,
- lcid);
+ TRACE("%s,%s,%p,0x%08x,%p,0x%08x)\n", debugstr_variant(pVarIn), debugstr_w(lpszFormat),
+ rgbTok, dwFlags, pbstrOut, lcid);
V_VT(&vStr) = VT_EMPTY;
@@ -2168,9 +2165,8 @@ HRESULT WINAPI VarFormat(LPVARIANT pVarIn, LPOLESTR lpszFormat,
BYTE buff[256];
HRESULT hres;
- TRACE("(%p->(%s%s),%s,%d,%d,0x%08x,%p)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), debugstr_w(lpszFormat), nFirstDay, nFirstWeek,
- dwFlags, pbstrOut);
+ TRACE("(%s,%s,%d,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), debugstr_w(lpszFormat),
+ nFirstDay, nFirstWeek, dwFlags, pbstrOut);
if (!pbstrOut)
return E_INVALIDARG;
@@ -2219,8 +2215,7 @@ HRESULT WINAPI VarFormatDateTime(LPVARIANT pVarIn, INT nFormat, ULONG dwFlags, B
static WCHAR szEmpty[] = { '\0' };
const BYTE* lpFmt = NULL;
- TRACE("(%p->(%s%s),%d,0x%08x,%p)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), nFormat, dwFlags, pbstrOut);
+ TRACE("%s,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), nFormat, dwFlags, pbstrOut);
if (!pVarIn || !pbstrOut || nFormat < 0 || nFormat > 4)
return E_INVALIDARG;
@@ -2272,8 +2267,8 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
HRESULT hRet;
VARIANT vStr;
- TRACE("(%p->(%s%s),%d,%d,%d,%d,0x%08x,%p)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), nDigits, nLeading, nParens, nGrouping, dwFlags, pbstrOut);
+ TRACE("(%s,%d,%d,%d,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), nDigits, nLeading,
+ nParens, nGrouping, dwFlags, pbstrOut);
if (!pVarIn || !pbstrOut || nDigits > 9)
return E_INVALIDARG;
@@ -2383,9 +2378,8 @@ HRESULT WINAPI VarFormatPercent(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
HRESULT hRet;
VARIANT vDbl;
- TRACE("(%p->(%s%s),%d,%d,%d,%d,0x%08x,%p)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), nDigits, nLeading, nParens, nGrouping,
- dwFlags, pbstrOut);
+ TRACE("(%s,%d,%d,%d,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), nDigits, nLeading,
+ nParens, nGrouping, dwFlags, pbstrOut);
if (!pVarIn || !pbstrOut || nDigits > 9)
return E_INVALIDARG;
@@ -2457,8 +2451,8 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading,
HRESULT hRet;
VARIANT vStr;
- TRACE("(%p->(%s%s),%d,%d,%d,%d,0x%08x,%p)\n", pVarIn, debugstr_VT(pVarIn),
- debugstr_VF(pVarIn), nDigits, nLeading, nParens, nGrouping, dwFlags, pbstrOut);
+ TRACE("(%s,%d,%d,%d,%d,0x%08x,%p)\n", debugstr_variant(pVarIn), nDigits, nLeading,
+ nParens, nGrouping, dwFlags, pbstrOut);
if (!pVarIn || !pbstrOut || nDigits > 9)
return E_INVALIDARG;
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index c3bd225..7221787 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -78,6 +78,39 @@ const char * const wine_vflags[16] =
"|VT_VECTOR|VT_ARRAY|VT_BYREF|VT_HARDTYPE",
};
+const char *debugstr_variant(const VARIANT *v)
+{
+ if(!v)
+ return "(null)";
+
+ switch(V_VT(v)) {
+ case VT_EMPTY:
+ return wine_dbg_sprintf("%p {VT_EMPTY}", v);
+ case VT_NULL:
+ return wine_dbg_sprintf("%p {VT_NULL}", v);
+ case VT_I1:
+ return wine_dbg_sprintf("%p {VT_I1: %d}", v, V_I1(v));
+ case VT_I2:
+ return wine_dbg_sprintf("%p {VT_I2: %d}", v, V_I2(v));
+ case VT_I4:
+ return wine_dbg_sprintf("%p {VT_I4: %d}", v, V_I4(v));
+ case VT_R8:
+ return wine_dbg_sprintf("%p {VT_R8: %lf}", v, V_R8(v));
+ case VT_BSTR:
+ return wine_dbg_sprintf("%p {VT_BSTR: %s}", v, debugstr_w(V_BSTR(v)));
+ case VT_DISPATCH:
+ return wine_dbg_sprintf("%p {VT_DISPATCH: %p}", v, V_DISPATCH(v));
+ case VT_ERROR:
+ return wine_dbg_sprintf("%p {VT_ERROR: %08x}", v, V_ERROR(v));
+ case VT_BOOL:
+ return wine_dbg_sprintf("%p {VT_BOOL: %x}", v, V_BOOL(v));
+ case VT_UINT:
+ return wine_dbg_sprintf("%p {VT_UINT: %u}", v, V_UINT(v));
+ default:
+ return wine_dbg_sprintf("%p {vt %s%s}", v, debugstr_VT(v), debugstr_VF(v));
+ }
+}
+
/* Convert a variant from one type to another */
static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
VARIANTARG* ps, VARTYPE vt)
diff --git a/dlls/oleaut32/variant.h b/dlls/oleaut32/variant.h
index d521b20..e13e56a 100644
--- a/dlls/oleaut32/variant.h
+++ b/dlls/oleaut32/variant.h
@@ -57,6 +57,8 @@ extern const char * const wine_vflags[] DECLSPEC_HIDDEN;
#define debugstr_vf(v) (wine_vflags[((v)&VT_EXTRA_TYPE)>>12])
#define debugstr_VF(v) (!(v) ? "(null)" : debugstr_vf(V_EXTRA_TYPE(v)))
+const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
+
/* Size constraints */
#define I1_MAX 0x7f
#define I1_MIN ((-I1_MAX)-1)
More information about the wine-cvs
mailing list