OLE: Support HREFTYPEs For ITypeInfos

Add support for reading the hreftype of a typeinfo, return it to the
application in ITypeComp_Bind for the DESKIND_APPOBJECT case and
support referencing it in ITypeInfo_GetRefTypeInfo.
This commit is contained in:
Robert Shearman 2005-12-03 18:20:27 +01:00 committed by Alexandre Julliard
parent d8d1693def
commit 190d05f4db
1 changed files with 30 additions and 2 deletions

View File

@ -976,6 +976,7 @@ typedef struct tagITypeInfoImpl
TYPEATTR TypeAttr ; /* _lots_ of type information. */
ITypeLibImpl * pTypeLib; /* back pointer to typelib */
int index; /* index in this typelib; */
HREFTYPE hreftype; /* hreftype for app object binding */
/* type libs seem to store the doc strings in ascii
* so why should we do it in unicode?
*/
@ -1448,6 +1449,22 @@ static void MSFT_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx)
TRACE_(typelib)("%s\n", debugstr_guid(pGuid));
}
static HREFTYPE MSFT_ReadHreftype( TLBContext *pcx, int offset )
{
MSFT_NameIntro niName;
if (offset < 0)
{
ERR_(typelib)("bad offset %d\n", offset);
return -1;
}
MSFT_ReadLEDWords(&niName, sizeof(niName), pcx,
pcx->pTblDir->pNametab.offset+offset);
return niName.hreftype;
}
static BSTR MSFT_ReadName( TLBContext *pcx, int offset)
{
char * name;
@ -2057,6 +2074,7 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
/* name, eventually add to a hash table */
ptiRet->Name=MSFT_ReadName(pcx, tiBase.NameOffset);
ptiRet->hreftype = MSFT_ReadHreftype(pcx, tiBase.NameOffset);
TRACE_(typelib)("reading %s\n", debugstr_w(ptiRet->Name));
/* help info */
ptiRet->DocString=MSFT_ReadString(pcx, tiBase.docstringoffs);
@ -4111,7 +4129,7 @@ static HRESULT WINAPI ITypeLibComp_fnBind(
TYPEDESC tdesc_appobject =
{
{
0 /* FIXME */
(TYPEDESC *)pTypeInfo->hreftype
},
VT_USERDEFINED
};
@ -4153,6 +4171,9 @@ static HRESULT WINAPI ITypeLibComp_fnBind(
}
if (subtypeinfo) ITypeInfo_Release(subtypeinfo);
if (pTypeInfo->hreftype == -1)
FIXME("no hreftype for interface %p\n", pTypeInfo);
hr = TLB_AllocAndInitVarDesc(&vardesc_appobject, &pBindPtr->lpvardesc);
if (FAILED(hr))
return hr;
@ -4202,6 +4223,7 @@ static ITypeInfo2 * WINAPI ITypeInfo_Constructor(void)
pTypeInfoImpl->lpVtbl = &tinfvt;
pTypeInfoImpl->lpVtblTypeComp = &tcompvt;
pTypeInfoImpl->ref=1;
pTypeInfoImpl->hreftype = -1;
}
TRACE("(%p)\n", pTypeInfoImpl);
return (ITypeInfo2*) pTypeInfoImpl;
@ -5535,7 +5557,13 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeInfo(
ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
HRESULT result = E_FAIL;
if (hRefType == -1 &&
if ((This->hreftype != -1) && (This->hreftype == hRefType))
{
*ppTInfo = (ITypeInfo *)&This->lpVtbl;
ITypeInfo_AddRef(*ppTInfo);
result = S_OK;
}
else if (hRefType == -1 &&
(((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) &&
(((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL))
{