mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:23:01 +00:00
[ATL] Add OBJECT_ENTRY_AUTO for simpler com object registration
Of course gcc needs a nasty hack to include the symbol. CORE-18936
This commit is contained in:
parent
bf29d98a54
commit
d12880829f
2 changed files with 216 additions and 19 deletions
|
@ -30,7 +30,12 @@ namespace ATL
|
|||
template <class Base, const IID *piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
|
||||
class CComEnum;
|
||||
|
||||
#if defined(_WINDLL) | defined(_USRDLL)
|
||||
#define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass;
|
||||
#else
|
||||
// Class factory should not change lock count
|
||||
#define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectNoLock<cf>> _ClassFactoryCreatorClass;
|
||||
#endif
|
||||
#define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory)
|
||||
#define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(ATL::CComClassFactorySingleton<obj>)
|
||||
|
||||
|
@ -539,6 +544,40 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Base>
|
||||
class CComObjectNoLock : public Base
|
||||
{
|
||||
public:
|
||||
CComObjectNoLock(void* = NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CComObjectNoLock()
|
||||
{
|
||||
this->FinalRelease();
|
||||
}
|
||||
|
||||
STDMETHOD_(ULONG, AddRef)()
|
||||
{
|
||||
return this->InternalAddRef();
|
||||
}
|
||||
|
||||
STDMETHOD_(ULONG, Release)()
|
||||
{
|
||||
ULONG newRefCount = this->InternalRelease();
|
||||
if (newRefCount == 0)
|
||||
delete this;
|
||||
return newRefCount;
|
||||
}
|
||||
|
||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
||||
{
|
||||
return this->_InternalQueryInterface(iid, ppvObject);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define BEGIN_COM_MAP(x) \
|
||||
public: \
|
||||
typedef x _ComMapClass; \
|
||||
|
@ -663,6 +702,24 @@ public:
|
|||
class::GetCategoryMap, \
|
||||
class::ObjectMain },
|
||||
|
||||
|
||||
|
||||
#define OBJECT_ENTRY_AUTO(clsid, class) \
|
||||
ATL::_ATL_OBJMAP_ENTRY __objMap_##class = { \
|
||||
&clsid, \
|
||||
class ::UpdateRegistry, \
|
||||
class ::_ClassFactoryCreatorClass::CreateInstance, \
|
||||
class ::_CreatorClass::CreateInstance, \
|
||||
NULL, \
|
||||
0, \
|
||||
class ::GetObjectDescription, \
|
||||
class ::GetCategoryMap, \
|
||||
class ::ObjectMain}; \
|
||||
extern "C" _ATLALLOC("ATL$__m") ATL::_ATL_OBJMAP_ENTRY *const __pobjMap_##class = &__objMap_##class; \
|
||||
OBJECT_ENTRY_PRAGMA(class)
|
||||
|
||||
|
||||
|
||||
class CComClassFactory :
|
||||
public IClassFactory,
|
||||
public CComObjectRootEx<CComGlobalsThreadModel>
|
||||
|
@ -772,6 +829,7 @@ class CComCoClass
|
|||
{
|
||||
public:
|
||||
DECLARE_CLASSFACTORY()
|
||||
//DECLARE_AGGREGATABLE(T) // This should be here, but gcc...
|
||||
|
||||
static LPCTSTR WINAPI GetObjectDescription()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue