[WINE/DEBUG]
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 25 Sep 2014 14:59:07 +0000 (14:59 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 25 Sep 2014 14:59:07 +0000 (14:59 +0000)
* Define debugstr_variant and co globally to avoid code duplication.
CORE-8540

svn path=/trunk/; revision=64270

reactos/dll/win32/ieframe/ieframe_main.c
reactos/dll/win32/jscript/jsutils.c
reactos/dll/win32/mshtml/main.c
reactos/dll/win32/msxml3/main.c
reactos/dll/win32/vbscript/vbscript_main.c
reactos/dll/win32/wbemprox/wbemprox_private.h
reactos/include/reactos/wine/debug.h

index 373e5d6..a83d7a9 100644 (file)
 LONG module_ref = 0;
 HINSTANCE ieframe_instance;
 
-const char *debugstr_variant(const VARIANT *v)
-{
-    if(!v)
-        return "(null)";
-
-    switch(V_VT(v)) {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I4:
-        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
-    case VT_R8:
-        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
-    case VT_BSTR:
-        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
-    case VT_DISPATCH:
-        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
-    case VT_BOOL:
-        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
-    default:
-        return wine_dbg_sprintf("{vt %d}", V_VT(v));
-    }
-}
-
 static ITypeLib *typelib;
 static ITypeInfo *typeinfos[LAST_tid];
 
index bf94580..dfdd090 100644 (file)
 
 WINE_DECLARE_DEBUG_CHANNEL(heap);
 
-const char *debugstr_variant(const VARIANT *v)
-{
-    if(!v)
-        return "(null)";
-
-    switch(V_VT(v)) {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I4:
-        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
-    case VT_UI4:
-        return wine_dbg_sprintf("{VT_UI4: %u}", V_UI4(v));
-    case VT_R8:
-        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
-    case VT_BSTR:
-        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
-    case VT_DISPATCH:
-        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
-    case VT_BOOL:
-        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
-    case VT_ARRAY|VT_VARIANT:
-        return "{VT_ARRAY|VT_VARIANT: ...}";
-    default:
-        return wine_dbg_sprintf("{vt %d}", V_VT(v));
-    }
-}
-
 const char *debugstr_jsval(const jsval_t v)
 {
     switch(jsval_type(v)) {
index f22c63c..320341f 100644 (file)
@@ -499,34 +499,3 @@ HRESULT WINAPI DllUnregisterServer(void)
     if(SUCCEEDED(hres)) hres = register_server(FALSE);
     return hres;
 }
-
-const char *debugstr_variant(const VARIANT *v)
-{
-    if(!v)
-        return "(null)";
-
-    switch(V_VT(v)) {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I2:
-        return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v));
-    case VT_I4:
-        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
-    case VT_R8:
-        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
-    case VT_BSTR:
-        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
-    case VT_DISPATCH:
-        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
-    case VT_ERROR:
-        return wine_dbg_sprintf("{VT_ERROR: %08x}", V_ERROR(v));
-    case VT_BOOL:
-        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
-    case VT_UINT:
-        return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v));
-    default:
-        return wine_dbg_sprintf("{vt %d}", V_VT(v));
-    }
-}
index e3247c3..3184ff1 100644 (file)
@@ -255,50 +255,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
     return TRUE;
 }
 
-const char *debugstr_variant(const VARIANT *v)
-{
-    if(!v)
-        return "(null)";
-
-    switch(V_VT(v)) {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I1:
-        return wine_dbg_sprintf("{VT_I1: %d}", V_I1(v));
-    case VT_I2:
-        return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v));
-    case VT_I4:
-        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
-    case VT_INT:
-        return wine_dbg_sprintf("{VT_INT: %d}", V_INT(v));
-    case VT_R8:
-        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
-    case VT_BSTR:
-        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
-    case VT_DISPATCH:
-        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
-    case VT_BOOL:
-        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
-    case VT_UNKNOWN:
-        return wine_dbg_sprintf("{VT_UNKNOWN: %p}", V_UNKNOWN(v));
-    case VT_UINT:
-        return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v));
-    case VT_BSTR|VT_BYREF:
-        return wine_dbg_sprintf("{VT_BSTR|VT_BYREF: ptr %p, data %s}",
-            V_BSTRREF(v), debugstr_w(V_BSTRREF(v) ? *V_BSTRREF(v) : NULL));
-    case VT_ERROR:
-        return wine_dbg_sprintf("{VT_ERROR: 0x%08x}", V_ERROR(v));
-    case VT_VARIANT|VT_BYREF:
-        return wine_dbg_sprintf("{VT_VARIANT|VT_BYREF: %s}", debugstr_variant(V_VARIANTREF(v)));
-    case VT_UI1|VT_ARRAY:
-        return "{VT_UI1|VT_ARRAY}";
-    default:
-        return wine_dbg_sprintf("{vt %d}", V_VT(v));
-    }
-}
-
 /***********************************************************************
  *             DllRegisterServer (MSXML3.@)
  */
index 224f06d..b04f143 100644 (file)
@@ -87,38 +87,6 @@ static void release_typelib(void)
     ITypeLib_Release(typelib);
 }
 
-const char *debugstr_variant(const VARIANT *v)
-{
-    if(!v)
-        return "(null)";
-
-    if(V_ISBYREF(v))
-        return wine_dbg_sprintf("{V_BYREF -> %s}", debugstr_variant(V_BYREF(v)));
-
-    switch(V_VT(v)) {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I2:
-        return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v));
-    case VT_I4:
-        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
-    case VT_UI4:
-        return wine_dbg_sprintf("{VT_UI4: %u}", V_UI4(v));
-    case VT_R8:
-        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
-    case VT_BSTR:
-        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
-    case VT_DISPATCH:
-        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
-    case VT_BOOL:
-        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
-    default:
-        return wine_dbg_sprintf("{vt %d}", V_VT(v));
-    }
-}
-
 #define MIN_BLOCK_SIZE  128
 #define ARENA_FREE_FILLER  0xaa
 
index 6a815ea..d155637 100644 (file)
@@ -280,37 +280,6 @@ static inline WCHAR *heap_strdupW( const WCHAR *src )
     return dst;
 }
 
-static inline const char *debugstr_variant( const VARIANT *v )
-{
-    if (!v) return "(null)";
-    switch (V_VT(v))
-    {
-    case VT_EMPTY:
-        return "{VT_EMPTY}";
-    case VT_NULL:
-        return "{VT_NULL}";
-    case VT_I4:
-        return wine_dbg_sprintf( "{VT_I4: %d}", V_I4(v) );
-    case VT_R8:
-        return wine_dbg_sprintf( "{VT_R8: %lf}", V_R8(v) );
-    case VT_BSTR:
-        return wine_dbg_sprintf( "{VT_BSTR: %s}", debugstr_w(V_BSTR(v)) );
-    case VT_DISPATCH:
-        return wine_dbg_sprintf( "{VT_DISPATCH: %p}", V_DISPATCH(v) );
-    case VT_BOOL:
-        return wine_dbg_sprintf( "{VT_BOOL: %x}", V_BOOL(v) );
-    case VT_UNKNOWN:
-        return wine_dbg_sprintf( "{VT_UNKNOWN: %p}", V_UNKNOWN(v) );
-    case VT_UINT:
-        return wine_dbg_sprintf( "{VT_UINT: %u}", V_UINT(v) );
-    case VT_BSTR|VT_BYREF:
-        return wine_dbg_sprintf( "{VT_BSTR|VT_BYREF: ptr %p, data %s}",
-            V_BSTRREF(v), V_BSTRREF(v) ? debugstr_w( *V_BSTRREF(v) ) : NULL );
-    default:
-        return wine_dbg_sprintf( "{vt %d}", V_VT(v) );
-    }
-}
-
 static const WCHAR class_processW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s',0};
 static const WCHAR class_serviceW[] = {'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
 static const WCHAR class_stdregprovW[] = {'S','t','d','R','e','g','P','r','o','v',0};
index 6eeb12e..16ef3f9 100644 (file)
@@ -231,6 +231,124 @@ static __inline const char *wine_dbgstr_longlong( ULONGLONG ll )
     else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
 }
 
+#if defined(__oaidl_h__) && defined(V_VT)
+
+static inline const char *wine_dbgstr_vt( VARTYPE vt )
+{
+    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",
+        "VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8",
+        "VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY",
+        "VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR","32","33","34","35",
+        "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_VERSIONED_STREAM"
+    };
+
+    static const char *const variant_flags[16] =
+    {
+        "",
+        "|VT_VECTOR",
+        "|VT_ARRAY",
+        "|VT_VECTOR|VT_ARRAY",
+        "|VT_BYREF",
+        "|VT_VECTOR|VT_ARRAY",
+        "|VT_ARRAY|VT_BYREF",
+        "|VT_VECTOR|VT_ARRAY|VT_BYREF",
+        "|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",
+    };
+
+    if (vt & ~VT_TYPEMASK)
+        return wine_dbg_sprintf( "%s%s", wine_dbgstr_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 );
+}
+
+static inline const char *wine_dbgstr_variant( const VARIANT *v )
+{
+    if (!v)
+        return "(null)";
+
+    if (V_VT(v) & VT_BYREF) {
+        if (V_VT(v) == (VT_VARIANT|VT_BYREF))
+            return wine_dbg_sprintf( "%p {VT_VARIANT|VT_BYREF: %s}", v, wine_dbgstr_variant(V_VARIANTREF(v)) );
+        return wine_dbg_sprintf( "%p {%s %p}", v, wine_dbgstr_vt(V_VT(v)), V_BYREF(v) );
+    }
+
+    if (V_ISARRAY(v) || V_ISVECTOR(v))
+        return wine_dbg_sprintf( "%p {%s %p}", v, wine_dbgstr_vt(V_VT(v)), V_ARRAY(v) );
+
+    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_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_R4:
+        return wine_dbg_sprintf( "%p {VT_R4: %f}", v, V_R4(v) );
+    case VT_R8:
+        return wine_dbg_sprintf( "%p {VT_R8: %lf}", v, V_R8(v) );
+    case VT_CY:
+        return wine_dbg_sprintf( "%p {VT_CY: %s}", v, wine_dbgstr_longlong(V_CY(v).int64) );
+    case VT_DATE:
+        return wine_dbg_sprintf( "%p {VT_DATE: %lf}", v, V_DATE(v) );
+    case VT_BSTR:
+        return wine_dbg_sprintf( "%p {VT_BSTR: %s}", v, wine_dbgstr_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_UNKNOWN:
+        return wine_dbg_sprintf( "%p {VT_UNKNOWN: %p}", v, V_UNKNOWN(v) );
+    case VT_I1:
+        return wine_dbg_sprintf( "%p {VT_I1: %d}", v, V_I1(v) );
+    case VT_UI1:
+        return wine_dbg_sprintf( "%p {VT_UI1: %u}", v, V_UI1(v) );
+    case VT_UI2:
+        return wine_dbg_sprintf( "%p {VT_UI2: %d}", v, V_UI2(v) );
+    case VT_UI4:
+        return wine_dbg_sprintf( "%p {VT_UI4: %d}", v, V_UI4(v) );
+    case VT_I8:
+        return wine_dbg_sprintf( "%p {VT_I8: %s}", v, wine_dbgstr_longlong(V_I8(v)) );
+    case VT_UI8:
+        return wine_dbg_sprintf( "%p {VT_UI8: %s}", v, wine_dbgstr_longlong(V_UI8(v)) );
+    case VT_INT:
+        return wine_dbg_sprintf( "%p {VT_INT: %d}", v, V_INT(v) );
+    case VT_UINT:
+        return wine_dbg_sprintf( "%p {VT_UINT: %u}", v, V_UINT(v) );
+    case VT_VOID:
+        return wine_dbg_sprintf( "%p {VT_VOID}", v );
+    case VT_RECORD:
+        return wine_dbg_sprintf( "%p {VT_RECORD: %p %p}", v, V_UNION(v,brecVal).pvRecord, V_UNION(v,brecVal).pRecInfo );
+    default:
+        return wine_dbg_sprintf( "%p {vt %s}", v, wine_dbgstr_vt(V_VT(v)) );
+    }
+}
+
+#endif /* defined(__oaidl_h__) && defined(V_VT) */
+
 #ifndef WINE_TRACE
 #define WINE_TRACE                 __WINE_DPRINTF(_TRACE,__wine_dbch___default)
 #define WINE_TRACE_(ch)            __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch)
@@ -270,6 +388,11 @@ static __inline const char *debugstr_guid( const struct _GUID *id ) { return win
 static __inline const char *debugstr_a( const char *s )  { return wine_dbgstr_an( s, -1 ); }
 static __inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
 
+#if defined(__oaidl_h__) && defined(V_VT)
+static __inline const char *debugstr_vt( VARTYPE vt ) { return wine_dbgstr_vt( vt ); }
+static __inline const char *debugstr_variant( const VARIANT *v ) { return wine_dbgstr_variant( v ); }
+#endif
+
 #define TRACE                      WINE_TRACE
 #define TRACE_(ch)                 WINE_TRACE_(ch)
 #define TRACE_ON(ch)               WINE_TRACE_ON(ch)