Fix test for overload registration with add_class utility
This commit is contained in:
@@ -73,23 +73,6 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Creates a new Proxy_Function object from a std::function object
|
|
||||||
/// \param[in] f std::function to expose to ChaiScript
|
|
||||||
///
|
|
||||||
/// \b Example:
|
|
||||||
/// \code
|
|
||||||
/// std::function<int (char, float, std::string)> f = get_some_function();
|
|
||||||
/// chaiscript::ChaiScript chai;
|
|
||||||
/// chai.add(fun(f), "some_function");
|
|
||||||
/// \endcode
|
|
||||||
///
|
|
||||||
/// \sa \ref addingfunctions
|
|
||||||
template<typename T>
|
|
||||||
Proxy_Function fun(const std::function<T> &f)
|
|
||||||
{
|
|
||||||
return Proxy_Function(new dispatch::Proxy_Function_Impl<T>(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Creates a new Proxy_Function object from a free function, member function or data member
|
/// \brief Creates a new Proxy_Function object from a free function, member function or data member
|
||||||
/// \param[in] t Function / member to expose
|
/// \param[in] t Function / member to expose
|
||||||
///
|
///
|
||||||
@@ -116,6 +99,25 @@ namespace chaiscript
|
|||||||
return dispatch::detail::Fun_Helper<std::is_member_object_pointer<T>::value>::go(t);
|
return dispatch::detail::Fun_Helper<std::is_member_object_pointer<T>::value>::go(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// \brief Creates a new Proxy_Function object from a std::function object
|
||||||
|
/// \param[in] f std::function to expose to ChaiScript
|
||||||
|
///
|
||||||
|
/// \b Example:
|
||||||
|
/// \code
|
||||||
|
/// std::function<int (char, float, std::string)> f = get_some_function();
|
||||||
|
/// chaiscript::ChaiScript chai;
|
||||||
|
/// chai.add(fun(f), "some_function");
|
||||||
|
/// \endcode
|
||||||
|
///
|
||||||
|
/// \sa \ref addingfunctions
|
||||||
|
template<typename T>
|
||||||
|
Proxy_Function fun(const std::function<T> &f)
|
||||||
|
{
|
||||||
|
return Proxy_Function(new dispatch::Proxy_Function_Impl<T>(f));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// \brief Creates a new Proxy_Function object from a free function, member function or data member and binds the first parameter of it
|
/// \brief Creates a new Proxy_Function object from a free function, member function or data member and binds the first parameter of it
|
||||||
/// \param[in] t Function / member to expose
|
/// \param[in] t Function / member to expose
|
||||||
/// \param[in] q Value to bind to first parameter
|
/// \param[in] q Value to bind to first parameter
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
|
#include <chaiscript/chaiscript.hpp>
|
||||||
#include <chaiscript/chaiscript_stdlib.hpp>
|
#include <chaiscript/chaiscript_stdlib.hpp>
|
||||||
#include <chaiscript/utility/utility.hpp>
|
#include <chaiscript/utility/utility.hpp>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
{
|
{
|
||||||
@@ -18,6 +20,7 @@ int main()
|
|||||||
|
|
||||||
using namespace chaiscript;
|
using namespace chaiscript;
|
||||||
|
|
||||||
|
/// \todo fix overload resolution for fun<>
|
||||||
chaiscript::utility::add_class<Test>(*m,
|
chaiscript::utility::add_class<Test>(*m,
|
||||||
"Test",
|
"Test",
|
||||||
{ constructor<Test ()>(),
|
{ constructor<Test ()>(),
|
||||||
@@ -25,9 +28,9 @@ int main()
|
|||||||
{ {fun(&Test::function), "function"},
|
{ {fun(&Test::function), "function"},
|
||||||
{fun(&Test::function2), "function2"},
|
{fun(&Test::function2), "function2"},
|
||||||
{fun(&Test::function3), "function3"},
|
{fun(&Test::function3), "function3"},
|
||||||
{fun<std::string (Test::*)(double)>(&Test::functionOverload), "functionOverload"},
|
{fun(static_cast<std::string(Test::*)(double)>(&Test::functionOverload)), "functionOverload" },
|
||||||
{fun<std::string (Test::*)(int)>(&Test::functionOverload), "functionOverload"},
|
{fun(static_cast<std::string(Test::*)(int)>(&Test::functionOverload)), "functionOverload" },
|
||||||
{fun<Test & (Test::*)(const Test &)>(&Test::operator=), "="}
|
{fun(static_cast<Test & (Test::*)(const Test &)>(&Test::operator=)), "=" }
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user