Add support for std::pair
This commit is contained in:
parent
975d8c9618
commit
3d23bb68f6
@ -199,7 +199,7 @@ namespace chaiscript
|
||||
dispatchkit::Bootstrap::bootstrap(ss);
|
||||
dispatchkit::bootstrap_vector<std::vector<dispatchkit::Boxed_Value> >(ss, "Vector");
|
||||
dispatchkit::bootstrap_map<std::map<std::string, dispatchkit::Boxed_Value> >(ss, "Map");
|
||||
|
||||
dispatchkit::bootstrap_pair<std::pair<dispatchkit::Boxed_Value, dispatchkit::Boxed_Value > >(ss, "Pair");
|
||||
|
||||
ss.register_function(boost::shared_ptr<dispatchkit::Proxy_Function>(
|
||||
new dispatchkit::Dynamic_Proxy_Function(boost::bind(&ChaiScript_System<Eval_Engine>::eval, boost::ref(*this), _1), 1)), "eval");
|
||||
|
@ -164,6 +164,16 @@ namespace dispatchkit
|
||||
{
|
||||
bootstrap_associative_container<ContainerType>(system, type);
|
||||
register_function(system, &ContainerType::count, "count");
|
||||
}
|
||||
|
||||
template<typename PairType>
|
||||
void bootstrap_pair(Dispatch_Engine &system, const std::string &type)
|
||||
{
|
||||
register_member(system, &PairType::first, "first");
|
||||
register_member(system, &PairType::second, "second");
|
||||
|
||||
system.register_function(build_constructor<PairType >(), type);
|
||||
system.register_function(build_constructor<PairType, const typename PairType::first_type &, const typename PairType::second_type &>(), type);
|
||||
}
|
||||
|
||||
template<typename ContainerType>
|
||||
|
@ -1,5 +1,5 @@
|
||||
cb_handler.add_callbacks( function() { "First"; }, function (x) { x * 1.1; } );
|
||||
cb_handler.add_callbacks( function() { "TimesThree"; }, function (x) { x * 3.0001; } );
|
||||
cb_handler.add_callbacks( function() { "TimesThree"; }, function(x) { x * 3.0} );
|
||||
cb_handler.add_callbacks( function() { "DivOnePtTwo"; }, function (x) { x / 1.2; } );
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user