mirror of
https://github.com/reactos/reactos.git
synced 2025-05-13 22:30:21 +00:00
[ATL]
- Simplify CComObject code. Fix warnings. Patch by Katayama Hirofumi MZ. CORE-7105 #resolve svn path=/trunk/; revision=58918
This commit is contained in:
parent
66675db02b
commit
c15b763fbc
2 changed files with 17 additions and 28 deletions
|
@ -2,6 +2,7 @@
|
||||||
* ReactOS ATL
|
* ReactOS ATL
|
||||||
*
|
*
|
||||||
* Copyright 2009 Andrew Hill <ash77@reactos.org>
|
* Copyright 2009 Andrew Hill <ash77@reactos.org>
|
||||||
|
* Copyright 2013 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -134,39 +135,28 @@ public:
|
||||||
|
|
||||||
virtual ~CComObject()
|
virtual ~CComObject()
|
||||||
{
|
{
|
||||||
CComObject<Base> *pThis;
|
this->FinalRelease();
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObject<Base> *>(this);
|
|
||||||
pThis->FinalRelease();
|
|
||||||
_pAtlModule->Unlock();
|
_pAtlModule->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD_(ULONG, AddRef)()
|
STDMETHOD_(ULONG, AddRef)()
|
||||||
{
|
{
|
||||||
CComObject<Base> *pThis;
|
return this->InternalAddRef();
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObject<Base> *>(this);
|
|
||||||
return pThis->InternalAddRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD_(ULONG, Release)()
|
STDMETHOD_(ULONG, Release)()
|
||||||
{
|
{
|
||||||
CComObject<Base> *pThis;
|
ULONG newRefCount;
|
||||||
ULONG l;
|
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObject<Base> *>(this);
|
newRefCount = this->InternalRelease();
|
||||||
l = pThis->InternalRelease();
|
if (newRefCount == 0)
|
||||||
if (l == 0)
|
|
||||||
delete this;
|
delete this;
|
||||||
return l;
|
return newRefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
||||||
{
|
{
|
||||||
CComObject<Base> *pThis;
|
return this->_InternalQueryInterface(iid, ppvObject);
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObject<Base> *>(this);
|
|
||||||
return pThis->_InternalQueryInterface(iid, ppvObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI CreateInstance(CComObject<Base> **pp)
|
static HRESULT WINAPI CreateInstance(CComObject<Base> **pp)
|
||||||
|
@ -283,11 +273,9 @@ public:
|
||||||
|
|
||||||
STDMETHOD_(ULONG, AddRef)()
|
STDMETHOD_(ULONG, AddRef)()
|
||||||
{
|
{
|
||||||
CComObjectCached<Base> *pThis;
|
|
||||||
ULONG newRefCount;
|
ULONG newRefCount;
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObjectCached<Base>*>(this);
|
newRefCount = this->InternalAddRef();
|
||||||
newRefCount = pThis->InternalAddRef();
|
|
||||||
if (newRefCount == 2)
|
if (newRefCount == 2)
|
||||||
_pAtlModule->Lock();
|
_pAtlModule->Lock();
|
||||||
return newRefCount;
|
return newRefCount;
|
||||||
|
@ -295,11 +283,9 @@ public:
|
||||||
|
|
||||||
STDMETHOD_(ULONG, Release)()
|
STDMETHOD_(ULONG, Release)()
|
||||||
{
|
{
|
||||||
CComObjectCached<Base> *pThis;
|
|
||||||
ULONG newRefCount;
|
ULONG newRefCount;
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObjectCached<Base>*>(this);
|
newRefCount = this->InternalRelease();
|
||||||
newRefCount = pThis->InternalRelease();
|
|
||||||
if (newRefCount == 0)
|
if (newRefCount == 0)
|
||||||
delete this;
|
delete this;
|
||||||
else if (newRefCount == 1)
|
else if (newRefCount == 1)
|
||||||
|
@ -309,10 +295,7 @@ public:
|
||||||
|
|
||||||
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
|
||||||
{
|
{
|
||||||
CComObjectCached<Base> *pThis;
|
return this->_InternalQueryInterface(iid, ppvObject);
|
||||||
|
|
||||||
pThis = reinterpret_cast<CComObjectCached<Base>*>(this);
|
|
||||||
return pThis->_InternalQueryInterface(iid, ppvObject);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -436,6 +419,11 @@ class CComClassFactory :
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
_ATL_CREATORFUNC *m_pfnCreateInstance;
|
_ATL_CREATORFUNC *m_pfnCreateInstance;
|
||||||
|
|
||||||
|
virtual ~CComClassFactory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
|
STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
hResult = ClearReplacements();
|
hResult = ClearReplacements();
|
||||||
ATLASSERT(SUCCEEDED(hResult));
|
ATLASSERT(SUCCEEDED(hResult));
|
||||||
|
(void)hResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(const IID & /* riid */, void ** /* ppvObject */ )
|
HRESULT STDMETHODCALLTYPE QueryInterface(const IID & /* riid */, void ** /* ppvObject */ )
|
||||||
|
|
Loading…
Reference in a new issue