Commit 294b3ebb authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

oleaut32: Rewrite get_funcdesc to avoid using the funcdesc's oVft member so that…

oleaut32: Rewrite get_funcdesc to avoid using the funcdesc's oVft member so that it works correctly for non-dual dispinterfaces.
parent b8a50dae
...@@ -1198,63 +1198,68 @@ deserialize_param( ...@@ -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;
}
/* Not found, so look in inherited ifaces. */ hr = get_funcdesc(pSubTypeInfo, iMethod, tactual, fdesc, iname, fname, &sub_funcs);
for (j=0;j<attr->cImplTypes;j++) { inherited_funcs += sub_funcs;
hres = ITypeInfo_GetRefTypeOfImplType(tinfo, j, &href); ITypeInfo_Release(pSubTypeInfo);
if (hres) { if(SUCCEEDED(hr)) return hr;
ERR("Did not find a reftype for interface offset %d?\n",j);
break;
}
hres = ITypeInfo_GetRefTypeInfo(tinfo, href, &tinfo2);
if (hres) {
ERR("Did not find a typeinfo for reftype %d?\n",href);
continue;
} }
hres = _get_funcdesc(tinfo2,iMethod,tactual,fdesc,iname,fname); if(iMethod < inherited_funcs)
ITypeInfo_Release(tinfo2); {
if (!hres) { ERR("shouldn't be here\n");
ITypeInfo_ReleaseTypeAttr(tinfo, attr); return E_INVALIDARG;
return S_OK;
} }
for(i = inherited_funcs; i <= iMethod; i++)
{
hr = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i - inherited_funcs, fdesc);
if(FAILED(hr))
{
if(num) *num = i;
return hr;
} }
ITypeInfo_ReleaseTypeAttr(tinfo, attr);
return hres;
} }
if (((*fdesc)->oVft/4) == iMethod) {
if (fname) /* found it. We don't care about num so zero it */
ITypeInfo_GetDocumentation(tinfo,(*fdesc)->memid,fname,NULL,NULL,NULL); if(num) *num = 0;
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 */) ...@@ -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( ...@@ -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( ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment