oleaut32: Simplify ICreateTypeInfo2_SetTypeFlags implementation.

This commit is contained in:
Piotr Caban 2010-03-15 23:37:48 +01:00 committed by Alexandre Julliard
parent 78166b0b23
commit 6b035d25a8
1 changed files with 24 additions and 32 deletions

View File

@ -1406,43 +1406,35 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetTypeFlags(ICreateTypeInfo2 *iface, U
TRACE("(%p,0x%x)\n", iface, uTypeFlags); TRACE("(%p,0x%x)\n", iface, uTypeFlags);
This->typeinfo->flags = uTypeFlags; if (uTypeFlags & (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL)) {
static const WCHAR stdole2tlb[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
ITypeLib *stdole;
ITypeInfo *dispatch;
HREFTYPE hreftype;
HRESULT hres;
if (uTypeFlags & TYPEFLAG_FDISPATCHABLE) { hres = LoadTypeLib(stdole2tlb, &stdole);
MSFT_GuidEntry foo; if(FAILED(hres))
int guidoffset; return hres;
int fileoffset;
MSFT_ImpInfo impinfo;
static const WCHAR stdole2tlb[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
foo.guid = IID_StdOle; hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
foo.hreftype = 2; ITypeLib_Release(stdole);
foo.next_hash = -1; if(FAILED(hres))
guidoffset = ctl2_alloc_guid(This->typelib, &foo); return hres;
if (guidoffset == -1) return E_OUTOFMEMORY;
fileoffset = ctl2_alloc_importfile(This->typelib, guidoffset, hres = ICreateTypeInfo2_AddRefTypeInfo(iface, dispatch, &hreftype);
This->typelib->typelib_header.lcid2, 2, 0, stdole2tlb); ITypeInfo_Release(dispatch);
if (fileoffset == -1) return E_OUTOFMEMORY; if(FAILED(hres))
return hres;
foo.guid = IID_IDispatch;
foo.hreftype = 1;
foo.next_hash = -1;
guidoffset = ctl2_alloc_guid(This->typelib, &foo);
if (guidoffset == -1) return E_OUTOFMEMORY;
impinfo.flags = TKIND_INTERFACE << 24 | MSFT_IMPINFO_OFFSET_IS_GUID;
impinfo.oImpFile = fileoffset;
impinfo.oGuid = guidoffset;
ctl2_alloc_importinfo(This->typelib, &impinfo);
This->typelib->typelib_header.dispatchpos = 1;
This->typeinfo->typekind |= 0x10;
This->typeinfo->typekind &= ~0x0f;
This->typeinfo->typekind |= TKIND_DISPATCH;
} }
if(uTypeFlags & TYPEFLAG_FDUAL) {
This->typeinfo->typekind |= 0x10;
This->typeinfo->typekind &= ~0x0f;
This->typeinfo->typekind |= TKIND_DISPATCH;
}
This->typeinfo->flags = uTypeFlags;
return S_OK; return S_OK;
} }