Andrey Turkin : oleaut32: Fix ICreateTypeLib2::SetFuncAndParamNames.

Alexandre Julliard julliard at winehq.org
Mon May 17 09:39:31 CDT 2010


Module: wine
Branch: master
Commit: b4025a3ed17c647240016b701fe1c457764bb41e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b4025a3ed17c647240016b701fe1c457764bb41e

Author: Andrey Turkin <andrey.turkin at gmail.com>
Date:   Mon May 17 02:27:34 2010 +0400

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 a081163..ff7defb 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 c870b4f..c1a3bd9 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; 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;
 
+    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;




More information about the wine-cvs mailing list