mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d6c0f9f784
Major DirectDraw restructure/reimplementation, using an improved component object model hierarchy. The implementation currently supports: - DirectDraw over GDI/USER in a window (using DIBsections and asynchronous updates) - XVidMode - XF86DGA2 - All DirectDraw interfaces from versions 1 to 7 (at least in theory) - Hooks for Direct3D interfaces
39 lines
1.5 KiB
C
39 lines
1.5 KiB
C
/* A few helpful macros for implementing COM objects.
|
|
*
|
|
* Copyright 2000 TransGaming Technologies Inc.
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
|
|
/* Generates the name for a vtable pointer for a given interface. */
|
|
/* The canonical name for a single interface is "lpVtbl". */
|
|
#define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
|
|
#define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
|
|
|
|
/* Declares a vtable pointer field in an implementation. */
|
|
#define ICOM_VFIELD_MULTI(iface) \
|
|
iface ICOM_VFIELD_MULTI_NAME(iface)
|
|
|
|
/* Returns the offset of a vtable pointer within an implementation object. */
|
|
#define ICOM_VFIELD_OFFSET(impltype, iface) \
|
|
offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
|
|
|
|
/* Given an interface pointer, returns the implementation pointer. */
|
|
#define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
|
|
(impltype*)((ifaceptr) == NULL ? NULL \
|
|
: (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
|
|
|
|
#define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
|
|
impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
|
|
|
|
/* Given an object and interface name, returns a pointer to that interface. */
|
|
#define ICOM_INTERFACE(implobj, iface) \
|
|
(&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
|
|
|
|
#define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
|
|
do { \
|
|
(implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
|
|
} while (0)
|
|
|
|
#define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
|
|
ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
|