From 3c747fec5024394fc35d5f5321f1f4cc87421f76 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 15 Mar 2010 23:38:57 +0100 Subject: [PATCH] oleaut32: Added ICreateTypeInfo2_SetFuncHelpContext implementation. --- dlls/oleaut32/tests/typelib.c | 12 +++++++++++ dlls/oleaut32/typelib2.c | 38 +++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 7b1d0fe4f1..0b26e6c889 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -1106,6 +1106,9 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); + hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab); + ok(hres == S_OK, "got %08x\n", hres); + funcdesc.invkind = INVOKE_PROPERTYPUT; hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres); @@ -1126,10 +1129,19 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); + hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab); + ok(hres == S_OK, "got %08x\n", hres); + funcdesc.invkind = INVOKE_PROPERTYPUTREF; hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); + hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0x201); + ok(hres == S_OK, "got %08x\n", hres); + funcdesc.memid = 1; funcdesc.lprgelemdescParam = NULL; funcdesc.invkind = INVOKE_FUNC; diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index d931c4554f..08f650cca0 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -2264,8 +2264,42 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncHelpContext( UINT index, DWORD dwHelpContext) { - FIXME("(%p,%d,%d), stub!\n", iface, index, dwHelpContext); - return E_OUTOFMEMORY; + ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface; + CyclicList *func; + int *typedata; + int size; + + TRACE("(%p,%d,%d)\n", iface, index, dwHelpContext); + + if(This->typeinfo->cElementtypeinfo->cElement == index) + func = This->typedata; + else + for(func=This->typedata->next->next; func!=This->typedata; func=func->next) + if(index-- == 0) + break; + + typedata = func->u.data; + + /* Compute func size without arguments */ + size = typedata[0] - typedata[5]*(typedata[4]&0x1000?16:12); + + /* Allocate memory for HelpContext if needed */ + if(size < 7*sizeof(int)) { + typedata = HeapReAlloc(GetProcessHeap(), 0, typedata, typedata[0]+sizeof(int)); + if(!typedata) + return E_OUTOFMEMORY; + + memmove(&typedata[7], &typedata[6], typedata[0]-sizeof(int)*6); + typedata[0] += sizeof(int); + This->typedata->next->u.val += sizeof(int); + func->u.data = typedata; + } + + typedata[6] = dwHelpContext; + return S_OK; } /****************************************************************************** -- 2.32.0.93.g670b81a890