operator= support in bootstrap code

This commit is contained in:
Jason Turner
2009-06-07 00:57:29 +00:00
parent af221b611d
commit 1c334064e8
3 changed files with 20 additions and 3 deletions

View File

@@ -41,6 +41,12 @@ bool bool_or(P1 p1, P2 p2)
return p1 || p2; return p1 || p2;
} }
template<typename P1, typename P2>
P1 &assign(P1 &p1, const P2 &p2)
{
return (p1 = p2);
}
template<typename P1, typename P2> template<typename P1, typename P2>
bool equals(P1 p1, P2 p2) bool equals(P1 p1, P2 p2)
{ {
@@ -138,6 +144,12 @@ void add_oper_not_equals(BoxedCPP_System &s)
register_function(s, &not_equals<const T&, const T&>, "!="); register_function(s, &not_equals<const T&, const T&>, "!=");
} }
template<typename T>
void add_oper_assign(BoxedCPP_System &s)
{
register_function(s, &assign<T,T>, "=");
}
template<typename T> template<typename T>
void add_oper_less_than(BoxedCPP_System &s) void add_oper_less_than(BoxedCPP_System &s)
{ {
@@ -220,6 +232,11 @@ void bootstrap(BoxedCPP_System &s)
add_opers_comparison<char>(s); add_opers_comparison<char>(s);
add_opers_comparison<std::string>(s); add_opers_comparison<std::string>(s);
add_oper_assign<int>(s);
add_oper_assign<double>(s);
add_oper_assign<char>(s);
add_oper_assign<std::string>(s);
add_opers_comparison_overload<int, double>(s); add_opers_comparison_overload<int, double>(s);
add_opers_comparison_overload<double, int>(s); add_opers_comparison_overload<double, int>(s);

View File

@@ -24,10 +24,8 @@ void bootstrap_random_access_container(BoxedCPP_System &system, const std::strin
template<typename Assignable> template<typename Assignable>
void bootstrap_assignable(BoxedCPP_System &system, const std::string &type) void bootstrap_assignable(BoxedCPP_System &system, const std::string &type)
{ {
/*
system.register_function( system.register_function(
boost::function<Assignable &(Assignable*, Assignable&)>(&Assignable::operator=), "="); boost::function<Assignable &(Assignable*, const Assignable&)>(&Assignable::operator=), "=");
*/
} }
template<typename ContainerType> template<typename ContainerType>

View File

@@ -441,6 +441,8 @@ BoxedCPP_System build_eval_system() {
register_function(ss, &print<size_t>, "print"); register_function(ss, &print<size_t>, "print");
register_function(ss, &concat_string, "concat_string"); register_function(ss, &concat_string, "concat_string");
register_function(ss, &print<int>, "print"); register_function(ss, &print<int>, "print");
ss.register_function(boost::function<void ()>(boost::bind(&dump_system, boost::ref(ss))), "dump_system");
ss.register_function(boost::shared_ptr<Proxy_Function>( ss.register_function(boost::shared_ptr<Proxy_Function>(
new Dynamic_Proxy_Function(boost::bind(&add_two, boost::ref(ss), _1), 2)), "add_two"); new Dynamic_Proxy_Function(boost::bind(&add_two, boost::ref(ss), _1), 2)), "add_two");