Module: wine Branch: master Commit: 77e1b7a13f858e678e8918a3c7e3987ebd93d385 URL: http://source.winehq.org/git/wine.git/?a=commit;h=77e1b7a13f858e678e8918a3c7...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Feb 24 14:28:09 2010 +0100
oleaut32: Added implementation of ITypeInfo2_GetRefTypeOfImplType.
---
dlls/oleaut32/tests/typelib.c | 23 +++++++++++++++++++++++ dlls/oleaut32/typelib2.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index be90570..aaaaceb 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -1037,6 +1037,10 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); ok(hres == S_OK, "got %08x\n", hres);
+ hres = ITypeInfo_GetRefTypeOfImplType(interface1, 0, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + ok(hreftype == 3, "hreftype = %d\n", hreftype); + memset(&funcdesc, 0, sizeof(FUNCDESC)); funcdesc.funckind = FUNC_PUREVIRTUAL; funcdesc.invkind = INVOKE_PROPERTYGET; @@ -1168,6 +1172,9 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2); ok(hres == S_OK, "got %08x\n", hres);
+ hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype); ok(hres == S_OK, "got %08x\n", hres);
@@ -1180,6 +1187,10 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); ok(hres == S_OK, "got %08x\n", hres);
+ hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + ok(hreftype == 2, "hreftype = %d\n", hreftype); + hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT); ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
@@ -1240,6 +1251,18 @@ static void test_CreateTypeLib(void) { ok(hres == S_OK, "got %08x\n", hres); ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
+ hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + ok(hreftype == 0, "hreftype = %d\n", hreftype); + + hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + ok(hreftype == 1, "hreftype = %d\n", hreftype); + + hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + ok(hreftype == 1, "hreftype = %d\n", hreftype); + ITypeInfo_Release(ti);
ICreateTypeInfo_Release(createti); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 8a3d808..03db7b5 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -2835,8 +2835,35 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeOfImplType( UINT index, HREFTYPE* pRefType) { - FIXME("(%p,%d,%p), stub!\n", iface, index, pRefType); - return E_OUTOFMEMORY; + ICreateTypeInfo2Impl *This = impl_from_ITypeInfo2(iface); + MSFT_RefRecord *ref; + int offset; + + TRACE("(%p,%d,%p)\n", iface, index, pRefType); + + if(!pRefType) + return E_INVALIDARG; + + if(index == -1) { + FIXME("Dual interfaces not handled yet\n"); + return E_NOTIMPL; + } + + if(index >= This->typeinfo->cImplTypes) + return TYPE_E_ELEMENTNOTFOUND; + + if((This->typeinfo->typekind&0xf) == TKIND_INTERFACE) { + *pRefType = This->typeinfo->datatype1 + 2; + return S_OK; + } + + offset = ctl2_find_nth_reference(This->typelib, This->typeinfo->datatype1, index); + if(offset == -1) + return TYPE_E_ELEMENTNOTFOUND; + + ref = (MSFT_RefRecord *)&This->typelib->typelib_segment_data[MSFT_SEG_REFERENCES][offset]; + *pRefType = ref->reftype; + return S_OK; }
/****************************************************************************** @@ -2968,10 +2995,10 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo( WCHAR *filename; HRESULT hres;
- if(hRefType-1 >= This->typelib->typelib_segdir[MSFT_SEG_IMPORTINFO].length) + if((hRefType&(~0x3)) >= This->typelib->typelib_segdir[MSFT_SEG_IMPORTINFO].length) return E_FAIL;
- impinfo = (MSFT_ImpInfo*)&This->typelib->typelib_segment_data[MSFT_SEG_IMPORTINFO][hRefType-1]; + impinfo = (MSFT_ImpInfo*)&This->typelib->typelib_segment_data[MSFT_SEG_IMPORTINFO][hRefType&(~0x3)]; impfile = (MSFT_ImpFile*)&This->typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES][impinfo->oImpFile]; guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][impinfo->oGuid];
@@ -2990,7 +3017,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo( int i = 0;
for(iter=This->typelib->typeinfos; iter; iter=iter->next_typeinfo) { - if(This->typelib->typelib_typeinfo_offsets[i] == hRefType) { + if(This->typelib->typelib_typeinfo_offsets[i] == (hRefType&(~0x3))) { *ppTInfo = (ITypeInfo*)&iter->lpVtblTypeInfo2;
ITypeLib_AddRef(*ppTInfo);