4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
5 * Copyright 2013 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 template <class Base
, const IID
*piid
, class T
, class Copy
, class ThreadModel
= CComObjectThreadModel
>
30 #define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass;
31 #define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory)
33 class CComObjectRootBase
51 HRESULT
_AtlFinalConstruct()
56 HRESULT
FinalConstruct()
61 void InternalFinalConstructAddRef()
65 void InternalFinalConstructRelease()
73 static void WINAPI
ObjectMain(bool)
77 static const struct _ATL_CATMAP_ENTRY
*GetCategoryMap()
82 static HRESULT WINAPI
InternalQueryInterface(void *pThis
, const _ATL_INTMAP_ENTRY
*pEntries
, REFIID iid
, void **ppvObject
)
84 return AtlInternalQueryInterface(pThis
, pEntries
, iid
, ppvObject
);
89 template <class ThreadModel
>
90 class CComObjectRootEx
: public CComObjectRootBase
93 typename
ThreadModel::AutoDeleteCriticalSection m_critsec
;
99 ULONG
InternalAddRef()
101 ATLASSERT(m_dwRef
>= 0);
102 return ThreadModel::Increment(&m_dwRef
);
105 ULONG
InternalRelease()
107 ATLASSERT(m_dwRef
> 0);
108 return ThreadModel::Decrement(&m_dwRef
);
121 HRESULT
_AtlInitialConstruct()
123 return m_critsec
.Init();
127 template <class Base
>
128 class CComObject
: public Base
131 CComObject(void * = NULL
)
136 virtual ~CComObject()
138 this->FinalRelease();
139 _pAtlModule
->Unlock();
142 STDMETHOD_(ULONG
, AddRef
)()
144 return this->InternalAddRef();
147 STDMETHOD_(ULONG
, Release
)()
151 newRefCount
= this->InternalRelease();
152 if (newRefCount
== 0)
157 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
159 return this->_InternalQueryInterface(iid
, ppvObject
);
162 static HRESULT WINAPI
CreateInstance(CComObject
<Base
> **pp
)
164 CComObject
<Base
> *newInstance
;
167 ATLASSERT(pp
!= NULL
);
171 hResult
= E_OUTOFMEMORY
;
173 ATLTRY(newInstance
= new CComObject
<Base
>())
174 if (newInstance
!= NULL
)
176 newInstance
->SetVoid(NULL
);
177 newInstance
->InternalFinalConstructAddRef();
178 hResult
= newInstance
->_AtlInitialConstruct();
179 if (SUCCEEDED(hResult
))
180 hResult
= newInstance
->FinalConstruct();
181 if (SUCCEEDED(hResult
))
182 hResult
= newInstance
->_AtlFinalConstruct();
183 newInstance
->InternalFinalConstructRelease();
197 template <HRESULT hResult
>
198 class CComFailCreator
201 static HRESULT WINAPI
CreateInstance(void *, REFIID
, LPVOID
*ppv
)
203 ATLASSERT(ppv
!= NULL
);
216 static HRESULT WINAPI
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
221 ATLASSERT(ppv
!= NULL
);
226 hResult
= E_OUTOFMEMORY
;
228 ATLTRY(newInstance
= new T1())
229 if (newInstance
!= NULL
)
231 newInstance
->SetVoid(pv
);
232 newInstance
->InternalFinalConstructAddRef();
233 hResult
= newInstance
->_AtlInitialConstruct();
234 if (SUCCEEDED(hResult
))
235 hResult
= newInstance
->FinalConstruct();
236 if (SUCCEEDED(hResult
))
237 hResult
= newInstance
->_AtlFinalConstruct();
238 newInstance
->InternalFinalConstructRelease();
239 if (SUCCEEDED(hResult
))
240 hResult
= newInstance
->QueryInterface(riid
, ppv
);
251 template <class T1
, class T2
>
255 static HRESULT WINAPI
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
257 ATLASSERT(ppv
!= NULL
&& ppv
!= NULL
);
260 return T1::CreateInstance(NULL
, riid
, ppv
);
262 return T2::CreateInstance(pv
, riid
, ppv
);
266 template <class Base
>
267 class CComObjectCached
: public Base
270 CComObjectCached(void * = NULL
)
274 STDMETHOD_(ULONG
, AddRef
)()
278 newRefCount
= this->InternalAddRef();
279 if (newRefCount
== 2)
284 STDMETHOD_(ULONG
, Release
)()
288 newRefCount
= this->InternalRelease();
289 if (newRefCount
== 0)
291 else if (newRefCount
== 1)
292 _pAtlModule
->Unlock();
296 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
298 return this->_InternalQueryInterface(iid
, ppvObject
);
302 #define BEGIN_COM_MAP(x) \
304 typedef x _ComMapClass; \
305 HRESULT _InternalQueryInterface(REFIID iid, void **ppvObject) \
307 return this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \
309 const static ATL::_ATL_INTMAP_ENTRY *WINAPI _GetEntries() \
311 static const ATL::_ATL_INTMAP_ENTRY _entries[] = {
313 #define END_COM_MAP() \
318 virtual ULONG STDMETHODCALLTYPE AddRef() = 0; \
319 virtual ULONG STDMETHODCALLTYPE Release() = 0; \
320 STDMETHOD(QueryInterface)(REFIID, void **) = 0;
322 #define COM_INTERFACE_ENTRY_IID(iid, x) \
323 {&iid, offsetofclass(x, _ComMapClass), _ATL_SIMPLEMAPENTRY},
325 #define COM_INTERFACE_ENTRY2_IID(iid, x, x2) \
327 reinterpret_cast<DWORD_PTR>(static_cast<x *>(static_cast<x2 *>(reinterpret_cast<_ComMapClass *>(_ATL_PACKING)))) - _ATL_PACKING, \
328 _ATL_SIMPLEMAPENTRY},
330 #define COM_INTERFACE_ENTRY_BREAK(x) \
333 _Break}, // Break is a function that issues int 3.
335 #define COM_INTERFACE_ENTRY_NOINTERFACE(x) \
338 _NoInterface}, // NoInterface returns E_NOINTERFACE.
340 #define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) \
345 #define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) \
350 #define COM_INTERFACE_ENTRY_CHAIN(classname) \
352 reinterpret_cast<DWORD>(&_CComChainData<classname, _ComMapClass>::data), \
355 #define DECLARE_NO_REGISTRY()\
356 static HRESULT WINAPI UpdateRegistry(BOOL /*bRegister*/) \
361 #define DECLARE_REGISTRY_RESOURCEID(x) \
362 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
364 return ATL::_pAtlModule->UpdateRegistryFromResource(x, bRegister); \
367 #define DECLARE_NOT_AGGREGATABLE(x) \
369 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
371 #define DECLARE_AGGREGATABLE(x) \
373 typedef CComCreator2<CComCreator<CComObject<x> >, CComCreator<CComAggObject<x> > > _CreatorClass;
375 #define DECLARE_ONLY_AGGREGATABLE(x) \
377 typedef CComCreator2<CComFailCreator<E_FAIL>, CComCreator<CComAggObject<x> > > _CreatorClass;
379 #define DECLARE_POLY_AGGREGATABLE(x) \
381 typedef CComCreator<CComPolyObject<x> > _CreatorClass;
383 #define DECLARE_GET_CONTROLLING_UNKNOWN() \
385 virtual IUnknown *GetControllingUnknown() \
387 return GetUnknown(); \
390 #define DECLARE_PROTECT_FINAL_CONSTRUCT() \
391 void InternalFinalConstructAddRef() \
395 void InternalFinalConstructRelease() \
400 #define BEGIN_OBJECT_MAP(x) static ATL::_ATL_OBJMAP_ENTRY x[] = {
402 #define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
404 #define OBJECT_ENTRY(clsid, class) \
407 class::UpdateRegistry, \
408 class::_ClassFactoryCreatorClass::CreateInstance, \
409 class::_CreatorClass::CreateInstance, \
412 class::GetObjectDescription, \
413 class::GetCategoryMap, \
416 class CComClassFactory
:
417 public IClassFactory
,
418 public CComObjectRootEx
<CComGlobalsThreadModel
>
421 _ATL_CREATORFUNC
*m_pfnCreateInstance
;
423 virtual ~CComClassFactory()
428 STDMETHOD(CreateInstance
)(LPUNKNOWN pUnkOuter
, REFIID riid
, void **ppvObj
)
432 ATLASSERT(m_pfnCreateInstance
!= NULL
);
438 if (pUnkOuter
!= NULL
&& InlineIsEqualUnknown(riid
) == FALSE
)
439 hResult
= CLASS_E_NOAGGREGATION
;
441 hResult
= m_pfnCreateInstance(pUnkOuter
, riid
, ppvObj
);
445 STDMETHOD(LockServer
)(BOOL fLock
)
450 _pAtlModule
->Unlock();
454 void SetVoid(void *pv
)
456 m_pfnCreateInstance
= (_ATL_CREATORFUNC
*)pv
;
459 BEGIN_COM_MAP(CComClassFactory
)
460 COM_INTERFACE_ENTRY_IID(IID_IClassFactory
, IClassFactory
)
464 template <class T
, const CLSID
*pclsid
= &CLSID_NULL
>
468 DECLARE_CLASSFACTORY()
470 static LPCTSTR WINAPI
GetObjectDescription()
480 static HRESULT
copy(T
*pTo
, const T
*pFrom
)
482 memcpy(pTo
, pFrom
, sizeof(T
));
486 static void init(T
*)
490 static void destroy(T
*)
496 class _Copy
<CONNECTDATA
>
499 static HRESULT
copy(CONNECTDATA
*pTo
, const CONNECTDATA
*pFrom
)
507 static void init(CONNECTDATA
*)
511 static void destroy(CONNECTDATA
*p
)
522 static HRESULT
copy(T
**pTo
, T
**pFrom
)
530 static void init(T
**)
534 static void destroy(T
**p
)
544 AtlFlagTakeOwnership
= 2, // BitOwn
545 AtlFlagCopy
= 3 // BitOwn | BitCopy
548 template <class Base
, const IID
*piid
, class T
, class Copy
>
549 class CComEnumImpl
: public Base
552 typedef CComObject
<CComEnum
<Base
, piid
, T
, Copy
> > enumeratorClass
;
554 CComPtr
<IUnknown
> m_spUnk
;
568 virtual ~CComEnumImpl()
572 if ((m_dwFlags
& BitOwn
) != 0)
574 for (x
= m_begin
; x
!= m_end
; x
++)
580 HRESULT
Init(T
*begin
, T
*end
, IUnknown
*pUnk
, CComEnumFlags flags
= AtlFlagNoCopy
)
588 if (flags
== AtlFlagCopy
)
590 ATLTRY(newBuffer
= new T
[end
- begin
])
591 if (newBuffer
== NULL
)
592 return E_OUTOFMEMORY
;
594 for (sourcePtr
= begin
; sourcePtr
!= end
; sourcePtr
++)
597 hResult
= Copy::copy(destPtr
, sourcePtr
);
600 cleanupPtr
= m_begin
;
601 while (cleanupPtr
< destPtr
)
602 Copy::destroy(cleanupPtr
++);
609 m_end
= m_begin
+ (end
- begin
);
622 STDMETHOD(Next
)(ULONG celt
, T
*rgelt
, ULONG
*pceltFetched
)
629 if (pceltFetched
!= NULL
)
633 if (rgelt
== NULL
|| (celt
!= 1 && pceltFetched
== NULL
))
635 if (m_begin
== NULL
|| m_end
== NULL
|| m_iter
== NULL
)
638 numAvailable
= static_cast<ULONG
>(m_end
- m_iter
);
639 if (celt
< numAvailable
)
642 numToFetch
= numAvailable
;
643 if (pceltFetched
!= NULL
)
644 *pceltFetched
= numToFetch
;
646 while (numToFetch
!= 0)
648 hResult
= Copy::copy(rgeltTemp
, m_iter
);
651 while (rgelt
< rgeltTemp
)
652 Copy::destroy(rgelt
++);
653 if (pceltFetched
!= NULL
)
661 if (numAvailable
< celt
)
666 STDMETHOD(Skip
)(ULONG celt
)
674 numAvailable
= static_cast<ULONG
>(m_end
- m_iter
);
675 if (celt
< numAvailable
)
678 numToSkip
= numAvailable
;
680 if (numAvailable
< celt
)
691 STDMETHOD(Clone
)(Base
**ppEnum
)
693 enumeratorClass
*newInstance
;
700 hResult
= enumeratorClass::CreateInstance(&newInstance
);
701 if (SUCCEEDED(hResult
))
703 hResult
= newInstance
->Init(m_begin
, m_end
, (m_dwFlags
& BitOwn
) ? this : m_spUnk
);
704 if (SUCCEEDED(hResult
))
706 newInstance
->m_iter
= m_iter
;
707 hResult
= newInstance
->_InternalQueryInterface(*piid
, (void **)ppEnum
);
724 template <class Base
, const IID
*piid
, class T
, class Copy
, class ThreadModel
>
726 public CComEnumImpl
<Base
, piid
, T
, Copy
>,
727 public CComObjectRootEx
<ThreadModel
>
730 typedef CComEnum
<Base
, piid
, T
, Copy
> _CComEnum
;
731 typedef CComEnumImpl
<Base
, piid
, T
, Copy
> _CComEnumBase
;
733 BEGIN_COM_MAP(_CComEnum
)
734 COM_INTERFACE_ENTRY_IID(*piid
, _CComEnumBase
)
738 #ifndef _DEFAULT_VECTORLENGTH
739 #define _DEFAULT_VECTORLENGTH 4
742 class CComDynamicUnkArray
748 CComDynamicUnkArray()
754 ~CComDynamicUnkArray()
766 return &m_ppUnk
[m_nSize
];
769 IUnknown
*GetAt(int nIndex
)
771 ATLASSERT(nIndex
>= 0 && nIndex
< m_nSize
);
772 if (nIndex
>= 0 && nIndex
< m_nSize
)
773 return m_ppUnk
[nIndex
];
778 IUnknown
*WINAPI
GetUnknown(DWORD dwCookie
)
780 ATLASSERT(dwCookie
!= 0 && dwCookie
<= static_cast<DWORD
>(m_nSize
));
781 if (dwCookie
!= 0 && dwCookie
<= static_cast<DWORD
>(m_nSize
))
782 return GetAt(dwCookie
- 1);
787 DWORD WINAPI
GetCookie(IUnknown
**ppFind
)
792 ATLASSERT(ppFind
!= NULL
&& *ppFind
!= NULL
);
793 if (ppFind
!= NULL
&& *ppFind
!= NULL
)
796 for (x
= begin(); x
< end(); x
++)
806 DWORD
Add(IUnknown
*pUnk
)
813 ATLASSERT(pUnk
!= NULL
);
816 newSize
= _DEFAULT_VECTORLENGTH
* sizeof(IUnknown
*);
817 ATLTRY(newArray
= reinterpret_cast<IUnknown
**>(malloc(newSize
)));
818 if (newArray
== NULL
)
820 memset(newArray
, 0, newSize
);
822 m_nSize
= _DEFAULT_VECTORLENGTH
;
825 for (x
= begin(); x
< end(); x
++)
834 newSize
= m_nSize
* 2;
835 newArray
= reinterpret_cast<IUnknown
**>(realloc(m_ppUnk
, newSize
* sizeof(IUnknown
*)));
836 if (newArray
== NULL
)
839 memset(&m_ppUnk
[m_nSize
], 0, (newSize
- m_nSize
) * sizeof(IUnknown
*));
840 curCookie
= m_nSize
+ 1;
842 m_ppUnk
[curCookie
- 1] = pUnk
;
846 BOOL
Remove(DWORD dwCookie
)
850 index
= dwCookie
- 1;
851 ATLASSERT(index
< dwCookie
&& index
< static_cast<DWORD
>(m_nSize
));
852 if (index
< dwCookie
&& index
< static_cast<DWORD
>(m_nSize
) && m_ppUnk
[index
] != NULL
)
854 m_ppUnk
[index
] = NULL
;
861 CComDynamicUnkArray
&operator = (const CComDynamicUnkArray
&)
866 CComDynamicUnkArray(const CComDynamicUnkArray
&)
871 struct _ATL_CONNMAP_ENTRY
876 template <const IID
*piid
>
880 STDMETHOD(_LocCPQueryInterface
)(REFIID riid
, void **ppvObject
) = 0;
881 virtual ULONG STDMETHODCALLTYPE
AddRef() = 0;
882 virtual ULONG STDMETHODCALLTYPE
Release() = 0;
885 template<class T
, const IID
*piid
, class CDV
= CComDynamicUnkArray
>
886 class IConnectionPointImpl
: public _ICPLocator
<piid
>
888 typedef CComEnum
<IEnumConnections
, &IID_IEnumConnections
, CONNECTDATA
, _Copy
<CONNECTDATA
> > CComEnumConnections
;
892 ~IConnectionPointImpl()
896 for (x
= m_vec
.begin(); x
< m_vec
.end(); x
++)
901 STDMETHOD(_LocCPQueryInterface
)(REFIID riid
, void **ppvObject
)
903 IConnectionPointImpl
<T
, piid
, CDV
> *pThis
;
905 pThis
= reinterpret_cast<IConnectionPointImpl
<T
, piid
, CDV
>*>(this);
907 ATLASSERT(ppvObject
!= NULL
);
908 if (ppvObject
== NULL
)
911 if (InlineIsEqualGUID(riid
, IID_IConnectionPoint
) || InlineIsEqualUnknown(riid
))
920 return E_NOINTERFACE
;
924 STDMETHOD(GetConnectionInterface
)(IID
*piid2
)
932 STDMETHOD(GetConnectionPointContainer
)(IConnectionPointContainer
**ppCPC
)
936 pThis
= static_cast<T
*>(this);
937 return pThis
->QueryInterface(IID_IConnectionPointContainer
, reinterpret_cast<void **>(ppCPC
));
940 STDMETHOD(Advise
)(IUnknown
*pUnkSink
, DWORD
*pdwCookie
)
942 IUnknown
*adviseTarget
;
946 if (pdwCookie
!= NULL
)
948 if (pUnkSink
== NULL
|| pdwCookie
== NULL
)
950 GetConnectionInterface(&interfaceID
); // can't fail
951 hResult
= pUnkSink
->QueryInterface(interfaceID
, reinterpret_cast<void **>(&adviseTarget
));
952 if (SUCCEEDED(hResult
))
954 *pdwCookie
= m_vec
.Add(adviseTarget
);
959 adviseTarget
->Release();
960 hResult
= CONNECT_E_ADVISELIMIT
;
963 else if (hResult
== E_NOINTERFACE
)
964 hResult
= CONNECT_E_CANNOTCONNECT
;
968 STDMETHOD(Unadvise
)(DWORD dwCookie
)
970 IUnknown
*adviseTarget
;
973 adviseTarget
= m_vec
.GetUnknown(dwCookie
);
974 if (m_vec
.Remove(dwCookie
))
976 if (adviseTarget
!= NULL
)
977 adviseTarget
->Release();
981 hResult
= CONNECT_E_NOCONNECTION
;
985 STDMETHOD(EnumConnections
)(IEnumConnections
**ppEnum
)
987 CComObject
<CComEnumConnections
> *newEnumerator
;
988 CONNECTDATA
*itemBuffer
;
989 CONNECTDATA
*itemBufferEnd
;
993 ATLASSERT(ppEnum
!= NULL
);
998 ATLTRY(itemBuffer
= new CONNECTDATA
[m_vec
.end() - m_vec
.begin()])
999 if (itemBuffer
== NULL
)
1000 return E_OUTOFMEMORY
;
1001 itemBufferEnd
= itemBuffer
;
1002 for (x
= m_vec
.begin(); x
< m_vec
.end(); x
++)
1007 itemBufferEnd
->pUnk
= *x
;
1008 itemBufferEnd
->dwCookie
= m_vec
.GetCookie(x
);
1012 ATLTRY(newEnumerator
= new CComObject
<CComEnumConnections
>)
1013 if (newEnumerator
== NULL
)
1014 return E_OUTOFMEMORY
;
1015 newEnumerator
->Init(itemBuffer
, itemBufferEnd
, NULL
, AtlFlagTakeOwnership
); // can't fail
1016 hResult
= newEnumerator
->_InternalQueryInterface(IID_IEnumConnections
, (void **)ppEnum
);
1017 if (FAILED(hResult
))
1018 delete newEnumerator
;
1024 class IConnectionPointContainerImpl
: public IConnectionPointContainer
1026 typedef const _ATL_CONNMAP_ENTRY
* (*handlerFunctionType
)(int *);
1027 typedef CComEnum
<IEnumConnectionPoints
, &IID_IEnumConnectionPoints
, IConnectionPoint
*, _CopyInterface
<IConnectionPoint
> >
1028 CComEnumConnectionPoints
;
1031 STDMETHOD(EnumConnectionPoints
)(IEnumConnectionPoints
**ppEnum
)
1033 const _ATL_CONNMAP_ENTRY
*entryPtr
;
1034 int connectionPointCount
;
1035 IConnectionPoint
**itemBuffer
;
1037 handlerFunctionType handlerFunction
;
1038 CComEnumConnectionPoints
*newEnumerator
;
1041 ATLASSERT(ppEnum
!= NULL
);
1046 entryPtr
= T::GetConnMap(&connectionPointCount
);
1047 ATLTRY(itemBuffer
= new IConnectionPoint
* [connectionPointCount
])
1048 if (itemBuffer
== NULL
)
1049 return E_OUTOFMEMORY
;
1052 while (entryPtr
->dwOffset
!= static_cast<DWORD_PTR
>(-1))
1054 if (entryPtr
->dwOffset
== static_cast<DWORD_PTR
>(-2))
1057 handlerFunction
= reinterpret_cast<handlerFunctionType
>(entryPtr
->dwOffset
);
1058 entryPtr
= handlerFunction(NULL
);
1062 itemBuffer
[destIndex
++] = reinterpret_cast<IConnectionPoint
*>((char *)this + entryPtr
->dwOffset
);
1067 ATLTRY(newEnumerator
= new CComObject
<CComEnumConnectionPoints
>)
1068 if (newEnumerator
== NULL
)
1070 delete [] itemBuffer
;
1071 return E_OUTOFMEMORY
;
1074 newEnumerator
->Init(&itemBuffer
[0], &itemBuffer
[destIndex
], NULL
, AtlFlagTakeOwnership
); // can't fail
1075 hResult
= newEnumerator
->QueryInterface(IID_IEnumConnectionPoints
, (void**)ppEnum
);
1076 if (FAILED(hResult
))
1077 delete newEnumerator
;
1081 STDMETHOD(FindConnectionPoint
)(REFIID riid
, IConnectionPoint
**ppCP
)
1084 const _ATL_CONNMAP_ENTRY
*entryPtr
;
1085 handlerFunctionType handlerFunction
;
1086 IConnectionPoint
*connectionPoint
;
1092 hResult
= CONNECT_E_NOCONNECTION
;
1093 entryPtr
= T::GetConnMap(NULL
);
1094 while (entryPtr
->dwOffset
!= static_cast<DWORD_PTR
>(-1))
1096 if (entryPtr
->dwOffset
== static_cast<DWORD_PTR
>(-2))
1099 handlerFunction
= reinterpret_cast<handlerFunctionType
>(entryPtr
->dwOffset
);
1100 entryPtr
= handlerFunction(NULL
);
1104 connectionPoint
= reinterpret_cast<IConnectionPoint
*>(reinterpret_cast<char *>(this) + entryPtr
->dwOffset
);
1105 if (SUCCEEDED(connectionPoint
->GetConnectionInterface(&interfaceID
)) && InlineIsEqualGUID(riid
, interfaceID
))
1107 *ppCP
= connectionPoint
;
1108 connectionPoint
->AddRef();
1119 #define BEGIN_CONNECTION_POINT_MAP(x) \
1120 typedef x _atl_conn_classtype; \
1121 static const ATL::_ATL_CONNMAP_ENTRY *GetConnMap(int *pnEntries) { \
1122 static const ATL::_ATL_CONNMAP_ENTRY _entries[] = {
1124 #define END_CONNECTION_POINT_MAP() \
1125 {(DWORD_PTR)-1} }; \
1127 *pnEntries = sizeof(_entries) / sizeof(ATL::_ATL_CONNMAP_ENTRY) - 1; \
1130 #define CONNECTION_POINT_ENTRY(iid) \
1131 {offsetofclass(ATL::_ICPLocator<&iid>, _atl_conn_classtype) - \
1132 offsetofclass(ATL::IConnectionPointContainerImpl<_atl_conn_classtype>, _atl_conn_classtype)},