Experimenting with adding comparisons

This commit is contained in:
Jonathan Turner
2009-06-04 15:28:45 +00:00
parent 8f89e44608
commit 00430e4592
3 changed files with 46 additions and 9 deletions

View File

@@ -28,6 +28,12 @@ Ret multiply(P1 p1, P2 p2)
return p1 * p2;
}
template<typename Ret, typename P1, typename P2>
Ret equals(P1 p1, P2 p2)
{
return p1 == p2;
}
template<typename P1, typename P2>
P1 &timesequal(P1 &p1, P2 p2)
{
@@ -46,6 +52,7 @@ void bootstrap(BoxedCPP_System &s)
s.register_type<double>("double");
s.register_type<int>("int");
s.register_type<char>("char");
s.register_type<bool>("bool");
s.register_type<std::string>("string");
s.register_function(boost::function<std::string (const std::string &, const std::string&)>(&add<std::string, const std::string &, const std::string &>), "+");
@@ -65,6 +72,11 @@ void bootstrap(BoxedCPP_System &s)
s.register_function(boost::function<double (double, int)>(&divide<double, double, int>), "/");
s.register_function(boost::function<double (double, double)>(&divide<double, double, double>), "/");
s.register_function(boost::function<int (int, int)>(&equals<bool, int, int>), "==");
s.register_function(boost::function<double (int, double)>(&equals<bool, int, double>), "==");
s.register_function(boost::function<double (double, int)>(&equals<bool, double, int>), "==");
s.register_function(boost::function<double (double, double)>(&equals<bool, double, double>), "==");
s.register_function(boost::function<int (int, int)>(&multiply<int, int, int>), "*");
s.register_function(boost::function<double (int, double)>(&multiply<double, int, double>), "*");
s.register_function(boost::function<double (double, int)>(&multiply<double, double, int>), "*");

View File

@@ -36,7 +36,8 @@ class BoxedCPP_System
template<typename Class>
void add_object(const std::string &name, const Class &obj)
{
m_objects.insert(std::make_pair(name, Boxed_Value(obj)));
//m_objects.insert(std::make_pair(name, Boxed_Value(obj)));
m_objects[name] = Boxed_Value(obj);
}
Boxed_Value get_object(const std::string &name) const