Module: wine Branch: master Commit: ea6b690f823daec63ac80da1cb7e2364e5d679be URL: http://source.winehq.org/git/wine.git/?a=commit;h=ea6b690f823daec63ac80da1cb...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Feb 24 14:26:32 2010 +0100
oleaut32: Improve TKIND_COCLASS handling while creating typelib.
---
dlls/oleaut32/tests/typelib.c | 39 +++++++++++++++++++++++++++++++++------ dlls/oleaut32/typelib2.c | 9 ++++++--- 2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 4da8ba5..6f2fcd9 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -972,6 +972,7 @@ static void test_CreateTypeLib(void) { static const WCHAR stdoleW[] = {'s','t','d','o','l','e','2','.','t','l','b',0}; static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0}; static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0}; + static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0}; static WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0}; static OLECHAR func1W[] = {'f','u','n','c','1',0}; static OLECHAR func2W[] = {'f','u','n','c','2',0}; @@ -983,7 +984,7 @@ static void test_CreateTypeLib(void) { char filename[MAX_PATH]; WCHAR filenameW[MAX_PATH]; ICreateTypeLib2 *createtl; - ICreateTypeInfo *createti, *createti2; + ICreateTypeInfo *createti; ITypeLib *tl, *stdole; ITypeInfo *interface1, *interface2, *unknown, *ti; FUNCDESC funcdesc; @@ -1163,13 +1164,13 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
- hres = ICreateTypeLib_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti2); + hres = ICreateTypeLib_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti); ok(hres == S_OK, "got %08x\n", hres);
- hres = ICreateTypeInfo_QueryInterface(createti2, &IID_ITypeInfo, (void**)&interface2); + hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2); ok(hres == S_OK, "got %08x\n", hres);
- hres = ICreateTypeInfo_AddRefTypeInfo(createti2, interface1, &hreftype); + hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype); ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeInfo_GetRefTypeInfo(interface2, 0, &ti); @@ -1178,10 +1179,36 @@ static void test_CreateTypeLib(void) {
ITypeInfo_Release(ti);
- hres = ICreateTypeInfo_AddImplType(createti2, 0, hreftype); + hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); + ok(hres == S_OK, "got %08x\n", hres); + + ICreateTypeInfo_Release(createti); + + hres = ICreateTypeLib_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype); ok(hres == S_OK, "got %08x\n", hres);
- ICreateTypeInfo_Release(createti2); + hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + + hres = ICreateTypeInfo_AddImplType(createti, 2, hreftype); + ok(hres == S_OK, "got %08x\n", hres); + + ICreateTypeInfo_Release(createti);
hres = ITypeInfo_GetTypeAttr(interface1, &typeattr); ok(hres == S_OK, "got %08x\n", hres); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 7ccb400..a8d83bf 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -1799,12 +1799,12 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddImplType( if( index != 0) return TYPE_E_ELEMENTNOTFOUND;
This->typeinfo->datatype1 = hRefType; - This->typeinfo->cImplTypes++; } else { FIXME("AddImplType unsupported on typekind %d\n", This->typeinfo->typekind & 15); return E_OUTOFMEMORY; }
+ This->typeinfo->cImplTypes++; return S_OK; }
@@ -2254,6 +2254,9 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut(
TRACE("(%p)\n", iface);
+ if((This->typeinfo->typekind&0xf) == TKIND_COCLASS) + return S_OK; + /* Validate inheritance */ This->typeinfo->datatype2 = 0; hreftype = This->typeinfo->datatype1; @@ -3933,9 +3936,9 @@ static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface) filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_TYPEINFO); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_GUIDHASH); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_GUID); + filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_REFERENCES); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_IMPORTINFO); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_IMPORTFILES); - filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_REFERENCES); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_NAMEHASH); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_NAME); filepos += ctl2_finalize_segment(This, filepos, MSFT_SEG_STRING); @@ -3958,9 +3961,9 @@ static HRESULT WINAPI ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2 * iface) if (!ctl2_write_segment(This, hFile, MSFT_SEG_TYPEINFO )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_GUIDHASH )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_GUID )) return retval; + if (!ctl2_write_segment(This, hFile, MSFT_SEG_REFERENCES )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_IMPORTINFO )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_IMPORTFILES )) return retval; - if (!ctl2_write_segment(This, hFile, MSFT_SEG_REFERENCES )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_NAMEHASH )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_NAME )) return retval; if (!ctl2_write_segment(This, hFile, MSFT_SEG_STRING )) return retval;