ChangeSet ID: 21185 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/09 04:31:20
Modified files: dlls/oleaut32 : typelib.c
Log message: Robert Shearman rob@codeweavers.com - Cleanup formating of DispCallFunc. - Fix DispCallFunc for functions with return values. - Don't rely on _copy_arg as it is going away soon.
Patch: http://cvs.winehq.org/patch.py?id=21185
Old revision New revision Changes Path 1.174 1.175 +26 -25 wine/dlls/oleaut32/typelib.c
Index: wine/dlls/oleaut32/typelib.c diff -u -p wine/dlls/oleaut32/typelib.c:1.174 wine/dlls/oleaut32/typelib.c:1.175 --- wine/dlls/oleaut32/typelib.c:1.174 9 Nov 2005 10:31:20 -0000 +++ wine/dlls/oleaut32/typelib.c 9 Nov 2005 10:31:20 -0000 @@ -4862,46 +4862,47 @@ static HRESULT typedescvt_to_variantvt(I HRESULT WINAPI DispCallFunc( void* pvInstance, ULONG oVft, CALLCONV cc, VARTYPE vtReturn, UINT cActuals, - VARTYPE* prgvt, VARIANTARG** prgpvarg, VARIANT* pvargResult -) { + VARTYPE* prgvt, VARIANTARG** prgpvarg, VARIANT* pvargResult) +{ int i, argsize, argspos; DWORD *args; HRESULT hres;
TRACE("(%p, %ld, %d, %d, %d, %p, %p, %p (vt=%d))\n", - pvInstance, oVft, cc, vtReturn, cActuals, prgvt, prgpvarg, pvargResult, V_VT(pvargResult) - ); - /* DispCallFunc is only used to invoke methods belonging to an IDispatch-derived COM interface. - So we need to add a first parameter to the list of arguments, to supply the interface pointer */ + pvInstance, oVft, cc, vtReturn, cActuals, prgvt, prgpvarg, + pvargResult, V_VT(pvargResult)); + + /* DispCallFunc is only used to invoke methods belonging to an + * IDispatch-derived COM interface. So we need to add a first parameter + * to the list of arguments, to supply the interface pointer */ argsize = 1; - for (i=0;i<cActuals;i++) { - TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_argsize(prgvt[i])); - dump_Variant(prgpvarg[i]); - argsize += _argsize(prgvt[i]); + for (i=0;i<cActuals;i++) + { + TRACE("arg %d: type %d, size %d\n",i,prgvt[i],_argsize(prgvt[i])); + dump_Variant(prgpvarg[i]); + argsize += _argsize(prgvt[i]); } args = HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize); args[0] = (DWORD)pvInstance; /* this is the fake IDispatch interface pointer */ argspos = 1; - for (i=0;i<cActuals;i++) { - VARIANT *arg = prgpvarg[i]; - TRACE("Storing arg %d (%d as %d)\n",i,V_VT(arg),prgvt[i]); - _copy_arg(NULL, NULL, &args[argspos], arg, prgvt[i]); - argspos += _argsize(prgvt[i]); - } - - if(pvargResult!=NULL && V_VT(pvargResult)==VT_EMPTY) + for (i=0;i<cActuals;i++) { - _invoke((*(FARPROC**)pvInstance)[oVft/4],cc,argsize,args); - hres=S_OK; + VARIANT *arg = prgpvarg[i]; + TRACE("Storing arg %d (%d as %d)\n",i,V_VT(arg),prgvt[i]); + memcpy(&args[argspos], &V_NONE(arg), _argsize(prgvt[i]) * sizeof(DWORD)); + argspos += _argsize(prgvt[i]); } - else + + hres = _invoke((*(FARPROC**)pvInstance)[oVft/sizeof(void *)],cc,argsize,args); + if (pvargResult && (vtReturn != VT_EMPTY)) { - FIXME("Do not know how to handle pvargResult %p. Expect crash ...\n",pvargResult); - hres = _invoke((*(FARPROC**)pvInstance)[oVft/4],cc,argsize,args); - FIXME("Method returned %lx\n",hres); + TRACE("Method returned 0x%08lx\n",hres); + V_VT(pvargResult) = vtReturn; + V_UI4(pvargResult) = hres; } + HeapFree(GetProcessHeap(),0,args); - return hres; + return S_OK; }
static HRESULT WINAPI ITypeInfo_fnInvoke(