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

Alexandre Julliard julliard at winehq.org
Mon Oct 13 06:37:11 CDT 2008


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat Oct 11 13:11:49 2008 +0200

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

---

 dlls/comcat/comcat_main.c    |    2 +-
 dlls/comcat/comcat_private.h |   12 +---------
 dlls/comcat/factory.c        |   47 ++++++++++-------------------------------
 3 files changed, 14 insertions(+), 47 deletions(-)

diff --git a/dlls/comcat/comcat_main.c b/dlls/comcat/comcat_main.c
index 5af9935..b1f6da7 100644
--- a/dlls/comcat/comcat_main.c
+++ b/dlls/comcat/comcat_main.c
@@ -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;
diff --git a/dlls/comcat/comcat_private.h b/dlls/comcat/comcat_private.h
index 4002dfd..96a3b09 100644
--- a/dlls/comcat/comcat_private.h
+++ b/dlls/comcat/comcat_private.h
@@ -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
diff --git a/dlls/comcat/factory.c b/dlls/comcat/factory.c
index 22be165..c70a02b 100644
--- a/dlls/comcat/factory.c
+++ b/dlls/comcat/factory.c
@@ -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);
+}




More information about the wine-cvs mailing list