Module: wine Branch: master Commit: 80a08012d837c6e55bce93391887d39fb663620a URL: http://source.winehq.org/git/wine.git/?a=commit;h=80a08012d837c6e55bce933918...
Author: Michael Stefaniuc mstefani@redhat.de Date: Tue Dec 21 11:30:58 2010 +0100
oleaut32: Standardize the COM usage in tmarshal.c.
---
dlls/oleaut32/tmarshal.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index 440319f..45aacf2 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -390,7 +390,7 @@ typedef struct _TMAsmProxy {
typedef struct _TMProxyImpl { LPVOID *lpvtbl; - const IRpcProxyBufferVtbl *lpvtbl2; + IRpcProxyBuffer IRpcProxyBuffer_iface; LONG ref;
TMAsmProxy *asmstubs; @@ -405,7 +405,7 @@ typedef struct _TMProxyImpl {
static inline TMProxyImpl *impl_from_IRpcProxyBuffer( IRpcProxyBuffer *iface ) { - return (TMProxyImpl *)((char*)iface - FIELD_OFFSET(TMProxyImpl, lpvtbl2)); + return CONTAINING_RECORD(iface, TMProxyImpl, IRpcProxyBuffer_iface); }
static HRESULT WINAPI @@ -1743,7 +1743,7 @@ PSFacBuf_CreateProxy( CoTaskMemFree(proxy); return E_OUTOFMEMORY; } - proxy->lpvtbl2 = &tmproxyvtable; + proxy->IRpcProxyBuffer_iface.lpVtbl = &tmproxyvtable; /* one reference for the proxy */ proxy->ref = 1; proxy->tinfo = tinfo; @@ -1835,17 +1835,17 @@ PSFacBuf_CreateProxy( if (hres == S_OK) { *ppv = proxy; - *ppProxy = (IRpcProxyBuffer *)&(proxy->lpvtbl2); + *ppProxy = &proxy->IRpcProxyBuffer_iface; IUnknown_AddRef((IUnknown *)*ppv); return S_OK; } else - TMProxyImpl_Release((IRpcProxyBuffer *)&proxy->lpvtbl2); + TMProxyImpl_Release(&proxy->IRpcProxyBuffer_iface); return hres; }
typedef struct _TMStubImpl { - const IRpcStubBufferVtbl *lpvtbl; + IRpcStubBuffer IRpcStubBuffer_iface; LONG ref;
LPUNKNOWN pUnk; @@ -1855,6 +1855,11 @@ typedef struct _TMStubImpl { BOOL dispatch_derivative; } TMStubImpl;
+static inline TMStubImpl *impl_from_IRpcStubBuffer(IRpcStubBuffer *iface) +{ + return CONTAINING_RECORD(iface, TMStubImpl, IRpcStubBuffer_iface); +} + static HRESULT WINAPI TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) { @@ -1870,9 +1875,9 @@ TMStubImpl_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) static ULONG WINAPI TMStubImpl_AddRef(LPRPCSTUBBUFFER iface) { - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface); ULONG refCount = InterlockedIncrement(&This->ref); - + TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
return refCount; @@ -1881,7 +1886,7 @@ TMStubImpl_AddRef(LPRPCSTUBBUFFER iface) static ULONG WINAPI TMStubImpl_Release(LPRPCSTUBBUFFER iface) { - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1); @@ -1900,7 +1905,7 @@ TMStubImpl_Release(LPRPCSTUBBUFFER iface) static HRESULT WINAPI TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer) { - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface);
TRACE("(%p)->(%p)\n", This, pUnkServer);
@@ -1916,7 +1921,7 @@ TMStubImpl_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN pUnkServer) static void WINAPI TMStubImpl_Disconnect(LPRPCSTUBBUFFER iface) { - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface);
TRACE("(%p)->()\n", This);
@@ -1937,7 +1942,7 @@ TMStubImpl_Invoke( #ifdef __i386__ int i; const FUNCDESC *fdesc; - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface); HRESULT hres; DWORD *args = NULL, res, *xargs, nrofargs; marshal_state buf; @@ -2113,7 +2118,7 @@ TMStubImpl_IsIIDSupported(LPRPCSTUBBUFFER iface, REFIID riid) {
static ULONG WINAPI TMStubImpl_CountRefs(LPRPCSTUBBUFFER iface) { - TMStubImpl *This = (TMStubImpl *)iface; + TMStubImpl *This = impl_from_IRpcStubBuffer(iface);
FIXME("()\n"); return This->ref; /*FIXME? */ @@ -2163,14 +2168,14 @@ PSFacBuf_CreateStub( stub = CoTaskMemAlloc(sizeof(TMStubImpl)); if (!stub) return E_OUTOFMEMORY; - stub->lpvtbl = &tmstubvtbl; + stub->IRpcStubBuffer_iface.lpVtbl = &tmstubvtbl; stub->ref = 1; stub->tinfo = tinfo; stub->dispatch_stub = NULL; stub->dispatch_derivative = FALSE; stub->iid = *riid; - hres = IRpcStubBuffer_Connect((LPRPCSTUBBUFFER)stub,pUnkServer); - *ppStub = (LPRPCSTUBBUFFER)stub; + hres = IRpcStubBuffer_Connect(&stub->IRpcStubBuffer_iface,pUnkServer); + *ppStub = &stub->IRpcStubBuffer_iface; TRACE("IRpcStubBuffer: %p\n", stub); if (hres) ERR("Connect to pUnkServer failed?\n");