COM inheritance Q

Ann and Jason Edmeades us at the-edmeades.demon.co.uk
Thu Jan 13 14:33:10 CST 2005


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?

Jason





More information about the wine-devel mailing list