COM inheritance Q

Robert Shearman rob at codeweavers.com
Thu Jan 13 14:43:10 CST 2005


Ann and Jason Edmeades wrote:

>Hiya,
>
>In the wined3d code I have, for example, a class surface which inherits a
>lot of methods of Resource. Most of these methods can be called as-is, and I
>have code which looks like:
> 
>HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface,
>IUnknown **pParent) {
>    return IWineD3DResource_GetParent((IWineD3DResource *)iface, pParent);
>}
>
>Great idea.... but this fails:
>
>IWineD3DResource_GetParent is a macro:
>#define IWineD3DSurface_GetParent(p,a)
>(p)->lpVtbl->GetParent(p,a)
>
>So we then go iface->lpVtbl->GetTable. Since iface is a surface, once cast
>to a resource its GetParent is in the same place in the table... Hence the
>call ends up being effectively
>
>HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface,
>IUnknown **pParent) {
>    return IWineD3DSurfaceImpl_GetParent (iface, pParent);
>}
>
>Whats the solution?
>
>In d3d8 I would have coded IWineD3DSurfaceImpl_GetParent as
>IWineD3DResourceImpl_GetParent(iface, pParent) because the Impl versions
>were prototyped - Is this the only way to solve this?
>  
>

I don't think I've got enough information to answer you correctly. Is 
this a multiple inheritance problem? I.e. does the object implement both 
IWineD3DSurface and IWineD3DResource and not have one directly 
inheriting from the other?

Rob



More information about the wine-devel mailing list