2011-08-28 15:45:42 +00:00
|
|
|
//
|
|
|
|
// Copyright (c) 2011 Alex Yatskov
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
|
// files (the "Software"), to deal in the Software without
|
|
|
|
// restriction, including without limitation the rights to use,
|
|
|
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following
|
|
|
|
// conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be
|
|
|
|
// included in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace metacall {
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// IFunctor
|
|
|
|
//
|
|
|
|
|
|
|
|
class IFunctor {
|
|
|
|
public:
|
2011-09-04 17:19:34 +00:00
|
|
|
virtual ~IFunctor() { }
|
2011-08-28 15:45:42 +00:00
|
|
|
virtual bool call(Deserializer* args, Serializer* ret) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor0p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R>
|
|
|
|
class Functor0p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R(*F)();
|
|
|
|
|
|
|
|
Functor0p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer*, Serializer* ret) const {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function());
|
2011-08-28 15:45:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class Functor0p<void> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void(*F)();
|
|
|
|
|
|
|
|
Functor0p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer*, Serializer*) const {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function();
|
2011-08-28 15:45:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor1p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1>
|
|
|
|
class Functor1p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1);
|
|
|
|
|
|
|
|
Functor1p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
|
|
|
|
const bool success = args->read(&p1);
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1>
|
|
|
|
class Functor1p<void, P1> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1);
|
|
|
|
|
|
|
|
Functor1p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
|
|
|
|
const bool success = args->read(&p1);
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor2p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2>
|
|
|
|
class Functor2p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2);
|
|
|
|
|
|
|
|
Functor2p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2>
|
|
|
|
class Functor2p<void, P1, P2> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2);
|
|
|
|
|
|
|
|
Functor2p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor3p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3>
|
|
|
|
class Functor3p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3);
|
|
|
|
|
|
|
|
Functor3p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3>
|
|
|
|
class Functor3p<void, P1, P2, P3> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3);
|
|
|
|
|
|
|
|
Functor3p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor4p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4>
|
|
|
|
class Functor4p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4);
|
|
|
|
|
|
|
|
Functor4p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4>
|
|
|
|
class Functor4p<void, P1, P2, P3, P4> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4);
|
|
|
|
|
|
|
|
Functor4p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor5p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
|
|
|
|
class Functor5p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4, P5);
|
|
|
|
|
|
|
|
Functor5p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4, p5));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4, typename P5>
|
|
|
|
class Functor5p<void, P1, P2, P3, P4, P5> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4, P5);
|
|
|
|
|
|
|
|
Functor5p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4, p5);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor6p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
|
|
|
|
class Functor6p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4, P5, P6);
|
|
|
|
|
|
|
|
Functor6p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4, p5, p6));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
|
|
|
|
class Functor6p<void, P1, P2, P3, P4, P5, P6> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4, P5, P6);
|
|
|
|
|
|
|
|
Functor6p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4, p5, p6);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor7p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
|
|
|
|
class Functor7p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4, P5, P6, P7);
|
|
|
|
|
|
|
|
Functor7p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4, p5, p6, p7));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
|
|
|
|
class Functor7p<void, P1, P2, P3, P4, P5, P6, P7> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4, P5, P6, P7);
|
|
|
|
|
|
|
|
Functor7p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4, p5, p6, p7);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor8p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
|
|
|
|
class Functor8p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4, P5, P6, P7, P8);
|
|
|
|
|
|
|
|
Functor8p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
typename StripConstRef<P8>::Type p8;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7) &&
|
|
|
|
args->read(&p8);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4, p5, p6, p7, p8));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8>
|
|
|
|
class Functor8p<void, P1, P2, P3, P4, P5, P6, P7, P8> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4, P5, P6, P7, P8);
|
|
|
|
|
|
|
|
Functor8p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
typename StripConstRef<P8>::Type p8;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7) &&
|
|
|
|
args->read(&p8);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4, p5, p6, p7, p8);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functor9p
|
|
|
|
//
|
|
|
|
|
|
|
|
template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
|
|
|
|
class Functor9p : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef R (*F)(P1, P2, P3, P4, P5, P6, P7, P8, P9);
|
|
|
|
|
|
|
|
Functor9p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer* ret) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
typename StripConstRef<P8>::Type p8;
|
|
|
|
typename StripConstRef<P9>::Type p9;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7) &&
|
|
|
|
args->read(&p8) &&
|
|
|
|
args->read(&p9);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
ret->write(m_function(p1, p2, p3, p4, p5, p6, p7, p8, p9));
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9>
|
|
|
|
class Functor9p<void, P1, P2, P3, P4, P5, P6, P7, P8, P9> : public IFunctor {
|
|
|
|
public:
|
|
|
|
typedef void (*F)(P1, P2, P3, P4, P5, P6, P7, P8, P9);
|
|
|
|
|
|
|
|
Functor9p(F function) :
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(function)
|
2011-08-28 15:45:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool call(Deserializer* args, Serializer*) const {
|
|
|
|
typename StripConstRef<P1>::Type p1;
|
|
|
|
typename StripConstRef<P2>::Type p2;
|
|
|
|
typename StripConstRef<P3>::Type p3;
|
|
|
|
typename StripConstRef<P4>::Type p4;
|
|
|
|
typename StripConstRef<P5>::Type p5;
|
|
|
|
typename StripConstRef<P6>::Type p6;
|
|
|
|
typename StripConstRef<P7>::Type p7;
|
|
|
|
typename StripConstRef<P8>::Type p8;
|
|
|
|
typename StripConstRef<P9>::Type p9;
|
|
|
|
|
|
|
|
const bool success =
|
|
|
|
args->read(&p1) &&
|
|
|
|
args->read(&p2) &&
|
|
|
|
args->read(&p3) &&
|
|
|
|
args->read(&p4) &&
|
|
|
|
args->read(&p5) &&
|
|
|
|
args->read(&p6) &&
|
|
|
|
args->read(&p7) &&
|
|
|
|
args->read(&p8) &&
|
|
|
|
args->read(&p9);
|
|
|
|
|
|
|
|
if (success) {
|
2012-02-19 17:55:16 +00:00
|
|
|
m_function(p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
2011-08-28 15:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-02-19 17:55:16 +00:00
|
|
|
F m_function;
|
2011-08-28 15:45:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|