2009-07-11 10:50:24 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
2010-11-24 02:34:14 +08:00
|
|
|
// File: tesscallback.h
|
2009-07-11 10:50:24 +08:00
|
|
|
// Description: classes and functions to replace pointer-to-functions
|
|
|
|
// Author: Samuel Charron
|
|
|
|
//
|
|
|
|
// (C) Copyright 2006, Google Inc.
|
|
|
|
// Licensed 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
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
#ifndef _TESS_CALLBACK_SPECIALIZATIONS_H
|
|
|
|
#define _TESS_CALLBACK_SPECIALIZATIONS_H
|
2009-07-11 10:50:24 +08:00
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
#include "host.h" // For NULL.
|
|
|
|
|
|
|
|
struct TessCallbackUtils_ {
|
2009-07-11 10:50:24 +08:00
|
|
|
static void FailIsRepeatable(const char* name);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessClosure {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessClosure() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual void Run() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessResultCallback {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessResultCallback() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual R Run() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class R, class T>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_0 : public TessResultCallback<R> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback<R> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run() {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)();
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_0<del, void, T>
|
|
|
|
: public TessClosure {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessClosure base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run() {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)();
|
|
|
|
} else {
|
|
|
|
(object_->*member_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_0<true,R,T1>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)() const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_0<true,R,T1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_0<false,R,T1>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)() const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_0<false,R,T1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class T>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_0 : public TessResultCallback<R> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback<R> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)() ;
|
|
|
|
|
|
|
|
private:
|
2010-11-24 02:34:14 +08:00
|
|
|
T* object_;
|
2009-07-11 10:50:24 +08:00
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run() {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)();
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_0<del, void, T>
|
|
|
|
: public TessClosure {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessClosure base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)() ;
|
|
|
|
|
|
|
|
private:
|
2010-11-24 02:34:14 +08:00
|
|
|
T* object_;
|
2009-07-11 10:50:24 +08:00
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run() {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)();
|
|
|
|
} else {
|
|
|
|
(object_->*member_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_0<true,R,T1>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)() ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_0<true,R,T1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_0<false,R,T1>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)() ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_0<false,R,T1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_0 : public TessResultCallback<R> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback<R> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (*FunctionSignature)();
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run() {
|
|
|
|
if (!del) {
|
|
|
|
R result = (*function_)();
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (*function_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_0<del, void>
|
|
|
|
: public TessClosure {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessClosure base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (*FunctionSignature)();
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_0(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run() {
|
|
|
|
if (!del) {
|
|
|
|
(*function_)();
|
|
|
|
} else {
|
|
|
|
(*function_)();
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_0<true,R>::base*
|
|
|
|
NewTessCallback(R (*function)()) {
|
|
|
|
return new _TessFunctionResultCallback_0_0<true,R>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class R>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_0<false,R>::base*
|
|
|
|
NewPermanentTessCallback(R (*function)()) {
|
|
|
|
return new _TessFunctionResultCallback_0_0<false,R>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessCallback1 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessCallback1() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual void Run(A1) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessResultCallback1 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessResultCallback1() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual R Run(A1) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_1 : public TessResultCallback1<R,A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback1<R,A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_1<del, void, T, A1>
|
|
|
|
: public TessCallback1<A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback1<A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_1<true,R,T1,A1>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_1<true,R,T1,A1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_1<false,R,T1,A1>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_1<false,R,T1,A1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_1 : public TessResultCallback1<R,A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback1<R,A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_1<del, void, T, A1>
|
|
|
|
: public TessCallback1<A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback1<A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_1<true,R,T1,A1>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_1<true,R,T1,A1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_1<false,R,T1,A1>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_1<false,R,T1,A1>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_1 : public TessResultCallback1<R,A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback1<R,A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (*FunctionSignature)(A1);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (*function_)(a1);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (*function_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_1<del, void, A1>
|
|
|
|
: public TessCallback1<A1> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback1<A1> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (*FunctionSignature)(A1);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_1(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1) {
|
|
|
|
if (!del) {
|
|
|
|
(*function_)(a1);
|
|
|
|
} else {
|
|
|
|
(*function_)(a1);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_1<true,R,A1>::base*
|
|
|
|
NewTessCallback(R (*function)(A1)) {
|
|
|
|
return new _TessFunctionResultCallback_0_1<true,R,A1>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class R, class A1>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_1<false,R,A1>::base*
|
|
|
|
NewPermanentTessCallback(R (*function)(A1)) {
|
|
|
|
return new _TessFunctionResultCallback_0_1<false,R,A1>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class A1,class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessCallback2 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessCallback2() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual void Run(A1,A2) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1,class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessResultCallback2 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessResultCallback2() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual R Run(A1,A2) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_2 : public TessResultCallback2<R,A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback2<R,A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1,A2) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1,a2);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_2<del, void, T, A1, A2>
|
|
|
|
: public TessCallback2<A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback2<A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1,A2) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1,a2);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_2<true,R,T1,A1,A2>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1,A2) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_2<true,R,T1,A1,A2>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_2<false,R,T1,A1,A2>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1,A2) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_2<false,R,T1,A1,A2>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_2 : public TessResultCallback2<R,A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback2<R,A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1,A2) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1,a2);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_2<del, void, T, A1, A2>
|
|
|
|
: public TessCallback2<A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback2<A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1,A2) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1,a2);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_2<true,R,T1,A1,A2>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1,A2) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_2<true,R,T1,A1,A2>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_2<false,R,T1,A1,A2>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1,A2) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_2<false,R,T1,A1,A2>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_2 : public TessResultCallback2<R,A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback2<R,A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (*FunctionSignature)(A1,A2);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (*function_)(a1,a2);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (*function_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_2<del, void, A1, A2>
|
|
|
|
: public TessCallback2<A1,A2> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback2<A1,A2> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (*FunctionSignature)(A1,A2);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_2(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2) {
|
|
|
|
if (!del) {
|
|
|
|
(*function_)(a1,a2);
|
|
|
|
} else {
|
|
|
|
(*function_)(a1,a2);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_2<true,R,A1,A2>::base*
|
|
|
|
NewTessCallback(R (*function)(A1,A2)) {
|
|
|
|
return new _TessFunctionResultCallback_0_2<true,R,A1,A2>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class R, class A1, class A2>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_2<false,R,A1,A2>::base*
|
|
|
|
NewPermanentTessCallback(R (*function)(A1,A2)) {
|
|
|
|
return new _TessFunctionResultCallback_0_2<false,R,A1,A2>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class A1,class A2,class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessCallback3 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessCallback3() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual void Run(A1,A2,A3) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1,class A2,class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class TessResultCallback3 {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
virtual ~TessResultCallback3() { }
|
2009-07-11 10:50:24 +08:00
|
|
|
virtual R Run(A1,A2,A3) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback3<R,A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1,A2,A3) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1,a2,a3);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _ConstTessMemberResultCallback_0_3<del, void, T, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1,A2,A3) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _ConstTessMemberResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1,a2,a3);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1,A2,A3) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _ConstTessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
const T1* obj, R (T2::*member)(A1,A2,A3) const) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _ConstTessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class T, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback3<R,A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (T::*MemberSignature)(A1,A2,A3) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (object_->*member_)(a1,a2,a3);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (object_->*member_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class T, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessMemberResultCallback_0_3<del, void, T, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (T::*MemberSignature)(A1,A2,A3) ;
|
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessMemberResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
T* object, MemberSignature member)
|
|
|
|
: object_(object),
|
|
|
|
member_(member) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
(object_->*member_)(a1,a2,a3);
|
|
|
|
} else {
|
|
|
|
(object_->*member_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>::base*
|
|
|
|
NewTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1,A2,A3) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_3<true,R,T1,A1,A2,A3>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
|
|
|
template <class T1, class T2, class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback(
|
2009-07-11 10:50:24 +08:00
|
|
|
T1* obj, R (T2::*member)(A1,A2,A3) ) {
|
2010-11-24 02:34:14 +08:00
|
|
|
return new _TessMemberResultCallback_0_3<false,R,T1,A1,A2,A3>(
|
2009-07-11 10:50:24 +08:00
|
|
|
obj, member);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <bool del, class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_3 : public TessResultCallback3<R,A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessResultCallback3<R,A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef R (*FunctionSignature)(A1,A2,A3);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual R Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
R result = (*function_)(a1,a2,a3);
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
R result = (*function_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <bool del, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
class _TessFunctionResultCallback_0_3<del, void, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2009-07-11 10:50:24 +08:00
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
2009-07-11 10:50:24 +08:00
|
|
|
typedef void (*FunctionSignature)(A1,A2,A3);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
|
|
|
|
public:
|
2010-11-24 02:34:14 +08:00
|
|
|
inline _TessFunctionResultCallback_0_3(
|
2009-07-11 10:50:24 +08:00
|
|
|
FunctionSignature function)
|
|
|
|
: function_(function) {
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Run(A1 a1,A2 a2,A3 a3) {
|
|
|
|
if (!del) {
|
|
|
|
(*function_)(a1,a2,a3);
|
|
|
|
} else {
|
|
|
|
(*function_)(a1,a2,a3);
|
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_3<true,R,A1,A2,A3>::base*
|
|
|
|
NewTessCallback(R (*function)(A1,A2,A3)) {
|
|
|
|
return new _TessFunctionResultCallback_0_3<true,R,A1,A2,A3>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class R, class A1, class A2, class A3>
|
2010-11-24 02:34:14 +08:00
|
|
|
inline typename _TessFunctionResultCallback_0_3<false,R,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback(R (*function)(A1,A2,A3)) {
|
|
|
|
return new _TessFunctionResultCallback_0_3<false,R,A1,A2,A3>(function);
|
2009-07-11 10:50:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-22 05:45:12 +08:00
|
|
|
// Specified by TR1 [4.7.2] Reference modifications.
|
|
|
|
template <class T> struct remove_reference;
|
|
|
|
template<typename T> struct remove_reference { typedef T type; };
|
|
|
|
template<typename T> struct remove_reference<T&> { typedef T type; };
|
|
|
|
|
|
|
|
// Identity<T>::type is a typedef of T. Useful for preventing the
|
|
|
|
// compiler from inferring the type of an argument in templates.
|
|
|
|
template <typename T>
|
|
|
|
struct Identity {
|
|
|
|
typedef T type;
|
|
|
|
};
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class R, class T, class P1, class A1, class A2, class A3>
|
|
|
|
class _ConstTessMemberResultCallback_1_3
|
|
|
|
: public TessResultCallback3<R,A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessResultCallback3<R,A1,A2,A3> base;
|
|
|
|
typedef R (T::*MemberSignature)(P1,A1,A2,A3) const;
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _ConstTessMemberResultCallback_1_3(T* object,
|
2011-03-22 05:45:12 +08:00
|
|
|
MemberSignature member, P1 p1)
|
|
|
|
: object_(object), member_(member), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual R Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
return result;
|
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class T, class P1, class A1, class A2, class A3>
|
|
|
|
class _ConstTessMemberResultCallback_1_3<del, void, T, P1, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
|
|
|
typedef void (T::*MemberSignature)(P1,A1,A2,A3) const;
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _ConstTessMemberResultCallback_1_3(T* object,
|
2011-03-22 05:45:12 +08:00
|
|
|
MemberSignature member, P1 p1)
|
|
|
|
: object_(object), member_(member), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual void Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
(object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
(object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class T1, class T2, class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _ConstTessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>::base*
|
|
|
|
NewTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) {
|
|
|
|
return new _ConstTessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>(obj, member, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class T1, class T2, class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _ConstTessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) {
|
|
|
|
return new _ConstTessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>(obj, member, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class R, class T, class P1, class A1, class A2, class A3>
|
|
|
|
class _TessMemberResultCallback_1_3 : public TessResultCallback3<R,A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessResultCallback3<R,A1,A2,A3> base;
|
|
|
|
typedef R (T::*MemberSignature)(P1,A1,A2,A3) ;
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _TessMemberResultCallback_1_3(T* object,
|
2011-03-22 05:45:12 +08:00
|
|
|
MemberSignature member, P1 p1)
|
|
|
|
: object_(object), member_(member), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual R Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
return result;
|
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class T, class P1, class A1, class A2, class A3>
|
|
|
|
class _TessMemberResultCallback_1_3<del, void, T, P1, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
|
|
|
typedef void (T::*MemberSignature)(P1,A1,A2,A3) ;
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
T* object_;
|
|
|
|
MemberSignature member_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _TessMemberResultCallback_1_3(T* object,
|
2011-03-22 05:45:12 +08:00
|
|
|
MemberSignature member, P1 p1)
|
|
|
|
: object_(object), member_(member), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual void Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
(object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
(object_->*member_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
member_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class T1, class T2, class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _TessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>::base*
|
|
|
|
NewTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) {
|
|
|
|
return new _TessMemberResultCallback_1_3<true,R,T1,P1,A1,A2,A3>(obj, member, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWIG
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class T1, class T2, class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _TessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback( T1* obj, R (T2::*member)(P1,A1,A2,A3) , typename Identity<P1>::type p1) {
|
|
|
|
return new _TessMemberResultCallback_1_3<false,R,T1,P1,A1,A2,A3>(obj, member, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class R, class P1, class A1, class A2, class A3>
|
|
|
|
class _TessFunctionResultCallback_1_3 : public TessCallback3<A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
|
|
|
typedef R (*FunctionSignature)(P1,A1,A2,A3);
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _TessFunctionResultCallback_1_3(FunctionSignature function, P1 p1)
|
2011-03-22 05:45:12 +08:00
|
|
|
: function_(function), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual R Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (*function_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
return result;
|
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
R result = (*function_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <bool del, class P1, class A1, class A2, class A3>
|
|
|
|
class _TessFunctionResultCallback_1_3<del, void, P1, A1, A2, A3>
|
|
|
|
: public TessCallback3<A1,A2,A3> {
|
2011-03-22 05:45:12 +08:00
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
typedef TessCallback3<A1,A2,A3> base;
|
|
|
|
typedef void (*FunctionSignature)(P1,A1,A2,A3);
|
2011-03-22 05:45:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
FunctionSignature function_;
|
|
|
|
typename remove_reference<P1>::type p1_;
|
|
|
|
|
|
|
|
public:
|
2012-02-02 11:14:43 +08:00
|
|
|
inline _TessFunctionResultCallback_1_3(FunctionSignature function, P1 p1)
|
2011-03-22 05:45:12 +08:00
|
|
|
: function_(function), p1_(p1) { }
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
virtual void Run(A1 a1, A2 a2, A3 a3) {
|
2011-03-22 05:45:12 +08:00
|
|
|
if (!del) {
|
2012-02-02 11:14:43 +08:00
|
|
|
(*function_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
} else {
|
2012-02-02 11:14:43 +08:00
|
|
|
(*function_)(p1_,a1,a2,a3);
|
2011-03-22 05:45:12 +08:00
|
|
|
// zero out the pointer to ensure segfault if used again
|
|
|
|
function_ = NULL;
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _TessFunctionResultCallback_1_3<true,R,P1,A1,A2,A3>::base*
|
|
|
|
NewTessCallback(R (*function)(P1,A1,A2,A3), typename Identity<P1>::type p1) {
|
|
|
|
return new _TessFunctionResultCallback_1_3<true,R,P1,A1,A2,A3>(function, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
|
2012-02-02 11:14:43 +08:00
|
|
|
template <class R, class P1, class A1, class A2, class A3>
|
|
|
|
inline typename _TessFunctionResultCallback_1_3<false,R,P1,A1,A2,A3>::base*
|
|
|
|
NewPermanentTessCallback(R (*function)(P1,A1,A2,A3), typename Identity<P1>::type p1) {
|
|
|
|
return new _TessFunctionResultCallback_1_3<false,R,P1,A1,A2,A3>(function, p1);
|
2011-03-22 05:45:12 +08:00
|
|
|
}
|
|
|
|
|
2010-11-24 02:34:14 +08:00
|
|
|
#endif /* _TESS_CALLBACK_SPECIALIZATIONS_H */
|