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

This commit is contained in:
Michael Stefaniuc 2010-12-05 15:15:50 +01:00 committed by Alexandre Julliard
parent 6d7d1b5850
commit dcef7c3bb5

View file

@ -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;
}