COM inheritance Q

Raphael fenix at club-internet.fr
Thu Jan 13 14:57:05 CST 2005


On Thursday 13 January 2005 21:43, Robert Shearman wrote:
> 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

Hi

Jason seems to have:
- IWineD3DSurface inherits from IWineD3DResource  
- IWineD3DResource inherits from IUnknown

Jason, why IWineD3DSurface inherits from IWineD3DResource ?
as D3DSurfaces dont inherits from Ressources 
(cf 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/d3d/interfaces/idirect3dsurface9/_idirect3dsurface9.asp)

But for me the only (proper) way to handle your problem is to do as done in 
d3d8 code

Regards,
Raphael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20050113/586c7b20/attachment-0001.pgp


More information about the wine-devel mailing list