oleaut32: Update TypeInfo flags when object inherits IDispatch.

This commit is contained in:
Piotr Caban 2010-02-25 15:08:11 +01:00 committed by Alexandre Julliard
parent 247b11e046
commit ccdafdb9c3
2 changed files with 54 additions and 4 deletions

View file

@ -973,6 +973,7 @@ static void test_CreateTypeLib(void) {
static OLECHAR typelibW[] = {'t','y','p','e','l','i','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 dualW[] = {'d','u','a','l',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};
@ -987,7 +988,7 @@ static void test_CreateTypeLib(void) {
ICreateTypeLib2 *createtl;
ICreateTypeInfo *createti;
ITypeLib *tl, *stdole;
ITypeInfo *interface1, *interface2, *unknown, *ti;
ITypeInfo *interface1, *interface2, *unknown, *dispatch, *ti;
FUNCDESC funcdesc;
ELEMDESC elemdesc[5];
PARAMDESCEX paramdescex;
@ -1008,6 +1009,9 @@ static void test_CreateTypeLib(void) {
hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unknown);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
ok(hres == S_OK, "got %08x\n", hres);
GetTempFileNameA(".", "tlb", 0, filename);
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH);
@ -1309,6 +1313,37 @@ static void test_CreateTypeLib(void) {
ICreateTypeInfo_Release(createti);
hres = ICreateTypeLib_CreateTypeInfo(createtl, dualW, TKIND_INTERFACE, &createti);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_AddRefTypeInfo(createti, dispatch, &hreftype);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti);
ok(hres == S_OK, "got %08x\n", hres);
hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
ok(hres == S_OK, "got %08x\n", hres);
ok(typeattr->cbSizeInstance == 4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
ok(typeattr->cbSizeVft == 28, "cbSizeVft = %d\n", typeattr->cbSizeVft);
ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
ok(typeattr->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "wTypeFlags = %d\n", typeattr->wTypeFlags);
ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
ITypeInfo_ReleaseTypeAttr(ti, typeattr);
ITypeInfo_Release(ti);
ICreateTypeInfo_Release(createti);
hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
ok(hres == S_OK, "got %08x\n", hres);
ok(typeattr->cbSizeInstance == 4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
@ -1348,6 +1383,7 @@ static void test_CreateTypeLib(void) {
ITypeInfo_Release(interface2);
ITypeInfo_Release(interface1);
ITypeInfo_Release(dispatch);
ITypeInfo_Release(unknown);
ITypeLib_Release(tl);

View file

@ -170,6 +170,9 @@ typedef struct tagICreateTypeLib2Impl
char *typelib_segment_data[MSFT_SEG_MAX];
int typelib_segment_block_length[MSFT_SEG_MAX];
int typelib_guids; /* Number of defined typelib guids */
int typeinfo_guids; /* Number of defined typeinfo guids */
INT typelib_typeinfo_offsets[0x200]; /* Hope that's enough. */
INT *typelib_namehash_segment;
@ -1547,7 +1550,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
WCHAR name[MAX_PATH], *p;
TLIBATTR *tlibattr;
TYPEATTR *typeattr;
MSFT_GuidEntry guid;
MSFT_GuidEntry guid, *check_guid;
MSFT_ImpInfo impinfo;
int guid_offset, import_offset;
DWORD len;
@ -1559,7 +1562,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
return hres;
guid.guid = tlibattr->guid;
guid.hreftype = 2;
guid.hreftype = This->typelib->typelib_guids*12+2;
guid.next_hash = -1;
guid_offset = ctl2_alloc_guid(This->typelib, &guid);
@ -1568,6 +1571,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
return E_OUTOFMEMORY;
}
check_guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][guid_offset];
if(check_guid->hreftype == guid.hreftype)
This->typelib->typelib_guids++;
/* Get import file name */
/* Check HKEY_CLASSES_ROOT\TypeLib\{GUID}\{Ver}\0\win32 */
len = MAX_PATH;
@ -1599,7 +1606,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
return hres;
guid.guid = typeattr->guid;
guid.hreftype = 1;
guid.hreftype = This->typelib->typeinfo_guids*12+1;
guid.next_hash = -1;
ITypeInfo_ReleaseTypeAttr(pTInfo, typeattr);
@ -1607,6 +1614,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
if(guid_offset == -1)
return E_OUTOFMEMORY;
check_guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][guid_offset];
if(check_guid->hreftype == guid.hreftype)
This->typelib->typeinfo_guids++;
/* Allocate importinfo */
impinfo.flags = ((This->typeinfo->typekind&0xf)<<24) | MSFT_IMPINFO_OFFSET_IS_GUID;
impinfo.oImpFile = import_offset;
@ -2316,6 +2327,9 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut(
if(FAILED(hres))
return hres;
if(!memcmp(&typeattr->guid, &IID_IDispatch, sizeof(IDispatch)))
This->typeinfo->flags |= TYPEFLAG_FDISPATCHABLE;
This->typeinfo->datatype2 += (typeattr->cFuncs<<16) + 1;
ITypeInfo_ReleaseTypeAttr(cur, typeattr);