Sync to Wine-20050111: Eric Pouech pouech-eric@wanadoo.fr - Removed excessive statement (break after return or goto, not useful break, not needed vars...) - Fixed some errors in function prototypes. - Some missing const correctness fixes. Francois Gouget fgouget@free.fr - Assorted spelling fixes. Robert Shearman rob@codeweavers.com - Make the DECIMAL_SETZERO macro take a DECIMAL instead of a DECIMAL* as in the Microsoft headers and fix up the only caller. Michael Stefaniuc mstefani@redhat.de - Do not check for non NULL pointer before HeapFree'ing it. It's redundant. Bill Medland billmedland@mercuryspeed.com - Fully initialise the structure to prevent ill-defined behaviour. Jon Griffiths jon_p_griffiths@yahoo.com - Remove unneeded headers to reduce unneeded rebuilds. Robert Shearman rob@codeweavers.com - Implement RPC_E_DISCONNECTED in proxies. Dmitry Timoshkov dmitry@codeweavers.com - Add Russian translations. Huw Davies huw@codeweavers.com - The value of a packed VARIANT can be up to 1L << 26 - 1. - Fix comment to reflect reality and indeed the code. - Remove the remaining dependencies on internal structures from Invoke. - GetTypeAttr should deep copy the typedesc. - Fix return value of GetVarIndexOfMemId. - Remove Invoke's dependence on the internal TLBFuncDesc structure. - Fix memory leaks in some failure cases. - GetFuncIndexOfMemId should respect invkind and return TYPE_E_ELEMENTNOTFOUND if the function cannot be found. - Allocate the TYPEATTR rather than copying it. - For a dual interface the dispinterface's cfuncs should include the inherited functions, cbSizeVft should just be the size of IDispatch's vtbl and we should strip TYPEFLAG_FOLEAUTOMATION. - Fix typelib generation of CARRAYs. Paul Vriens Paul.Vriens@xs4all.nl - use Interlocked* functions in AddRef and Release. - store the result of the Interlocked functions and use only this. Walt Ogburn reuben@ugcs.caltech.edu - In OlePictureImpl_Load, always use DIB_RGB_COLORS because no indexed palette has been defined. Alexandre Julliard julliard@winehq.org - Another warning fix. - Avoid warnings. Modified: trunk/reactos/lib/oleaut32/ole2disp.c Modified: trunk/reactos/lib/oleaut32/oleaut32.rc Modified: trunk/reactos/lib/oleaut32/olefont.c Modified: trunk/reactos/lib/oleaut32/olepicture.c Modified: trunk/reactos/lib/oleaut32/safearray.c Modified: trunk/reactos/lib/oleaut32/tmarshal.c Modified: trunk/reactos/lib/oleaut32/typelib.c Modified: trunk/reactos/lib/oleaut32/typelib16.c Modified: trunk/reactos/lib/oleaut32/typelib2.c Modified: trunk/reactos/lib/oleaut32/varformat.c Modified: trunk/reactos/lib/oleaut32/variant.c _____
Modified: trunk/reactos/lib/oleaut32/ole2disp.c --- trunk/reactos/lib/oleaut32/ole2disp.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/ole2disp.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -33,7 +33,6 @@
#include "winerror.h"
#include "ole2disp.h" -#include "olectl.h"
#include "wine/debug.h"
_____
Modified: trunk/reactos/lib/oleaut32/oleaut32.rc --- trunk/reactos/lib/oleaut32/oleaut32.rc 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/oleaut32.rc 2005-01-12 19:51:40 UTC (rev 12987) @@ -36,12 +36,13 @@
#include "oleaut32_No.rc" #include "oleaut32_Pl.rc" #include "oleaut32_Pt.rc" +#include "oleaut32_Ru.rc" #include "oleaut32_Sv.rc" #include "oleaut32_Th.rc"
/* * FIXME: * Finnish, Greek, Hebrew, Japanese, Korean, Portuguese, - * Russian, Turkish, Slovenian (at least) are localised in XP Home. + * Turkish, Slovenian (at least) are localised in XP Home. * I expect Chinese etc are localised in Asian Editions also. */ _____
Modified: trunk/reactos/lib/oleaut32/olefont.c --- trunk/reactos/lib/oleaut32/olefont.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/olefont.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -454,8 +454,7 @@
{ TRACE("(%p)\n", fontDesc);
- if (fontDesc->description.lpstrName!=0) - HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName); + HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
if (fontDesc->gdiFont!=0) DeleteObject(fontDesc->gdiFont); @@ -1594,8 +1593,7 @@ if (cbRead!=bStringSize) return E_FAIL;
- if (this->description.lpstrName!=0) - HeapFree(GetProcessHeap(), 0, this->description.lpstrName); + HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
len = MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, NULL, 0 ); this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) ); _____
Modified: trunk/reactos/lib/oleaut32/olepicture.c --- trunk/reactos/lib/oleaut32/olepicture.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/olepicture.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -301,7 +301,7 @@
break; } } - if (Obj->data) HeapFree(GetProcessHeap(), 0, Obj->data); + HeapFree(GetProcessHeap(), 0, Obj->data); HeapFree(GetProcessHeap(), 0, Obj); }
@@ -1172,7 +1172,6 @@ FIXME("Trying to load GIF, but no support for libgif/libungif compiled in.\n"); return E_FAIL; #endif - break; } case 0xd8ff: { /* JPEG */ #ifdef HAVE_JPEGLIB_H _____
Modified: trunk/reactos/lib/oleaut32/safearray.c --- trunk/reactos/lib/oleaut32/safearray.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/safearray.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -154,7 +154,7 @@
/* Get the number of cells in a SafeArray */ static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa) { - SAFEARRAYBOUND* psab = psa->rgsabound; + const SAFEARRAYBOUND* psab = psa->rgsabound; USHORT cCount = psa->cDims; ULONG ulNumCells = 1;
_____
Modified: trunk/reactos/lib/oleaut32/tmarshal.c --- trunk/reactos/lib/oleaut32/tmarshal.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/tmarshal.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -42,11 +42,8 @@
#include "winuser.h"
#include "ole2.h" -#include "wine/unicode.h" -#include "ole2disp.h" #include "typelib.h" #include "wine/debug.h" -#include "winternl.h"
static const WCHAR riidW[5] = {'r','i','i','d',0}; static const WCHAR pdispparamsW[] = {'p','d','i','s','p','p','a','r','a','m','s',0}; @@ -1159,7 +1156,6 @@ } i++; } - return E_FAIL; }
static DWORD @@ -1185,6 +1181,13 @@ return E_FAIL; }
+ if (!tpinfo->chanbuf) + { + WARN("Tried to use disconnected proxy\n"); + LeaveCriticalSection(&tpinfo->crit); + return RPC_E_DISCONNECTED; + } + if (relaydeb) { TRACE_(olerelay)("->"); if (iname) @@ -1471,6 +1474,7 @@ proxy->ref = 2; proxy->tinfo = tinfo; memcpy(&proxy->iid,riid,sizeof(*riid)); + proxy->chanbuf = 0; *ppv = (LPVOID)proxy; *ppProxy = (IRpcProxyBuffer *)&(proxy->lpvtbl2); return S_OK; _____
Modified: trunk/reactos/lib/oleaut32/typelib.c --- trunk/reactos/lib/oleaut32/typelib.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/typelib.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -74,7 +74,6 @@
#include "wine/unicode.h" #include "objbase.h" -#include "ole2disp.h" #include "typelib.h" #include "wine/debug.h" #include "variant.h" @@ -848,7 +847,7 @@ { ITypeLib2Vtbl *lpVtbl; ITypeCompVtbl *lpVtblTypeComp; - UINT ref; + ULONG ref; TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */
/* strings can be stored in tlb as multibyte strings BUT they are *always* @@ -959,7 +958,7 @@ { ITypeInfo2Vtbl *lpVtbl; ITypeCompVtbl *lpVtblTypeComp; - UINT ref; + ULONG ref; TYPEATTR TypeAttr ; /* _lots_ of type information. */ ITypeLibImpl * pTypeLib; /* back pointer to typelib */ int index; /* index in this typelib; */ @@ -989,7 +988,7 @@ static struct ITypeInfo2Vtbl tinfvt; static struct ITypeCompVtbl tcompvt;
-static ITypeInfo2 * WINAPI ITypeInfo_Constructor(); +static ITypeInfo2 * WINAPI ITypeInfo_Constructor(void);
typedef struct tagTLBContext { @@ -1277,7 +1276,7 @@
static void dump_TypeInfo(ITypeInfoImpl * pty) { - TRACE("%p ref=%u\n", pty, pty->ref); + TRACE("%p ref=%lu\n", pty, pty->ref); TRACE("attr:%s\n", debugstr_guid(&(pty->TypeAttr.guid))); TRACE("kind:%s\n", typekind_desc[pty->TypeAttr.typekind]); TRACE("fct:%u var:%u impl:%u\n", @@ -1331,7 +1330,51 @@ HeapFree(GetProcessHeap(), 0, ptr); }
+/* deep copy a typedesc */ +static void copy_typedesc(TYPEDESC *out, const TYPEDESC *in) +{ + out->vt = in->vt; + switch(in->vt) { + case VT_PTR: + out->u.lptdesc = HeapAlloc(GetProcessHeap(), 0, sizeof(TYPEDESC)); + copy_typedesc(out->u.lptdesc, in->u.lptdesc); + break; + case VT_USERDEFINED: + out->u.hreftype = in->u.hreftype; + break; + case VT_CARRAY: + out->u.lpadesc = HeapAlloc(GetProcessHeap(), 0, sizeof(ARRAYDESC) + + (in->u.lpadesc->cDims - 1) * sizeof(SAFEARRAYBOUND)); + copy_typedesc(&out->u.lpadesc->tdescElem, &in->u.lpadesc->tdescElem); + out->u.lpadesc->cDims = in->u.lpadesc->cDims; + memcpy(out->u.lpadesc->rgbounds, in->u.lpadesc->rgbounds, in->u.lpadesc->cDims * sizeof(SAFEARRAYBOUND)); + break; + default: + break; + } +}
+/* free()s any allocated memory pointed to by the tdesc. NB does not + free the tdesc itself - this is because the tdesc is typically part + of a larger structure */ +static void free_deep_typedesc(TYPEDESC *tdesc) +{ + switch(tdesc->vt) { + case VT_PTR: + free_deep_typedesc(tdesc->u.lptdesc); + HeapFree(GetProcessHeap(), 0, tdesc->u.lptdesc); + tdesc->u.lptdesc = NULL; + break; + case VT_CARRAY: + free_deep_typedesc(&tdesc->u.lpadesc->tdescElem); + HeapFree(GetProcessHeap(), 0, tdesc->u.lpadesc); + tdesc->u.lpadesc = NULL; + break; + default: + break; + } +} + /********************************************************************** * * Functions for reading MSFT typelibs (those created by CreateTypeLib2) @@ -1473,7 +1516,7 @@
if(offset <0) { /* data are packed in here */ V_VT(pVar) = (offset & 0x7c000000 )>> 26; - V_UNION(pVar, iVal) = offset & 0xffff; + V_UNION(pVar, iVal) = offset & 0x3ffffff; return; } MSFT_ReadLEWords(&(V_VT(pVar)), sizeof(VARTYPE), pcx, @@ -1604,7 +1647,7 @@ * of this (first) part excluding this field. Then follow the records, * for each member there is one record. * - * First entry is always the length of the record (excluding this + * First entry is always the length of the record (including this * length word). * Rest of the record depends on the type of the member. If there is * a field indicating the member type (function variable intereface etc) @@ -3391,10 +3434,11 @@ static ULONG WINAPI ITypeLib2_fnAddRef( ITypeLib2 *iface) { ITypeLibImpl *This = (ITypeLibImpl *)iface; + ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->ref was %u\n",This, This->ref); + TRACE("(%p)->ref was %lu\n",This, ref - 1);
- return ++(This->ref); + return ref; }
/* ITypeLib::Release @@ -3402,12 +3446,11 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface) { ITypeLibImpl *This = (ITypeLibImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref);
- --(This->ref); + TRACE("(%p)->(%lu)\n",This, ref);
- TRACE("(%p)->(%u)\n",This, This->ref); - - if (!This->ref) + if (!ref) { /* remove cache entry */ TRACE("removing from cache list\n"); @@ -3450,7 +3493,7 @@ return 0; }
- return This->ref; + return ref; }
/* ITypeLib::GetTypeInfoCount @@ -4067,12 +4110,12 @@ static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; + ULONG ref = InterlockedIncrement(&This->ref);
- ++(This->ref); ITypeLib2_AddRef((ITypeLib2*)This->pTypeLib);
- TRACE("(%p)->ref is %u\n",This, This->ref); - return This->ref; + TRACE("(%p)->ref is %lu\n",This, ref); + return ref; }
/* ITypeInfo::Release @@ -4080,12 +4123,11 @@ static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref);
- --(This->ref); + TRACE("(%p)->(%lu)\n",This, ref);
- TRACE("(%p)->(%u)\n",This, This->ref); - - if (This->ref) { + if (ref) { /* We don't release ITypeLib when ref=0 becouse it means that funtion is called by ITypeLi2_Release */ ITypeLib2_Release((ITypeLib2*)This->pTypeLib); @@ -4113,7 +4155,7 @@ HeapFree(GetProcessHeap(),0,This); return 0; } - return This->ref; + return ref; }
/* ITypeInfo::GetTypeAttr @@ -4127,8 +4169,18 @@ { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TRACE("(%p)\n",This); - /* FIXME: must do a copy here */ - *ppTypeAttr=&This->TypeAttr; + *ppTypeAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(**ppTypeAttr)); + memcpy(*ppTypeAttr, &This->TypeAttr, sizeof(**ppTypeAttr)); + + if(This->TypeAttr.typekind == TKIND_ALIAS) /* need to deep copy typedesc */ + copy_typedesc(&(*ppTypeAttr)->tdescAlias, &This->TypeAttr.tdescAlias); + + if((*ppTypeAttr)->typekind == TKIND_DISPATCH && (*ppTypeAttr)->wTypeFlags & TYPEFLAG_FDUAL) { + (*ppTypeAttr)->cFuncs = (*ppTypeAttr)->cbSizeVft / 4; /* This should include all the inherited + funcs */ + (*ppTypeAttr)->cbSizeVft = 28; /* This is always the size of IDispatch's vtbl */ + (*ppTypeAttr)->wTypeFlags &= ~TYPEFLAG_FOLEAUTOMATION; + } return S_OK; }
@@ -4683,9 +4735,9 @@ UINT *pArgErr) { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; - TLBFuncDesc * pFDesc; - TLBVarDesc * pVDesc; int i; + unsigned int func_index, var_index; + TYPEKIND type_kind; HRESULT hres;
TRACE("(%p)(%p,id=%ld,flags=0x%08x,%p,%p,%p,%p) partial stub!\n", @@ -4693,31 +4745,30 @@ ); dump_DispParms(pDispParams);
- for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) - if (pFDesc->funcdesc.memid == memid) { - if (pFDesc->funcdesc.invkind & dwFlags) - break; - } - - if (pFDesc) { - if (TRACE_ON(typelib)) dump_TLBFuncDescOne(pFDesc); - /* dump_FUNCDESC(&pFDesc->funcdesc);*/ - switch (pFDesc->funcdesc.funckind) { + hres = ITypeInfo2_GetFuncIndexOfMemId(iface, memid, dwFlags, &func_index); + if (SUCCEEDED(hres)) { + FUNCDESC *func_desc; + + hres = ITypeInfo2_GetFuncDesc(iface, func_index, &func_desc); + if(FAILED(hres)) return hres; + + switch (func_desc->funckind) { case FUNC_PUREVIRTUAL: case FUNC_VIRTUAL: { DWORD res; int numargs, numargs2, argspos, args2pos; DWORD *args , *args2; - VARIANT *rgvarg = HeapAlloc(GetProcessHeap(),0,sizeof(VARIANT)*pFDesc->funcdesc.cParams); + VARIANT *rgvarg = HeapAlloc(GetProcessHeap(), 0, sizeof(VARIANT) * func_desc->cParams);
memcpy(rgvarg,pDispParams->rgvarg,sizeof(VARIANT)*pDispParams->cArgs);
+ hres = S_OK; numargs = 1; numargs2 = 0; - for (i=0;i<pFDesc->funcdesc.cParams;i++) { + for (i = 0; i < func_desc->cParams; i++) { if (i<pDispParams->cArgs) - numargs += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); + numargs += _argsize(func_desc->lprgelemdescParam[i].tdesc.vt); else { numargs += 1; /* sizeof(lpvoid) */ - numargs2 += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); + numargs2 += _argsize(func_desc->lprgelemdescParam[i].tdesc.vt); } }
@@ -4726,14 +4777,14 @@
args[0] = (DWORD)pIUnk; argspos = 1; args2pos = 0; - for (i=0;i<pFDesc->funcdesc.cParams;i++) { - int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); + for (i = 0; i < func_desc->cParams; i++) { + int arglen = _argsize(func_desc->lprgelemdescParam[i].tdesc.vt); if (i<pDispParams->cArgs) { VARIANT *arg = &rgvarg[pDispParams->cArgs-i-1]; - TYPEDESC *tdesc = &pFDesc->funcdesc.lprgelemdescParam[i].tdesc; - USHORT paramFlags = pFDesc->funcdesc.lprgelemdescParam[i].u.paramdesc.wParamFlags; + TYPEDESC *tdesc = &func_desc->lprgelemdescParam[i].tdesc; + USHORT paramFlags = func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags; if (paramFlags & PARAMFLAG_FOPT) { - if(i < pFDesc->funcdesc.cParams-pFDesc->funcdesc.cParamsOpt) + if(i < func_desc->cParams - func_desc->cParamsOpt) ERR("Parameter has PARAMFLAG_FOPT flag but is not one of last cParamOpt parameters\n"); if(V_VT(arg) == VT_EMPTY || ((V_VT(arg) & VT_BYREF) && !V_BYREF(arg))) { @@ -4748,23 +4799,23 @@ } } hres = _copy_arg(iface, tdesc, &args[argspos], arg, tdesc->vt); - if (FAILED(hres)) return hres; + if (FAILED(hres)) goto func_fail; argspos += arglen; - } else if(pFDesc->funcdesc.lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FOPT) { + } else if(func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FOPT) { VARIANT *arg = &rgvarg[i]; - TYPEDESC *tdesc = &pFDesc->funcdesc.lprgelemdescParam[i].tdesc; - if(i < pFDesc->funcdesc.cParams-pFDesc->funcdesc.cParamsOpt) + TYPEDESC *tdesc = &func_desc->lprgelemdescParam[i].tdesc; + if(i < func_desc->cParams - func_desc->cParamsOpt) ERR("Parameter has PARAMFLAG_FOPT flag but is not one of last cParamOpt parameters\n"); - if(pFDesc->funcdesc.lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) + if(func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT) FIXME("PARAMFLAG_FHASDEFAULT flag not supported\n"); V_VT(arg) = VT_ERROR; V_ERROR(arg) = DISP_E_PARAMNOTFOUND; arglen = _argsize(VT_ERROR); hres = _copy_arg(iface, tdesc, &args[argspos], arg, tdesc->vt); - if (FAILED(hres)) return hres; + if (FAILED(hres)) goto func_fail; argspos += arglen; } else { - TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i].tdesc); + TYPEDESC *tdesc = &(func_desc->lprgelemdescParam[i].tdesc); if (tdesc->vt != VT_PTR) FIXME("set %d to pointer for get (type is %d)\n",i,tdesc->vt); /*FIXME: give pointers for the rest, so propertyget works*/ @@ -4774,32 +4825,28 @@ if ((tdesc->vt == VT_PTR) && (tdesc->u.lptdesc->vt == VT_VARIANT) && pVarResult - ) - args[argspos]= (DWORD)pVarResult; + ) + args[argspos]= (DWORD)pVarResult; argspos += 1; args2pos += arglen; } } - if (pFDesc->funcdesc.cParamsOpt < 0) - FIXME("Does not support optional parameters (%d)\n", - pFDesc->funcdesc.cParamsOpt - ); + if (func_desc->cParamsOpt < 0) + FIXME("Does not support optional parameters (%d)\n", func_desc->cParamsOpt);
- res = _invoke((*(FARPROC**)pIUnk)[pFDesc->funcdesc.oVft/4], - pFDesc->funcdesc.callconv, + res = _invoke((*(FARPROC**)pIUnk)[func_desc->oVft/4], + func_desc->callconv, numargs, args );
- HeapFree(GetProcessHeap(), 0, rgvarg); - if (pVarResult && (dwFlags & (DISPATCH_PROPERTYGET))) { args2pos = 0; - for (i=0;i<pFDesc->funcdesc.cParams-pDispParams->cArgs;i++) { - int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); - TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i+pDispParams->cArgs].tdesc); - TYPEDESC i4_tdesc; - i4_tdesc.vt = VT_I4; + for (i = 0; i < func_desc->cParams - pDispParams->cArgs; i++) { + int arglen = _argsize(func_desc->lprgelemdescParam[i].tdesc.vt); + TYPEDESC *tdesc = &(func_desc->lprgelemdescParam[i + pDispParams->cArgs].tdesc); + TYPEDESC i4_tdesc; + i4_tdesc.vt = VT_I4;
/* If we are a pointer to a variant, we are done already */ if ((tdesc->vt==VT_PTR)&&(tdesc->u.lptdesc->vt==VT_VARIANT)) @@ -4815,16 +4862,16 @@ TYPEATTR *tattr;
hres = ITypeInfo_GetRefTypeInfo(iface,tdesc->u.hreftype,&tinfo2); - if (hres) { + if (FAILED(hres)) { FIXME("Could not get typeinfo of hreftype %lx for VT_USERDEFINED, while coercing. Copying 4 byte.\n",tdesc->u.hreftype); - return E_FAIL; + goto func_fail; } ITypeInfo_GetTypeAttr(tinfo2,&tattr); switch (tattr->typekind) { case TKIND_ENUM: - /* force the return type to be VT_I4 */ - tdesc = &i4_tdesc; - break; + /* force the return type to be VT_I4 */ + tdesc = &i4_tdesc; + break; case TKIND_ALIAS: TRACE("TKIND_ALIAS to vt 0x%x\n",tattr->tdescAlias.vt); tdesc = &(tattr->tdescAlias); @@ -4859,57 +4906,67 @@ args2pos += arglen; } } +func_fail: + HeapFree(GetProcessHeap(), 0, rgvarg); HeapFree(GetProcessHeap(),0,args2); HeapFree(GetProcessHeap(),0,args); - return S_OK; + break; } case FUNC_DISPATCH: { IDispatch *disp; - HRESULT hr;
- hr = IUnknown_QueryInterface((LPUNKNOWN)pIUnk,&IID_IDispatch,(LPVOID*)&disp); - if (hr) { + hres = IUnknown_QueryInterface((LPUNKNOWN)pIUnk,&IID_IDispatch,(LPVOID*)&disp); + if (SUCCEEDED(hres)) { + FIXME("Calling Invoke in IDispatch iface. untested!\n"); + hres = IDispatch_Invoke( + disp,memid,&IID_NULL,LOCALE_USER_DEFAULT,dwFlags,pDispParams, + pVarResult,pExcepInfo,pArgErr + ); + if (FAILED(hres)) + FIXME("IDispatch::Invoke failed with %08lx. (Could be not a real error?)\n", hres); + IDispatch_Release(disp); + } else FIXME("FUNC_DISPATCH used on object without IDispatch iface?\n"); - return hr; - } - FIXME("Calling Invoke in IDispatch iface. untested!\n"); - hr = IDispatch_Invoke( - disp,memid,&IID_NULL,LOCALE_USER_DEFAULT,dwFlags,pDispParams, - pVarResult,pExcepInfo,pArgErr - ); - if (hr) - FIXME("IDispatch::Invoke failed with %08lx. (Could be not a real error?)\n",hr); - IDispatch_Release(disp); - return hr; + break; } default: - FIXME("Unknown function invocation type %d\n",pFDesc->funcdesc.funckind); - return E_FAIL; - } - } else { - for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) { - if (pVDesc->vardesc.memid == memid) { - FIXME("varseek: Found memid name %s, but variable-based invoking not supported\n",debugstr_w(((LPWSTR)pVDesc->Name))); - dump_TLBVarDesc(pVDesc); - break; - } - } + FIXME("Unknown function invocation type %d\n", func_desc->funckind); + hres = E_FAIL; + break; + } + + ITypeInfo2_ReleaseFuncDesc(iface, func_desc); + return hres; + + } else if(SUCCEEDED(hres = ITypeInfo2_GetVarIndexOfMemId(iface, memid, &var_index))) { + VARDESC *var_desc; + + hres = ITypeInfo2_GetVarDesc(iface, var_index, &var_desc); + if(FAILED(hres)) return hres; + + FIXME("varseek: Found memid, but variable-based invoking not supported\n"); + dump_VARDESC(var_desc); + ITypeInfo2_ReleaseVarDesc(iface, var_desc); + return E_NOTIMPL; } + /* not found, look for it in inherited interfaces */ - if (This->TypeAttr.cImplTypes && - (This->TypeAttr.typekind==TKIND_INTERFACE || This->TypeAttr.typekind==TKIND_DISPATCH)) { - /* recursive search */ - ITypeInfo *pTInfo; - HRESULT hr; - hr=ITypeInfo_GetRefTypeInfo(iface, This->impltypelist->hRef, &pTInfo); - if(SUCCEEDED(hr)){ - hr=ITypeInfo_Invoke(pTInfo,pIUnk,memid,dwFlags,pDispParams,pVarResult,pE xcepInfo,pArgErr); - ITypeInfo_Release(pTInfo); - return hr; + ITypeInfo2_GetTypeKind(iface, &type_kind); + if(type_kind == TKIND_INTERFACE || type_kind == TKIND_DISPATCH) { + HREFTYPE ref_type; + if(SUCCEEDED(ITypeInfo2_GetRefTypeOfImplType(iface, 0, &ref_type))) { + /* recursive search */ + ITypeInfo *pTInfo; + hres = ITypeInfo_GetRefTypeInfo(iface, ref_type, &pTInfo); + if(SUCCEEDED(hres)){ + hres = ITypeInfo_Invoke(pTInfo,pIUnk,memid,dwFlags,pDispParams,pVarResult,pExce pInfo,pArgErr); + ITypeInfo_Release(pTInfo); + return hres; + } + WARN("Could not search inherited interface!\n"); } - WARN("Could not search inherited interface!\n"); } - ERR("did not find member id %d, flags %d!\n", (int)memid, dwFlags); + ERR("did not find member id %08lx, flags %d!\n", memid, dwFlags); return DISP_E_MEMBERNOTFOUND; }
@@ -5176,6 +5233,9 @@ { ITypeInfoImpl *This = (ITypeInfoImpl *)iface; TRACE("(%p)->(%p)\n", This, pTypeAttr); + if(This->TypeAttr.typekind == TKIND_ALIAS) + free_deep_typedesc(&pTypeAttr->tdescAlias); + HeapFree(GetProcessHeap(), 0, pTypeAttr); }
/* ITypeInfo::ReleaseFuncDesc @@ -5242,18 +5302,18 @@ TLBFuncDesc *pFuncInfo; int i; HRESULT result; - /* FIXME: should check for invKind??? */ - for(i=0, pFuncInfo=This->funclist;pFuncInfo && - memid != pFuncInfo->funcdesc.memid; i++, pFuncInfo=pFuncInfo->next); - if(pFuncInfo){ - *pFuncIndex=i; - result= S_OK; - }else{ - *pFuncIndex=0; - result=E_INVALIDARG; - } + + for(i = 0, pFuncInfo = This->funclist; pFuncInfo; i++, pFuncInfo=pFuncInfo->next) + if(memid == pFuncInfo->funcdesc.memid && (invKind & pFuncInfo->funcdesc.invkind)) + break; + if(pFuncInfo) { + *pFuncIndex = i; + result = S_OK; + } else + result = TYPE_E_ELEMENTNOTFOUND; + TRACE("(%p) memid 0x%08lx invKind 0x%04x -> %s\n", This, - memid, invKind, SUCCEEDED(result)? "SUCCES":"FAILED"); + memid, invKind, SUCCEEDED(result) ? "SUCCESS" : "FAILED"); return result; }
@@ -5273,15 +5333,14 @@ for(i=0, pVarInfo=This->varlist; pVarInfo && memid != pVarInfo->vardesc.memid; i++, pVarInfo=pVarInfo->next) ; - if(pVarInfo){ - *pVarIndex=i; - result= S_OK; - }else{ - *pVarIndex=0; - result=E_INVALIDARG; - } + if(pVarInfo) { + *pVarIndex = i; + result = S_OK; + } else + result = TYPE_E_ELEMENTNOTFOUND; + TRACE("(%p) memid 0x%08lx -> %s\n", This, - memid, SUCCEEDED(result)? "SUCCES":"FAILED"); + memid, SUCCEEDED(result) ? "SUCCESS" : "FAILED"); return result; }
_____
Modified: trunk/reactos/lib/oleaut32/typelib16.c --- trunk/reactos/lib/oleaut32/typelib16.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/typelib16.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -39,7 +39,6 @@
#include "objbase.h" #include "ole2disp.h" -#include "typelib.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole); _____
Modified: trunk/reactos/lib/oleaut32/typelib2.c --- trunk/reactos/lib/oleaut32/typelib2.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/typelib2.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -48,10 +48,8 @@
#include "wine/unicode.h" #include "objbase.h" -#include "ole2disp.h" #include "typelib.h" #include "wine/debug.h" -#include "variant.h"
WINE_DEFAULT_DEBUG_CHANNEL(typelib2); /* WINE_DEFAULT_DEBUG_CHANNEL(ole); */ @@ -150,7 +148,7 @@ ICreateTypeLib2Vtbl *lpVtbl; ITypeLib2Vtbl *lpVtblTypeLib2;
- UINT ref; + ULONG ref;
WCHAR *filename;
@@ -176,7 +174,7 @@ ICreateTypeInfo2Vtbl *lpVtbl; ITypeInfo2Vtbl *lpVtblTypeInfo2;
- UINT ref; + ULONG ref;
ICreateTypeLib2Impl *typelib; MSFT_TypeInfoBase *typeinfo; @@ -979,18 +977,25 @@ break;
case VT_CARRAY: + { /* FIXME: Make with the error checking. */ - FIXME("Array vartype, hacking badly.\n"); + int num_dims = tdesc->u.lpadesc->cDims, elements = 1, dim;
ctl2_encode_typedesc(This, &tdesc->u.lpadesc->tdescElem, &target_type, width, alignment, NULL); - arrayoffset = ctl2_alloc_segment(This, MSFT_SEG_ARRAYDESC, 16, 0); + arrayoffset = ctl2_alloc_segment(This, MSFT_SEG_ARRAYDESC, (2 + 2 * num_dims) * sizeof(int), 0); arraydata = (void *)&This->typelib_segment_data[MSFT_SEG_ARRAYDESC][arrayoffset];
arraydata[0] = target_type; - arraydata[1] = 0x00080001; - arraydata[2] = 0x8; - arraydata[3] = 0; + arraydata[1] = num_dims; + arraydata[1] |= ((num_dims * 2 * sizeof(int)) << 16); + arraydata += 2;
+ for(dim = 0; dim < num_dims; dim++) { + arraydata[0] = tdesc->u.lpadesc->rgbounds[dim].cElements; + arraydata[1] = tdesc->u.lpadesc->rgbounds[dim].lLbound; + elements *= tdesc->u.lpadesc->rgbounds[dim].cElements; + arraydata += 2; + } typeoffset = ctl2_alloc_segment(This, MSFT_SEG_TYPEDESC, 8, 0); typedata = (void *)&This->typelib_segment_data[MSFT_SEG_TYPEDESC][typeoffset];
@@ -998,12 +1003,11 @@ typedata[1] = arrayoffset;
*encoded_tdesc = typeoffset; - *width = 8; - *alignment = 1; - *decoded_size = sizeof(ARRAYDESC); + *width = *width * elements; + *decoded_size = sizeof(ARRAYDESC) + (num_dims - 1) * sizeof(SAFEARRAYBOUND);
break; - + } case VT_USERDEFINED: TRACE("USERDEFINED.\n"); for (typeoffset = 0; typeoffset < This->typelib_segdir[MSFT_SEG_TYPEDESC].length; typeoffset += 8) { @@ -1138,10 +1142,11 @@ static ULONG WINAPI ICreateTypeInfo2_fnAddRef(ICreateTypeInfo2 *iface) { ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; + ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->ref was %u\n",This, This->ref); + TRACE("(%p)->ref was %lu\n",This, ref - 1);
- return ++(This->ref); + return ref; }
/*********************************************************************** ******* @@ -1152,12 +1157,11 @@ static ULONG WINAPI ICreateTypeInfo2_fnRelease(ICreateTypeInfo2 *iface) { ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; + ULONG ref = InterlockedDecrement(&This->ref);
- --(This->ref); + TRACE("(%p)->(%lu)\n",This, ref);
- TRACE("(%p)->(%u)\n",This, This->ref); - - if (!This->ref) { + if (!ref) { if (This->typelib) { ICreateTypeLib2_fnRelease((ICreateTypeLib2 *)This->typelib); This->typelib = NULL; @@ -1168,7 +1172,7 @@ return 0; }
- return This->ref; + return ref; }
@@ -3005,10 +3009,11 @@ static ULONG WINAPI ICreateTypeLib2_fnAddRef(ICreateTypeLib2 *iface) { ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface; + ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)->ref was %u\n",This, This->ref); + TRACE("(%p)->ref was %lu\n",This, ref - 1);
- return ++(This->ref); + return ref; }
/*********************************************************************** ******* @@ -3019,30 +3024,25 @@ static ULONG WINAPI ICreateTypeLib2_fnRelease(ICreateTypeLib2 *iface) { ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface; + ULONG ref = InterlockedDecrement(&This->ref);
- --(This->ref); + TRACE("(%p)->(%lu)\n",This, ref);
- TRACE("(%p)->(%u)\n",This, This->ref); - - if (!This->ref) { + if (!ref) { int i;
for (i = 0; i < MSFT_SEG_MAX; i++) { - if (This->typelib_segment_data[i]) { - HeapFree(GetProcessHeap(), 0, This->typelib_segment_data[i]); - This->typelib_segment_data[i] = NULL; - } + HeapFree(GetProcessHeap(), 0, This->typelib_segment_data[i]); + This->typelib_segment_data[i] = NULL; }
- if (This->filename) { - HeapFree(GetProcessHeap(), 0, This->filename); - This->filename = NULL; - } + HeapFree(GetProcessHeap(), 0, This->filename); + This->filename = NULL;
while (This->typeinfos) { ICreateTypeInfo2Impl *typeinfo = This->typeinfos; This->typeinfos = typeinfo->next_typeinfo; - if (typeinfo->typedata) HeapFree(GetProcessHeap(), 0, typeinfo->typedata); + HeapFree(GetProcessHeap(), 0, typeinfo->typedata); HeapFree(GetProcessHeap(), 0, typeinfo); }
@@ -3050,7 +3050,7 @@ return 0; }
- return This->ref; + return ref; }
_____
Modified: trunk/reactos/lib/oleaut32/varformat.c --- trunk/reactos/lib/oleaut32/varformat.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/varformat.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -1310,12 +1310,10 @@
case FMT_NUM_YES_NO: boolFlag = VAR_BOOLYESNO; goto VARIANT_FormatNumber_Bool; - break;
case FMT_NUM_ON_OFF: boolFlag = VAR_BOOLONOFF; goto VARIANT_FormatNumber_Bool; - break;
case FMT_NUM_TRUE_FALSE: boolFlag = VAR_LOCALBOOL; @@ -1452,7 +1450,6 @@ ERR("Unknown token 0x%02x!\n", *pToken); hRes = E_INVALIDARG; goto VARIANT_FormatNumber_Exit; - break; } if (localeValue) { @@ -1762,7 +1759,6 @@ ERR("Unknown token 0x%02x!\n", *pToken); hRes = E_INVALIDARG; goto VARIANT_FormatDate_Exit; - break; } if (localeValue) { @@ -1916,7 +1912,6 @@ ERR("Unknown token 0x%02x!\n", *pToken); hRes = E_INVALIDARG; goto VARIANT_FormatString_Exit; - break; } pToken++; } _____
Modified: trunk/reactos/lib/oleaut32/variant.c --- trunk/reactos/lib/oleaut32/variant.c 2005-01-12 19:51:26 UTC (rev 12986) +++ trunk/reactos/lib/oleaut32/variant.c 2005-01-12 19:51:40 UTC (rev 12987) @@ -764,24 +764,24 @@
switch (V_TYPE(pv)) { case VT_I1: - case VT_UI1: return sizeof(BYTE); break; + case VT_UI1: return sizeof(BYTE); case VT_I2: - case VT_UI2: return sizeof(SHORT); break; + case VT_UI2: return sizeof(SHORT); case VT_INT: case VT_UINT: case VT_I4: - case VT_UI4: return sizeof(LONG); break; + case VT_UI4: return sizeof(LONG); case VT_I8: - case VT_UI8: return sizeof(LONGLONG); break; - case VT_R4: return sizeof(float); break; - case VT_R8: return sizeof(double); break; - case VT_DATE: return sizeof(DATE); break; - case VT_BOOL: return sizeof(VARIANT_BOOL); break; + case VT_UI8: return sizeof(LONGLONG); + case VT_R4: return sizeof(float); + case VT_R8: return sizeof(double); + case VT_DATE: return sizeof(DATE); + case VT_BOOL: return sizeof(VARIANT_BOOL); case VT_DISPATCH: case VT_UNKNOWN: - case VT_BSTR: return sizeof(void*); break; - case VT_CY: return sizeof(CY); break; - case VT_ERROR: return sizeof(SCODE); break; + case VT_BSTR: return sizeof(void*); + case VT_CY: return sizeof(CY); + case VT_ERROR: return sizeof(SCODE); } TRACE("Shouldn't be called for vt %s%s!\n", debugstr_VT(pv), debugstr_VF(pv)); return 0; @@ -3925,7 +3925,7 @@ * Failure: An HRESULT error code indicating the error. * * NOTES - * - Strictly speaking, this function performs a bitwise ones compliment + * - Strictly speaking, this function performs a bitwise ones complement * on the variants value (after possibly converting to VT_I4, see below). * This only behaves like a boolean not operation if the value in * pVarIn is either VARIANT_TRUE or VARIANT_FALSE and the type is signed.