Add support for automatic conversion between chaiscript functions and boost::function. Might merit some look to see how much overhead this adds.

This commit is contained in:
Jason Turner
2010-09-13 14:24:12 +00:00
parent cfa42158af
commit 10986c159f
6 changed files with 143 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
#include <chaiscript/utility/utility.hpp>
double test_call(const boost::function<double (int)> &f, int val)
{
return f(val);
}
int main()
{
chaiscript::ChaiScript chai;
chai.add(chaiscript::fun(&test_call), "test_call");
chai.eval("def func(i) { return i * 3.5; };");
double d = chai.eval<double>("test_call(func, 3)");
if (d == 3 * 3.5)
{
return EXIT_SUCCESS;
} else {
return EXIT_FAILURE;
}
}