comcat: Simplify the class factory implementation and make it more similar to the other ones in ole32.

This commit is contained in:
Alexandre Julliard 2008-10-11 13:11:49 +02:00
parent d4f107f54b
commit f8ff1bd6fb
3 changed files with 14 additions and 47 deletions

View File

@ -38,7 +38,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
{
*ppv = NULL;
if (IsEqualGUID(rclsid, &CLSID_StdComponentCategoriesMgr)) {
return IClassFactory_QueryInterface((LPCLASSFACTORY)&COMCAT_ClassFactory, iid, ppv);
return ComCatCF_Create(iid, ppv);
}
FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
return CLASS_E_CLASSNOTAVAILABLE;

View File

@ -39,17 +39,7 @@
*/
extern LONG dll_ref;
/**********************************************************************
* ClassFactory declaration for comcat.dll
*/
typedef struct
{
/* IUnknown fields */
const IClassFactoryVtbl *lpVtbl;
LONG ref;
} ClassFactoryImpl;
extern ClassFactoryImpl COMCAT_ClassFactory;
extern HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv);
/**********************************************************************
* StdComponentCategoriesMgr declaration for comcat.dll

View File

@ -24,7 +24,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface);
/**********************************************************************
* COMCAT_IClassFactory_QueryInterface (also IUnknown)
@ -42,7 +41,7 @@ static HRESULT WINAPI COMCAT_IClassFactory_QueryInterface(
IsEqualGUID(riid, &IID_IClassFactory))
{
*ppvObj = (LPVOID)iface;
COMCAT_IClassFactory_AddRef(iface);
IUnknown_AddRef(iface);
return S_OK;
}
@ -54,16 +53,7 @@ static HRESULT WINAPI COMCAT_IClassFactory_QueryInterface(
*/
static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface)
{
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
ULONG ref;
TRACE("\n");
ref = InterlockedIncrement(&This->ref);
if (ref == 1) {
InterlockedIncrement(&dll_ref);
}
return ref;
return 2; /* non-heap based object */
}
/**********************************************************************
@ -71,16 +61,7 @@ static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface)
*/
static ULONG WINAPI COMCAT_IClassFactory_Release(LPCLASSFACTORY iface)
{
ClassFactoryImpl *This = (ClassFactoryImpl *)iface;
ULONG ref;
TRACE("\n");
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
InterlockedDecrement(&dll_ref);
}
return ref;
return 1; /* non-heap based object */
}
/**********************************************************************
@ -115,20 +96,14 @@ static HRESULT WINAPI COMCAT_IClassFactory_LockServer(
LPCLASSFACTORY iface,
BOOL fLock)
{
TRACE("\n");
if (fLock != FALSE) {
IClassFactory_AddRef(iface);
} else {
IClassFactory_Release(iface);
}
FIXME("(%d), stub!\n",fLock);
return S_OK;
}
/**********************************************************************
* IClassFactory_Vtbl
* static ClassFactory instance
*/
static const IClassFactoryVtbl IClassFactory_Vtbl =
static const IClassFactoryVtbl ComCatCFVtbl =
{
COMCAT_IClassFactory_QueryInterface,
COMCAT_IClassFactory_AddRef,
@ -137,7 +112,9 @@ static const IClassFactoryVtbl IClassFactory_Vtbl =
COMCAT_IClassFactory_LockServer
};
/**********************************************************************
* static ClassFactory instance
*/
ClassFactoryImpl COMCAT_ClassFactory = { &IClassFactory_Vtbl, 0 };
static const IClassFactoryVtbl *ComCatCF = &ComCatCFVtbl;
HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv)
{
return IClassFactory_QueryInterface((IClassFactory *)&ComCatCF, riid, ppv);
}