From b4025a3ed17c647240016b701fe1c457764bb41e Mon Sep 17 00:00:00 2001 From: Andrey Turkin Date: Mon, 17 May 2010 02:27:34 +0400 Subject: [PATCH] oleaut32: Fix ICreateTypeLib2::SetFuncAndParamNames. Getters and setters for same property can have an identical name --- dlls/oleaut32/tests/typelib.c | 12 ++++++++++++ dlls/oleaut32/typelib2.c | 26 ++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index a0811632bb3..ff7defb3b26 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -982,10 +982,12 @@ static void test_CreateTypeLib(void) { 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 prop1W[] = {'P','r','o','p','1',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}; + static OLECHAR *propname[] = {prop1W, param1W}; static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}}; char filename[MAX_PATH]; @@ -1171,6 +1173,16 @@ static void test_CreateTypeLib(void) { hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab); ok(hres == S_OK, "got %08x\n", hres); + hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 1); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 1); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 2); + ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres); + + funcdesc.invkind = INVOKE_PROPERTYPUTREF; hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc); ok(hres == S_OK, "got %08x\n", hres); diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index c870b4f0390..c1a3bd9f16b 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -2132,21 +2132,27 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncAndParamNames( 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++; - } + for(iter=This->typedata->next->next, i=0; inext; /* 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; + len = ctl2_encode_name(This->typelib, rgszNames[0], &namedata); + for(iter2=This->typedata->next->next; iter2!=This->typedata->next; iter2=iter2->next) { + if(iter2->name!=-1 && !memcmp(namedata, + This->typelib->typelib_segment_data[MSFT_SEG_NAME]+iter2->name+8, len)) + { + /* getters/setters can have a same name */ + INT inv1 = iter2->u.data[4] >> 3; + INT inv2 = iter->u.data[4] >> 3; + if (!((inv1&(INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF)) && (inv2&INVOKE_PROPERTYGET)) && + !((inv2&(INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF)) && (inv1&INVOKE_PROPERTYGET))) + return TYPE_E_AMBIGUOUSNAME; + } + } + offset = ctl2_alloc_name(This->typelib, rgszNames[0]); if(offset == -1) return E_OUTOFMEMORY; -- 2.11.4.GIT