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

Alexandre Julliard julliard at winehq.org
Mon Dec 6 13:18:32 CST 2010


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

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

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

---

 dlls/dinput8/dinput8_main.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/dlls/dinput8/dinput8_main.c b/dlls/dinput8/dinput8_main.c
index 9d426fb..a5efc54 100644
--- a/dlls/dinput8/dinput8_main.c
+++ b/dlls/dinput8/dinput8_main.c
@@ -94,11 +94,16 @@ HRESULT WINAPI DECLSPEC_HOTPATCH DirectInput8Create(HINSTANCE hinst, DWORD dwVer
 typedef struct
 {
     /* IUnknown fields */
-    const IClassFactoryVtbl    *lpVtbl;
+    IClassFactory IClassFactory_iface;
 } IClassFactoryImpl;
 
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+    return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
 static HRESULT WINAPI DI8CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
-    IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
     FIXME("%p %s %p\n",This,debugstr_guid(riid),ppobj);
     return E_NOINTERFACE;
 }
@@ -114,7 +119,7 @@ static ULONG WINAPI DI8CF_Release(LPCLASSFACTORY iface) {
 }
 
 static HRESULT WINAPI DI8CF_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_IDirectInput8A, riid ) || IsEqualGUID( &IID_IDirectInput8W, riid ) || IsEqualGUID( &IID_IUnknown, riid )) {
@@ -143,7 +148,7 @@ static const IClassFactoryVtbl DI8CF_Vtbl = {
     DI8CF_CreateInstance,
     DI8CF_LockServer
 };
-static IClassFactoryImpl DINPUT8_CF = { &DI8CF_Vtbl };
+static IClassFactoryImpl DINPUT8_CF = { { &DI8CF_Vtbl } };
 
 
 /***********************************************************************




More information about the wine-cvs mailing list