Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
224 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// This file is distributed under the BSD License. | ||
// See "license.txt" for details. | ||
// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com) | ||
// Copyright 2009-2015, Jason Turner (jason@emptycrate.com) | ||
// http://www.chaiscript.com | ||
|
||
#ifndef CHAISCRIPT_CALLABLE_TRAITS_HPP_ | ||
#define CHAISCRIPT_CALLABLE_TRAITS_HPP_ | ||
|
||
#include <memory> | ||
|
||
namespace chaiscript { | ||
namespace dispatch { | ||
namespace detail { | ||
template<typename Class, typename ... Param> | ||
struct Constructor | ||
{ | ||
template<typename ... Inner> | ||
std::shared_ptr<Class> operator()(Inner&& ... inner) const { | ||
return std::make_shared<Class>(std::forward<Inner>(inner)...); | ||
} | ||
}; | ||
|
||
template<typename Ret, typename Class, typename ... Param> | ||
struct Const_Caller | ||
{ | ||
Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) {} | ||
|
||
template<typename ... Inner> | ||
Ret operator()(const Class &o, Inner&& ... inner) const { | ||
return (o.*m_func)(std::forward<Inner>(inner)...); | ||
} | ||
|
||
Ret (Class::*m_func)(Param...) const; | ||
}; | ||
|
||
template<typename Ret, typename Class, typename ... Param> | ||
struct Caller | ||
{ | ||
Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) {} | ||
|
||
template<typename ... Inner> | ||
Ret operator()(Class &o, Inner&& ... inner) const { | ||
return (o.*m_func)(std::forward<Inner>(inner)...); | ||
} | ||
|
||
Ret (Class::*m_func)(Param...); | ||
}; | ||
|
||
|
||
template<typename T> | ||
struct Function_Signature | ||
{ | ||
}; | ||
|
||
template<typename Ret, typename ... Params> | ||
struct Function_Signature<Ret (Params...)> | ||
{ | ||
typedef Ret Return_Type; | ||
typedef Ret (Signature)(Params...); | ||
}; | ||
|
||
template<typename Ret, typename T, typename ... Params> | ||
struct Function_Signature<Ret (T::*)(Params...) const> | ||
{ | ||
typedef Ret Return_Type; | ||
typedef Ret (Signature)(Params...); | ||
}; | ||
|
||
|
||
template<typename T> | ||
struct Callable_Traits | ||
{ | ||
typedef typename Function_Signature<decltype(&T::operator())>::Signature Signature; | ||
typedef typename Function_Signature<decltype(&T::operator())>::Return_Type Return_Type; | ||
}; | ||
} | ||
} | ||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.