diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-04-27 20:48:29 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-04-29 18:30:00 +0200 |
commit | 4a7dcee7456495b03382aff7b04afa4ddfc74444 (patch) | |
tree | aecc5ec845487f026408601c5ed59542c2aee891 /include | |
parent | 0acd47f68e3efb46dafd866ee95497da818fa34f (diff) |
Clean up tools/link.hxx
Change-Id: I44e4abb228394f99109f7d7e005cfeb26e4b95c1
Diffstat (limited to 'include')
-rw-r--r-- | include/svtools/svparser.hxx | 1 | ||||
-rw-r--r-- | include/tools/link.hxx | 159 | ||||
-rw-r--r-- | include/vcl/evntpost.hxx | 1 |
3 files changed, 69 insertions, 92 deletions
diff --git a/include/svtools/svparser.hxx b/include/svtools/svparser.hxx index 8a9d1609a6fd..575a51de0554 100644 --- a/include/svtools/svparser.hxx +++ b/include/svtools/svparser.hxx @@ -23,6 +23,7 @@ #include <svtools/svtdllapi.h> #include <tools/link.hxx> #include <tools/ref.hxx> +#include <tools/solar.h> #include <rtl/textenc.h> #include <rtl/ustring.hxx> #include <boost/noncopyable.hpp> diff --git a/include/tools/link.hxx b/include/tools/link.hxx index ea55a3eb2e46..2dd0100096ba 100644 --- a/include/tools/link.hxx +++ b/include/tools/link.hxx @@ -16,125 +16,100 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ + #ifndef INCLUDED_TOOLS_LINK_HXX #define INCLUDED_TOOLS_LINK_HXX -#include <tools/toolsdllapi.h> #include <sal/config.h> + #include <sal/types.h> -#include <tools/solar.h> +#include <tools/toolsdllapi.h> -typedef sal_IntPtr (*PSTUB)( void*, void* ); +#define DECL_LINK(Member, ArgType) \ + static sal_IntPtr LinkStub##Member(void *, void *); \ + sal_IntPtr Member(ArgType) -#define DECL_LINK( Method, ArgType ) \ - sal_IntPtr Method( ArgType ); \ - static sal_IntPtr LinkStub##Method( void* pThis, void* ) +#define DECL_STATIC_LINK(Class, Member, ArgType) \ + static sal_IntPtr LinkStub##Member(void *, void *); \ + static sal_IntPtr Member(Class *, ArgType) -#define DECL_STATIC_LINK( Class, Method, ArgType ) \ - static sal_IntPtr LinkStub##Method( void* pThis, void* ); \ - static sal_IntPtr Method( Class*, ArgType ) +#define DECL_DLLPRIVATE_LINK(Member, ArgType) \ + SAL_DLLPRIVATE static sal_IntPtr LinkStub##Member(void *, void *); \ + SAL_DLLPRIVATE sal_IntPtr Member(ArgType) -#define DECL_DLLPRIVATE_LINK(Method, ArgType) \ - SAL_DLLPRIVATE sal_IntPtr Method(ArgType); \ - SAL_DLLPRIVATE static sal_IntPtr LinkStub##Method(void * pThis, void *) +#define DECL_DLLPRIVATE_STATIC_LINK(Class, Member, ArgType) \ + SAL_DLLPRIVATE static sal_IntPtr LinkStub##Member(void *, void *); \ + SAL_DLLPRIVATE static sal_IntPtr Member(Class *, ArgType) -#define DECL_DLLPRIVATE_STATIC_LINK(Class, Method, ArgType) \ - SAL_DLLPRIVATE static sal_IntPtr LinkStub##Method( void* pThis, void* ); \ - SAL_DLLPRIVATE static sal_IntPtr Method(Class *, ArgType) +#define IMPL_LINK(Class, Member, ArgType, ArgName) \ + sal_IntPtr Class::LinkStub##Member(void * instance, void * data) { \ + return static_cast<Class *>(instance)->Member( \ + static_cast<ArgType>(data)); \ + } \ + sal_IntPtr Class::Member(ArgType ArgName) -#define IMPL_STUB(Class, Method, ArgType) \ - sal_IntPtr Class::LinkStub##Method( void* pThis, void* pCaller) \ - { \ - return static_cast<Class*>(pThis)->Method( static_cast<ArgType>(pCaller) ); \ - } +#define IMPL_LINK_NOARG(Class, Member) \ + sal_IntPtr Class::LinkStub##Member(void * instance, void * data) { \ + return static_cast<Class *>(instance)->Member(data); \ + } \ + sal_IntPtr Class::Member(SAL_UNUSED_PARAMETER void *) -#define IMPL_STATIC_LINK( Class, Method, ArgType, ArgName ) \ - sal_IntPtr Class::LinkStub##Method( void* pThis, void* pCaller) \ - { \ - return Method( static_cast<Class*>(pThis), static_cast<ArgType>(pCaller) ); \ +#define IMPL_STATIC_LINK(Class, Member, ArgType, ArgName) \ + sal_IntPtr Class::LinkStub##Member(void * instance, void * data) { \ + return Member( \ + static_cast<Class *>(instance), static_cast<ArgType>(data)); \ } \ - sal_IntPtr Class::Method( Class* pThis, ArgType ArgName ) + sal_IntPtr Class::Member(Class * pThis, ArgType ArgName) -#define IMPL_STATIC_LINK_NOINSTANCE( Class, Method, ArgType, ArgName ) \ - sal_IntPtr Class::LinkStub##Method( void* pThis, void* pCaller) \ - { \ - return Method( static_cast<Class*>(pThis), static_cast<ArgType>(pCaller) ); \ +#define IMPL_STATIC_LINK_NOINSTANCE(Class, Member, ArgType, ArgName) \ + sal_IntPtr Class::LinkStub##Member(void * instance, void * data) { \ + return Member( \ + static_cast<Class *>(instance), static_cast<ArgType>(data)); \ } \ - sal_IntPtr Class::Method( SAL_UNUSED_PARAMETER Class*, ArgType ArgName ) + sal_IntPtr Class::Member(SAL_UNUSED_PARAMETER Class *, ArgType ArgName) -#define IMPL_STATIC_LINK_NOINSTANCE_NOARG( Class, Method ) \ - sal_IntPtr Class::LinkStub##Method( void* pThis, void* pCaller) \ - { \ - return Method( static_cast<Class*>(pThis), pCaller ); \ +#define IMPL_STATIC_LINK_NOINSTANCE_NOARG(Class, Member) \ + sal_IntPtr Class::LinkStub##Member(void * instance, void * data) { \ + return Member(static_cast<Class *>(instance), data); \ } \ - sal_IntPtr Class::Method( SAL_UNUSED_PARAMETER Class*, SAL_UNUSED_PARAMETER void* ) + sal_IntPtr Class::Member( \ + SAL_UNUSED_PARAMETER Class *, SAL_UNUSED_PARAMETER void *) + +#define LINK(Instance, Class, Member) \ + Link(static_cast<Class *>(Instance), &Class::LinkStub##Member) -#define LINK( Inst, Class, Member ) \ - Link( static_cast<Class*>(Inst), &Class::LinkStub##Member ) +#define EMPTYARG -#define IMPL_LINK( Class, Method, ArgType, ArgName ) \ - IMPL_STUB( Class, Method, ArgType ) \ - sal_IntPtr Class::Method( ArgType ArgName ) +class TOOLS_DLLPUBLIC Link { +public: + typedef sal_IntPtr Stub(void *, void *); -#define IMPL_LINK_NOARG( Class, Method ) \ - IMPL_STUB( Class, Method, void* ) \ - sal_IntPtr Class::Method( SAL_UNUSED_PARAMETER void* ) + Link(): function_(nullptr), instance_(nullptr) {} -#define EMPTYARG + Link(void * instance, Stub * function): + function_(function), instance_(instance) {} -class TOOLS_DLLPUBLIC Link -{ - void* pInst; - PSTUB pFunc; + sal_IntPtr Call(void * data) const + { return function_ == nullptr ? 0 : (*function_)(instance_, data); } -public: - Link(); - Link( void* pLinkHdl, PSTUB pMemFunc ); + bool IsSet() const { return function_ != nullptr; } - sal_IntPtr Call( void* pCaller ) const; + bool operator !() const { return !IsSet(); } - bool IsSet() const; - bool operator !() const; + bool operator <(Link const & other) const { + return reinterpret_cast<sal_uIntPtr>(function_) + < reinterpret_cast<sal_uIntPtr>(other.function_); + }; - bool operator==( const Link& rLink ) const; - bool operator!=( const Link& rLink ) const - { return !(Link::operator==( rLink )); } - bool operator<( const Link& rLink ) const - { return reinterpret_cast<sal_uIntPtr>(rLink.pFunc) < reinterpret_cast<sal_uIntPtr>(pFunc); } -}; + bool operator ==(Link const & other) const + { return function_ == other.function_ && instance_ == other.instance_; }; + + bool operator !=(Link const & other) const { return !operator ==(other); }; -inline Link::Link() -{ - pInst = 0; - pFunc = 0; -} - -inline Link::Link( void* pLinkHdl, PSTUB pMemFunc ) -{ - pInst = pLinkHdl; - pFunc = pMemFunc; -} - -inline sal_IntPtr Link::Call(void *pCaller) const -{ - return pFunc ? (*pFunc)(pInst, pCaller) : 0; -} - -inline bool Link::IsSet() const -{ - if ( pFunc ) - return true; - else - return false; -} - -inline bool Link::operator !() const -{ - if ( !pFunc ) - return true; - else - return false; -} +private: + Stub * function_; + void * instance_; +}; #endif diff --git a/include/vcl/evntpost.hxx b/include/vcl/evntpost.hxx index 59898236c391..86b38f69253d 100644 --- a/include/vcl/evntpost.hxx +++ b/include/vcl/evntpost.hxx @@ -20,6 +20,7 @@ #define INCLUDED_VCL_EVNTPOST_HXX #include <tools/link.hxx> +#include <tools/solar.h> #include <vcl/dllapi.h> struct ImplSVEvent; |