diff --git a/chaiscript/callbacktest.cpp b/chaiscript/callbacktest.cpp index 707ea74d..01bb9f9a 100644 --- a/chaiscript/callbacktest.cpp +++ b/chaiscript/callbacktest.cpp @@ -1,7 +1,7 @@ #include -#include "chaiscript.hpp" #include "function_call.hpp" +#include "chaiscript.hpp" #include struct Callback_Handler @@ -53,5 +53,11 @@ int main(int argc, char *argv[]) { } cb_handler.do_callbacks(); + + boost::function f = + dispatchkit::build_functor + (chai, "function(x, y) { x + y }"); + + std::cout << "Functor call: " << f("Hello", " World") << std::endl; } diff --git a/dispatchkit/boxed_value.hpp b/dispatchkit/boxed_value.hpp index 2f559c2f..1f084037 100644 --- a/dispatchkit/boxed_value.hpp +++ b/dispatchkit/boxed_value.hpp @@ -2,6 +2,7 @@ #define __boxed_value_hpp__ #include "type_info.hpp" +#include #include #include #include diff --git a/dispatchkit/dispatchkit.hpp b/dispatchkit/dispatchkit.hpp index 2466f03b..435ae0b9 100644 --- a/dispatchkit/dispatchkit.hpp +++ b/dispatchkit/dispatchkit.hpp @@ -222,6 +222,8 @@ namespace dispatchkit } std::cout << std::endl; } + + } #endif diff --git a/dispatchkit/function_call.hpp b/dispatchkit/function_call.hpp index d969253e..bbc63dbd 100644 --- a/dispatchkit/function_call.hpp +++ b/dispatchkit/function_call.hpp @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include "proxy_functions.hpp" namespace dispatchkit { @@ -58,6 +61,13 @@ namespace dispatchkit FunctionType *p; return build_function_caller_helper(p, func); } + + + template + boost::function build_functor(ScriptEngine &e, const std::string &script) + { + return build_function_caller(Cast_Helper >()(e.evaluate_string(script))); + } } # endif