20#ifndef INCLUDED_TOOLS_LINK_HXX
21#define INCLUDED_TOOLS_LINK_HXX
28#define DECL_LINK(Member, ArgType, RetType) \
29 static RetType LinkStub##Member(void *, ArgType); \
30 RetType Member(ArgType)
32#define DECL_STATIC_LINK(Class, Member, ArgType, RetType) \
33 static RetType LinkStub##Member(void *, ArgType); \
34 static RetType Member(Class *, ArgType)
36#define DECL_DLLPRIVATE_LINK(Member, ArgType, RetType) \
37 SAL_DLLPRIVATE static RetType LinkStub##Member(void *, ArgType); \
38 SAL_DLLPRIVATE RetType Member(ArgType)
40#define DECL_DLLPRIVATE_STATIC_LINK(Class, Member, ArgType, RetType) \
41 SAL_DLLPRIVATE static RetType LinkStub##Member(void *, ArgType); \
42 SAL_DLLPRIVATE static RetType Member(Class *, ArgType)
44#define IMPL_LINK(Class, Member, ArgType, ArgName, RetType) \
45 RetType Class::LinkStub##Member(void * instance, ArgType data) { \
46 return static_cast<Class *>(instance)->Member(data); \
48 RetType Class::Member(ArgType ArgName)
50#define IMPL_LINK_NOARG(Class, Member, ArgType, RetType) \
51 RetType Class::LinkStub##Member(void * instance, ArgType data) { \
52 return static_cast<Class *>(instance)->Member(data); \
54 RetType Class::Member(SAL_UNUSED_PARAMETER ArgType)
56#define IMPL_STATIC_LINK( \
57 Class, Member, ArgType, ArgName, RetType) \
58 RetType Class::LinkStub##Member(void * instance, ArgType data) { \
59 return Member(static_cast<Class *>(instance), data); \
61 RetType Class::Member(SAL_UNUSED_PARAMETER Class *, ArgType ArgName)
63#define IMPL_STATIC_LINK_NOARG( \
64 Class, Member, ArgType, RetType) \
65 RetType Class::LinkStub##Member(void * instance, ArgType data) { \
66 return Member(static_cast<Class *>(instance), data); \
68 RetType Class::Member( \
69 SAL_UNUSED_PARAMETER Class *, SAL_UNUSED_PARAMETER ArgType)
72#define LINK(Instance, Class, Member) ::tools::detail::makeLink( \
73 ::tools::detail::castTo<Class *>(Instance), &Class::LinkStub##Member, __FILE__, __LINE__, SAL_STRINGIFY(Class::LinkStub##Member))
75#define LINK(Instance, Class, Member) ::tools::detail::makeLink( \
76 ::tools::detail::castTo<Class *>(Instance), &Class::LinkStub##Member)
79template<
typename Arg,
typename Ret>
82 typedef Ret Stub(
void *,
Arg);
94 Link(
void* instance, Stub* function,
const char*
const file =
"unknown",
const int line = 0,
95 const char*
const target =
"unknown")
104 Link(): function_(
nullptr), instance_(
nullptr) {}
106 Link(
void * instance, Stub * function):
107 function_(function), instance_(instance) {}
111 {
return function_ ==
nullptr ? Ret() : (*function_)(instance_, data); }
113 bool IsSet()
const {
return function_ !=
nullptr; }
115 bool operator !()
const {
return !IsSet(); }
118 char* ptr1 =
reinterpret_cast<char*
>(function_);
119 char* ptr2 =
reinterpret_cast<char*
>(other.function_);
122 else if (ptr1 > ptr2)
125 return instance_ < other.instance_;
129 {
return function_ == other.function_ && instance_ == other.instance_; };
131 void *GetInstance()
const {
return instance_; }
134 const char* getSourceFilename()
const {
return file_; }
135 int getSourceLineNumber()
const {
return line_; }
136 const char* getTargetName()
const {
return target_; }
161template<
typename To,
typename From>
To castTo(From from)
162{
return static_cast<To>(
from); }
165template<
typename Arg,
typename Ret>
170template<
typename Arg,
typename Ret>
bool operator==(const BigInt &rVal1, const BigInt &rVal2)
bool operator<(const BigInt &rVal1, const BigInt &rVal2)
rtl::Reference< MappedFile > file_