Commit 67fe27d0 authored by Alexandre Julliard's avatar Alexandre Julliard

comcat: Get rid of the redundant IUnknown vtable for the manager implementation.

parent f8ff1bd6
...@@ -9,7 +9,6 @@ C_SRCS = \ ...@@ -9,7 +9,6 @@ C_SRCS = \
comcat_main.c \ comcat_main.c \
factory.c \ factory.c \
information.c \ information.c \
manager.c \
register.c register.c
RC_SRCS = \ RC_SRCS = \
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "comcat.h" #include "comcat.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
/********************************************************************** /**********************************************************************
* Dll lifetime tracking declaration for comcat.dll * Dll lifetime tracking declaration for comcat.dll
...@@ -46,15 +45,11 @@ extern HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv); ...@@ -46,15 +45,11 @@ extern HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv);
*/ */
typedef struct typedef struct
{ {
/* IUnknown fields */ const ICatRegisterVtbl *lpVtbl;
const IUnknownVtbl *unkVtbl;
const ICatRegisterVtbl *regVtbl;
const ICatInformationVtbl *infVtbl; const ICatInformationVtbl *infVtbl;
LONG ref;
} ComCatMgrImpl; } ComCatMgrImpl;
extern ComCatMgrImpl COMCAT_ComCatMgr; extern ComCatMgrImpl COMCAT_ComCatMgr;
extern const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl;
extern const ICatInformationVtbl COMCAT_ICatInformation_Vtbl; extern const ICatInformationVtbl COMCAT_ICatInformation_Vtbl;
/********************************************************************** /**********************************************************************
......
...@@ -43,6 +43,12 @@ static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct( ...@@ -43,6 +43,12 @@ static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct(
static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct( static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct(
REFCLSID rclsid, LPCWSTR impl_req); REFCLSID rclsid, LPCWSTR impl_req);
static inline ComCatMgrImpl *impl_from_ICatInformation( ICatInformation *iface )
{
return (ComCatMgrImpl *)((char*)iface - FIELD_OFFSET(ComCatMgrImpl, infVtbl));
}
/********************************************************************** /**********************************************************************
* COMCAT_ICatInformation_QueryInterface * COMCAT_ICatInformation_QueryInterface
*/ */
...@@ -51,12 +57,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface( ...@@ -51,12 +57,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
REFIID riid, REFIID riid,
LPVOID *ppvObj) LPVOID *ppvObj)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); ComCatMgrImpl *This = impl_from_ICatInformation( iface );
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); return IUnknown_QueryInterface((LPUNKNOWN)This, riid, ppvObj);
if (ppvObj == NULL) return E_POINTER;
return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj);
} }
/********************************************************************** /**********************************************************************
...@@ -64,10 +66,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface( ...@@ -64,10 +66,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
*/ */
static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface) static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); ComCatMgrImpl *This = impl_from_ICatInformation( iface );
TRACE("\n"); return IUnknown_AddRef((LPUNKNOWN)This);
return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl);
} }
/********************************************************************** /**********************************************************************
...@@ -75,10 +75,8 @@ static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface) ...@@ -75,10 +75,8 @@ static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
*/ */
static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface) static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); ComCatMgrImpl *This = impl_from_ICatInformation( iface );
TRACE("\n"); return IUnknown_Release((LPUNKNOWN)This);
return IUnknown_Release((LPUNKNOWN)&This->unkVtbl);
} }
/********************************************************************** /**********************************************************************
...@@ -89,7 +87,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories( ...@@ -89,7 +87,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories(
LCID lcid, LCID lcid,
LPENUMCATEGORYINFO *ppenumCatInfo) LPENUMCATEGORYINFO *ppenumCatInfo)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
TRACE("\n"); TRACE("\n");
if (ppenumCatInfo == NULL) return E_POINTER; if (ppenumCatInfo == NULL) return E_POINTER;
...@@ -109,7 +106,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc( ...@@ -109,7 +106,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc(
LCID lcid, LCID lcid,
PWCHAR *ppszDesc) PWCHAR *ppszDesc)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
't', ' ', 'C', 'a', 't', 'e', 'g', 'o', 't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', '\\', 0 }; 'r', 'i', 'e', 's', '\\', 0 };
...@@ -154,7 +150,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories( ...@@ -154,7 +150,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories(
CATID *rgcatidReq, CATID *rgcatidReq,
LPENUMCLSID *ppenumCLSID) LPENUMCLSID *ppenumCLSID)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
struct class_categories *categories; struct class_categories *categories;
TRACE("\n"); TRACE("\n");
...@@ -191,7 +186,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories( ...@@ -191,7 +186,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
ULONG cRequired, ULONG cRequired,
CATID *rgcatidReq) CATID *rgcatidReq)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 }; WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 };
HRESULT res; HRESULT res;
struct class_categories *categories; struct class_categories *categories;
...@@ -236,7 +230,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass( ...@@ -236,7 +230,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
REFCLSID rclsid, REFCLSID rclsid,
LPENUMCATID *ppenumCATID) LPENUMCATID *ppenumCATID)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e', static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e',
'n', 't', 'e', 'd', ' ', 'C', 'a', 't', 'n', 't', 'e', 'd', ' ', 'C', 'a', 't',
'e', 'g', 'o', 'r', 'i', 'e', 's', 0 }; 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 };
...@@ -259,7 +252,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass( ...@@ -259,7 +252,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
REFCLSID rclsid, REFCLSID rclsid,
LPENUMCATID *ppenumCATID) LPENUMCATID *ppenumCATID)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e', static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e',
'd', ' ', 'C', 'a', 't', 'e', 'g', 'o', 'd', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 }; 'r', 'i', 'e', 's', 0 };
......
/*
* ComCatMgr IUnknown implementation for comcat.dll
*
* Copyright (C) 2002 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "comcat_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface);
/**********************************************************************
* COMCAT_IUnknown_QueryInterface
*/
static HRESULT WINAPI COMCAT_IUnknown_QueryInterface(
LPUNKNOWN iface,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown)) {
*ppvObj = &This->unkVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatRegister)) {
*ppvObj = &This->regVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatInformation)) {
*ppvObj = &This->infVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
return E_NOINTERFACE;
}
/**********************************************************************
* COMCAT_IUnknown_AddRef
*/
static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
ULONG ref;
TRACE("\n");
ref = InterlockedIncrement(&This->ref);
if (ref == 1) {
InterlockedIncrement(&dll_ref);
}
return ref;
}
/**********************************************************************
* COMCAT_IUnknown_Release
*/
static ULONG WINAPI COMCAT_IUnknown_Release(LPUNKNOWN iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
ULONG ref;
TRACE("\n");
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
InterlockedDecrement(&dll_ref);
}
return ref;
}
/**********************************************************************
* COMCAT_IUnknown_Vtbl
*/
static const IUnknownVtbl COMCAT_IUnknown_Vtbl =
{
COMCAT_IUnknown_QueryInterface,
COMCAT_IUnknown_AddRef,
COMCAT_IUnknown_Release
};
/**********************************************************************
* static ComCatMgr instance
*/
ComCatMgrImpl COMCAT_ComCatMgr =
{
&COMCAT_IUnknown_Vtbl,
&COMCAT_ICatRegister_Vtbl,
&COMCAT_ICatInformation_Vtbl,
0
};
...@@ -54,12 +54,24 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface( ...@@ -54,12 +54,24 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
REFIID riid, REFIID riid,
LPVOID *ppvObj) LPVOID *ppvObj)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); ComCatMgrImpl *This = (ComCatMgrImpl *)iface;
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid)); TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER; if (ppvObj == NULL) return E_POINTER;
return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj); if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ICatRegister)) {
*ppvObj = iface;
IUnknown_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatInformation)) {
*ppvObj = &This->infVtbl;
IUnknown_AddRef(iface);
return S_OK;
}
return E_NOINTERFACE;
} }
/********************************************************************** /**********************************************************************
...@@ -67,10 +79,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface( ...@@ -67,10 +79,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
*/ */
static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface) static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); return 2; /* non-heap based object */
TRACE("\n");
return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl);
} }
/********************************************************************** /**********************************************************************
...@@ -78,10 +87,7 @@ static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface) ...@@ -78,10 +87,7 @@ static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
*/ */
static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface) static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface)
{ {
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); return 1; /* non-heap based object */
TRACE("\n");
return IUnknown_Release((LPUNKNOWN)&This->unkVtbl);
} }
/********************************************************************** /**********************************************************************
...@@ -92,7 +98,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories( ...@@ -92,7 +98,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
ULONG cCategories, ULONG cCategories,
CATEGORYINFO *rgci) CATEGORYINFO *rgci)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
HKEY comcat_key; HKEY comcat_key;
HRESULT res; HRESULT res;
...@@ -139,7 +144,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories( ...@@ -139,7 +144,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
ULONG cCategories, ULONG cCategories,
CATID *rgcatid) CATID *rgcatid)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
HKEY comcat_key; HKEY comcat_key;
HRESULT res; HRESULT res;
...@@ -174,7 +178,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories( ...@@ -174,7 +178,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories(
ULONG cCategories, ULONG cCategories,
CATID *rgcatid) CATID *rgcatid)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n"); TRACE("\n");
return COMCAT_RegisterClassCategories( return COMCAT_RegisterClassCategories(
...@@ -190,7 +193,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories( ...@@ -190,7 +193,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories(
ULONG cCategories, ULONG cCategories,
CATID *rgcatid) CATID *rgcatid)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n"); TRACE("\n");
return COMCAT_UnRegisterClassCategories( return COMCAT_UnRegisterClassCategories(
...@@ -206,7 +208,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories( ...@@ -206,7 +208,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories(
ULONG cCategories, ULONG cCategories,
CATID *rgcatid) CATID *rgcatid)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n"); TRACE("\n");
return COMCAT_RegisterClassCategories( return COMCAT_RegisterClassCategories(
...@@ -222,7 +223,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories( ...@@ -222,7 +223,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
ULONG cCategories, ULONG cCategories,
CATID *rgcatid) CATID *rgcatid)
{ {
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n"); TRACE("\n");
return COMCAT_UnRegisterClassCategories( return COMCAT_UnRegisterClassCategories(
...@@ -232,7 +232,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories( ...@@ -232,7 +232,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
/********************************************************************** /**********************************************************************
* COMCAT_ICatRegister_Vtbl * COMCAT_ICatRegister_Vtbl
*/ */
const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl = static const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
{ {
COMCAT_ICatRegister_QueryInterface, COMCAT_ICatRegister_QueryInterface,
COMCAT_ICatRegister_AddRef, COMCAT_ICatRegister_AddRef,
...@@ -245,6 +245,16 @@ const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl = ...@@ -245,6 +245,16 @@ const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
COMCAT_ICatRegister_UnRegisterClassReqCategories COMCAT_ICatRegister_UnRegisterClassReqCategories
}; };
/**********************************************************************
* static ComCatMgr instance
*/
ComCatMgrImpl COMCAT_ComCatMgr =
{
&COMCAT_ICatRegister_Vtbl,
&COMCAT_ICatInformation_Vtbl
};
/********************************************************************** /**********************************************************************
* COMCAT_RegisterClassCategories * COMCAT_RegisterClassCategories
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment