// This file is distributed under the BSD License. // See "license.txt" for details. // Copyright 2009, Jonathan Turner (jturner@minnow-lang.org) // and Jason Turner (lefticus@gmail.com) // http://www.chaiscript.com #ifndef __function_call_hpp__ #define __function_call_hpp__ #include #include #include #include #include #include "proxy_functions.hpp" #include "function_call_detail.hpp" namespace chaiscript { /** * Build a function caller that knows how to dispatch on a set of functions * example: * boost::function f = * build_function_caller(dispatchkit.get_function("print")); * \returns A boost::function object for dispatching * \param[in] funcs the set of functions to dispatch on. */ template boost::function functor(const std::vector > &funcs) { FunctionType *p=0; return build_function_caller_helper(p, funcs); } /** * Build a function caller for a particular Proxy_Function object * useful in the case that a function is being pass out from scripting back * into code * example: * void my_function(Proxy_Function f) * { * boost::function local_f = * build_function_caller(f); * } * \returns A boost::function object for dispatching * \param[in] func A function to execute. */ template boost::function functor(Proxy_Function func) { std::vector > funcs; funcs.push_back(std::make_pair(std::string(), func)); return functor(funcs); } /** * Helper for automatically unboxing a Boxed_Value that contains a function object * and creating a typesafe C++ function caller from it. */ template boost::function functor(const Boxed_Value &bv) { return functor(boxed_cast(bv)); } } #endif