mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-07 01:06:54 +08:00
Fix arity when registering lambdas and functions
This commit is contained in:
parent
46859b1918
commit
ae3ce3fcb2
@ -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) : {
|
||||||
|
|||||||
@ -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));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user