Huw Davies : oleaut32: Move the proxy thunk creation code to a separate function.

Alexandre Julliard julliard at wine.codeweavers.com
Fri May 18 13:56:08 CDT 2007


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu May 17 15:23:51 2007 +0100

oleaut32: Move the proxy thunk creation code to a separate function.

---

 dlls/oleaut32/tmarshal.c |  104 ++++++++++++++++++++++++---------------------
 1 files changed, 55 insertions(+), 49 deletions(-)

diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c
index 94c6e58..f11d835 100644
--- a/dlls/oleaut32/tmarshal.c
+++ b/dlls/oleaut32/tmarshal.c
@@ -1640,6 +1640,58 @@ static inline HRESULT get_facbuf_for_iid(REFIID riid, IPSFactoryBuffer **facbuf)
                              &IID_IPSFactoryBuffer, (LPVOID*)facbuf);
 }
 
+static HRESULT init_proxy_entry_point(TMProxyImpl *proxy, unsigned int num)
+{
+    int j;
+    /* nrofargs without This */
+    int nrofargs;
+    ITypeInfo *tinfo2;
+    TMAsmProxy	*xasm = proxy->asmstubs + num;
+    HRESULT hres;
+    const FUNCDESC *fdesc;
+
+    hres = get_funcdesc(proxy->tinfo, num, &tinfo2, &fdesc, NULL, NULL, NULL);
+    if (hres) {
+        ERR("GetFuncDesc %x should not fail here.\n",hres);
+        return hres;
+    }
+    ITypeInfo_Release(tinfo2);
+    /* 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);
+
+#ifdef __i386__
+    if (fdesc->callconv != CC_STDCALL) {
+        ERR("calling convention is not stdcall????\n");
+        return E_FAIL;
+    }
+/* popl %eax	-	return ptr
+ * pushl <nr>
+ * pushl %eax
+ * call xCall
+ * lret <nr> (+4)
+ *
+ *
+ * arg3 arg2 arg1 <method> <returnptr>
+ */
+    xasm->popleax       = 0x58;
+    xasm->pushlval      = 0x6a;
+    xasm->nr            = num;
+    xasm->pushleax      = 0x50;
+    xasm->lcall         = 0xe8; /* relative jump */
+    xasm->xcall         = (DWORD)xCall;
+    xasm->xcall        -= (DWORD)&(xasm->lret);
+    xasm->lret          = 0xc2;
+    xasm->bytestopop    = (nrofargs+2)*4; /* pop args, This, iMethod */
+    proxy->lpvtbl[num]  = xasm;
+#else
+    FIXME("not implemented on non i386\n");
+    return E_FAIL;
+#endif
+    return S_OK;
+}
+
 static HRESULT WINAPI
 PSFacBuf_CreateProxy(
     LPPSFACTORYBUFFER iface, IUnknown* pUnkOuter, REFIID riid,
@@ -1648,7 +1700,6 @@ PSFacBuf_CreateProxy(
     HRESULT	hres;
     ITypeInfo	*tinfo;
     int		i, nroffuncs;
-    const FUNCDESC *fdesc;
     TMProxyImpl	*proxy;
     TYPEATTR	*typeattr;
 
@@ -1685,8 +1736,6 @@ PSFacBuf_CreateProxy(
 
     proxy->lpvtbl = HeapAlloc(GetProcessHeap(),0,sizeof(LPBYTE)*nroffuncs);
     for (i=0;i<nroffuncs;i++) {
-	TMAsmProxy	*xasm = proxy->asmstubs+i;
-
 	switch (i) {
 	case 0:
 		proxy->lpvtbl[i] = ProxyIUnknown_QueryInterface;
@@ -1697,52 +1746,9 @@ PSFacBuf_CreateProxy(
 	case 2:
 		proxy->lpvtbl[i] = ProxyIUnknown_Release;
 		break;
-	default: {
-		int j;
-		/* nrofargs without This */
-		int nrofargs;
-                ITypeInfo *tinfo2;
-		hres = get_funcdesc(tinfo,i,&tinfo2,&fdesc,NULL,NULL,NULL);
-		if (hres) {
-		    ERR("GetFuncDesc %x should not fail here.\n",hres);
-		    return hres;
-		}
-                ITypeInfo_Release(tinfo2);
-		/* 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);
-
-#ifdef __i386__
-		if (fdesc->callconv != CC_STDCALL) {
-		    ERR("calling convention is not stdcall????\n");
-		    return E_FAIL;
-		}
-/* popl %eax	-	return ptr
- * pushl <nr>
- * pushl %eax
- * call xCall
- * lret <nr> (+4)
- *
- *
- * arg3 arg2 arg1 <method> <returnptr>
- */
-		xasm->popleax	= 0x58;
-		xasm->pushlval	= 0x6a;
-		xasm->nr	= i;
-		xasm->pushleax	= 0x50;
-		xasm->lcall	= 0xe8;	/* relative jump */
-		xasm->xcall	= (DWORD)xCall;
-		xasm->xcall     -= (DWORD)&(xasm->lret);
-		xasm->lret	= 0xc2;
-		xasm->bytestopop= (nrofargs+2)*4; /* pop args, This, iMethod */
-		proxy->lpvtbl[i] = xasm;
-		break;
-#else
-                FIXME("not implemented on non i386\n");
-                return E_FAIL;
-#endif
-	    }
+	default:
+                hres = init_proxy_entry_point(proxy, i);
+                if(FAILED(hres)) return hres;
 	}
     }
 




More information about the wine-cvs mailing list