Add arity registration for dynamic functions

This commit is contained in:
Jason Turner
2009-06-05 16:12:21 +00:00
parent 5799d7f0ef
commit 37a36f783c
2 changed files with 12 additions and 14 deletions

View File

@@ -82,16 +82,6 @@ std::string concat_string(const std::string &s1, const std::string &s2) {
}
const Boxed_Value add_two(BoxedCPP_System &ss, const std::vector<Boxed_Value> &vals) {
//We can check the arity if we want, or in this case just allow the dispatch
//to do it for us:
if (vals.size() != 2)
{
//I very much need to do a cleanup and provide a custom set of
//bad_cast and wrong_arity exceptions so they can be caught more
//cleanly
throw std::runtime_error("Wrong number of args");
}
return dispatch(ss.get_function("+"), vals);
}
@@ -414,7 +404,7 @@ BoxedCPP_System build_eval_system() {
ss.register_function(boost::function<std::string (const std::string &, const std::string &)>(concat_string), "concat_string");
ss.register_function(boost::shared_ptr<Proxy_Function>(
new Dynamic_Proxy_Function(boost::bind(&add_two, boost::ref(ss), _1))), "add_two");
new Dynamic_Proxy_Function(boost::bind(&add_two, boost::ref(ss), _1), 2)), "add_two");
return ss;