oleaut32: Convert TLBImplType to be stored as an array.

This commit is contained in:
Andrew Eikum 2011-03-10 15:21:52 -06:00 committed by Alexandre Julliard
parent 016795a9bf
commit f76334fd3e
1 changed files with 98 additions and 105 deletions

View File

@ -1095,7 +1095,6 @@ typedef struct tagTLBImplType
int implflags; /* IMPLFLAG_*s */ int implflags; /* IMPLFLAG_*s */
int ctCustData; int ctCustData;
TLBCustData * pCustData;/* linked list to custom data; */ TLBCustData * pCustData;/* linked list to custom data; */
struct tagTLBImplType *next;
} TLBImplType; } TLBImplType;
/* internal TypeInfo data */ /* internal TypeInfo data */
@ -1125,7 +1124,7 @@ typedef struct tagITypeInfoImpl
TLBVarDesc * varlist; /* linked list with variable descriptions */ TLBVarDesc * varlist; /* linked list with variable descriptions */
/* Implemented Interfaces */ /* Implemented Interfaces */
TLBImplType * impltypelist; TLBImplType *impltypes;
int ctCustData; int ctCustData;
TLBCustData * pCustData; /* linked list to cust data; */ TLBCustData * pCustData; /* linked list to cust data; */
@ -1334,13 +1333,15 @@ static void dump_TLBRefType(const ITypeLibImpl *pTL)
} }
} }
static void dump_TLBImplType(const TLBImplType * impl) static void dump_TLBImplType(const TLBImplType * impl, UINT n)
{ {
while (impl) { if(!impl)
TRACE_(typelib)( return;
"implementing/inheriting interface hRef = %x implflags %x\n", while (n) {
impl->hRef, impl->implflags); TRACE_(typelib)("implementing/inheriting interface hRef = %x implflags %x\n",
impl = impl->next; impl->hRef, impl->implflags);
++impl;
--n;
} }
} }
@ -1434,7 +1435,7 @@ static void dump_TypeInfo(const ITypeInfoImpl * pty)
if (TRACE_ON(ole)) if (TRACE_ON(ole))
dump_TLBFuncDesc(pty->funcdescs, pty->TypeAttr.cFuncs); dump_TLBFuncDesc(pty->funcdescs, pty->TypeAttr.cFuncs);
dump_TLBVarDesc(pty->varlist); dump_TLBVarDesc(pty->varlist);
dump_TLBImplType(pty->impltypelist); dump_TLBImplType(pty->impltypes, pty->TypeAttr.cImplTypes);
} }
static void dump_VARDESC(const VARDESC *v) static void dump_VARDESC(const VARDESC *v)
@ -2224,21 +2225,22 @@ static void MSFT_DoImplTypes(TLBContext *pcx, ITypeInfoImpl *pTI, int count,
{ {
int i; int i;
MSFT_RefRecord refrec; MSFT_RefRecord refrec;
TLBImplType **ppImpl = &pTI->impltypelist; TLBImplType *pImpl;
TRACE_(typelib)("\n"); TRACE_(typelib)("\n");
pTI->impltypes = heap_alloc_zero(count * sizeof(TLBImplType));
pImpl = pTI->impltypes;
for(i=0;i<count;i++){ for(i=0;i<count;i++){
if(offset<0) break; /* paranoia */ if(offset<0) break; /* paranoia */
*ppImpl = heap_alloc_zero(sizeof(**ppImpl));
MSFT_ReadLEDWords(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset); MSFT_ReadLEDWords(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset);
MSFT_DoRefType(pcx, pTI->pTypeLib, refrec.reftype); MSFT_DoRefType(pcx, pTI->pTypeLib, refrec.reftype);
(*ppImpl)->hRef = refrec.reftype; pImpl->hRef = refrec.reftype;
(*ppImpl)->implflags=refrec.flags; pImpl->implflags=refrec.flags;
(*ppImpl)->ctCustData= pImpl->ctCustData=
MSFT_CustData(pcx, refrec.oCustData, &(*ppImpl)->pCustData); MSFT_CustData(pcx, refrec.oCustData, &pImpl->pCustData);
offset=refrec.onext; offset=refrec.onext;
ppImpl=&((*ppImpl)->next); ++pImpl;
} }
} }
/* /*
@ -2324,15 +2326,15 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
if (tiBase.datatype1 != -1) if (tiBase.datatype1 != -1)
{ {
ptiRet->impltypelist = heap_alloc_zero(sizeof(TLBImplType)); ptiRet->impltypes = heap_alloc_zero(sizeof(TLBImplType));
ptiRet->impltypelist->hRef = tiBase.datatype1; ptiRet->impltypes[0].hRef = tiBase.datatype1;
MSFT_DoRefType(pcx, pLibInfo, tiBase.datatype1); MSFT_DoRefType(pcx, pLibInfo, tiBase.datatype1);
} }
break; break;
default: default:
ptiRet->impltypelist = heap_alloc_zero(sizeof(TLBImplType)); ptiRet->impltypes = heap_alloc_zero(sizeof(TLBImplType));
MSFT_DoRefType(pcx, pLibInfo, tiBase.datatype1); MSFT_DoRefType(pcx, pLibInfo, tiBase.datatype1);
ptiRet->impltypelist->hRef = tiBase.datatype1; ptiRet->impltypes[0].hRef = tiBase.datatype1;
break; break;
} }
} }
@ -3401,7 +3403,7 @@ static char *SLTG_DoImpls(char *pBlk, ITypeInfoImpl *pTI,
BOOL OneOnly, const sltg_ref_lookup_t *ref_lookup) BOOL OneOnly, const sltg_ref_lookup_t *ref_lookup)
{ {
SLTG_ImplInfo *info; SLTG_ImplInfo *info;
TLBImplType **ppImplType = &pTI->impltypelist; TLBImplType *pImplType;
/* I don't really get this structure, usually it's 0x16 bytes /* I don't really get this structure, usually it's 0x16 bytes
long, but iuser.tlb contains some that are 0x18 bytes long. long, but iuser.tlb contains some that are 0x18 bytes long.
That's ok because we can use the next ptr to jump to the next That's ok because we can use the next ptr to jump to the next
@ -3410,14 +3412,22 @@ static char *SLTG_DoImpls(char *pBlk, ITypeInfoImpl *pTI,
the last one is the regular 0x16 bytes. */ the last one is the regular 0x16 bytes. */
info = (SLTG_ImplInfo*)pBlk; info = (SLTG_ImplInfo*)pBlk;
while(1) { while(1){
*ppImplType = heap_alloc_zero(sizeof(**ppImplType)); pTI->TypeAttr.cImplTypes++;
sltg_get_typelib_ref(ref_lookup, info->ref, &(*ppImplType)->hRef);
(*ppImplType)->implflags = info->impltypeflags;
pTI->TypeAttr.cImplTypes++;
ppImplType = &(*ppImplType)->next;
if(info->next == 0xffff) if(info->next == 0xffff)
break;
info = (SLTG_ImplInfo*)(pBlk + info->next);
}
info = (SLTG_ImplInfo*)pBlk;
pTI->impltypes = heap_alloc_zero(pTI->TypeAttr.cImplTypes * sizeof(TLBImplType));
pImplType = pTI->impltypes;
while(1) {
sltg_get_typelib_ref(ref_lookup, info->ref, &pImplType->hRef);
pImplType->implflags = info->impltypeflags;
++pImplType;
if(info->next == 0xffff)
break; break;
if(OneOnly) if(OneOnly)
FIXME_(typelib)("Interface inheriting more than one interface\n"); FIXME_(typelib)("Interface inheriting more than one interface\n");
@ -4982,8 +4992,7 @@ static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface)
static void ITypeInfoImpl_Destroy(ITypeInfoImpl *This) static void ITypeInfoImpl_Destroy(ITypeInfoImpl *This)
{ {
TLBVarDesc *pVInfo, *pVInfoNext; TLBVarDesc *pVInfo, *pVInfoNext;
TLBImplType *pImpl, *pImplNext; UINT fdc, itc;
UINT fdc;
TRACE("destroying ITypeInfo(%p)\n",This); TRACE("destroying ITypeInfo(%p)\n",This);
@ -5034,12 +5043,15 @@ static void ITypeInfoImpl_Destroy(ITypeInfoImpl *This)
pVInfoNext = pVInfo->next; pVInfoNext = pVInfo->next;
heap_free(pVInfo); heap_free(pVInfo);
} }
for (pImpl = This->impltypelist; pImpl; pImpl = pImplNext)
{ if(This->impltypes){
TLB_FreeCustData(pImpl->pCustData); for (itc = 0; itc < This->TypeAttr.cImplTypes; ++itc){
pImplNext = pImpl->next; TLBImplType *pImpl = &This->impltypes[itc];
heap_free(pImpl); TLB_FreeCustData(pImpl->pCustData);
}
heap_free(This->impltypes);
} }
TLB_FreeCustData(This->pCustData); TLB_FreeCustData(This->pCustData);
heap_free(This); heap_free(This);
@ -5269,12 +5281,12 @@ static HRESULT ITypeInfoImpl_GetInternalDispatchFuncDesc( ITypeInfo *iface,
else else
*hrefoffset = DISPATCH_HREF_OFFSET; *hrefoffset = DISPATCH_HREF_OFFSET;
if(This->impltypelist) if(This->impltypes)
{ {
ITypeInfo *pSubTypeInfo; ITypeInfo *pSubTypeInfo;
UINT sub_funcs; UINT sub_funcs;
hr = ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, &pSubTypeInfo); hr = ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef, &pSubTypeInfo);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -5485,12 +5497,12 @@ static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
} }
else else
{ {
if(This->impltypelist && if(This->impltypes &&
(This->TypeAttr.typekind==TKIND_INTERFACE || This->TypeAttr.typekind==TKIND_DISPATCH)) { (This->TypeAttr.typekind==TKIND_INTERFACE || This->TypeAttr.typekind==TKIND_DISPATCH)) {
/* recursive search */ /* recursive search */
ITypeInfo *pTInfo; ITypeInfo *pTInfo;
HRESULT result; HRESULT result;
result=ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, result=ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef,
&pTInfo); &pTInfo);
if(SUCCEEDED(result)) if(SUCCEEDED(result))
{ {
@ -5526,9 +5538,7 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeOfImplType(
HREFTYPE *pRefType) HREFTYPE *pRefType)
{ {
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
UINT i;
HRESULT hr = S_OK; HRESULT hr = S_OK;
const TLBImplType *pImpl = This->impltypelist;
TRACE("(%p) index %d\n", This, index); TRACE("(%p) index %d\n", This, index);
if (TRACE_ON(ole)) dump_TypeInfo(This); if (TRACE_ON(ole)) dump_TypeInfo(This);
@ -5556,16 +5566,10 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeOfImplType(
} }
else else
{ {
/* get element n from linked list */ if(index >= This->TypeAttr.cImplTypes)
for(i=0; pImpl && i<index; i++) hr = TYPE_E_ELEMENTNOTFOUND;
{ else
pImpl = pImpl->next; *pRefType = This->impltypes[index].hRef;
}
if (pImpl)
*pRefType = pImpl->hRef;
else
hr = TYPE_E_ELEMENTNOTFOUND;
} }
if(TRACE_ON(ole)) if(TRACE_ON(ole))
@ -5588,24 +5592,20 @@ static HRESULT WINAPI ITypeInfo_fnGetImplTypeFlags( ITypeInfo2 *iface,
UINT index, INT *pImplTypeFlags) UINT index, INT *pImplTypeFlags)
{ {
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
UINT i;
TLBImplType *pImpl;
TRACE("(%p) index %d\n", This, index); TRACE("(%p) index %d\n", This, index);
for(i=0, pImpl=This->impltypelist; i<index && pImpl;
i++, pImpl=pImpl->next) if(This->TypeAttr.typekind == TKIND_DISPATCH && index == 0){
; *pImplTypeFlags = 0;
if(i==index && pImpl){
*pImplTypeFlags=pImpl->implflags;
return S_OK; return S_OK;
} }
*pImplTypeFlags=0;
if(This->TypeAttr.typekind==TKIND_DISPATCH && !index) if(index >= This->TypeAttr.cImplTypes)
return S_OK; return TYPE_E_ELEMENTNOTFOUND;
WARN("ImplType %d not found\n", index); *pImplTypeFlags = This->impltypes[index].implflags;
return TYPE_E_ELEMENTNOTFOUND;
return S_OK;
} }
/* GetIDsOfNames /* GetIDsOfNames
@ -5652,11 +5652,11 @@ static HRESULT WINAPI ITypeInfo_fnGetIDsOfNames( ITypeInfo2 *iface,
} }
} }
/* not found, see if it can be found in an inherited interface */ /* not found, see if it can be found in an inherited interface */
if(This->impltypelist) { if(This->impltypes) {
/* recursive search */ /* recursive search */
ITypeInfo *pTInfo; ITypeInfo *pTInfo;
ret=ITypeInfo_GetRefTypeInfo(iface, ret=ITypeInfo_GetRefTypeInfo(iface,
This->impltypelist->hRef, &pTInfo); This->impltypes[0].hRef, &pTInfo);
if(SUCCEEDED(ret)){ if(SUCCEEDED(ret)){
ret=ITypeInfo_GetIDsOfNames(pTInfo, rgszNames, cNames, pMemId ); ret=ITypeInfo_GetIDsOfNames(pTInfo, rgszNames, cNames, pMemId );
ITypeInfo_Release(pTInfo); ITypeInfo_Release(pTInfo);
@ -6639,10 +6639,10 @@ func_fail:
/* not found, look for it in inherited interfaces */ /* not found, look for it in inherited interfaces */
ITypeInfo2_GetTypeKind(iface, &type_kind); ITypeInfo2_GetTypeKind(iface, &type_kind);
if(type_kind == TKIND_INTERFACE || type_kind == TKIND_DISPATCH) { if(type_kind == TKIND_INTERFACE || type_kind == TKIND_DISPATCH) {
if(This->impltypelist) { if(This->impltypes) {
/* recursive search */ /* recursive search */
ITypeInfo *pTInfo; ITypeInfo *pTInfo;
hres = ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, &pTInfo); hres = ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef, &pTInfo);
if(SUCCEEDED(hres)){ if(SUCCEEDED(hres)){
hres = ITypeInfo_Invoke(pTInfo,pIUnk,memid,wFlags,pDispParams,pVarResult,pExcepInfo,pArgErr); hres = ITypeInfo_Invoke(pTInfo,pIUnk,memid,wFlags,pDispParams,pVarResult,pExcepInfo,pArgErr);
ITypeInfo_Release(pTInfo); ITypeInfo_Release(pTInfo);
@ -6705,12 +6705,12 @@ static HRESULT WINAPI ITypeInfo_fnGetDocumentation( ITypeInfo2 *iface,
} }
} }
if(This->impltypelist && if(This->impltypes &&
(This->TypeAttr.typekind==TKIND_INTERFACE || This->TypeAttr.typekind==TKIND_DISPATCH)) { (This->TypeAttr.typekind==TKIND_INTERFACE || This->TypeAttr.typekind==TKIND_DISPATCH)) {
/* recursive search */ /* recursive search */
ITypeInfo *pTInfo; ITypeInfo *pTInfo;
HRESULT result; HRESULT result;
result = ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, result = ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef,
&pTInfo); &pTInfo);
if(SUCCEEDED(result)) { if(SUCCEEDED(result)) {
result = ITypeInfo_GetDocumentation(pTInfo, memid, pBstrName, result = ITypeInfo_GetDocumentation(pTInfo, memid, pBstrName,
@ -6781,11 +6781,11 @@ static HRESULT ITypeInfoImpl_GetDispatchRefTypeInfo( ITypeInfo *iface,
TRACE("%p, 0x%x\n", iface, *hRefType); TRACE("%p, 0x%x\n", iface, *hRefType);
if (This->impltypelist && (*hRefType & DISPATCH_HREF_MASK)) if (This->impltypes && (*hRefType & DISPATCH_HREF_MASK))
{ {
ITypeInfo *pSubTypeInfo; ITypeInfo *pSubTypeInfo;
hr = ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, &pSubTypeInfo); hr = ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef, &pSubTypeInfo);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
@ -7345,17 +7345,14 @@ static HRESULT WINAPI ITypeInfo2_fnGetImplTypeCustData(
{ {
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
TLBCustData *pCData=NULL; TLBCustData *pCData=NULL;
TLBImplType * pRDesc; TLBImplType *pRDesc = &This->impltypes[index];
UINT i;
for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++, pRDesc=pRDesc->next); if(index >= This->TypeAttr.cImplTypes)
return TYPE_E_ELEMENTNOTFOUND;
if(pRDesc) for(pCData = pRDesc->pCustData; pCData; pCData = pCData->next)
{ {
for(pCData=pRDesc->pCustData; pCData; pCData = pCData->next)
{
if( IsEqualIID(guid, &pCData->guid)) break; if( IsEqualIID(guid, &pCData->guid)) break;
}
} }
TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT"); TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT");
@ -7366,7 +7363,8 @@ static HRESULT WINAPI ITypeInfo2_fnGetImplTypeCustData(
VariantCopy( pVarVal, &pCData->data); VariantCopy( pVarVal, &pCData->data);
return S_OK; return S_OK;
} }
return E_INVALIDARG; /* FIXME: correct? */
return TYPE_E_ELEMENTNOTFOUND;
} }
/* ITypeInfo2::GetDocumentation2 /* ITypeInfo2::GetDocumentation2
@ -7582,30 +7580,25 @@ static HRESULT WINAPI ITypeInfo2_fnGetAllImplTypeCustData(
{ {
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
TLBCustData *pCData; TLBCustData *pCData;
TLBImplType * pRDesc; TLBImplType *pRDesc = &This->impltypes[index];
UINT i; UINT i;
TRACE("(%p) index %d\n", This, index); TRACE("(%p) index %d\n", This, index);
for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++,
pRDesc=pRDesc->next) if(index >= This->TypeAttr.cImplTypes)
; return TYPE_E_ELEMENTNOTFOUND;
if(pRDesc){
pCustData->prgCustData = pCustData->prgCustData = heap_alloc_zero(pRDesc->ctCustData * sizeof(CUSTDATAITEM));
heap_alloc_zero(pRDesc->ctCustData * sizeof(CUSTDATAITEM)); if(!pCustData->prgCustData)
if(pCustData->prgCustData ){ return E_OUTOFMEMORY;
pCustData->cCustData=pRDesc->ctCustData;
for(i=0, pCData=pRDesc->pCustData; pCData; i++, pCustData->cCustData=pRDesc->ctCustData;
pCData = pCData->next){ for(i = 0, pCData = pRDesc->pCustData; pCData; i++, pCData = pCData->next){
pCustData->prgCustData[i].guid=pCData->guid; pCustData->prgCustData[i].guid = pCData->guid;
VariantCopy(& pCustData->prgCustData[i].varValue, VariantCopy(&pCustData->prgCustData[i].varValue, &pCData->data);
& pCData->data);
}
}else{
ERR(" OUT OF MEMORY!\n");
return E_OUTOFMEMORY;
}
return S_OK;
} }
return TYPE_E_ELEMENTNOTFOUND;
return S_OK;
} }
static const ITypeInfo2Vtbl tinfvt = static const ITypeInfo2Vtbl tinfvt =
@ -7758,8 +7751,8 @@ HRESULT WINAPI CreateDispTypeInfo(
pTIClass->TypeAttr.cVars = 0; pTIClass->TypeAttr.cVars = 0;
pTIClass->TypeAttr.wTypeFlags = 0; pTIClass->TypeAttr.wTypeFlags = 0;
pTIClass->impltypelist = heap_alloc_zero(sizeof(*pTIClass->impltypelist)); pTIClass->impltypes = heap_alloc_zero(sizeof(*pTIClass->impltypes));
pTIClass->impltypelist->hRef = 0; pTIClass->impltypes[0].hRef = 0;
ref = heap_alloc_zero(sizeof(*ref)); ref = heap_alloc_zero(sizeof(*ref));
ref->index = 0; ref->index = 0;
@ -7857,12 +7850,12 @@ static HRESULT WINAPI ITypeComp_fnBind(
} }
} }
/* FIXME: search each inherited interface, not just the first */ /* FIXME: search each inherited interface, not just the first */
if (hr == DISP_E_MEMBERNOTFOUND && This->impltypelist) { if (hr == DISP_E_MEMBERNOTFOUND && This->impltypes) {
/* recursive search */ /* recursive search */
ITypeInfo *pTInfo; ITypeInfo *pTInfo;
ITypeComp *pTComp; ITypeComp *pTComp;
HRESULT hr; HRESULT hr;
hr=ITypeInfo_GetRefTypeInfo((ITypeInfo *)&This->lpVtbl, This->impltypelist->hRef, &pTInfo); hr=ITypeInfo_GetRefTypeInfo((ITypeInfo *)&This->lpVtbl, This->impltypes[0].hRef, &pTInfo);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = ITypeInfo_GetTypeComp(pTInfo,&pTComp); hr = ITypeInfo_GetTypeComp(pTInfo,&pTComp);