Jacek Caban : oleaut32: Rewrite debugstr_vt.

Alexandre Julliard julliard at winehq.org
Mon May 26 07:34:25 CDT 2014


Module: wine
Branch: master
Commit: 5614770c242834cd9dcbf4f6f4aeacbf2aaac8da
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5614770c242834cd9dcbf4f6f4aeacbf2aaac8da

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri May 23 15:40:16 2014 +0200

oleaut32: Rewrite debugstr_vt.

---

 dlls/oleaut32/tmarshal.c |    2 +-
 dlls/oleaut32/typelib.c  |    7 +++----
 dlls/oleaut32/variant.c  |   47 ++++++++++++++++++++++++++++++----------------
 dlls/oleaut32/variant.h  |   10 +---------
 4 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c
index 0dec7e7..ee2a95b 100644
--- a/dlls/oleaut32/tmarshal.c
+++ b/dlls/oleaut32/tmarshal.c
@@ -711,7 +711,7 @@ serialize_param(
 	    hres = xbuf_add(buf,(LPBYTE)arg,sizeof(DWORD));
 	return hres;
     case VT_VARIANT: {
-        if (debugout) TRACE_(olerelay)("Vt(%s%s)(",debugstr_vt(V_VT((VARIANT *)arg)),debugstr_vf(V_VT((VARIANT *)arg)));
+        if (debugout) TRACE_(olerelay)("%s", debugstr_variant((VARIANT *)arg));
         if (writeit)
         {
             ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 4a16fca..d3ff4e5 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -1541,7 +1541,7 @@ static void dump_Variant(const VARIANT * pvar)
 {
     SYSTEMTIME st;
 
-    TRACE("%p->{%s%s", pvar, debugstr_VT(pvar), debugstr_VF(pvar));
+    TRACE("%p->{%s", pvar, debugstr_vt(V_VT(pvar)));
 
     if (pvar)
     {
@@ -7188,9 +7188,8 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
 
                         if (FAILED(hres))
                         {
-                            ERR("failed to convert param %d to %s%s from %s%s\n", i,
-                                debugstr_vt(rgvt[i]), debugstr_vf(rgvt[i]),
-                                debugstr_VT(src_arg), debugstr_VF(src_arg));
+                            ERR("failed to convert param %d to %s from %s\n", i,
+                                debugstr_vt(rgvt[i]), debugstr_variant(src_arg));
                             break;
                         }
                         prgpvarg[i] = &rgvarg[i];
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index 562236e..ef3b7bf 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -45,7 +45,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(variant);
 
-const char * const wine_vtypes[VT_CLSID+1] =
+static const char * const variant_types[] =
 {
   "VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE",
   "VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN",
@@ -55,10 +55,11 @@ const char * const wine_vtypes[VT_CLSID+1] =
   "VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45",
   "46","47","48","49","50","51","52","53","54","55","56","57","58","59","60",
   "61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE",
-  "VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID"
+  "VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID",
+  "VT_VERSIONED_STREAM"
 };
 
-const char * const wine_vflags[16] =
+static const char * const variant_flags[16] =
 {
  "",
  "|VT_VECTOR",
@@ -68,16 +69,30 @@ const char * const wine_vflags[16] =
  "|VT_VECTOR|VT_ARRAY",
  "|VT_ARRAY|VT_BYREF",
  "|VT_VECTOR|VT_ARRAY|VT_BYREF",
- "|VT_HARDTYPE",
- "|VT_VECTOR|VT_HARDTYPE",
- "|VT_ARRAY|VT_HARDTYPE",
- "|VT_VECTOR|VT_ARRAY|VT_HARDTYPE",
- "|VT_BYREF|VT_HARDTYPE",
- "|VT_VECTOR|VT_ARRAY|VT_HARDTYPE",
- "|VT_ARRAY|VT_BYREF|VT_HARDTYPE",
- "|VT_VECTOR|VT_ARRAY|VT_BYREF|VT_HARDTYPE",
+ "|VT_RESERVED",
+ "|VT_VECTOR|VT_RESERVED",
+ "|VT_ARRAY|VT_RESERVED",
+ "|VT_VECTOR|VT_ARRAY|VT_RESERVED",
+ "|VT_BYREF|VT_RESERVED",
+ "|VT_VECTOR|VT_ARRAY|VT_RESERVED",
+ "|VT_ARRAY|VT_BYREF|VT_RESERVED",
+ "|VT_VECTOR|VT_ARRAY|VT_BYREF|VT_RESERVED",
 };
 
+const char *debugstr_vt(VARTYPE vt)
+{
+    if(vt & ~VT_TYPEMASK)
+        return wine_dbg_sprintf("%s%s", debugstr_vt(vt&VT_TYPEMASK), variant_flags[vt>>12]);
+
+    if(vt <= sizeof(variant_types)/sizeof(*variant_types))
+        return variant_types[vt];
+
+    if(vt == VT_BSTR_BLOB)
+        return "VT_BSTR_BLOB";
+
+    return wine_dbg_sprintf("vt(invalid %x)", vt);
+}
+
 const char *debugstr_variant(const VARIANT *v)
 {
     if(!v)
@@ -109,7 +124,7 @@ const char *debugstr_variant(const VARIANT *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));
+        return wine_dbg_sprintf("%p {vt %s}", v, debugstr_vt(V_VT(v)));
     }
 }
 
@@ -121,8 +136,8 @@ static inline HRESULT VARIANT_Coerce(VARIANTARG* pd, LCID lcid, USHORT wFlags,
   VARTYPE vtFrom =  V_TYPE(ps);
   DWORD dwFlags = 0;
 
-  TRACE("(%s,0x%08x,0x%04x,%s,%s%s)\n", debugstr_variant(pd), lcid, wFlags,
-        debugstr_variant(ps), debugstr_vt(vt), debugstr_vf(vt));
+  TRACE("(%s,0x%08x,0x%04x,%s,%s)\n", debugstr_variant(pd), lcid, wFlags,
+        debugstr_variant(ps), debugstr_vt(vt));
 
   if (vt == VT_BSTR || vtFrom == VT_BSTR)
   {
@@ -1030,8 +1045,8 @@ HRESULT WINAPI VariantChangeTypeEx(VARIANTARG* pvargDest, VARIANTARG* pvargSrc,
 {
   HRESULT res = S_OK;
 
-  TRACE("(%s,%s,0x%08x,0x%04x,%s%s)\n", debugstr_variant(pvargDest),
-        debugstr_variant(pvargSrc), lcid, wFlags, debugstr_vt(vt), debugstr_vf(vt));
+  TRACE("(%s,%s,0x%08x,0x%04x,%s)\n", debugstr_variant(pvargDest),
+        debugstr_variant(pvargSrc), lcid, wFlags, debugstr_vt(vt));
 
   if (vt == VT_CLSID)
     res = DISP_E_BADVARTYPE;
diff --git a/dlls/oleaut32/variant.h b/dlls/oleaut32/variant.h
index e13e56a..a4e3acf 100644
--- a/dlls/oleaut32/variant.h
+++ b/dlls/oleaut32/variant.h
@@ -48,16 +48,8 @@
 #define VTBIT_VARIANT   (1 << VT_VARIANT)
 #define VTBIT_15        (1 << 15)        /* no variant type with this number */
 
-extern const char * const wine_vtypes[] DECLSPEC_HIDDEN;
-#define debugstr_vt(v) (((v)&VT_TYPEMASK) <= VT_CLSID ? wine_vtypes[((v)&VT_TYPEMASK)] : \
-  ((v)&VT_TYPEMASK) == VT_BSTR_BLOB ? "VT_BSTR_BLOB": "Invalid")
-#define debugstr_VT(v) (!(v) ? "(null)" : debugstr_vt(V_TYPE((v))))
-
-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;
+const char *debugstr_vt(VARTYPE) DECLSPEC_HIDDEN;
 
 /* Size constraints */
 #define I1_MAX   0x7f




More information about the wine-cvs mailing list