Commit 3102176c authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Improved ICreateTypeInfo2_SetFuncAndParamNames implementation.

parent e68c7cf7
......@@ -971,6 +971,12 @@ if(use_midl_tlb) {
static void test_CreateTypeLib(void) {
static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',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};
static OLECHAR param1W[] = {'p','a','r','a','m','1',0};
static OLECHAR param2W[] = {'p','a','r','a','m','2',0};
static OLECHAR *names1[] = {func1W, param1W, param2W};
static OLECHAR *names2[] = {func2W, param1W, param2W};
char filename[MAX_PATH];
WCHAR filenameW[MAX_PATH];
......@@ -1083,6 +1089,27 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
ok(hres == E_INVALIDARG, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, names1, 1);
ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 2);
ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names2, 1);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names1, 3);
ok(hres == TYPE_E_AMBIGUOUSNAME, "got %08x\n", hres);
ICreateTypeInfo_Release(createti);
hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
......
......@@ -1914,32 +1914,50 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncAndParamNames(
UINT cNames)
{
ICreateTypeInfo2Impl *This = (ICreateTypeInfo2Impl *)iface;
CyclicList *iter;
UINT i;
int offset;
CyclicList *iter = NULL, *iter2;
int offset, len, i=0;
char *namedata;
FIXME("(%p,%d,%s,%d), stub!\n", iface, index, debugstr_w(*rgszNames), cNames);
TRACE("(%p %d %p %d)\n", iface, index, rgszNames, cNames);
offset = ctl2_alloc_name(This->typelib, rgszNames[0]);
if(!rgszNames)
return E_INVALIDARG;
namedata = This->typelib->typelib_segment_data[MSFT_SEG_NAME] + offset;
namedata[9] &= ~0x10;
if (*((INT *)namedata) == -1) {
*((INT *)namedata) = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
if(index >= This->typeinfo->cElement || !cNames)
return TYPE_E_ELEMENTNOTFOUND;
len = ctl2_encode_name(This->typelib, rgszNames[0], &namedata);
for(iter2=This->typedata->next->next; iter2!=This->typedata->next; iter2=iter2->next) {
if(i == index)
iter = iter2;
else if(iter2->name!=-1 && !memcmp(namedata,
This->typelib->typelib_segment_data[MSFT_SEG_NAME]+iter2->name+8, len))
return TYPE_E_AMBIGUOUSNAME;
i++;
}
iter = This->typedata->next->next;
for(i=0; i<index; i++)
iter = iter->next;
/* cNames == cParams for put or putref accessor, cParams+1 otherwise */
if(cNames != iter->u.data[5] + ((iter->u.data[4]>>3)&(INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF) ? 0 : 1))
return TYPE_E_ELEMENTNOTFOUND;
offset = ctl2_alloc_name(This->typelib, rgszNames[0]);
if(offset == -1)
return E_OUTOFMEMORY;
iter->name = offset;
namedata = This->typelib->typelib_segment_data[MSFT_SEG_NAME] + offset;
*((INT *)namedata) = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
if(iter->u.data[4]&0x1000)
len = iter->u.data[5];
else
len = 0;
for (i = 1; i < cNames; i++) {
/* FIXME: Almost certainly easy to break */
offset = ctl2_alloc_name(This->typelib, rgszNames[i]);
iter->u.data[(i * 3) + 5] = offset;
iter->u.data[(i*3) + 4 + len] = offset;
}
return S_OK;
......
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