Commit 77e1b7a1 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Added implementation of ITypeInfo2_GetRefTypeOfImplType.

parent 31837863
...@@ -1037,6 +1037,10 @@ static void test_CreateTypeLib(void) { ...@@ -1037,6 +1037,10 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
ok(hres == S_OK, "got %08x\n", hres); 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)); memset(&funcdesc, 0, sizeof(FUNCDESC));
funcdesc.funckind = FUNC_PUREVIRTUAL; funcdesc.funckind = FUNC_PUREVIRTUAL;
funcdesc.invkind = INVOKE_PROPERTYGET; funcdesc.invkind = INVOKE_PROPERTYGET;
...@@ -1168,6 +1172,9 @@ static void test_CreateTypeLib(void) { ...@@ -1168,6 +1172,9 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2); hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2);
ok(hres == S_OK, "got %08x\n", hres); 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); hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
ok(hres == S_OK, "got %08x\n", hres); ok(hres == S_OK, "got %08x\n", hres);
...@@ -1180,6 +1187,10 @@ static void test_CreateTypeLib(void) { ...@@ -1180,6 +1187,10 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
ok(hres == S_OK, "got %08x\n", hres); 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); hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres); ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
...@@ -1240,6 +1251,18 @@ static void test_CreateTypeLib(void) { ...@@ -1240,6 +1251,18 @@ static void test_CreateTypeLib(void) {
ok(hres == S_OK, "got %08x\n", hres); ok(hres == S_OK, "got %08x\n", hres);
ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags); 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); ITypeInfo_Release(ti);
ICreateTypeInfo_Release(createti); ICreateTypeInfo_Release(createti);
......
...@@ -2835,8 +2835,35 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeOfImplType( ...@@ -2835,8 +2835,35 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeOfImplType(
UINT index, UINT index,
HREFTYPE* pRefType) HREFTYPE* pRefType)
{ {
FIXME("(%p,%d,%p), stub!\n", iface, index, pRefType); ICreateTypeInfo2Impl *This = impl_from_ITypeInfo2(iface);
return E_OUTOFMEMORY; 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( ...@@ -2968,10 +2995,10 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo(
WCHAR *filename; WCHAR *filename;
HRESULT hres; 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; 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]; 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]; guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][impinfo->oGuid];
...@@ -2990,7 +3017,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo( ...@@ -2990,7 +3017,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo(
int i = 0; int i = 0;
for(iter=This->typelib->typeinfos; iter; iter=iter->next_typeinfo) { 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; *ppTInfo = (ITypeInfo*)&iter->lpVtblTypeInfo2;
ITypeLib_AddRef(*ppTInfo); ITypeLib_AddRef(*ppTInfo);
......
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