Kaydet (Commit) 4a7dcee7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up tools/link.hxx

Change-Id: I44e4abb228394f99109f7d7e005cfeb26e4b95c1
üst 0acd47f6
......@@ -30,6 +30,7 @@
#include <string.h>
#include <tools/link.hxx>
#include <tools/solar.h>
#include <osl/pipe.hxx>
#include <osl/mutex.hxx>
#include <osl/conditn.hxx>
......
......@@ -93,6 +93,8 @@ extern "C" {
#include <postx.h>
#include <tools/solar.h>
class ConnectorInstance
{
public:
......
......@@ -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>
......
......@@ -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
......
......@@ -20,6 +20,7 @@
#define INCLUDED_VCL_EVNTPOST_HXX
#include <tools/link.hxx>
#include <tools/solar.h>
#include <vcl/dllapi.h>
struct ImplSVEvent;
......
......@@ -19,6 +19,9 @@
#ifndef INCLUDED_RSC_INC_RSCDEF_HXX
#define INCLUDED_RSC_INC_RSCDEF_HXX
#include <sal/config.h>
#include <tools/solar.h>
#include <tools/unqidx.hxx>
#include <rsctree.hxx>
#include <rtl/strbuf.hxx>
......
......@@ -20,6 +20,9 @@
#ifndef INCLUDED_SC_INC_REFRESHTIMER_HXX
#define INCLUDED_SC_INC_REFRESHTIMER_HXX
#include <sal/config.h>
#include <tools/solar.h>
#include <vcl/timer.hxx>
#include <osl/mutex.hxx>
#include "scdllapi.h"
......
......@@ -58,7 +58,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/generic/fract \
tools/source/generic/gen \
tools/source/generic/line \
tools/source/generic/link \
tools/source/generic/point \
tools/source/generic/poly \
tools/source/generic/poly2 \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <tools/link.hxx>
bool Link::operator==( const Link& rLink ) const
{
if ( pFunc == rLink.pFunc )
{
if ( pFunc )
{
if ( pInst == rLink.pInst )
return true;
else
return false;
}
else
return true;
}
else
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment