From d4ec79607f1a6c3ea7aea5edaba762cc8bbe1a53 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 21 Jun 2009 17:20:26 +0000 Subject: [PATCH] Clean up syntax for build_function_caller to allow for further use of it better --- chaiscript/callbacktest.cpp | 4 ++-- chaiscript/sensors.cpp | 2 +- dispatchkit/function_call.hpp | 18 ++++++++++++++++-- dispatchkit/test.cpp | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/chaiscript/callbacktest.cpp b/chaiscript/callbacktest.cpp index 9a3007b..707ea74 100644 --- a/chaiscript/callbacktest.cpp +++ b/chaiscript/callbacktest.cpp @@ -15,8 +15,8 @@ struct Callback_Handler boost::shared_ptr t_value) { m_callbacks.push_back( - std::make_pair(dispatchkit::build_function_caller(t_name), - dispatchkit::build_function_caller(t_value) + std::make_pair(dispatchkit::build_function_caller(t_name), + dispatchkit::build_function_caller(t_value) ) ); } diff --git a/chaiscript/sensors.cpp b/chaiscript/sensors.cpp index 91682af..14a71dd 100644 --- a/chaiscript/sensors.cpp +++ b/chaiscript/sensors.cpp @@ -73,7 +73,7 @@ struct Sensor_Manager m_sensors.insert( std::make_pair(t_name, Sensor(t_milliseconds, t_state_object, - dispatchkit::build_function_caller(t_func) + dispatchkit::build_function_caller(t_func) ) ) ); diff --git a/dispatchkit/function_call.hpp b/dispatchkit/function_call.hpp index 713d534..d969253 100644 --- a/dispatchkit/function_call.hpp +++ b/dispatchkit/function_call.hpp @@ -48,6 +48,18 @@ namespace dispatchkit #define BOOST_PP_ITERATION_LIMITS ( 0, 9 ) #define BOOST_PP_FILENAME_1 "function_call.hpp" #include BOOST_PP_ITERATE() + +namespace dispatchkit +{ + template + boost::function + build_function_caller(Function func) + { + FunctionType *p; + return build_function_caller_helper(p, func); + } +} + # endif #else # define n BOOST_PP_ITERATION() @@ -67,7 +79,7 @@ namespace dispatchkit template boost::function - build_function_caller(boost::shared_ptr func) + build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), boost::shared_ptr func) { std::vector > > funcs; funcs.push_back(std::make_pair(std::string(), func)); @@ -77,11 +89,13 @@ namespace dispatchkit template boost::function - build_function_caller(const std::vector > > &funcs) + build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector > > &funcs) { return boost::bind(&function_caller, funcs BOOST_PP_ENUM_TRAILING(n, curry, ~)); } + + } #endif diff --git a/dispatchkit/test.cpp b/dispatchkit/test.cpp index 85408be..a64fc86 100644 --- a/dispatchkit/test.cpp +++ b/dispatchkit/test.cpp @@ -157,7 +157,7 @@ int main() //Build a bound function proxy for calling the script handled function boost::function show_message = - build_function_caller(ss.get_function("show_message")); + build_function_caller(ss.get_function("show_message")); Test &t = Cast_Helper()(ss.get_object("testobj2"));