BEGIN_COM_MAP和END_COM_MAP
1
#define
BEGIN_COM_MAP(x) public: \
2 typedef x _ComMapClass; \
3 static HRESULT WINAPI _Cache( void * pv, REFIID iid, void ** ppvObject, DWORD_PTR dw) throw ()\
4 {\
5 _ComMapClass * p = (_ComMapClass * )pv;\
6 p -> Lock();\
7 HRESULT hRes = E_FAIL; \
8 __try \
9 { \
10 hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
11 } \
12 __finally \
13 { \
14 p -> Unlock();\
15 } \
16 return hRes;\
17 }\
18 IUnknown * _GetRawUnknown() throw () \
19 { ATLASSERT(_GetEntries()[ 0 ].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown * )((INT_PTR) this + _GetEntries() -> dw); } \
20 _ATL_DECLARE_GET_UNKNOWN(x)\
21 HRESULT _InternalQueryInterface(REFIID iid, void ** ppvObject) throw () \
22 { return InternalQueryInterface( this , _GetEntries(), iid, ppvObject); } \
23 const static ATL::_ATL_INTMAP_ENTRY * WINAPI _GetEntries() throw () { \
24 static const ATL::_ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x)
25
26 #ifdef _ATL_DEBUG
27 #define DEBUG_QI_ENTRY(x) \
28 {NULL, \
29 (DWORD_PTR)_T(#x), \
30 (ATL::_ATL_CREATORARGFUNC * ) 0 },
31 #else
32 #define DEBUG_QI_ENTRY(x)
33 #endif // _ATL_DEBUG
34
35 #define COM_INTERFACE_ENTRY_IMPL(x)\
36 COM_INTERFACE_ENTRY_IID(_ATL_IIDOF(x), x##Impl < _ComMapClass > )
37
38 #define _ATL_IIDOF(x) __uuidof(x)
39
40 #define COM_INTERFACE_ENTRY_IID(iid, x)\
41 { & iid,\
42 offsetofclass(x, _ComMapClass),\
43 _ATL_SIMPLEMAPENTRY},
44
45 #define offsetofclass(base, derived) ((DWORD_PTR)(static_cast<base*>((derived*)_ATL_PACKING))-_ATL_PACKING)
46
47 #define _ATL_SIMPLEMAPENTRY ((ATL::_ATL_CREATORARGFUNC*)1)
48
49 #define COM_INTERFACE_ENTRY(x)\
50 { & _ATL_IIDOF(x), \
51 offsetofclass(x, _ComMapClass), \
52 _ATL_SIMPLEMAPENTRY},
53
54 #define END_COM_MAP() \
55 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }\
56 {NULL, 0 , 0 }}; return & _entries[ 1 ];} \
57 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ; \
58 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ; \
59 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
60 #else
61 #define END_COM_MAP() \
62 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }\
63 {NULL, 0 , 0 }}; return _entries;} \
64 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ; \
65 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ; \
66 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
67 #endif // _ATL_DEBUG
68
69
70 // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71 class d
72 {
73 public :
74 d(){}
75 typedef x _ComMapClass;
76 static HRESULT WINAPI _Cache( void * pv, REFIID iid, void ** ppvObject, DWORD_PTR dw) throw ()\
77 {
78 _ComMapClass * p = (_ComMapClass * )pv;
79 p -> Lock();
80 HRESULT hRes = E_FAIL;
81 __try
82 {
83 hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);
84 }
85 __finally
86 {
87 p -> Unlock();
88 }
89 return hRes;
90 }
91 IUnknown * _GetRawUnknown() throw ()
92 { ATLASSERT(_GetEntries()[ 0 ].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown * )((INT_PTR) this + _GetEntries() -> dw); }
93 _ATL_DECLARE_GET_UNKNOWN(x)
94 HRESULT _InternalQueryInterface(REFIID iid, void ** ppvObject) throw ()
95 { return InternalQueryInterface( this , _GetEntries(), iid, ppvObject); }
96 const static ATL::_ATL_INTMAP_ENTRY * WINAPI _GetEntries() throw ()
97 {
98 static const ATL::_ATL_INTMAP_ENTRY _entries[] =
99 {
100 {NULL, (DWORD_PTR)_T(#x), (ATL::_ATL_CREATORARGFUNC * ) 0 },
101 { & iid, ((DWORD_PTR)(static_cast < base *> ((derived * )_ATL_PACKING)) - _ATL_PACKING), ((ATL::_ATL_CREATORARGFUNC * ) 1 )},
102 { & __uuidof(x), ((DWORD_PTR)(static_cast < base *> ((derived * )_ATL_PACKING)) - _ATL_PACKING), ((ATL::_ATL_CREATORARGFUNC * ) 1 )},
103 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }
104 {NULL, 0 , 0 }
105 };
106 return & _entries[ 1 ];
107 }
108 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ;
109 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ;
110 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
111 }
2 typedef x _ComMapClass; \
3 static HRESULT WINAPI _Cache( void * pv, REFIID iid, void ** ppvObject, DWORD_PTR dw) throw ()\
4 {\
5 _ComMapClass * p = (_ComMapClass * )pv;\
6 p -> Lock();\
7 HRESULT hRes = E_FAIL; \
8 __try \
9 { \
10 hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
11 } \
12 __finally \
13 { \
14 p -> Unlock();\
15 } \
16 return hRes;\
17 }\
18 IUnknown * _GetRawUnknown() throw () \
19 { ATLASSERT(_GetEntries()[ 0 ].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown * )((INT_PTR) this + _GetEntries() -> dw); } \
20 _ATL_DECLARE_GET_UNKNOWN(x)\
21 HRESULT _InternalQueryInterface(REFIID iid, void ** ppvObject) throw () \
22 { return InternalQueryInterface( this , _GetEntries(), iid, ppvObject); } \
23 const static ATL::_ATL_INTMAP_ENTRY * WINAPI _GetEntries() throw () { \
24 static const ATL::_ATL_INTMAP_ENTRY _entries[] = { DEBUG_QI_ENTRY(x)
25
26 #ifdef _ATL_DEBUG
27 #define DEBUG_QI_ENTRY(x) \
28 {NULL, \
29 (DWORD_PTR)_T(#x), \
30 (ATL::_ATL_CREATORARGFUNC * ) 0 },
31 #else
32 #define DEBUG_QI_ENTRY(x)
33 #endif // _ATL_DEBUG
34
35 #define COM_INTERFACE_ENTRY_IMPL(x)\
36 COM_INTERFACE_ENTRY_IID(_ATL_IIDOF(x), x##Impl < _ComMapClass > )
37
38 #define _ATL_IIDOF(x) __uuidof(x)
39
40 #define COM_INTERFACE_ENTRY_IID(iid, x)\
41 { & iid,\
42 offsetofclass(x, _ComMapClass),\
43 _ATL_SIMPLEMAPENTRY},
44
45 #define offsetofclass(base, derived) ((DWORD_PTR)(static_cast<base*>((derived*)_ATL_PACKING))-_ATL_PACKING)
46
47 #define _ATL_SIMPLEMAPENTRY ((ATL::_ATL_CREATORARGFUNC*)1)
48
49 #define COM_INTERFACE_ENTRY(x)\
50 { & _ATL_IIDOF(x), \
51 offsetofclass(x, _ComMapClass), \
52 _ATL_SIMPLEMAPENTRY},
53
54 #define END_COM_MAP() \
55 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }\
56 {NULL, 0 , 0 }}; return & _entries[ 1 ];} \
57 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ; \
58 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ; \
59 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
60 #else
61 #define END_COM_MAP() \
62 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }\
63 {NULL, 0 , 0 }}; return _entries;} \
64 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ; \
65 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ; \
66 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
67 #endif // _ATL_DEBUG
68
69
70 // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71 class d
72 {
73 public :
74 d(){}
75 typedef x _ComMapClass;
76 static HRESULT WINAPI _Cache( void * pv, REFIID iid, void ** ppvObject, DWORD_PTR dw) throw ()\
77 {
78 _ComMapClass * p = (_ComMapClass * )pv;
79 p -> Lock();
80 HRESULT hRes = E_FAIL;
81 __try
82 {
83 hRes = ATL::CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);
84 }
85 __finally
86 {
87 p -> Unlock();
88 }
89 return hRes;
90 }
91 IUnknown * _GetRawUnknown() throw ()
92 { ATLASSERT(_GetEntries()[ 0 ].pFunc == _ATL_SIMPLEMAPENTRY); return (IUnknown * )((INT_PTR) this + _GetEntries() -> dw); }
93 _ATL_DECLARE_GET_UNKNOWN(x)
94 HRESULT _InternalQueryInterface(REFIID iid, void ** ppvObject) throw ()
95 { return InternalQueryInterface( this , _GetEntries(), iid, ppvObject); }
96 const static ATL::_ATL_INTMAP_ENTRY * WINAPI _GetEntries() throw ()
97 {
98 static const ATL::_ATL_INTMAP_ENTRY _entries[] =
99 {
100 {NULL, (DWORD_PTR)_T(#x), (ATL::_ATL_CREATORARGFUNC * ) 0 },
101 { & iid, ((DWORD_PTR)(static_cast < base *> ((derived * )_ATL_PACKING)) - _ATL_PACKING), ((ATL::_ATL_CREATORARGFUNC * ) 1 )},
102 { & __uuidof(x), ((DWORD_PTR)(static_cast < base *> ((derived * )_ATL_PACKING)) - _ATL_PACKING), ((ATL::_ATL_CREATORARGFUNC * ) 1 )},
103 __if_exists(_GetAttrEntries) {{NULL, (DWORD_PTR)_GetAttrEntries, _ChainAttr }, }
104 {NULL, 0 , 0 }
105 };
106 return & _entries[ 1 ];
107 }
108 virtual ULONG STDMETHODCALLTYPE AddRef( void ) throw () = 0 ;
109 virtual ULONG STDMETHODCALLTYPE Release( void ) throw () = 0 ;
110 STDMETHOD(QueryInterface)(REFIID, void ** ) throw () = 0 ;
111 }