[ros-diffs] [cwittich] 36403: sync oleaut32 with wine 1.1.5

cwittich at svn.reactos.org cwittich at svn.reactos.org
Mon Sep 22 16:20:28 CEST 2008


Author: cwittich
Date: Mon Sep 22 09:20:27 2008
New Revision: 36403

URL: http://svn.reactos.org/svn/reactos?rev=36403&view=rev
Log:
sync oleaut32 with wine 1.1.5

Modified:
    trunk/reactos/dll/win32/oleaut32/hash.c
    trunk/reactos/dll/win32/oleaut32/tmarshal.c
    trunk/reactos/dll/win32/oleaut32/typelib.c
    trunk/reactos/dll/win32/oleaut32/varformat.c
    trunk/reactos/dll/win32/oleaut32/vartype.c

Modified: trunk/reactos/dll/win32/oleaut32/hash.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/hash.c?rev=36403&r1=36402&r2=36403&view=diff
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/hash.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/hash.c [iso-8859-1] Mon Sep 22 09:20:27 2008
@@ -509,6 +509,9 @@
   ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
   ULONG nHiWord, nLoWord = 0x0deadbee;
   const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
+
+  TRACE("(%d, %d, %s) %s\n", skind, lcid, debugstr_a(lpStr),
+    (skind == SYS_WIN16) ? "SYS_WIN16" : (skind == SYS_WIN32) ? "SYS_WIN32" : "");
 
   if (!str)
     return 0;

Modified: trunk/reactos/dll/win32/oleaut32/tmarshal.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/tmarshal.c?rev=36403&r1=36402&r2=36403&view=diff
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/tmarshal.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/tmarshal.c [iso-8859-1] Mon Sep 22 09:20:27 2008
@@ -508,9 +508,10 @@
 };
 
 /* how much space do we use on stack in DWORD steps. */
-int
-_argsize(DWORD vt) {
-    switch (vt) {
+static int
+_argsize(TYPEDESC *tdesc, ITypeInfo *tinfo) {
+    switch (tdesc->vt) {
+    case VT_I8:
     case VT_UI8:
 	return 8/sizeof(DWORD);
     case VT_R8:
@@ -519,30 +520,53 @@
         return sizeof(CY)/sizeof(DWORD);
     case VT_DATE:
 	return sizeof(DATE)/sizeof(DWORD);
+    case VT_DECIMAL:
+        return (sizeof(DECIMAL)+3)/sizeof(DWORD);
     case VT_VARIANT:
 	return (sizeof(VARIANT)+3)/sizeof(DWORD);
+    case VT_USERDEFINED:
+    {
+        ITypeInfo *tinfo2;
+        TYPEATTR *tattr;
+        HRESULT hres;
+        DWORD ret;
+
+        hres = ITypeInfo_GetRefTypeInfo(tinfo,tdesc->u.hreftype,&tinfo2);
+        if (FAILED(hres))
+            return 0; /* should fail critically in serialize_param */
+        ITypeInfo_GetTypeAttr(tinfo2,&tattr);
+        ret = (tattr->cbSizeInstance+3)/sizeof(DWORD);
+        ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
+        ITypeInfo_Release(tinfo2);
+        return ret;
+    }
     default:
 	return 1;
     }
 }
 
+/* how much space do we use on the heap (in bytes) */
 static int
-_xsize(const TYPEDESC *td) {
+_xsize(const TYPEDESC *td, ITypeInfo *tinfo) {
     switch (td->vt) {
     case VT_DATE:
 	return sizeof(DATE);
+    case VT_CY:
+        return sizeof(CY);
+    /* FIXME: VT_BOOL should return 2? */
     case VT_VARIANT:
-	return sizeof(VARIANT)+3;
+	return sizeof(VARIANT)+3; /* FIXME: why the +3? */
     case VT_CARRAY: {
 	int i, arrsize = 1;
 	const ARRAYDESC *adesc = td->u.lpadesc;
 
 	for (i=0;i<adesc->cDims;i++)
 	    arrsize *= adesc->rgbounds[i].cElements;
-	return arrsize*_xsize(&adesc->tdescElem);
+	return arrsize*_xsize(&adesc->tdescElem, tinfo);
     }
     case VT_UI8:
     case VT_I8:
+    case VT_R8:
 	return 8;
     case VT_UI2:
     case VT_I2:
@@ -550,6 +574,22 @@
     case VT_UI1:
     case VT_I1:
 	return 1;
+    case VT_USERDEFINED:
+    {
+        ITypeInfo *tinfo2;
+        TYPEATTR *tattr;
+        HRESULT hres;
+        DWORD ret;
+
+        hres = ITypeInfo_GetRefTypeInfo(tinfo,td->u.hreftype,&tinfo2);
+        if (FAILED(hres))
+            return 0;
+        ITypeInfo_GetTypeAttr(tinfo2,&tattr);
+        ret = tattr->cbSizeInstance;
+        ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
+        ITypeInfo_Release(tinfo2);
+        return ret;
+    }
     default:
 	return 4;
     }
@@ -843,7 +883,7 @@
 	if (debugout) TRACE_(olerelay)("(vt %s)",debugstr_vt(adesc->tdescElem.vt));
 	if (debugout) TRACE_(olerelay)("[");
 	for (i=0;i<arrsize;i++) {
-	    hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem)), buf);
+	    hres = serialize_param(tinfo, writeit, debugout, dealloc, &adesc->tdescElem, (DWORD*)((LPBYTE)arg+i*_xsize(&adesc->tdescElem, tinfo)), buf);
 	    if (hres)
 		return hres;
 	    if (debugout && (i<arrsize-1)) TRACE_(olerelay)(",");
@@ -1092,7 +1132,7 @@
 	    if (alloc) {
 		/* Allocate space for the referenced struct */
 		if (derefhere)
-		    *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc));
+		    *arg=(DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,_xsize(tdesc->u.lptdesc, tinfo));
 	    }
 	    if (derefhere)
 		return deserialize_param(tinfo, readit, debugout, alloc, tdesc->u.lptdesc, (LPDWORD)*arg, buf);
@@ -1141,9 +1181,6 @@
 		case TKIND_RECORD: {
 		    int i;
 
-		    if (alloc)
-			*arg = (DWORD)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,tattr->cbSizeInstance);
-
 		    if (debugout) TRACE_(olerelay)("{");
 		    for (i=0;i<tattr->cVars;i++) {
 			VARDESC *vdesc;
@@ -1161,7 +1198,7 @@
 			    debugout,
 			    alloc,
 			    &vdesc->elemdescVar.tdesc,
-			    (DWORD*)(((LPBYTE)*arg)+vdesc->u.oInst),
+			    (DWORD*)(((LPBYTE)arg)+vdesc->u.oInst),
 			    buf
 			);
                         ITypeInfo2_ReleaseVarDesc(tinfo2, vdesc);
@@ -1207,7 +1244,7 @@
 		    debugout,
 		    alloc,
 		    &adesc->tdescElem,
-		    (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem)),
+		    (DWORD*)((LPBYTE)(arg)+i*_xsize(&adesc->tdescElem, tinfo)),
 		    buf
 		);
 	    return S_OK;
@@ -1407,7 +1444,7 @@
 	}
 	/* No need to marshal other data than FIN and any VT_PTR. */
 	if (!is_in_elem(elem) && (elem->tdesc.vt != VT_PTR)) {
-	    xargs+=_argsize(elem->tdesc.vt);
+	    xargs+=_argsize(&elem->tdesc, tinfo);
 	    if (relaydeb) TRACE_(olerelay)("[out]");
 	    continue;
 	}
@@ -1425,7 +1462,7 @@
 	    ERR("Failed to serialize param, hres %x\n",hres);
 	    break;
 	}
-	xargs+=_argsize(elem->tdesc.vt);
+	xargs+=_argsize(&elem->tdesc, tinfo);
     }
     if (relaydeb) TRACE_(olerelay)(")");
 
@@ -1466,7 +1503,7 @@
 	}
 	/* No need to marshal other data than FOUT and any VT_PTR */
 	if (!is_out_elem(elem) && (elem->tdesc.vt != VT_PTR)) {
-	    xargs += _argsize(elem->tdesc.vt);
+	    xargs += _argsize(&elem->tdesc, tinfo);
 	    if (relaydeb) TRACE_(olerelay)("[in]");
 	    continue;
 	}
@@ -1484,7 +1521,7 @@
 	    status = hres;
 	    break;
 	}
-	xargs += _argsize(elem->tdesc.vt);
+	xargs += _argsize(&elem->tdesc, tinfo);
     }
 
     hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD));
@@ -1725,7 +1762,7 @@
     /* some args take more than 4 byte on the stack */
     nrofargs = 0;
     for (j=0;j<fdesc->cParams;j++)
-        nrofargs += _argsize(fdesc->lprgelemdescParam[j].tdesc.vt);
+        nrofargs += _argsize(&fdesc->lprgelemdescParam[j].tdesc, proxy->tinfo);
 
 #ifdef __i386__
     if (fdesc->callconv != CC_STDCALL) {
@@ -2055,7 +2092,7 @@
     /*dump_FUNCDESC(fdesc);*/
     nrofargs = 0;
     for (i=0;i<fdesc->cParams;i++)
-	nrofargs += _argsize(fdesc->lprgelemdescParam[i].tdesc.vt);
+	nrofargs += _argsize(&fdesc->lprgelemdescParam[i].tdesc, tinfo);
     args = HeapAlloc(GetProcessHeap(),0,(nrofargs+1)*sizeof(DWORD));
     if (!args)
     {
@@ -2077,7 +2114,7 @@
 	   xargs,
 	   &buf
 	);
-	xargs += _argsize(elem->tdesc.vt);
+	xargs += _argsize(&elem->tdesc, tinfo);
 	if (hres) {
 	    ERR("Failed to deserialize param %s, hres %x\n",relaystr(names[i+1]),hres);
 	    break;
@@ -2123,7 +2160,7 @@
 	   xargs,
 	   &buf
 	);
-	xargs += _argsize(elem->tdesc.vt);
+	xargs += _argsize(&elem->tdesc, tinfo);
 	if (hres) {
 	    ERR("Failed to stuballoc param, hres %x\n",hres);
 	    break;

Modified: trunk/reactos/dll/win32/oleaut32/typelib.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/typelib.c?rev=36403&r1=36402&r2=36403&view=diff
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/typelib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/typelib.c [iso-8859-1] Mon Sep 22 09:20:27 2008
@@ -3146,7 +3146,7 @@
 						       sizeof(VARIANT));
         V_VT((*ppVarDesc)->vardesc.u.lpvarValue) = VT_INT;
         if (pItem->flags & 0x08)
-          V_UNION((*ppVarDesc)->vardesc.u.lpvarValue, intVal) = pItem->byte_offs;
+          V_INT((*ppVarDesc)->vardesc.u.lpvarValue) = pItem->byte_offs;
         else {
           switch ((*ppVarDesc)->vardesc.elemdescVar.tdesc.vt)
           {
@@ -3172,7 +3172,9 @@
             case VT_UI2:
             case VT_I4:
             case VT_UI4:
-              V_UNION((*ppVarDesc)->vardesc.u.lpvarValue, intVal) =
+            case VT_INT:
+            case VT_UINT:
+              V_INT((*ppVarDesc)->vardesc.u.lpvarValue) =
                 *(INT*)(pBlk + pItem->byte_offs);
               break;
             default:
@@ -5483,7 +5485,32 @@
     return res;
 }
 
-extern int _argsize(DWORD vt);
+/* The size of the argument on the stack in DWORD units (in all x86 call
+ * convetions the arguments on the stack are DWORD-aligned)
+ */
+int _dispargsize(VARTYPE vt)
+{
+    switch (vt) {
+    case VT_I8:
+    case VT_UI8:
+	return 8/sizeof(DWORD);
+    case VT_R8:
+        return sizeof(double)/sizeof(DWORD);
+    case VT_DECIMAL:
+        return (sizeof(DECIMAL)+3)/sizeof(DWORD);
+    case VT_CY:
+        return sizeof(CY)/sizeof(DWORD);
+    case VT_DATE:
+	return sizeof(DATE)/sizeof(DWORD);
+    case VT_VARIANT:
+	return (sizeof(VARIANT)+3)/sizeof(DWORD);
+    case VT_RECORD:
+        FIXME("VT_RECORD not implemented\n");
+        return 1;
+    default:
+	return 1;
+    }
+}
 
 static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt)
 {
@@ -5671,9 +5698,9 @@
 
     for (i=0;i<cActuals;i++)
     {
-        TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_argsize(prgvt[i]));
+        TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_dispargsize(prgvt[i]));
         dump_Variant(prgpvarg[i]);
-        argsize += _argsize(prgvt[i]);
+        argsize += _dispargsize(prgvt[i]);
     }
     args = HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize);
 
@@ -5689,10 +5716,10 @@
         VARIANT *arg = prgpvarg[i];
         TRACE("Storing arg %d (%d as %d)\n",i,V_VT(arg),prgvt[i]);
         if (prgvt[i] == VT_VARIANT)
-            memcpy(&args[argspos], arg, _argsize(prgvt[i]) * sizeof(DWORD));
+            memcpy(&args[argspos], arg, _dispargsize(prgvt[i]) * sizeof(DWORD));
         else
-            memcpy(&args[argspos], &V_NONE(arg), _argsize(prgvt[i]) * sizeof(DWORD));
-        argspos += _argsize(prgvt[i]);
+            memcpy(&args[argspos], &V_NONE(arg), _dispargsize(prgvt[i]) * sizeof(DWORD));
+        argspos += _dispargsize(prgvt[i]);
     }
 
     if (pvInstance)

Modified: trunk/reactos/dll/win32/oleaut32/varformat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/varformat.c?rev=36403&r1=36402&r2=36403&view=diff
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/varformat.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/varformat.c [iso-8859-1] Mon Sep 22 09:20:27 2008
@@ -966,7 +966,7 @@
       }
       fmt_state &= ~FMT_STATE_OPEN_COPY;
     }
-    else if ((*pFormat == 'q' || *pFormat == 'q') && COULD_BE(FMT_TYPE_DATE))
+    else if ((*pFormat == 'q' || *pFormat == 'Q') && COULD_BE(FMT_TYPE_DATE))
     {
       /* Date formats: Quarter specifier
        * Other formats: Literal

Modified: trunk/reactos/dll/win32/oleaut32/vartype.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/oleaut32/vartype.c?rev=36403&r1=36402&r2=36403&view=diff
==============================================================================
--- trunk/reactos/dll/win32/oleaut32/vartype.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/oleaut32/vartype.c [iso-8859-1] Mon Sep 22 09:20:27 2008
@@ -5500,7 +5500,7 @@
   VARIANT_DIFromDec(pDecLeft, &di_left);
   VARIANT_DIFromDec(pDecRight, &di_right);
   divresult = VARIANT_DI_div(&di_left, &di_right, &di_result);
-  if (divresult)
+  if (divresult != S_OK)
   {
       /* division actually overflowed */
       hRet = divresult;



More information about the Ros-diffs mailing list