Fix arity when registering lambdas and functions

This commit is contained in:
Jonathan Turner 2009-06-25 23:14:46 +00:00
parent 46859b1918
commit ae3ce3fcb2
2 changed files with 7 additions and 6 deletions

View File

@ -431,7 +431,7 @@ namespace chaiscript
} }
ss.register_function(boost::shared_ptr<dispatchkit::Proxy_Function>( ss.register_function(boost::shared_ptr<dispatchkit::Proxy_Function>(
new dispatchkit::Dynamic_Proxy_Function(boost::bind(&eval_function<Eval_System>, boost::ref(ss), node->children.back(), param_names, _1))), node->children[0]->text); new dispatchkit::Dynamic_Proxy_Function(boost::bind(&eval_function<Eval_System>, boost::ref(ss), node->children.back(), param_names, _1), num_args)), node->children[0]->text);
} }
break; break;
case (TokenType::Lambda_Def) : { case (TokenType::Lambda_Def) : {
@ -444,7 +444,7 @@ namespace chaiscript
//retval = boost::shared_ptr<dispatchkit::Proxy_Function>(new dispatchkit::Proxy_Function_Impl<boost::function<void (const std::string &)> >(&test)); //retval = boost::shared_ptr<dispatchkit::Proxy_Function>(new dispatchkit::Proxy_Function_Impl<boost::function<void (const std::string &)> >(&test));
retval = dispatchkit::Boxed_Value(boost::shared_ptr<dispatchkit::Proxy_Function>( retval = dispatchkit::Boxed_Value(boost::shared_ptr<dispatchkit::Proxy_Function>(
new dispatchkit::Dynamic_Proxy_Function( new dispatchkit::Dynamic_Proxy_Function(
boost::bind(&eval_function<Eval_System>, boost::ref(ss), node->children.back(), param_names, _1)))); boost::bind(&eval_function<Eval_System>, boost::ref(ss), node->children.back(), param_names, _1), num_args)));
} }
break; break;
case (TokenType::Scoped_Block) : { case (TokenType::Scoped_Block) : {

View File

@ -27,4 +27,5 @@ def concat(a,b,c,d)
var d = bind(concat, _(), " Hello ", _(), " World "); var d = bind(concat, _(), " Hello ", _(), " World ");
print(d(1, 3)); print(d(1, 3));
print(d(1, 3, 4)); //This checks to make sure arity is handled correctly:
//print(d(1, 3, 4));