[PATCH v2 1/4] rpcrt4: Write type format strings for coclasses.

Huw Davies huw at codeweavers.com
Wed Nov 14 02:48:59 CST 2018


On Tue, Nov 13, 2018 at 11:52:48PM -0600, Zebediah Figura wrote:
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=19016
> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
> ---
>  dlls/rpcrt4/ndr_typelib.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/dlls/rpcrt4/ndr_typelib.c b/dlls/rpcrt4/ndr_typelib.c
> index f68e61e5fa..82ee53d7e7 100644
> --- a/dlls/rpcrt4/ndr_typelib.c
> +++ b/dlls/rpcrt4/ndr_typelib.c
> @@ -324,6 +324,37 @@ static size_t write_ip_tfs(unsigned char *str, size_t *len, const GUID *iid)
>      return off;
>  }
>  
> +static void get_default_iface(ITypeInfo *typeinfo, WORD count, GUID *iid)
> +{
> +    ITypeInfo *refinfo;
> +    HREFTYPE reftype;
> +    TYPEATTR *attr;
> +    int flags, i;
> +
> +    for (i = 0; i < count; ++i)
> +    {
> +        ITypeInfo_GetImplTypeFlags(typeinfo, i, &flags);
> +        if (flags & IMPLTYPEFLAG_FDEFAULT)
> +        {
> +            ITypeInfo_GetRefTypeOfImplType(typeinfo, i, &reftype);
> +            ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &refinfo);
> +            ITypeInfo_GetTypeAttr(refinfo, &attr);
> +            *iid = attr->guid;
> +            ITypeInfo_ReleaseTypeAttr(refinfo, attr);
> +            ITypeInfo_Release(refinfo);
> +            return;
> +        }
> +    }
> +
> +    /* If no interface was explicitly marked default, choose the first one. */
> +    ITypeInfo_GetRefTypeOfImplType(typeinfo, 0, &reftype);
> +    ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &refinfo);
> +    ITypeInfo_GetTypeAttr(refinfo, &attr);
> +    *iid = attr->guid;
> +    ITypeInfo_ReleaseTypeAttr(refinfo, attr);
> +    ITypeInfo_Release(refinfo);
> +}

The code duplication here isn't great.  How about using the loop to
simply find the index?

Huw.



More information about the wine-devel mailing list