From c15b763fbc2463a514dd7fcce04f2d0aad11f50f Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sat, 4 May 2013 08:39:05 +0000 Subject: [PATCH] [ATL] - Simplify CComObject code. Fix warnings. Patch by Katayama Hirofumi MZ. CORE-7105 #resolve svn path=/trunk/; revision=58918 --- reactos/lib/atl/atlcom.h | 44 ++++++++++++++------------------------- reactos/lib/atl/statreg.h | 1 + 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/reactos/lib/atl/atlcom.h b/reactos/lib/atl/atlcom.h index b787ec6d8a7..b46c5577dc8 100644 --- a/reactos/lib/atl/atlcom.h +++ b/reactos/lib/atl/atlcom.h @@ -2,6 +2,7 @@ * ReactOS ATL * * Copyright 2009 Andrew Hill + * Copyright 2013 Katayama Hirofumi MZ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -134,39 +135,28 @@ public: virtual ~CComObject() { - CComObject *pThis; - - pThis = reinterpret_cast *>(this); - pThis->FinalRelease(); + this->FinalRelease(); _pAtlModule->Unlock(); } STDMETHOD_(ULONG, AddRef)() { - CComObject *pThis; - - pThis = reinterpret_cast *>(this); - return pThis->InternalAddRef(); + return this->InternalAddRef(); } STDMETHOD_(ULONG, Release)() { - CComObject *pThis; - ULONG l; + ULONG newRefCount; - pThis = reinterpret_cast *>(this); - l = pThis->InternalRelease(); - if (l == 0) + newRefCount = this->InternalRelease(); + if (newRefCount == 0) delete this; - return l; + return newRefCount; } STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject) { - CComObject *pThis; - - pThis = reinterpret_cast *>(this); - return pThis->_InternalQueryInterface(iid, ppvObject); + return this->_InternalQueryInterface(iid, ppvObject); } static HRESULT WINAPI CreateInstance(CComObject **pp) @@ -283,11 +273,9 @@ public: STDMETHOD_(ULONG, AddRef)() { - CComObjectCached *pThis; ULONG newRefCount; - pThis = reinterpret_cast*>(this); - newRefCount = pThis->InternalAddRef(); + newRefCount = this->InternalAddRef(); if (newRefCount == 2) _pAtlModule->Lock(); return newRefCount; @@ -295,11 +283,9 @@ public: STDMETHOD_(ULONG, Release)() { - CComObjectCached *pThis; ULONG newRefCount; - pThis = reinterpret_cast*>(this); - newRefCount = pThis->InternalRelease(); + newRefCount = this->InternalRelease(); if (newRefCount == 0) delete this; else if (newRefCount == 1) @@ -309,10 +295,7 @@ public: STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject) { - CComObjectCached *pThis; - - pThis = reinterpret_cast*>(this); - return pThis->_InternalQueryInterface(iid, ppvObject); + return this->_InternalQueryInterface(iid, ppvObject); } }; @@ -436,6 +419,11 @@ class CComClassFactory : { public: _ATL_CREATORFUNC *m_pfnCreateInstance; + + virtual ~CComClassFactory() + { + } + public: STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj) { diff --git a/reactos/lib/atl/statreg.h b/reactos/lib/atl/statreg.h index 6ae3187e5aa..33f219a4779 100644 --- a/reactos/lib/atl/statreg.h +++ b/reactos/lib/atl/statreg.h @@ -63,6 +63,7 @@ public: hResult = ClearReplacements(); ATLASSERT(SUCCEEDED(hResult)); + (void)hResult; } HRESULT STDMETHODCALLTYPE QueryInterface(const IID & /* riid */, void ** /* ppvObject */ )