oleaut32: Rewrite get_funcdesc to avoid using the funcdesc's oVft member so that it works correctly for non-dual dispinterfaces.

This commit is contained in:
Huw Davies 2007-04-26 11:56:44 +01:00 committed by Alexandre Julliard
parent b8a50daec7
commit 294b3ebba1
1 changed files with 59 additions and 54 deletions

View File

@ -1198,63 +1198,68 @@ deserialize_param(
} }
} }
/* Searches function, also in inherited interfaces */ /* Retrieves a function's funcdesc, searching back into inherited interfaces. */
static HRESULT static HRESULT get_funcdesc(ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, const FUNCDESC **fdesc,
_get_funcdesc( BSTR *iname, BSTR *fname, UINT *num)
ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, const FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
{ {
int i = 0, j = 0; HRESULT hr;
HRESULT hres; UINT i, impl_types;
UINT inherited_funcs = 0;
TYPEATTR *attr;
if (fname) *fname = NULL; if (fname) *fname = NULL;
if (iname) *iname = NULL; if (iname) *iname = NULL;
if (num) *num = 0;
*tactual = NULL;
while (1) { hr = ITypeInfo_GetTypeAttr(tinfo, &attr);
hres = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i, fdesc); if (FAILED(hr))
{
ERR("GetTypeAttr failed with %x\n",hr);
return hr;
}
impl_types = attr->cImplTypes;
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
if (hres) { for (i = 0; i < impl_types; i++)
ITypeInfo *tinfo2; {
HREFTYPE href; HREFTYPE href;
TYPEATTR *attr; ITypeInfo *pSubTypeInfo;
UINT sub_funcs;
hres = ITypeInfo_GetTypeAttr(tinfo, &attr); hr = ITypeInfo_GetRefTypeOfImplType(tinfo, i, &href);
if (hres) { if (FAILED(hr)) return hr;
ERR("GetTypeAttr failed with %x\n",hres); hr = ITypeInfo_GetRefTypeInfo(tinfo, href, &pSubTypeInfo);
return hres; if (FAILED(hr)) return hr;
hr = get_funcdesc(pSubTypeInfo, iMethod, tactual, fdesc, iname, fname, &sub_funcs);
inherited_funcs += sub_funcs;
ITypeInfo_Release(pSubTypeInfo);
if(SUCCEEDED(hr)) return hr;
} }
/* Not found, so look in inherited ifaces. */ if(iMethod < inherited_funcs)
for (j=0;j<attr->cImplTypes;j++) { {
hres = ITypeInfo_GetRefTypeOfImplType(tinfo, j, &href); ERR("shouldn't be here\n");
if (hres) { return E_INVALIDARG;
ERR("Did not find a reftype for interface offset %d?\n",j);
break;
} }
hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
if (hres) { for(i = inherited_funcs; i <= iMethod; i++)
ERR("Did not find a typeinfo for reftype %d?\n",href); {
continue; hr = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i - inherited_funcs, fdesc);
} if(FAILED(hr))
hres = _get_funcdesc(tinfo2,iMethod,tactual,fdesc,iname,fname); {
ITypeInfo_Release(tinfo2); if(num) *num = i;
if (!hres) { return hr;
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
return S_OK;
} }
} }
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
return hres; /* found it. We don't care about num so zero it */
} if(num) *num = 0;
if (((*fdesc)->oVft/4) == iMethod) {
if (fname)
ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL);
if (iname)
ITypeInfo_GetDocumentation(tinfo,-1,iname,NULL,NULL,NULL);
*tactual = tinfo; *tactual = tinfo;
ITypeInfo_AddRef(*tactual); ITypeInfo_AddRef(*tactual);
if (fname) ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL);
if (iname) ITypeInfo_GetDocumentation(tinfo,-1,iname,NULL,NULL,NULL);
return S_OK; return S_OK;
}
i++;
}
} }
static inline BOOL is_in_elem(const ELEMDESC *elem) static inline BOOL is_in_elem(const ELEMDESC *elem)
@ -1286,7 +1291,7 @@ xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
EnterCriticalSection(&tpinfo->crit); EnterCriticalSection(&tpinfo->crit);
hres = _get_funcdesc(tpinfo->tinfo,method,&tinfo,&fdesc,&iname,&fname); hres = get_funcdesc(tpinfo->tinfo,method,&tinfo,&fdesc,&iname,&fname,NULL);
if (hres) { if (hres) {
ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method); ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
LeaveCriticalSection(&tpinfo->crit); LeaveCriticalSection(&tpinfo->crit);
@ -1700,7 +1705,7 @@ PSFacBuf_CreateProxy(
/* nrofargs without This */ /* nrofargs without This */
int nrofargs; int nrofargs;
ITypeInfo *tinfo2; ITypeInfo *tinfo2;
hres = _get_funcdesc(tinfo,i,&tinfo2,&fdesc,NULL,NULL); hres = get_funcdesc(tinfo,i,&tinfo2,&fdesc,NULL,NULL,NULL);
if (hres) { if (hres) {
ERR("GetFuncDesc %x should not fail here.\n",hres); ERR("GetFuncDesc %x should not fail here.\n",hres);
return hres; return hres;
@ -1916,7 +1921,7 @@ TMStubImpl_Invoke(
memcpy(buf.base, xmsg->Buffer, xmsg->cbBuffer); memcpy(buf.base, xmsg->Buffer, xmsg->cbBuffer);
buf.curoff = 0; buf.curoff = 0;
hres = _get_funcdesc(This->tinfo,xmsg->iMethod,&tinfo,&fdesc,&iname,NULL); hres = get_funcdesc(This->tinfo,xmsg->iMethod,&tinfo,&fdesc,&iname,NULL,NULL);
if (hres) { if (hres) {
ERR("GetFuncDesc on method %d failed with %x\n",xmsg->iMethod,hres); ERR("GetFuncDesc on method %d failed with %x\n",xmsg->iMethod,hres);
return hres; return hres;