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

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


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

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

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

---

 dlls/dinput/dinput_main.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index 06971db..c672077 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -794,24 +794,29 @@ static const IDirectInput8WVtbl ddi8wvt = {
 typedef struct
 {
     /* IUnknown fields */
-    const IClassFactoryVtbl    *lpVtbl;
-    LONG                        ref;
+    IClassFactory IClassFactory_iface;
+    LONG          ref;
 } 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));
 }
@@ -819,7 +824,7 @@ static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
 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);
         if ( IsEqualGUID( &IID_IUnknown, riid ) ||
@@ -840,7 +845,7 @@ static HRESULT WINAPI DICF_CreateInstance(
 }
 
 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;
 }
@@ -852,7 +857,7 @@ static const IClassFactoryVtbl DICF_Vtbl = {
 	DICF_CreateInstance,
 	DICF_LockServer
 };
-static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
+static IClassFactoryImpl DINPUT_CF = {{&DICF_Vtbl}, 1 };
 
 /***********************************************************************
  *		DllCanUnloadNow (DINPUT.@)




More information about the wine-cvs mailing list