[PATCH v2 5/6] oleaut32: Make GetNames omit same parameters as GetFuncDesc.

Kevin Puetz PuetzKevinA at JohnDeere.com
Mon Sep 21 09:17:21 CDT 2020


GetFuncDesc removes parameters which are handled specially by Invoke;
GetNames should omit their names so *pcNames is consistent with cParams.

Signed-off-by: Kevin Puetz <PuetzKevinA at JohnDeere.com>
---
 dlls/oleaut32/typelib.c | 53 ++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 16 deletions(-)

diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 13ccb6041a..93b69c89e8 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -6124,36 +6124,38 @@ static HRESULT WINAPI ITypeInfo_fnGetVarDesc( ITypeInfo2 *iface, UINT index,
     return TLB_AllocAndInitVarDesc(&pVDesc->vardesc, ppVarDesc);
 }
 
-/* ITypeInfo_GetNames
- *
- * Retrieves the variable with the specified member ID (or the name of the
- * property or method and its parameters) that correspond to the specified
- * function ID.
- */
-static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
-        BSTR  *rgBstrNames, UINT cMaxNames, UINT  *pcNames)
+/* internal function to make the inherited interfaces' methods appear
+ * part of the interface, remembering if the top-level was dispinterface */
+static HRESULT typeinfo_getnames( ITypeInfo *iface,
+        MEMBERID memid, BSTR  *rgBstrNames, UINT cMaxNames, UINT  *pcNames,
+        BOOL dispinterface)
 {
-    ITypeInfoImpl *This = impl_from_ITypeInfo2(iface);
+    ITypeInfoImpl *This = impl_from_ITypeInfo(iface);
     const TLBFuncDesc *pFDesc;
     const TLBVarDesc *pVDesc;
     int i;
-    TRACE("(%p) memid=0x%08x Maxname=%d\n", This, memid, cMaxNames);
-
-    if(!rgBstrNames)
-        return E_INVALIDARG;
 
     *pcNames = 0;
 
     pFDesc = TLB_get_funcdesc_by_memberid(This, memid);
     if(pFDesc)
     {
+        UINT cParams = pFDesc->funcdesc.cParams;
         if(!cMaxNames || !pFDesc->Name)
             return S_OK;
 
         *rgBstrNames = SysAllocString(TLB_get_bstr(pFDesc->Name));
         ++(*pcNames);
 
-        for(i = 0; i < pFDesc->funcdesc.cParams; ++i){
+        if(dispinterface && (pFDesc->funcdesc.funckind != FUNC_DISPATCH)) {
+            /* match the rewriting of special trailing parameters in TLB_AllocAndInitFuncDesc; */
+            if ((cParams > 0) && (pFDesc->funcdesc.lprgelemdescParam[cParams - 1].u.paramdesc.wParamFlags & PARAMFLAG_FRETVAL))
+                --cParams; /* Invoke(pVarResult) supplies the [retval] parameter, so its hidden from DISPPARAMS*/
+            if ((cParams > 0) && (pFDesc->funcdesc.lprgelemdescParam[cParams - 1].u.paramdesc.wParamFlags & PARAMFLAG_FLCID))
+                --cParams; /* Invoke(lcid) supplies the [lcid] parameter, so its hidden from DISPPARAMS */
+        }
+
+        for(i = 0; i < cParams; ++i) {
             if(*pcNames >= cMaxNames || !pFDesc->pParamDesc[i].Name)
                 return S_OK;
             rgBstrNames[*pcNames] = SysAllocString(TLB_get_bstr(pFDesc->pParamDesc[i].Name));
@@ -6175,10 +6177,10 @@ static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
           /* recursive search */
           ITypeInfo *pTInfo;
           HRESULT result;
-          result = ITypeInfo2_GetRefTypeInfo(iface, This->impltypes[0].hRef, &pTInfo);
+          result = ITypeInfo_GetRefTypeInfo(iface, This->impltypes[0].hRef, &pTInfo);
           if(SUCCEEDED(result))
 	  {
-            result=ITypeInfo_GetNames(pTInfo, memid, rgBstrNames, cMaxNames, pcNames);
+            result=typeinfo_getnames(pTInfo, memid, rgBstrNames, cMaxNames, pcNames, dispinterface);
             ITypeInfo_Release(pTInfo);
             return result;
           }
@@ -6194,6 +6196,25 @@ static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
     return S_OK;
 }
 
+/* ITypeInfo_GetNames
+ *
+ * Retrieves the variable with the specified member ID (or the name of the
+ * property or method and its parameters) that correspond to the specified
+ * function ID.
+ */
+static HRESULT WINAPI ITypeInfo_fnGetNames( ITypeInfo2 *iface, MEMBERID memid,
+        BSTR  *rgBstrNames, UINT cMaxNames, UINT  *pcNames)
+{
+    ITypeInfoImpl *This = impl_from_ITypeInfo2(iface);
+    TRACE("(%p) memid=0x%08x Maxname=%d\n", This, memid, cMaxNames);
+
+    if(!rgBstrNames)
+        return E_INVALIDARG;
+
+    return typeinfo_getnames((ITypeInfo *)iface,
+        memid, rgBstrNames, cMaxNames, pcNames,
+        This->typeattr.typekind == TKIND_DISPATCH);
+}
 
 /* ITypeInfo::GetRefTypeOfImplType
  *



More information about the wine-devel mailing list