ddraw: Add some comments about virtual call tables.

Henri Verbeet hverbeet at codeweavers.com
Thu Jan 22 03:33:37 CST 2009


Personally I don't see much value in these and would prefer if the patch
wasn't applied. However, Rob requested some comments on the dependency on
the field offset of virtual call tables in our COM object implementations.
---
 dlls/ddraw/ddraw_private.h |   96 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index e1434fb..49baa90 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -98,6 +98,14 @@ struct FvfToDecl
 struct IDirectDrawImpl
 {
     /* IUnknown fields */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirectDraw7Vtbl *vtbl;
     const IDirectDraw4Vtbl *IDirectDraw4_vtbl;
     const IDirectDraw3Vtbl *IDirectDraw3_vtbl;
@@ -257,6 +265,14 @@ extern WINED3DSURFTYPE DefaultSurfaceType;
 struct IDirectDrawSurfaceImpl
 {
     /* IUnknown fields */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirectDrawSurface7Vtbl *vtbl;
     const IDirectDrawSurface3Vtbl *IDirectDrawSurface3_vtbl;
     const IDirectDrawGammaControlVtbl *IDirectDrawGammaControl_vtbl;
@@ -345,6 +361,14 @@ static inline IDirectDrawSurfaceImpl *surface_from_surface3(IDirectDrawSurface3
 struct IParentImpl
 {
     /* IUnknown fields */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IParentVtbl *vtbl;
     LONG                    ref;
 
@@ -376,6 +400,14 @@ struct HandleEntry
 struct IDirect3DDeviceImpl
 {
     /* IUnknown */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DDevice7Vtbl *vtbl;
     const IDirect3DDevice3Vtbl *IDirect3DDevice3_vtbl;
     const IDirect3DDevice2Vtbl *IDirect3DDevice2_vtbl;
@@ -478,6 +510,14 @@ struct EnumZBufferFormatsData
 struct IDirectDrawClipperImpl
 {
     /* IUnknown fields */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirectDrawClipperVtbl *vtbl;
     LONG ref;
 
@@ -495,6 +535,14 @@ typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper;
 struct IDirectDrawPaletteImpl
 {
     /* IUnknown fields */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirectDrawPaletteVtbl *vtbl;
     LONG ref;
 
@@ -512,6 +560,14 @@ extern const IDirectDrawPaletteVtbl IDirectDrawPalette_Vtbl;
  ******************************************************************************/
 typedef struct
 {
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IClassFactoryVtbl *vtbl;
 
     LONG ref;
@@ -531,6 +587,14 @@ struct object_creation_info
  ******************************************************************************/
 struct IDirect3DLightImpl
 {
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DLightVtbl *vtbl;
     LONG ref;
 
@@ -567,6 +631,14 @@ void light_desactivate(IDirect3DLightImpl* This);
  ******************************************************************************/
 struct IDirect3DMaterialImpl
 {
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DMaterial3Vtbl *vtbl;
     const IDirect3DMaterial2Vtbl *IDirect3DMaterial2_vtbl;
     const IDirect3DMaterialVtbl *IDirect3DMaterial_vtbl;
@@ -595,6 +667,14 @@ void material_activate(IDirect3DMaterialImpl* This);
  *****************************************************************************/
 struct IDirect3DViewportImpl
 {
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DViewport3Vtbl *vtbl;
     LONG ref;
 
@@ -640,6 +720,14 @@ void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights);
 struct IDirect3DExecuteBufferImpl
 {
     /* IUnknown */
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DExecuteBufferVtbl *vtbl;
     LONG                 ref;
 
@@ -676,6 +764,14 @@ IDirect3DExecuteBufferImpl_Execute(IDirect3DExecuteBufferImpl *This,
 struct IDirect3DVertexBufferImpl
 {
     /*** IUnknown Methods ***/
+    /* This is a virtual call table, it allows applications to call the COM
+     * methods we implement. It also serves as interface pointer. Putting this
+     * at offset 0 in the implementation struct allows for simple and efficient
+     * conversion between interface and implementation pointers with a cast.
+     * Putting it at any other offset would require us to subtract the field
+     * offset when converting from an interface pointer to an implementation
+     * pointer, and add the field offset when converting from an
+     * implementation pointer to an interface pointer. */
     const IDirect3DVertexBuffer7Vtbl *vtbl;
     const IDirect3DVertexBufferVtbl *IDirect3DVertexBuffer_vtbl;
     LONG                 ref;
-- 
1.6.0.6



--------------050505000000060405050706--



More information about the wine-patches mailing list