DCOM: Function Naming Cleanup

Robert Shearman rob at codeweavers.com
Sat Jul 31 10:38:51 CDT 2004


Hi,

Now that the dust is starting to settle, I thought I'd submit this patch 
to do a few cleanups. The first change is to add "static" to those 
functions not exported from marshal.c, which then allowed us to see 
which functions were not used and hence could be removed. The second 
change is to improve the naming of several functions in rpc.c to better 
reflect what they do.
_xread -> read_pipe
_xwrite -> write_pipe
_read_one -> COM_RpcReceive
_invoke_onereq -> COM_InvokeAndRpcSend

COM_RpcReceive was chosen to reflect the fact that this is kind of the 
COM implementation of I_RpcReceive.

Rob

Changelog:

Robert Shearman <rob at codeweavers.com>
- Add static to non-exported marshal functions.
- Remove unused marshal functions.
- Rename several RPC functions.

-------------- next part --------------
diff -u -N -r -x '*~' -x '.#*' -x CVS -x Makefile -x '*.o' -x '*.orig' -x '*.diff' -x '*.rej' -x '*.spec.c' wine/dlls/ole32_old2/marshal.c wine/dlls/ole32/marshal.c
--- wine/dlls/ole32_old2/marshal.c	2004-07-30 14:42:58.264415968 +0100
+++ wine/dlls/ole32/marshal.c	2004-07-30 14:58:32.171440520 +0100
@@ -107,22 +107,6 @@
 }
 
 HRESULT
-MARSHAL_Find_Stub_Server(wine_marshal_id *mid,LPUNKNOWN *punk) {
-    int i;
-
-    for (i=0;i<nrofstubs;i++) {
-       if (!stubs[i].valid) continue;
-
-	if (MARSHAL_Compare_Mids_NoInterface(mid,&(stubs[i].mid))) {
-	    *punk = stubs[i].pUnkServer;
-	    IUnknown_AddRef((*punk));
-	    return S_OK;
-	}
-    }
-    return E_FAIL;
-}
-
-HRESULT
 MARSHAL_Find_Stub_Buffer(wine_marshal_id *mid,IRpcStubBuffer **stub) {
     int i;
 
@@ -138,7 +122,7 @@
     return E_FAIL;
 }
 
-HRESULT
+static HRESULT
 MARSHAL_Find_Stub(wine_marshal_id *mid,LPUNKNOWN *pUnk) {
     int i;
 
@@ -154,7 +138,7 @@
     return E_FAIL;
 }
 
-HRESULT
+static HRESULT
 MARSHAL_Register_Stub(wine_marshal_id *mid,LPUNKNOWN pUnk,IRpcStubBuffer *stub) {
     LPUNKNOWN	xPunk;
     if (!MARSHAL_Find_Stub(mid,&xPunk)) {
@@ -175,19 +159,6 @@
 }
 
 HRESULT
-MARSHAL_Find_Proxy(wine_marshal_id *mid,LPUNKNOWN *punk) {
-    int i;
-
-    for (i=0;i<nrofproxies;i++)
-	if (MARSHAL_Compare_Mids(mid,&(proxies[i].mid))) {
-	    *punk = proxies[i].pUnk;
-	    IUnknown_AddRef((*punk));
-	    return S_OK;
-	}
-    return E_FAIL;
-}
-
-HRESULT
 MARSHAL_Disconnect_Proxies() {
     int i;
 
@@ -199,20 +170,7 @@
     return S_OK;
 }
 
-HRESULT
-MARSHAL_Find_Proxy_Object(wine_marshal_id *mid,LPUNKNOWN *punk) {
-    int i;
-
-    for (i=0;i<nrofproxies;i++)
-	if (MARSHAL_Compare_Mids_NoInterface(mid,&(proxies[i].mid))) {
-	    *punk = proxies[i].pUnk;
-	    IUnknown_AddRef((*punk));
-	    return S_OK;
-	}
-    return E_FAIL;
-}
-
-HRESULT
+static HRESULT
 MARSHAL_Register_Proxy(wine_marshal_id *mid,LPUNKNOWN punk) {
     int i;
 
@@ -244,7 +202,7 @@
   DWORD			mshlflags;
 } StdMarshalImpl;
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) {
   *ppv = NULL;
   if (IsEqualIID(&IID_IUnknown,riid) || IsEqualIID(&IID_IMarshal,riid)) {
@@ -256,14 +214,14 @@
   return E_NOINTERFACE;
 }
 
-ULONG WINAPI
+static ULONG WINAPI
 StdMarshalImpl_AddRef(LPMARSHAL iface) {
   ICOM_THIS(StdMarshalImpl,iface);
   This->ref++;
   return This->ref;
 }
 
-ULONG WINAPI
+static ULONG WINAPI
 StdMarshalImpl_Release(LPMARSHAL iface) {
   ICOM_THIS(StdMarshalImpl,iface);
   This->ref--;
@@ -274,7 +232,7 @@
   return 0;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_GetUnmarshalClass(
   LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
   void* pvDestContext, DWORD mshlflags, CLSID* pCid
@@ -283,7 +241,7 @@
   return S_OK;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_GetMarshalSizeMax(
   LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
   void* pvDestContext, DWORD mshlflags, DWORD* pSize
@@ -292,7 +250,7 @@
   return S_OK;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_MarshalInterface(
   LPMARSHAL iface, IStream *pStm,REFIID riid, void* pv, DWORD dwDestContext,
   void* pvDestContext, DWORD mshlflags
@@ -339,7 +297,7 @@
   return S_OK;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_UnmarshalInterface(
   LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv
 ) {
@@ -392,7 +350,7 @@
   return hres;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm) {
   wine_marshal_id       mid;
   ULONG                 res;
@@ -427,7 +385,7 @@
   return S_OK;
 }
 
-HRESULT WINAPI
+static HRESULT WINAPI
 StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved) {
   FIXME("(), stub!\n");
   return S_OK;
diff -u -N -r -x '*~' -x '.#*' -x CVS -x Makefile -x '*.o' -x '*.orig' -x '*.diff' -x '*.rej' -x '*.spec.c' wine/dlls/ole32_old2/rpc.c wine/dlls/ole32/rpc.c
--- wine/dlls/ole32_old2/rpc.c	2004-07-30 14:42:58.351402744 +0100
+++ wine/dlls/ole32/rpc.c	2004-07-30 14:54:08.840472912 +0100
@@ -117,7 +117,7 @@
 } PipeBuf;
 
 static HRESULT WINAPI
-_xread(HANDLE hf, LPVOID ptr, DWORD size) {
+read_pipe(HANDLE hf, LPVOID ptr, DWORD size) {
     DWORD res;
     if (!ReadFile(hf,ptr,size,&res,NULL)) {
 	FIXME("Failed to read from %p, le is %lx\n",hf,GetLastError());
@@ -157,7 +157,7 @@
 }
 
 static HRESULT WINAPI
-_xwrite(HANDLE hf, LPVOID ptr, DWORD size) {
+write_pipe(HANDLE hf, LPVOID ptr, DWORD size) {
     DWORD res;
     if (!WriteFile(hf,ptr,size,&res,NULL)) {
 	FIXME("Failed to write to %p, le is %lx\n",hf,GetLastError());
@@ -307,8 +307,8 @@
 
     pipe = PIPE_FindByMID(&This->mid);
 
-    _xwrite(pipe, &reqtype, sizeof(reqtype));
-    _xwrite(pipe, &header, sizeof(wine_rpc_disconnect_header));
+    write_pipe(pipe, &reqtype, sizeof(reqtype));
+    write_pipe(pipe, &header, sizeof(wine_rpc_disconnect_header));
 
     TRACE("written disconnect packet\n");
 
@@ -330,7 +330,7 @@
 }
 
 static HRESULT
-_invoke_onereq(wine_rpc_request *req) {
+COM_InvokeAndRpcSend(wine_rpc_request *req) {
     IRpcStubBuffer	*stub;
     RPCOLEMESSAGE	msg;
     HRESULT		hres;
@@ -351,18 +351,18 @@
     req->Buffer		= msg.Buffer;
     req->resph.cbBuffer	= msg.cbBuffer;
     reqtype 		= REQTYPE_RESPONSE;
-    hres = _xwrite(req->hPipe,&reqtype,sizeof(reqtype));
+    hres = write_pipe(req->hPipe,&reqtype,sizeof(reqtype));
     if (hres) return hres;
-    hres = _xwrite(req->hPipe,&(req->resph),sizeof(req->resph));
+    hres = write_pipe(req->hPipe,&(req->resph),sizeof(req->resph));
     if (hres) return hres;
-    hres = _xwrite(req->hPipe,req->Buffer,req->resph.cbBuffer);
+    hres = write_pipe(req->hPipe,req->Buffer,req->resph.cbBuffer);
     if (hres) return hres;
     req->state = REQSTATE_DONE;
     drs("invoke");
     return S_OK;
 }
 
-static HRESULT _read_one(wine_pipe *xpipe);
+static HRESULT COM_RpcReceive(wine_pipe *xpipe);
 
 static HRESULT
 RPC_QueueRequestAndWait(wine_rpc_request *req) {
@@ -383,23 +383,23 @@
     req->hPipe = xpipe->hPipe;
     req->state = REQSTATE_REQ_WAITING_FOR_REPLY;
     reqtype = REQTYPE_REQUEST;
-    hres = _xwrite(req->hPipe,&reqtype,sizeof(reqtype));
+    hres = write_pipe(req->hPipe,&reqtype,sizeof(reqtype));
     if (hres) return hres;
-    hres = _xwrite(req->hPipe,&(req->reqh),sizeof(req->reqh));
+    hres = write_pipe(req->hPipe,&(req->reqh),sizeof(req->reqh));
     if (hres) return hres;
-    hres = _xwrite(req->hPipe,req->Buffer,req->reqh.cbBuffer);
+    hres = write_pipe(req->hPipe,req->Buffer,req->reqh.cbBuffer);
     if (hres) return hres;
 
     /* This loop is about allowing re-entrancy. While waiting for the
      * response to one RPC we may receive a request starting another. */
     while (!hres) {
-	hres = _read_one(xpipe);
+	hres = COM_RpcReceive(xpipe);
 	if (hres) break;
 
 	for (i=0;i<nrofreqs;i++) {
 	    xreq = reqs[i];
 	    if ((xreq->state==REQSTATE_REQ_GOT) && (xreq->hPipe==req->hPipe)) {
-		hres = _invoke_onereq(xreq);
+		hres = COM_InvokeAndRpcSend(xreq);
 		if (hres) break;
 	    }
 	}
@@ -637,7 +637,7 @@
     wine_marshal_id	remoteid;
     HRESULT		hres;
 
-    hres = _xread(xhPipe,&remoteid,sizeof(remoteid));
+    hres = read_pipe(xhPipe,&remoteid,sizeof(remoteid));
     if (hres) {
 	ERR("Failed to read remote mid!\n");
 	return;
@@ -646,13 +646,13 @@
 }
 
 static HRESULT
-_read_one(wine_pipe *xpipe) {
+COM_RpcReceive(wine_pipe *xpipe) {
     DWORD	reqtype;
     HRESULT	hres = S_OK;
     HANDLE	xhPipe = xpipe->hPipe;
 
     /*FIXME("%lx %d reading reqtype\n",GetCurrentProcessId(),xhPipe);*/
-    hres = _xread(xhPipe,&reqtype,sizeof(reqtype));
+    hres = read_pipe(xhPipe,&reqtype,sizeof(reqtype));
     if (hres) goto end;
     EnterCriticalSection(&(xpipe->crit));
     /*FIXME("%lx got reqtype %ld\n",GetCurrentProcessId(),reqtype);*/
@@ -662,7 +662,7 @@
         IRpcStubBuffer *stub;
         ULONG ret;
 
-        hres = _xread(xhPipe, &header, sizeof(header));
+        hres = read_pipe(xhPipe, &header, sizeof(header));
         if (hres) {
             ERR("could not read disconnect header\n");
             goto end;
@@ -689,11 +689,11 @@
 	wine_rpc_request	*xreq;
 	RPC_GetRequest(&xreq);
 	xreq->hPipe = xhPipe;
-	hres = _xread(xhPipe,&(xreq->reqh),sizeof(xreq->reqh));
+	hres = read_pipe(xhPipe,&(xreq->reqh),sizeof(xreq->reqh));
 	if (hres) goto end;
 	xreq->resph.reqid = xreq->reqh.reqid;
 	xreq->Buffer = HeapAlloc(GetProcessHeap(),0, xreq->reqh.cbBuffer);
-	hres = _xread(xhPipe,xreq->Buffer,xreq->reqh.cbBuffer);
+	hres = read_pipe(xhPipe,xreq->Buffer,xreq->reqh.cbBuffer);
 	if (hres) goto end;
 	xreq->state = REQSTATE_REQ_GOT;
 	goto end;
@@ -701,7 +701,7 @@
 	wine_rpc_response_header	resph;
 	int i;
 
-	hres = _xread(xhPipe,&resph,sizeof(resph));
+	hres = read_pipe(xhPipe,&resph,sizeof(resph));
 	if (hres) goto end;
 	for (i=nrofreqs;i--;) {
 	    wine_rpc_request *xreq = reqs[i];
@@ -715,7 +715,7 @@
 		else
 		    xreq->Buffer = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,xreq->resph.cbBuffer);
 
-		hres = _xread(xhPipe,xreq->Buffer,xreq->resph.cbBuffer);
+		hres = read_pipe(xhPipe,xreq->Buffer,xreq->resph.cbBuffer);
 		if (hres) goto end;
 		xreq->state = REQSTATE_RESP_GOT;
 		/*PulseEvent(hRpcChanged);*/
@@ -742,13 +742,13 @@
     TRACE("STUB reader thread %lx\n",GetCurrentProcessId());
     while (!hres) {
 	int i;
-	hres = _read_one(xpipe);
+	hres = COM_RpcReceive(xpipe);
 	if (hres) break;
 
 	for (i=nrofreqs;i--;) {
 	    wine_rpc_request *xreq = reqs[i];
 	    if ((xreq->state == REQSTATE_REQ_GOT) && (xreq->hPipe == xhPipe)) {
-		hres = _invoke_onereq(xreq);
+		hres = COM_InvokeAndRpcSend(xreq);
 		if (!hres) break;
 	    }
 	}


More information about the wine-patches mailing list