oleaut32: COM clean up of ITypeLib2 interface implementation.

This commit is contained in:
Jacek Caban 2013-02-12 14:36:36 +01:00 committed by Alexandre Julliard
parent 0800f29b25
commit 253fdf1574
1 changed files with 50 additions and 59 deletions

View File

@ -983,7 +983,7 @@ typedef struct tagTLBImpLib
/* internal ITypeLib data */
typedef struct tagITypeLibImpl
{
const ITypeLib2Vtbl *lpVtbl;
ITypeLib2 ITypeLib2_iface;
const ITypeCompVtbl *lpVtblTypeComp;
LONG ref;
TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */
@ -2916,7 +2916,7 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath
if (!strcmpiW(entry->path, pszPath) && entry->index == index)
{
TRACE("cache hit\n");
*ppTypeLib = (ITypeLib2*)entry;
*ppTypeLib = &entry->ITypeLib2_iface;
ITypeLib2_AddRef(*ppTypeLib);
LeaveCriticalSection(&cache_section);
return S_OK;
@ -2987,7 +2987,7 @@ static ITypeLibImpl* TypeLibImpl_Constructor(void)
pTypeLibImpl = heap_alloc_zero(sizeof(ITypeLibImpl));
if (!pTypeLibImpl) return NULL;
pTypeLibImpl->lpVtbl = &tlbvt;
pTypeLibImpl->ITypeLib2_iface.lpVtbl = &tlbvt;
pTypeLibImpl->lpVtblTypeComp = &tlbtcvt;
pTypeLibImpl->ref = 1;
@ -3205,7 +3205,7 @@ static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength)
}
TRACE("(%p)\n", pTypeLibImpl);
return (ITypeLib2*) pTypeLibImpl;
return &pTypeLibImpl->ITypeLib2_iface;
}
@ -4203,58 +4203,53 @@ static ITypeLib2* ITypeLib2_Constructor_SLTG(LPVOID pLib, DWORD dwTLBLength)
}
heap_free(pOtherTypeInfoBlks);
return (ITypeLib2*)pTypeLibImpl;
return &pTypeLibImpl->ITypeLib2_iface;
}
/* ITypeLib::QueryInterface
*/
static HRESULT WINAPI ITypeLib2_fnQueryInterface(
ITypeLib2 * iface,
REFIID riid,
VOID **ppvObject)
static inline ITypeLibImpl *impl_from_ITypeLib2(ITypeLib2 *iface)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
return CONTAINING_RECORD(iface, ITypeLibImpl, ITypeLib2_iface);
}
static HRESULT WINAPI ITypeLib2_fnQueryInterface(ITypeLib2 *iface, REFIID riid, void **ppv)
{
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p)->(IID: %s)\n",This,debugstr_guid(riid));
*ppvObject=NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid,&IID_ITypeLib)||
IsEqualIID(riid,&IID_ITypeLib2))
{
*ppvObject = This;
*ppv = &This->ITypeLib2_iface;
}
else
{
*ppv = NULL;
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
if(*ppvObject)
{
ITypeLib2_AddRef(iface);
TRACE("-- Interface: (%p)->(%p)\n",ppvObject,*ppvObject);
return S_OK;
}
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
/* ITypeLib::AddRef
*/
static ULONG WINAPI ITypeLib2_fnAddRef( ITypeLib2 *iface)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->ref was %u\n",This, ref - 1);
TRACE("(%p) ref=%u\n", This, ref);
return ref;
}
/* ITypeLib::Release
*/
static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%u)\n",This, ref);
TRACE("(%p) ref=%u\n",This, ref);
if (!ref)
{
@ -4298,7 +4293,7 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface)
LIST_FOR_EACH_ENTRY_SAFE(pImpLib, pImpLibNext, &This->implib_list, TLBImpLib, entry)
{
if (pImpLib->pImpTypeLib)
ITypeLib_Release((ITypeLib *)pImpLib->pImpTypeLib);
ITypeLib2_Release(&pImpLib->pImpTypeLib->ITypeLib2_iface);
SysFreeString(pImpLib->name);
list_remove(&pImpLib->entry);
@ -4327,7 +4322,7 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface)
*/
static UINT WINAPI ITypeLib2_fnGetTypeInfoCount( ITypeLib2 *iface)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p)->count is %d\n",This, This->TypeInfoCount);
return This->TypeInfoCount;
}
@ -4341,7 +4336,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfo(
UINT index,
ITypeInfo **ppTInfo)
{
ITypeLibImpl *This = (ITypeLibImpl*)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("%p %u %p\n", This, index, ppTInfo);
@ -4367,7 +4362,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoType(
UINT index,
TYPEKIND *pTKind)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p, %d, %p)\n", This, index, pTKind);
@ -4392,7 +4387,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoOfGuid(
REFGUID guid,
ITypeInfo **ppTInfo)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
UINT i;
TRACE("%p %s %p\n", This, debugstr_guid(guid), ppTInfo);
@ -4417,7 +4412,7 @@ static HRESULT WINAPI ITypeLib2_fnGetLibAttr(
ITypeLib2 *iface,
LPTLIBATTR *attr)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p, %p)\n", This, attr);
@ -4440,7 +4435,7 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeComp(
ITypeLib2 *iface,
ITypeComp **ppTComp)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p)->(%p)\n",This,ppTComp);
*ppTComp = (ITypeComp *)&This->lpVtblTypeComp;
@ -4466,13 +4461,10 @@ static HRESULT WINAPI ITypeLib2_fnGetDocumentation(
DWORD *pdwHelpContext,
BSTR *pBstrHelpFile)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
HRESULT result = E_INVALIDARG;
ITypeInfo *pTInfo;
TRACE("(%p) index %d Name(%p) DocString(%p) HelpContext(%p) HelpFile(%p)\n",
This, index,
pBstrName, pBstrDocString,
@ -4560,7 +4552,7 @@ static HRESULT WINAPI ITypeLib2_fnIsName(
ULONG lHashVal,
BOOL *pfName)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
UINT nNameBufLen = (lstrlenW(szNameBuf)+1)*sizeof(WCHAR), tic, fdc, vrc, pc;
TRACE("(%p)->(%s,%08x,%p)\n", This, debugstr_w(szNameBuf), lHashVal,
@ -4606,7 +4598,7 @@ static HRESULT WINAPI ITypeLib2_fnFindName(
MEMBERID *memid,
UINT16 *found)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
UINT tic, count = 0;
UINT len;
@ -4659,10 +4651,9 @@ static VOID WINAPI ITypeLib2_fnReleaseTLibAttr(
ITypeLib2 *iface,
TLIBATTR *pTLibAttr)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
TRACE("freeing (%p)\n",This);
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p)->(%p)\n", This, pTLibAttr);
heap_free(pTLibAttr);
}
/* ITypeLib2::GetCustData
@ -4674,10 +4665,10 @@ static HRESULT WINAPI ITypeLib2_fnGetCustData(
REFGUID guid,
VARIANT *pVarVal)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TLBCustData *pCData;
TRACE("%p %s %p\n", This, debugstr_guid(guid), pVarVal);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(guid), pVarVal);
pCData = TLB_get_custdata_by_guid(&This->custdata_list, guid);
if(!pCData)
@ -4700,7 +4691,7 @@ static HRESULT WINAPI ITypeLib2_fnGetLibStatistics(
ULONG *pcUniqueNames,
ULONG *pcchUniqueNames)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
FIXME("(%p): stub!\n", This);
@ -4724,7 +4715,7 @@ static HRESULT WINAPI ITypeLib2_fnGetDocumentation2(
DWORD *pdwHelpStringContext,
BSTR *pbstrHelpStringDll)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
HRESULT result;
ITypeInfo *pTInfo;
@ -4810,8 +4801,8 @@ static HRESULT WINAPI ITypeLib2_fnGetAllCustData(
ITypeLib2 * iface,
CUSTDATA *pCustData)
{
ITypeLibImpl *This = (ITypeLibImpl *)iface;
TRACE("%p %p\n", iface, pCustData);
ITypeLibImpl *This = impl_from_ITypeLib2(iface);
TRACE("(%p)->(%p)\n", This, pCustData);
return TLB_copy_all_custdata(&This->custdata_list, pCustData);
}
@ -4841,21 +4832,21 @@ static HRESULT WINAPI ITypeLibComp_fnQueryInterface(ITypeComp * iface, REFIID ri
{
ITypeLibImpl *This = impl_from_ITypeComp(iface);
return ITypeLib2_QueryInterface((ITypeLib2 *)This, riid, ppv);
return ITypeLib2_QueryInterface(&This->ITypeLib2_iface, riid, ppv);
}
static ULONG WINAPI ITypeLibComp_fnAddRef(ITypeComp * iface)
{
ITypeLibImpl *This = impl_from_ITypeComp(iface);
return ITypeLib2_AddRef((ITypeLib2 *)This);
return ITypeLib2_AddRef(&This->ITypeLib2_iface);
}
static ULONG WINAPI ITypeLibComp_fnRelease(ITypeComp * iface)
{
ITypeLibImpl *This = impl_from_ITypeComp(iface);
return ITypeLib2_Release((ITypeLib2 *)This);
return ITypeLib2_Release(&This->ITypeLib2_iface);
}
static HRESULT WINAPI ITypeLibComp_fnBind(
@ -5099,7 +5090,7 @@ static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface)
TRACE("(%p)->ref is %u\n",This, ref);
if (ref == 1 /* incremented from 0 */)
ITypeLib2_AddRef((ITypeLib2*)This->pTypeLib);
ITypeLib2_AddRef(&This->pTypeLib->ITypeLib2_iface);
return ref;
}
@ -5182,7 +5173,7 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface)
if (!ref)
{
BOOL not_attached_to_typelib = This->not_attached_to_typelib;
ITypeLib2_Release((ITypeLib2*)This->pTypeLib);
ITypeLib2_Release(&This->pTypeLib->ITypeLib2_iface);
if (not_attached_to_typelib)
heap_free(This);
/* otherwise This will be freed when typelib is freed */
@ -7056,7 +7047,7 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeInfo(
} else {
if(ref_type->pImpTLInfo->pImpTypeLib) {
TRACE("typeinfo in imported typelib that is already loaded\n");
pTLib = (ITypeLib*)ref_type->pImpTLInfo->pImpTypeLib;
pTLib = (ITypeLib*)&ref_type->pImpTLInfo->pImpTypeLib->ITypeLib2_iface;
ITypeLib_AddRef(pTLib);
result = S_OK;
} else {
@ -7841,7 +7832,7 @@ HRESULT WINAPI CreateDispTypeInfo(
*pptinfo = (ITypeInfo*)pTIClass;
ITypeInfo_AddRef(*pptinfo);
ITypeLib_Release((ITypeLib *)&pTypeLibImpl->lpVtbl);
ITypeLib2_Release(&pTypeLibImpl->ITypeLib2_iface);
return S_OK;