Michael Stefaniuc : dpnet: Use an iface instead of a vtbl pointer in IClassFactoryImpl.

Alexandre Julliard julliard at winehq.org
Sun Dec 5 12:10:09 CST 2010


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Sun Dec  5 15:15:50 2010 +0100

dpnet: Use an iface instead of a vtbl pointer in IClassFactoryImpl.

---

 dlls/dpnet/dpnet_main.c |   43 ++++++++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/dlls/dpnet/dpnet_main.c b/dlls/dpnet/dpnet_main.c
index 34429ac..b08d9d3 100644
--- a/dlls/dpnet/dpnet_main.c
+++ b/dlls/dpnet/dpnet_main.c
@@ -64,39 +64,44 @@ HRESULT WINAPI DirectPlay8Create(REFGUID lpGUID, LPVOID *ppvInt, LPUNKNOWN punkO
 typedef struct
 {
   /* IUnknown fields */
-  const IClassFactoryVtbl *lpVtbl;
-  LONG       ref; 
-  REFCLSID   rclsid;
-  HRESULT   (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
+  IClassFactory IClassFactory_iface;
+  LONG          ref;
+  REFCLSID      rclsid;
+  HRESULT       (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
 } IClassFactoryImpl;
 
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
 static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
-  IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
-  
+  IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
   FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
   return E_NOINTERFACE;
 }
 
 static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
-  IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+  IClassFactoryImpl *This = impl_from_IClassFactory(iface);
   return InterlockedIncrement(&This->ref);
 }
 
 static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
-  IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+  IClassFactoryImpl *This = impl_from_IClassFactory(iface);
   /* static class, won't be  freed */
   return InterlockedDecrement(&This->ref);
 }
 
 static HRESULT WINAPI DICF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
-  IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
-  
+  IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
   TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
   return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj);
 }
 
 static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
-  IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+  IClassFactoryImpl *This = impl_from_IClassFactory(iface);
   FIXME("(%p)->(%d),stub!\n",This,dolock);
   return S_OK;
 }
@@ -110,13 +115,13 @@ static const IClassFactoryVtbl DICF_Vtbl = {
 };
 
 static IClassFactoryImpl DPNET_CFS[] = {
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8Client,  DPNET_CreateDirectPlay8Client },
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8Server,  DPNET_CreateDirectPlay8Server },
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8Peer,    DPNET_CreateDirectPlay8Peer },
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8Address, DPNET_CreateDirectPlay8Address },
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8LobbiedApplication, DPNET_CreateDirectPlay8LobbiedApp },
-  { &DICF_Vtbl, 1, &CLSID_DirectPlay8ThreadPool, DPNET_CreateDirectPlay8ThreadPool},
-  { NULL, 0, NULL, NULL }
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Client,  DPNET_CreateDirectPlay8Client },
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Server,  DPNET_CreateDirectPlay8Server },
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Peer,    DPNET_CreateDirectPlay8Peer },
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8Address, DPNET_CreateDirectPlay8Address },
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8LobbiedApplication, DPNET_CreateDirectPlay8LobbiedApp },
+  { { &DICF_Vtbl }, 1, &CLSID_DirectPlay8ThreadPool, DPNET_CreateDirectPlay8ThreadPool},
+  { { NULL }, 0, NULL, NULL }
 };
 
 /***********************************************************************
@@ -144,7 +149,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
     */
     while (NULL != DPNET_CFS[i].rclsid) {
       if (IsEqualGUID(rclsid, DPNET_CFS[i].rclsid)) {
-	DICF_AddRef((IClassFactory*) &DPNET_CFS[i]);
+        DICF_AddRef(&DPNET_CFS[i].IClassFactory_iface);
 	*ppv = &DPNET_CFS[i];
 	return S_OK;
       }




More information about the wine-cvs mailing list