wined3d: Remove some unneeded context cache members from the device.
[wine/multimedia.git] / dlls / ddraw / ddcomimpl.h
blob553d29fccf5444c0a6ad58453297e20226bad550
1 /* A few helpful macros for implementing COM objects.
3 * Copyright 2000 TransGaming Technologies Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef _DDCOMIMPL_H_
21 #define _DDCOMIMPL_H_
23 #include <stddef.h>
25 /* Generates the name for a vtable pointer for a given interface. */
26 /* The canonical name for a single interface is "lpVtbl". */
27 #define ICOM_VFIELD_MULTI_NAME2(iface) ITF_##iface
28 #define ICOM_VFIELD_MULTI_NAME(iface) ICOM_VFIELD_MULTI_NAME2(iface)
30 /* Declares a vtable pointer field in an implementation. */
31 #define ICOM_VFIELD_MULTI(iface) \
32 iface ICOM_VFIELD_MULTI_NAME(iface)
34 /* Returns the offset of a vtable pointer within an implementation object. */
35 #define ICOM_VFIELD_OFFSET(impltype, iface) \
36 offsetof(impltype, ICOM_VFIELD_MULTI_NAME(iface))
38 /* Given an interface pointer, returns the implementation pointer. */
39 #define ICOM_OBJECT(impltype, ifacename, ifaceptr) \
40 (impltype*)((ifaceptr) == NULL ? NULL \
41 : (char*)(ifaceptr) - ICOM_VFIELD_OFFSET(impltype,ifacename))
43 #define ICOM_THIS_FROM(impltype, ifacename, ifaceptr) \
44 impltype* This = ICOM_OBJECT(impltype, ifacename, ifaceptr)
46 /* Given an object and interface name, returns a pointer to that interface. */
47 #define ICOM_INTERFACE(implobj, iface) \
48 (implobj == NULL ? NULL :&((implobj)->ICOM_VFIELD_MULTI_NAME(iface)))
50 #define ICOM_INIT_INTERFACE(implobj, ifacename, vtblname) \
51 do { \
52 (implobj)->ICOM_VFIELD_MULTI_NAME(ifacename).lpVtbl = &(vtblname); \
53 } while (0)
55 #define COM_INTERFACE_CAST(impltype, ifnamefrom, ifnameto, ifaceptr) \
56 ICOM_INTERFACE(ICOM_OBJECT(impltype, ifnamefrom, ifaceptr), ifnameto)
58 #endif /* _DDCOMIMPL_H_ */