Robert Shearman : OLE: Support HREFTYPEs For ITypeInfos

Alexandre Julliard julliard at wine.codeweavers.com
Sat Dec 3 12:31:18 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 190d05f4db08190b86517832a5608325da9734e3
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=190d05f4db08190b86517832a5608325da9734e3

Author: Robert Shearman <rob at codeweavers.com>
Date:   Sat Dec  3 18:20:27 2005 +0100

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.

---

 dlls/oleaut32/typelib.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 3e4b83b..4d8a736 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -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, 
     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_fnBin
                 TYPEDESC tdesc_appobject =
                 {
                     {
-                        0 /* FIXME */
+                        (TYPEDESC *)pTypeInfo->hreftype
                     },
                     VT_USERDEFINED
                 };
@@ -4153,6 +4171,9 @@ static HRESULT WINAPI ITypeLibComp_fnBin
                 }
                 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_Con
       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_fnGetRef
     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))
     {




More information about the wine-cvs mailing list