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

This commit is contained in:
Alexandre Julliard 2008-10-11 13:14:44 +02:00
parent f8ff1bd6fb
commit 67fe27d036
5 changed files with 40 additions and 160 deletions

View File

@ -9,7 +9,6 @@ C_SRCS = \
comcat_main.c \
factory.c \
information.c \
manager.c \
register.c
RC_SRCS = \

View File

@ -32,7 +32,6 @@
#include "comcat.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
@ -46,15 +45,11 @@ extern HRESULT ComCatCF_Create(REFIID riid, LPVOID *ppv);
*/
typedef struct
{
/* IUnknown fields */
const IUnknownVtbl *unkVtbl;
const ICatRegisterVtbl *regVtbl;
const ICatRegisterVtbl *lpVtbl;
const ICatInformationVtbl *infVtbl;
LONG ref;
} ComCatMgrImpl;
extern ComCatMgrImpl COMCAT_ComCatMgr;
extern const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl;
extern const ICatInformationVtbl COMCAT_ICatInformation_Vtbl;
/**********************************************************************

View File

@ -43,6 +43,12 @@ static LPENUMGUID COMCAT_CLSID_IEnumGUID_Construct(
static LPENUMGUID COMCAT_CATID_IEnumGUID_Construct(
REFCLSID rclsid, LPCWSTR impl_req);
static inline ComCatMgrImpl *impl_from_ICatInformation( ICatInformation *iface )
{
return (ComCatMgrImpl *)((char*)iface - FIELD_OFFSET(ComCatMgrImpl, infVtbl));
}
/**********************************************************************
* COMCAT_ICatInformation_QueryInterface
*/
@ -51,12 +57,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (ppvObj == NULL) return E_POINTER;
return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj);
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_QueryInterface((LPUNKNOWN)This, riid, ppvObj);
}
/**********************************************************************
@ -64,10 +66,8 @@ static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
*/
static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
TRACE("\n");
return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl);
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_AddRef((LPUNKNOWN)This);
}
/**********************************************************************
@ -75,10 +75,8 @@ static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
*/
static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
TRACE("\n");
return IUnknown_Release((LPUNKNOWN)&This->unkVtbl);
ComCatMgrImpl *This = impl_from_ICatInformation( iface );
return IUnknown_Release((LPUNKNOWN)This);
}
/**********************************************************************
@ -89,7 +87,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories(
LCID lcid,
LPENUMCATEGORYINFO *ppenumCatInfo)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
TRACE("\n");
if (ppenumCatInfo == NULL) return E_POINTER;
@ -109,7 +106,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc(
LCID lcid,
PWCHAR *ppszDesc)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', '\\', 0 };
@ -154,7 +150,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories(
CATID *rgcatidReq,
LPENUMCLSID *ppenumCLSID)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
struct class_categories *categories;
TRACE("\n");
@ -191,7 +186,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
ULONG cRequired,
CATID *rgcatidReq)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
WCHAR keyname[45] = { 'C', 'L', 'S', 'I', 'D', '\\', 0 };
HRESULT res;
struct class_categories *categories;
@ -236,7 +230,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
static const WCHAR postfix[24] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e',
'n', 't', 'e', 'd', ' ', 'C', 'a', 't',
'e', 'g', 'o', 'r', 'i', 'e', 's', 0 };
@ -259,7 +252,6 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
static const WCHAR postfix[21] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e',
'd', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 };

View File

@ -1,116 +0,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
};

View File

@ -54,12 +54,24 @@ static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
ComCatMgrImpl *This = (ComCatMgrImpl *)iface;
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
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(
*/
static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
TRACE("\n");
return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl);
return 2; /* non-heap based object */
}
/**********************************************************************
@ -78,10 +87,7 @@ static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
*/
static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
TRACE("\n");
return IUnknown_Release((LPUNKNOWN)&This->unkVtbl);
return 1; /* non-heap based object */
}
/**********************************************************************
@ -92,7 +98,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
ULONG cCategories,
CATEGORYINFO *rgci)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
HKEY comcat_key;
HRESULT res;
@ -139,7 +144,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
ULONG cCategories,
CATID *rgcatid)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
HKEY comcat_key;
HRESULT res;
@ -174,7 +178,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories(
ULONG cCategories,
CATID *rgcatid)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n");
return COMCAT_RegisterClassCategories(
@ -190,7 +193,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories(
ULONG cCategories,
CATID *rgcatid)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n");
return COMCAT_UnRegisterClassCategories(
@ -206,7 +208,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories(
ULONG cCategories,
CATID *rgcatid)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n");
return COMCAT_RegisterClassCategories(
@ -222,7 +223,6 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
ULONG cCategories,
CATID *rgcatid)
{
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
TRACE("\n");
return COMCAT_UnRegisterClassCategories(
@ -232,7 +232,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
/**********************************************************************
* COMCAT_ICatRegister_Vtbl
*/
const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
static const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
{
COMCAT_ICatRegister_QueryInterface,
COMCAT_ICatRegister_AddRef,
@ -245,6 +245,16 @@ const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
COMCAT_ICatRegister_UnRegisterClassReqCategories
};
/**********************************************************************
* static ComCatMgr instance
*/
ComCatMgrImpl COMCAT_ComCatMgr =
{
&COMCAT_ICatRegister_Vtbl,
&COMCAT_ICatInformation_Vtbl
};
/**********************************************************************
* COMCAT_RegisterClassCategories
*/