From ce7788e5ea25471fa091ef980d3e2bb0cc722fe7 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 5 May 2017 17:02:31 +0200 Subject: [PATCH] Refactor implementation of IUnknown in wxNotificationMessage (WinRT) Use dedicated macros to declare and define IUnknown interface in the helper class of wxNotificationMessage implementation. Now dependency on wxUSE_OLE is more visible, since these macros are defined in oleutils.h (see f2e707f095ce2ae7fab24aab482b53525b0dd895). --- src/msw/rt/notifmsgrt.cpp | 49 ++++++++------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/src/msw/rt/notifmsgrt.cpp b/src/msw/rt/notifmsgrt.cpp index 15482819a1..ba8e05330e 100644 --- a/src/msw/rt/notifmsgrt.cpp +++ b/src/msw/rt/notifmsgrt.cpp @@ -72,50 +72,21 @@ public: IFACEMETHODIMP Invoke(IToastNotification *sender, IToastFailedEventArgs *e); // IUnknown - IFACEMETHODIMP_(ULONG) AddRef() - { - return ++m_cRef; - } - - IFACEMETHODIMP_(ULONG) Release() - { - if ( --m_cRef == wxAutoULong(0) ) - { - delete this; - return 0; - } - else - return m_cRef; - } - - IFACEMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if ( IsEqualIID(riid, IID_IUnknown) ) - *ppv = static_cast(static_cast(this)); - else if ( IsEqualIID(riid, __uuidof(DesktopToastActivatedEventHandler)) ) - *ppv = static_cast(this); - else if ( IsEqualIID(riid, __uuidof(DesktopToastDismissedEventHandler)) ) - *ppv = static_cast(this); - else if ( IsEqualIID(riid, __uuidof(DesktopToastFailedEventHandler)) ) - *ppv = static_cast(this); - else - *ppv = NULL; - - if ( *ppv ) - { - reinterpret_cast(*ppv)->AddRef(); - return S_OK; - } - - return E_NOINTERFACE; - } + DECLARE_IUNKNOWN_METHODS; private: - wxAutoULong m_cRef; - wxToastNotifMsgImpl* m_impl; }; +BEGIN_IID_TABLE(wxToastEventHandler) +ADD_IID(Unknown) +ADD_RAW_IID(__uuidof(DesktopToastActivatedEventHandler)) +ADD_RAW_IID(__uuidof(DesktopToastDismissedEventHandler)) +ADD_RAW_IID(__uuidof(DesktopToastFailedEventHandler)) +END_IID_TABLE; + +IMPLEMENT_IUNKNOWN_METHODS(wxToastEventHandler) + class wxToastNotifMsgImpl : public wxNotificationMessageImpl { public: