4 * Copyright 2009 Andrew Hill <ash77@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 template <class Base
, const IID
*piid
, class T
, class Copy
, class ThreadModel
= CComObjectThreadModel
>
29 #define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass;
30 #define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory)
32 class CComObjectRootBase
50 HRESULT
_AtlFinalConstruct()
55 HRESULT
FinalConstruct()
60 void InternalFinalConstructAddRef()
64 void InternalFinalConstructRelease()
72 static void WINAPI
ObjectMain(bool)
76 static const struct _ATL_CATMAP_ENTRY
*GetCategoryMap()
81 static HRESULT WINAPI
InternalQueryInterface(void *pThis
, const _ATL_INTMAP_ENTRY
*pEntries
, REFIID iid
, void **ppvObject
)
83 return AtlInternalQueryInterface(pThis
, pEntries
, iid
, ppvObject
);
88 template <class ThreadModel
>
89 class CComObjectRootEx
: public CComObjectRootBase
92 typename
ThreadModel::AutoDeleteCriticalSection m_critsec
;
98 ULONG
InternalAddRef()
100 ATLASSERT(m_dwRef
>= 0);
101 return ThreadModel::Increment(&m_dwRef
);
104 ULONG
InternalRelease()
106 ATLASSERT(m_dwRef
> 0);
107 return ThreadModel::Decrement(&m_dwRef
);
120 HRESULT
_AtlInitialConstruct()
122 return m_critsec
.Init();
126 template <class Base
>
127 class CComObject
: public Base
130 CComObject(void * = NULL
)
135 virtual ~CComObject()
137 CComObject
<Base
> *pThis
;
139 pThis
= reinterpret_cast<CComObject
<Base
> *>(this);
140 pThis
->FinalRelease();
141 _pAtlModule
->Unlock();
144 STDMETHOD_(ULONG
, AddRef
)()
146 CComObject
<Base
> *pThis
;
148 pThis
= reinterpret_cast<CComObject
<Base
> *>(this);
149 return pThis
->InternalAddRef();
152 STDMETHOD_(ULONG
, Release
)()
154 CComObject
<Base
> *pThis
;
157 pThis
= reinterpret_cast<CComObject
<Base
> *>(this);
158 l
= pThis
->InternalRelease();
164 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
166 CComObject
<Base
> *pThis
;
168 pThis
= reinterpret_cast<CComObject
<Base
> *>(this);
169 return pThis
->_InternalQueryInterface(iid
, ppvObject
);
172 static HRESULT WINAPI
CreateInstance(CComObject
<Base
> **pp
)
174 CComObject
<Base
> *newInstance
;
177 ATLASSERT(pp
!= NULL
);
181 hResult
= E_OUTOFMEMORY
;
183 ATLTRY(newInstance
= new CComObject
<Base
>())
184 if (newInstance
!= NULL
)
186 newInstance
->SetVoid(NULL
);
187 newInstance
->InternalFinalConstructAddRef();
188 hResult
= newInstance
->_AtlInitialConstruct();
189 if (SUCCEEDED(hResult
))
190 hResult
= newInstance
->FinalConstruct();
191 if (SUCCEEDED(hResult
))
192 hResult
= newInstance
->_AtlFinalConstruct();
193 newInstance
->InternalFinalConstructRelease();
207 template <HRESULT hResult
>
208 class CComFailCreator
211 static HRESULT WINAPI
CreateInstance(void *, REFIID
, LPVOID
*ppv
)
213 ATLASSERT(ppv
!= NULL
);
226 static HRESULT WINAPI
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
231 ATLASSERT(ppv
!= NULL
);
236 hResult
= E_OUTOFMEMORY
;
238 ATLTRY(newInstance
= new T1())
239 if (newInstance
!= NULL
)
241 newInstance
->SetVoid(pv
);
242 newInstance
->InternalFinalConstructAddRef();
243 hResult
= newInstance
->_AtlInitialConstruct();
244 if (SUCCEEDED(hResult
))
245 hResult
= newInstance
->FinalConstruct();
246 if (SUCCEEDED(hResult
))
247 hResult
= newInstance
->_AtlFinalConstruct();
248 newInstance
->InternalFinalConstructRelease();
249 if (SUCCEEDED(hResult
))
250 hResult
= newInstance
->QueryInterface(riid
, ppv
);
261 template <class T1
, class T2
>
265 static HRESULT WINAPI
CreateInstance(void *pv
, REFIID riid
, LPVOID
*ppv
)
267 ATLASSERT(ppv
!= NULL
&& ppv
!= NULL
);
270 return T1::CreateInstance(NULL
, riid
, ppv
);
272 return T2::CreateInstance(pv
, riid
, ppv
);
276 template <class Base
>
277 class CComObjectCached
: public Base
280 CComObjectCached(void * = NULL
)
284 STDMETHOD_(ULONG
, AddRef
)()
286 CComObjectCached
<Base
> *pThis
;
289 pThis
= reinterpret_cast<CComObjectCached
<Base
>*>(this);
290 newRefCount
= pThis
->InternalAddRef();
291 if (newRefCount
== 2)
296 STDMETHOD_(ULONG
, Release
)()
298 CComObjectCached
<Base
> *pThis
;
301 pThis
= reinterpret_cast<CComObjectCached
<Base
>*>(this);
302 newRefCount
= pThis
->InternalRelease();
303 if (newRefCount
== 0)
305 else if (newRefCount
== 1)
306 _pAtlModule
->Unlock();
310 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
312 CComObjectCached
<Base
> *pThis
;
314 pThis
= reinterpret_cast<CComObjectCached
<Base
>*>(this);
315 return pThis
->_InternalQueryInterface(iid
, ppvObject
);
319 #define BEGIN_COM_MAP(x) \
321 typedef x _ComMapClass; \
322 HRESULT _InternalQueryInterface(REFIID iid, void **ppvObject) \
324 return InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \
326 const static ATL::_ATL_INTMAP_ENTRY *WINAPI _GetEntries() \
328 static const ATL::_ATL_INTMAP_ENTRY _entries[] = {
330 #define END_COM_MAP() \
335 virtual ULONG STDMETHODCALLTYPE AddRef() = 0; \
336 virtual ULONG STDMETHODCALLTYPE Release() = 0; \
337 STDMETHOD(QueryInterface)(REFIID, void **) = 0;
339 #define COM_INTERFACE_ENTRY_IID(iid, x) \
340 {&iid, offsetofclass(x, _ComMapClass), _ATL_SIMPLEMAPENTRY},
342 #define COM_INTERFACE_ENTRY2_IID(iid, x, x2) \
344 reinterpret_cast<DWORD_PTR>(static_cast<x *>(static_cast<x2 *>(reinterpret_cast<_ComMapClass *>(_ATL_PACKING)))) - _ATL_PACKING, \
345 _ATL_SIMPLEMAPENTRY},
347 #define COM_INTERFACE_ENTRY_BREAK(x) \
350 _Break}, // Break is a function that issues int 3.
352 #define COM_INTERFACE_ENTRY_NOINTERFACE(x) \
355 _NoInterface}, // NoInterface returns E_NOINTERFACE.
357 #define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) \
362 #define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) \
367 #define COM_INTERFACE_ENTRY_CHAIN(classname) \
369 reinterpret_cast<DWORD>(&_CComChainData<classname, _ComMapClass>::data), \
372 #define DECLARE_REGISTRY_RESOURCEID(x)\
373 static HRESULT WINAPI UpdateRegistry(BOOL bRegister)\
375 return ATL::_pAtlModule->UpdateRegistryFromResource(x, bRegister); \
378 #define DECLARE_NOT_AGGREGATABLE(x) \
380 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
382 #define DECLARE_AGGREGATABLE(x) \
384 typedef CComCreator2<CComCreator<CComObject<x> >, CComCreator<CComAggObject<x> > > _CreatorClass;
386 #define DECLARE_ONLY_AGGREGATABLE(x) \
388 typedef CComCreator2<CComFailCreator<E_FAIL>, CComCreator<CComAggObject<x> > > _CreatorClass;
390 #define DECLARE_POLY_AGGREGATABLE(x) \
392 typedef CComCreator<CComPolyObject<x> > _CreatorClass;
394 #define DECLARE_GET_CONTROLLING_UNKNOWN() \
396 virtual IUnknown *GetControllingUnknown() \
398 return GetUnknown(); \
401 #define DECLARE_PROTECT_FINAL_CONSTRUCT() \
402 void InternalFinalConstructAddRef() \
406 void InternalFinalConstructRelease() \
411 #define BEGIN_OBJECT_MAP(x) static ATL::_ATL_OBJMAP_ENTRY x[] = {
413 #define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
415 #define OBJECT_ENTRY(clsid, class) \
418 class::UpdateRegistry, \
419 class::_ClassFactoryCreatorClass::CreateInstance, \
420 class::_CreatorClass::CreateInstance, \
423 class::GetObjectDescription, \
424 class::GetCategoryMap, \
427 class CComClassFactory
:
428 public IClassFactory
,
429 public CComObjectRootEx
<CComGlobalsThreadModel
>
432 _ATL_CREATORFUNC
*m_pfnCreateInstance
;
434 STDMETHOD(CreateInstance
)(LPUNKNOWN pUnkOuter
, REFIID riid
, void **ppvObj
)
438 ATLASSERT(m_pfnCreateInstance
!= NULL
);
444 if (pUnkOuter
!= NULL
&& InlineIsEqualUnknown(riid
) == FALSE
)
445 hResult
= CLASS_E_NOAGGREGATION
;
447 hResult
= m_pfnCreateInstance(pUnkOuter
, riid
, ppvObj
);
451 STDMETHOD(LockServer
)(BOOL fLock
)
456 _pAtlModule
->Unlock();
460 void SetVoid(void *pv
)
462 m_pfnCreateInstance
= (_ATL_CREATORFUNC
*)pv
;
465 BEGIN_COM_MAP(CComClassFactory
)
466 COM_INTERFACE_ENTRY_IID(IID_IClassFactory
, IClassFactory
)
470 template <class T
, const CLSID
*pclsid
= &CLSID_NULL
>
474 DECLARE_CLASSFACTORY()
476 static LPCTSTR WINAPI
GetObjectDescription()
486 static HRESULT
copy(T
*pTo
, const T
*pFrom
)
488 memcpy(pTo
, pFrom
, sizeof(T
));
492 static void init(T
*)
496 static void destroy(T
*)
502 class _Copy
<CONNECTDATA
>
505 static HRESULT
copy(CONNECTDATA
*pTo
, const CONNECTDATA
*pFrom
)
513 static void init(CONNECTDATA
*)
517 static void destroy(CONNECTDATA
*p
)
528 static HRESULT
copy(T
**pTo
, T
**pFrom
)
536 static void init(T
**)
540 static void destroy(T
**p
)
550 AtlFlagTakeOwnership
= 2, // BitOwn
551 AtlFlagCopy
= 3 // BitOwn | BitCopy
554 template <class Base
, const IID
*piid
, class T
, class Copy
>
555 class CComEnumImpl
: public Base
558 typedef CComObject
<CComEnum
<Base
, piid
, T
, Copy
> > enumeratorClass
;
560 CComPtr
<IUnknown
> m_spUnk
;
574 virtual ~CComEnumImpl()
578 if ((m_dwFlags
& BitOwn
) != 0)
580 for (x
= m_begin
; x
!= m_end
; x
++)
586 HRESULT
Init(T
*begin
, T
*end
, IUnknown
*pUnk
, CComEnumFlags flags
= AtlFlagNoCopy
)
594 if (flags
== AtlFlagCopy
)
596 ATLTRY(newBuffer
= new T
[end
- begin
])
597 if (newBuffer
== NULL
)
598 return E_OUTOFMEMORY
;
600 for (sourcePtr
= begin
; sourcePtr
!= end
; sourcePtr
++)
603 hResult
= Copy::copy(destPtr
, sourcePtr
);
606 cleanupPtr
= m_begin
;
607 while (cleanupPtr
< destPtr
)
608 Copy::destroy(cleanupPtr
++);
615 m_end
= m_begin
+ (end
- begin
);
628 STDMETHOD(Next
)(ULONG celt
, T
*rgelt
, ULONG
*pceltFetched
)
635 if (pceltFetched
!= NULL
)
639 if (rgelt
== NULL
|| (celt
!= 1 && pceltFetched
== NULL
))
641 if (m_begin
== NULL
|| m_end
== NULL
|| m_iter
== NULL
)
644 numAvailable
= static_cast<ULONG
>(m_end
- m_iter
);
645 if (celt
< numAvailable
)
648 numToFetch
= numAvailable
;
649 if (pceltFetched
!= NULL
)
650 *pceltFetched
= numToFetch
;
652 while (numToFetch
!= 0)
654 hResult
= Copy::copy(rgeltTemp
, m_iter
);
657 while (rgelt
< rgeltTemp
)
658 Copy::destroy(rgelt
++);
659 if (pceltFetched
!= NULL
)
667 if (numAvailable
< celt
)
672 STDMETHOD(Skip
)(ULONG celt
)
680 numAvailable
= static_cast<ULONG
>(m_end
- m_iter
);
681 if (celt
< numAvailable
)
684 numToSkip
= numAvailable
;
686 if (numAvailable
< celt
)
697 STDMETHOD(Clone
)(Base
**ppEnum
)
699 enumeratorClass
*newInstance
;
706 hResult
= enumeratorClass::CreateInstance(&newInstance
);
707 if (SUCCEEDED(hResult
))
709 hResult
= newInstance
->Init(m_begin
, m_end
, (m_dwFlags
& BitOwn
) ? this : m_spUnk
);
710 if (SUCCEEDED(hResult
))
712 newInstance
->m_iter
= m_iter
;
713 hResult
= newInstance
->_InternalQueryInterface(*piid
, (void **)ppEnum
);
730 template <class Base
, const IID
*piid
, class T
, class Copy
, class ThreadModel
>
732 public CComEnumImpl
<Base
, piid
, T
, Copy
>,
733 public CComObjectRootEx
<ThreadModel
>
736 typedef CComEnum
<Base
, piid
, T
, Copy
> _CComEnum
;
737 typedef CComEnumImpl
<Base
, piid
, T
, Copy
> _CComEnumBase
;
739 BEGIN_COM_MAP(_CComEnum
)
740 COM_INTERFACE_ENTRY_IID(*piid
, _CComEnumBase
)
744 #ifndef _DEFAULT_VECTORLENGTH
745 #define _DEFAULT_VECTORLENGTH 4
748 class CComDynamicUnkArray
754 CComDynamicUnkArray()
760 ~CComDynamicUnkArray()
772 return &m_ppUnk
[m_nSize
];
775 IUnknown
*GetAt(int nIndex
)
777 ATLASSERT(nIndex
>= 0 && nIndex
< m_nSize
);
778 if (nIndex
>= 0 && nIndex
< m_nSize
)
779 return m_ppUnk
[nIndex
];
784 IUnknown
*WINAPI
GetUnknown(DWORD dwCookie
)
786 ATLASSERT(dwCookie
!= 0 && dwCookie
<= static_cast<DWORD
>(m_nSize
));
787 if (dwCookie
!= 0 && dwCookie
<= static_cast<DWORD
>(m_nSize
))
788 return GetAt(dwCookie
- 1);
793 DWORD WINAPI
GetCookie(IUnknown
**ppFind
)
798 ATLASSERT(ppFind
!= NULL
&& *ppFind
!= NULL
);
799 if (ppFind
!= NULL
&& *ppFind
!= NULL
)
802 for (x
= begin(); x
< end(); x
++)
812 DWORD
Add(IUnknown
*pUnk
)
819 ATLASSERT(pUnk
!= NULL
);
822 newSize
= _DEFAULT_VECTORLENGTH
* sizeof(IUnknown
*);
823 ATLTRY(newArray
= reinterpret_cast<IUnknown
**>(malloc(newSize
)));
824 if (newArray
== NULL
)
826 memset(newArray
, 0, newSize
);
828 m_nSize
= _DEFAULT_VECTORLENGTH
;
831 for (x
= begin(); x
< end(); x
++)
840 newSize
= m_nSize
* 2;
841 newArray
= reinterpret_cast<IUnknown
**>(realloc(m_ppUnk
, newSize
* sizeof(IUnknown
*)));
842 if (newArray
== NULL
)
844 memset(&m_ppUnk
[m_nSize
], 0, (newSize
- m_nSize
) * sizeof(IUnknown
*));
847 m_ppUnk
[m_nSize
] = pUnk
;
851 BOOL
Remove(DWORD dwCookie
)
855 index
= dwCookie
- 1;
856 ATLASSERT(index
< dwCookie
&& index
< static_cast<DWORD
>(m_nSize
));
857 if (index
< dwCookie
&& index
< static_cast<DWORD
>(m_nSize
) && m_ppUnk
[index
] != NULL
)
859 m_ppUnk
[index
] = NULL
;
867 struct _ATL_CONNMAP_ENTRY
872 template <const IID
*piid
>
876 STDMETHOD(_LocCPQueryInterface
)(REFIID riid
, void **ppvObject
) = 0;
877 virtual ULONG STDMETHODCALLTYPE
AddRef() = 0;
878 virtual ULONG STDMETHODCALLTYPE
Release() = 0;
881 template<class T
, const IID
*piid
, class CDV
= CComDynamicUnkArray
>
882 class IConnectionPointImpl
: public _ICPLocator
<piid
>
884 typedef CComEnum
<IEnumConnections
, &IID_IEnumConnections
, CONNECTDATA
, _Copy
<CONNECTDATA
> > CComEnumConnections
;
888 ~IConnectionPointImpl()
892 for (x
= m_vec
.begin(); x
< m_vec
.end(); x
++)
897 STDMETHOD(_LocCPQueryInterface
)(REFIID riid
, void **ppvObject
)
899 IConnectionPointImpl
<T
, piid
, CDV
> *pThis
;
901 pThis
= reinterpret_cast<IConnectionPointImpl
<T
, piid
, CDV
>*>(this);
903 ATLASSERT(ppvObject
!= NULL
);
904 if (ppvObject
== NULL
)
907 if (InlineIsEqualGUID(riid
, IID_IConnectionPoint
) || InlineIsEqualUnknown(riid
))
916 return E_NOINTERFACE
;
920 STDMETHOD(GetConnectionInterface
)(IID
*piid2
)
928 STDMETHOD(GetConnectionPointContainer
)(IConnectionPointContainer
**ppCPC
)
932 pThis
= static_cast<T
*>(this);
933 return pThis
->QueryInterface(IID_IConnectionPointContainer
, reinterpret_cast<void **>(ppCPC
));
936 STDMETHOD(Advise
)(IUnknown
*pUnkSink
, DWORD
*pdwCookie
)
938 IUnknown
*adviseTarget
;
942 if (pdwCookie
!= NULL
)
944 if (pUnkSink
== NULL
|| pdwCookie
== NULL
)
946 GetConnectionInterface(&interfaceID
); // can't fail
947 hResult
= pUnkSink
->QueryInterface(interfaceID
, reinterpret_cast<void **>(&adviseTarget
));
948 if (SUCCEEDED(hResult
))
950 *pdwCookie
= m_vec
.Add(adviseTarget
);
955 adviseTarget
->Release();
956 hResult
= CONNECT_E_ADVISELIMIT
;
959 else if (hResult
== E_NOINTERFACE
)
960 hResult
= CONNECT_E_CANNOTCONNECT
;
964 STDMETHOD(Unadvise
)(DWORD dwCookie
)
966 IUnknown
*adviseTarget
;
969 adviseTarget
= m_vec
.GetUnknown(dwCookie
);
970 if (m_vec
.Remove(dwCookie
))
972 if (adviseTarget
!= NULL
)
973 adviseTarget
->Release();
977 hResult
= CONNECT_E_NOCONNECTION
;
981 STDMETHOD(EnumConnections
)(IEnumConnections
**ppEnum
)
983 CComObject
<CComEnumConnections
> *newEnumerator
;
984 CONNECTDATA
*itemBuffer
;
985 CONNECTDATA
*itemBufferEnd
;
989 ATLASSERT(ppEnum
!= NULL
);
994 ATLTRY(itemBuffer
= new CONNECTDATA
[m_vec
.end() - m_vec
.begin()])
995 if (itemBuffer
== NULL
)
996 return E_OUTOFMEMORY
;
997 itemBufferEnd
= itemBuffer
;
998 for (x
= m_vec
.begin(); x
< m_vec
.end(); x
++)
1003 itemBufferEnd
->pUnk
= *x
;
1004 itemBufferEnd
->dwCookie
= m_vec
.GetCookie(x
);
1008 ATLTRY(newEnumerator
= new CComObject
<CComEnumConnections
>)
1009 if (newEnumerator
== NULL
)
1010 return E_OUTOFMEMORY
;
1011 newEnumerator
->Init(itemBuffer
, itemBufferEnd
, NULL
, AtlFlagTakeOwnership
); // can't fail
1012 hResult
= newEnumerator
->_InternalQueryInterface(IID_IEnumConnections
, (void **)ppEnum
);
1013 if (FAILED(hResult
))
1014 delete newEnumerator
;
1020 class IConnectionPointContainerImpl
: public IConnectionPointContainer
1022 typedef const _ATL_CONNMAP_ENTRY
* (*handlerFunctionType
)(int *);
1023 typedef CComEnum
<IEnumConnectionPoints
, &IID_IEnumConnectionPoints
, IConnectionPoint
*, _CopyInterface
<IConnectionPoint
> >
1024 CComEnumConnectionPoints
;
1027 STDMETHOD(EnumConnectionPoints
)(IEnumConnectionPoints
**ppEnum
)
1029 const _ATL_CONNMAP_ENTRY
*entryPtr
;
1030 int connectionPointCount
;
1031 IConnectionPoint
**itemBuffer
;
1033 handlerFunctionType handlerFunction
;
1034 CComEnumConnectionPoints
*newEnumerator
;
1037 ATLASSERT(ppEnum
!= NULL
);
1042 entryPtr
= T::GetConnMap(&connectionPointCount
);
1043 ATLTRY(itemBuffer
= new IConnectionPoint
* [connectionPointCount
])
1044 if (itemBuffer
== NULL
)
1045 return E_OUTOFMEMORY
;
1048 while (entryPtr
->dwOffset
!= static_cast<DWORD_PTR
>(-1))
1050 if (entryPtr
->dwOffset
== static_cast<DWORD_PTR
>(-2))
1053 handlerFunction
= reinterpret_cast<handlerFunctionType
>(entryPtr
->dwOffset
);
1054 entryPtr
= handlerFunction(NULL
);
1058 itemBuffer
[destIndex
++] = reinterpret_cast<IConnectionPoint
*>((char *)this + entryPtr
->dwOffset
);
1063 ATLTRY(newEnumerator
= new CComObject
<CComEnumConnectionPoints
>)
1064 if (newEnumerator
== NULL
)
1066 delete [] itemBuffer
;
1067 return E_OUTOFMEMORY
;
1070 newEnumerator
->Init(&itemBuffer
[0], &itemBuffer
[destIndex
], NULL
, AtlFlagTakeOwnership
); // can't fail
1071 hResult
= newEnumerator
->QueryInterface(IID_IEnumConnectionPoints
, (void**)ppEnum
);
1072 if (FAILED(hResult
))
1073 delete newEnumerator
;
1077 STDMETHOD(FindConnectionPoint
)(REFIID riid
, IConnectionPoint
**ppCP
)
1080 const _ATL_CONNMAP_ENTRY
*entryPtr
;
1081 handlerFunctionType handlerFunction
;
1082 IConnectionPoint
*connectionPoint
;
1088 hResult
= CONNECT_E_NOCONNECTION
;
1089 entryPtr
= T::GetConnMap(NULL
);
1090 while (entryPtr
->dwOffset
!= static_cast<DWORD_PTR
>(-1))
1092 if (entryPtr
->dwOffset
== static_cast<DWORD_PTR
>(-2))
1095 handlerFunction
= reinterpret_cast<handlerFunctionType
>(entryPtr
->dwOffset
);
1096 entryPtr
= handlerFunction(NULL
);
1100 connectionPoint
= reinterpret_cast<IConnectionPoint
*>(reinterpret_cast<char *>(this) + entryPtr
->dwOffset
);
1101 if (SUCCEEDED(connectionPoint
->GetConnectionInterface(&interfaceID
)) && InlineIsEqualGUID(riid
, interfaceID
))
1103 *ppCP
= connectionPoint
;
1104 connectionPoint
->AddRef();
1115 #define BEGIN_CONNECTION_POINT_MAP(x) \
1116 typedef x _atl_conn_classtype; \
1117 static const ATL::_ATL_CONNMAP_ENTRY *GetConnMap(int *pnEntries) { \
1118 static const ATL::_ATL_CONNMAP_ENTRY _entries[] = {
1120 #define END_CONNECTION_POINT_MAP() \
1121 {(DWORD_PTR)-1} }; \
1123 *pnEntries = sizeof(_entries) / sizeof(ATL::_ATL_CONNMAP_ENTRY) - 1; \
1126 #define CONNECTION_POINT_ENTRY(iid) \
1127 {offsetofclass(ATL::_ICPLocator<&iid>, _atl_conn_classtype) - \
1128 offsetofclass(ATL::IConnectionPointContainerImpl<_atl_conn_classtype>, _atl_conn_classtype)},