Name change from BoxedCPP_System to Dispatch_Engine

This commit is contained in:
Jonathan Turner
2009-06-11 15:52:44 +00:00
parent e313376a00
commit 3b220bd4dc
8 changed files with 57 additions and 57 deletions

View File

@@ -246,95 +246,95 @@ P1 &prefixnot(P1 &p1)
//Add canonical forms of operators //Add canonical forms of operators
template<typename T> template<typename T>
void add_oper_equals(BoxedCPP_System &s) void add_oper_equals(Dispatch_Engine &s)
{ {
register_function(s, &equals<const T&, const T&>, "="); register_function(s, &equals<const T&, const T&>, "=");
} }
template<typename T> template<typename T>
void add_oper_add(BoxedCPP_System &s) void add_oper_add(Dispatch_Engine &s)
{ {
register_function(s, &add<T, const T&, const T&>, "+"); register_function(s, &add<T, const T&, const T&>, "+");
} }
template<typename T> template<typename T>
void add_oper_add_equals(BoxedCPP_System &s) void add_oper_add_equals(Dispatch_Engine &s)
{ {
register_function(s, &addsequal<T, T>, "+="); register_function(s, &addsequal<T, T>, "+=");
} }
template<typename T> template<typename T>
void add_oper_subtract(BoxedCPP_System &s) void add_oper_subtract(Dispatch_Engine &s)
{ {
register_function(s, &subtract<T, const T&, const T&>, "-"); register_function(s, &subtract<T, const T&, const T&>, "-");
} }
template<typename T> template<typename T>
void add_oper_divide(BoxedCPP_System &s) void add_oper_divide(Dispatch_Engine &s)
{ {
register_function(s, &divide<T, const T&, const T&>, "-"); register_function(s, &divide<T, const T&, const T&>, "-");
} }
template<typename T> template<typename T>
void add_oper_multiply(BoxedCPP_System &s) void add_oper_multiply(Dispatch_Engine &s)
{ {
register_function(s, &multiply<T, const T&, const T&>, "*"); register_function(s, &multiply<T, const T&, const T&>, "*");
} }
template<typename T> template<typename T>
void add_oper_not_equals(BoxedCPP_System &s) void add_oper_not_equals(Dispatch_Engine &s)
{ {
register_function(s, &not_equals<const T&, const T&>, "!="); register_function(s, &not_equals<const T&, const T&>, "!=");
} }
template<typename T, typename U> template<typename T, typename U>
void add_oper_assign_overload(BoxedCPP_System &s) void add_oper_assign_overload(Dispatch_Engine &s)
{ {
register_function(s, &assign<T,U>, "="); register_function(s, &assign<T,U>, "=");
} }
template<typename T> template<typename T>
void add_oper_assign(BoxedCPP_System &s) void add_oper_assign(Dispatch_Engine &s)
{ {
register_function(s, &assign<T,T>, "="); register_function(s, &assign<T,T>, "=");
} }
template<typename T> template<typename T>
void add_oper_assign_pod(BoxedCPP_System &s) void add_oper_assign_pod(Dispatch_Engine &s)
{ {
register_function(s, &assign_pod<T>, "="); register_function(s, &assign_pod<T>, "=");
} }
template<typename T> template<typename T>
void add_oper_less_than(BoxedCPP_System &s) void add_oper_less_than(Dispatch_Engine &s)
{ {
register_function(s, &less_than<const T&, const T&>, "<"); register_function(s, &less_than<const T&, const T&>, "<");
} }
template<typename T> template<typename T>
void add_oper_greater_than(BoxedCPP_System &s) void add_oper_greater_than(Dispatch_Engine &s)
{ {
register_function(s, &greater_than<const T&, const T&>, ">"); register_function(s, &greater_than<const T&, const T&>, ">");
} }
template<typename T> template<typename T>
void add_oper_less_than_equals(BoxedCPP_System &s) void add_oper_less_than_equals(Dispatch_Engine &s)
{ {
register_function(s, &less_than_equals<const T&, const T&>, "<="); register_function(s, &less_than_equals<const T&, const T&>, "<=");
} }
template<typename T> template<typename T>
void add_oper_greater_than_equals(BoxedCPP_System &s) void add_oper_greater_than_equals(Dispatch_Engine &s)
{ {
register_function(s, &greater_than_equals<const T&, const T&>, ">="); register_function(s, &greater_than_equals<const T&, const T&>, ">=");
} }
template<typename T, typename R> template<typename T, typename R>
void add_opers_comparison_overload(BoxedCPP_System &s) void add_opers_comparison_overload(Dispatch_Engine &s)
{ {
register_function(s, &equals<const T&, const R&>, "=="); register_function(s, &equals<const T&, const R&>, "==");
register_function(s, &not_equals<const T&, const R&>, "!="); register_function(s, &not_equals<const T&, const R&>, "!=");
@@ -344,7 +344,7 @@ void add_opers_comparison_overload(BoxedCPP_System &s)
register_function(s, &greater_than_equals<const T&, const R&>, ">="); register_function(s, &greater_than_equals<const T&, const R&>, ">=");
} }
void add_opers_comparison_pod(BoxedCPP_System &s) void add_opers_comparison_pod(Dispatch_Engine &s)
{ {
register_function(s, &pod_equals, "=="); register_function(s, &pod_equals, "==");
register_function(s, &pod_not_equals, "!="); register_function(s, &pod_not_equals, "!=");
@@ -354,7 +354,7 @@ void add_opers_comparison_pod(BoxedCPP_System &s)
register_function(s, &pod_greater_than_equals, ">="); register_function(s, &pod_greater_than_equals, ">=");
} }
void add_opers_arithmetic_pod(BoxedCPP_System &s) void add_opers_arithmetic_pod(Dispatch_Engine &s)
{ {
register_function(s, &pod_add, "+"); register_function(s, &pod_add, "+");
register_function(s, &pod_subtract, "-"); register_function(s, &pod_subtract, "-");
@@ -363,13 +363,13 @@ void add_opers_arithmetic_pod(BoxedCPP_System &s)
} }
template<typename T> template<typename T>
void add_opers_comparison(BoxedCPP_System &s) void add_opers_comparison(Dispatch_Engine &s)
{ {
add_opers_comparison_overload<T, T>(s); add_opers_comparison_overload<T, T>(s);
} }
template<typename Ret, typename T, typename R> template<typename Ret, typename T, typename R>
void add_opers_arithmetic_overload(BoxedCPP_System &s) void add_opers_arithmetic_overload(Dispatch_Engine &s)
{ {
register_function(s, &add<Ret, T, R>, "+"); register_function(s, &add<Ret, T, R>, "+");
register_function(s, &subtract<Ret, T, R>, "-"); register_function(s, &subtract<Ret, T, R>, "-");
@@ -386,7 +386,7 @@ void add_opers_arithmetic_overload(BoxedCPP_System &s)
} }
template<typename T> template<typename T>
void add_opers_arithmetic_modify_pod(BoxedCPP_System &s) void add_opers_arithmetic_modify_pod(Dispatch_Engine &s)
{ {
register_function(s, &timesequal_pod<T>, "*="); register_function(s, &timesequal_pod<T>, "*=");
register_function(s, &dividesequal_pod<T>, "/="); register_function(s, &dividesequal_pod<T>, "/=");
@@ -395,7 +395,7 @@ void add_opers_arithmetic_modify_pod(BoxedCPP_System &s)
} }
template<typename T> template<typename T>
void add_basic_constructors(BoxedCPP_System &s, const std::string &type) void add_basic_constructors(Dispatch_Engine &s, const std::string &type)
{ {
s.register_function(build_constructor<T>(), type); s.register_function(build_constructor<T>(), type);
s.register_function(build_constructor<T, const T &>(), type); s.register_function(build_constructor<T, const T &>(), type);
@@ -403,13 +403,13 @@ void add_basic_constructors(BoxedCPP_System &s, const std::string &type)
} }
template<typename T, typename U> template<typename T, typename U>
void add_constructor_overload(BoxedCPP_System &s, const std::string &type) void add_constructor_overload(Dispatch_Engine &s, const std::string &type)
{ {
s.register_function(build_constructor<T, const U &>(), type); s.register_function(build_constructor<T, const U &>(), type);
} }
template<typename T> template<typename T>
void add_opers_arithmetic(BoxedCPP_System &s) void add_opers_arithmetic(Dispatch_Engine &s)
{ {
add_opers_arithmetic_overload<T, T, T>(s); add_opers_arithmetic_overload<T, T, T>(s);
@@ -464,7 +464,7 @@ template<> std::string to_string(bool b)
} }
template<typename T> template<typename T>
void bootstrap_pod_type(BoxedCPP_System &s, const std::string &name) void bootstrap_pod_type(Dispatch_Engine &s, const std::string &name)
{ {
s.register_type<T>(name); s.register_type<T>(name);
add_basic_constructors<T>(s, name); add_basic_constructors<T>(s, name);
@@ -480,7 +480,7 @@ void print(const std::string &s)
std::cout << s << std::endl; std::cout << s << std::endl;
} }
void bootstrap(BoxedCPP_System &s) void bootstrap(Dispatch_Engine &s)
{ {
s.register_type<void>("void"); s.register_type<void>("void");

View File

@@ -4,12 +4,12 @@
#include "boxedcpp.hpp" #include "boxedcpp.hpp"
template<typename ContainerType> template<typename ContainerType>
void bootstrap_reversible_container(BoxedCPP_System &system, const std::string &type) void bootstrap_reversible_container(Dispatch_Engine &system, const std::string &type)
{ {
} }
template<typename ContainerType> template<typename ContainerType>
void bootstrap_random_access_container(BoxedCPP_System &system, const std::string &type) void bootstrap_random_access_container(Dispatch_Engine &system, const std::string &type)
{ {
bootstrap_reversible_container<ContainerType>(system, type); bootstrap_reversible_container<ContainerType>(system, type);
@@ -22,14 +22,14 @@ 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(Dispatch_Engine &system, const std::string &type)
{ {
system.register_function( system.register_function(
boost::function<Assignable &(Assignable*, const Assignable&)>(&Assignable::operator=), "="); boost::function<Assignable &(Assignable*, const Assignable&)>(&Assignable::operator=), "=");
} }
template<typename ContainerType> template<typename ContainerType>
void bootstrap_container(BoxedCPP_System &system, const std::string &type) void bootstrap_container(Dispatch_Engine &system, const std::string &type)
{ {
bootstrap_assignable<ContainerType>(system, type); bootstrap_assignable<ContainerType>(system, type);
@@ -40,26 +40,26 @@ void bootstrap_container(BoxedCPP_System &system, const std::string &type)
} }
template<typename ContainerType> template<typename ContainerType>
void bootstrap_forward_container(BoxedCPP_System &system, const std::string &type) void bootstrap_forward_container(Dispatch_Engine &system, const std::string &type)
{ {
bootstrap_container<ContainerType>(system, type); bootstrap_container<ContainerType>(system, type);
} }
template<typename Type> template<typename Type>
void bootstrap_default_constructible(BoxedCPP_System &system, const std::string &type) void bootstrap_default_constructible(Dispatch_Engine &system, const std::string &type)
{ {
system.register_function(build_constructor<Type>(), type); system.register_function(build_constructor<Type>(), type);
} }
template<typename SequenceType> template<typename SequenceType>
void bootstrap_sequence(BoxedCPP_System &system, const std::string &type) void bootstrap_sequence(Dispatch_Engine &system, const std::string &type)
{ {
bootstrap_forward_container<SequenceType>(system, type); bootstrap_forward_container<SequenceType>(system, type);
bootstrap_default_constructible<SequenceType>(system, type); bootstrap_default_constructible<SequenceType>(system, type);
} }
template<typename SequenceType> template<typename SequenceType>
void bootstrap_back_insertion_sequence(BoxedCPP_System &system, const std::string &type) void bootstrap_back_insertion_sequence(Dispatch_Engine &system, const std::string &type)
{ {
bootstrap_sequence<SequenceType>(system, type); bootstrap_sequence<SequenceType>(system, type);
@@ -72,7 +72,7 @@ void bootstrap_back_insertion_sequence(BoxedCPP_System &system, const std::strin
} }
template<typename VectorType> template<typename VectorType>
void bootstrap_vector(BoxedCPP_System &system, const std::string &type) void bootstrap_vector(Dispatch_Engine &system, const std::string &type)
{ {
system.register_type<VectorType>(type); system.register_type<VectorType>(type);
bootstrap_random_access_container<VectorType>(system, type); bootstrap_random_access_container<VectorType>(system, type);

View File

@@ -16,7 +16,7 @@
#include "proxy_functions.hpp" #include "proxy_functions.hpp"
#include "proxy_constructors.hpp" #include "proxy_constructors.hpp"
class BoxedCPP_System class Dispatch_Engine
{ {
public: public:
typedef std::multimap<std::string, boost::shared_ptr<Proxy_Function> > Function_Map; typedef std::multimap<std::string, boost::shared_ptr<Proxy_Function> > Function_Map;
@@ -24,7 +24,7 @@ class BoxedCPP_System
typedef std::map<std::string, Boxed_Value> Scope; typedef std::map<std::string, Boxed_Value> Scope;
typedef std::deque<Scope> Stack; typedef std::deque<Scope> Stack;
BoxedCPP_System() Dispatch_Engine()
{ {
m_scopes.push_back(Scope()); m_scopes.push_back(Scope());
} }
@@ -160,7 +160,7 @@ void dump_type(const Type_Info &type)
std::cout << type.m_bare_type_info->name(); std::cout << type.m_bare_type_info->name();
} }
void dump_function(const BoxedCPP_System::Function_Map::value_type &f) void dump_function(const Dispatch_Engine::Function_Map::value_type &f)
{ {
std::vector<Type_Info> params = f.second->get_param_types(); std::vector<Type_Info> params = f.second->get_param_types();
@@ -178,11 +178,11 @@ void dump_function(const BoxedCPP_System::Function_Map::value_type &f)
std::cout << ")" << std::endl; std::cout << ")" << std::endl;
} }
void dump_system(const BoxedCPP_System &s) void dump_system(const Dispatch_Engine &s)
{ {
std::cout << "Registered Types: " << std::endl; std::cout << "Registered Types: " << std::endl;
std::vector<BoxedCPP_System::Type_Name_Map::value_type> types = s.get_types(); std::vector<Dispatch_Engine::Type_Name_Map::value_type> types = s.get_types();
for (std::vector<BoxedCPP_System::Type_Name_Map::value_type>::const_iterator itr = types.begin(); for (std::vector<Dispatch_Engine::Type_Name_Map::value_type>::const_iterator itr = types.begin();
itr != types.end(); itr != types.end();
++itr) ++itr)
{ {
@@ -192,10 +192,10 @@ void dump_system(const BoxedCPP_System &s)
} }
std::cout << std::endl; std::vector<BoxedCPP_System::Function_Map::value_type> funcs = s.get_functions(); std::cout << std::endl; std::vector<Dispatch_Engine::Function_Map::value_type> funcs = s.get_functions();
std::cout << "Functions: " << std::endl; std::cout << "Functions: " << std::endl;
for (std::vector<BoxedCPP_System::Function_Map::value_type>::const_iterator itr = funcs.begin(); for (std::vector<Dispatch_Engine::Function_Map::value_type>::const_iterator itr = funcs.begin();
itr != funcs.end(); itr != funcs.end();
++itr) ++itr)
{ {

View File

@@ -19,13 +19,13 @@
# define n BOOST_PP_ITERATION() # define n BOOST_PP_ITERATION()
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)> template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
void register_function(BoxedCPP_System &s, Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const std::string &name) void register_function(Dispatch_Engine &s, Ret (*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const std::string &name)
{ {
s.register_function(boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>(f), name); s.register_function(boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))>(f), name);
} }
template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)> template<typename Ret, typename Class BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
void register_function(BoxedCPP_System &s, Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const std::string &name) void register_function(Dispatch_Engine &s, Ret (Class::*f)(BOOST_PP_ENUM_PARAMS(n, Param)), const std::string &name)
{ {
s.register_function(boost::function<Ret (Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f), name); s.register_function(boost::function<Ret (Class* BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Param))>(f), name);
} }

View File

@@ -31,7 +31,7 @@ struct Test
Boxed_Value named_func_call(BoxedCPP_System &ss, Boxed_Value named_func_call(Dispatch_Engine &ss,
const std::string &nametocall, const std::vector<Boxed_Value> &params) const std::string &nametocall, const std::vector<Boxed_Value> &params)
{ {
if (params.size() == 2) if (params.size() == 2)
@@ -45,7 +45,7 @@ Boxed_Value named_func_call(BoxedCPP_System &ss,
// A function that takes a dynamic list of params // A function that takes a dynamic list of params
// and calls a bunch of conversion functions on them and // and calls a bunch of conversion functions on them and
// returns the result as a boxed_value // returns the result as a boxed_value
Boxed_Value dynamic_function(BoxedCPP_System &ss, const std::string &name, Boxed_Value dynamic_function(Dispatch_Engine &ss, const std::string &name,
const std::vector<Boxed_Value> &params) const std::vector<Boxed_Value> &params)
{ {
if (name == "concat_string") if (name == "concat_string")
@@ -87,7 +87,7 @@ void test(const std::string &p)
//Test main //Test main
int main() int main()
{ {
BoxedCPP_System ss; Dispatch_Engine ss;
bootstrap(ss); bootstrap(ss);
bootstrap_vector<std::vector<int> >(ss, "VectorInt"); bootstrap_vector<std::vector<int> >(ss, "VectorInt");
dump_system(ss); dump_system(ss);

View File

@@ -7,7 +7,7 @@
BOOST_AUTO_TEST_CASE( add_operators ) BOOST_AUTO_TEST_CASE( add_operators )
{ {
BoxedCPP_System ss; Dispatch_Engine ss;
bootstrap(ss); bootstrap(ss);
dump_system(ss); dump_system(ss);

View File

@@ -262,7 +262,7 @@ public:
} }
}; };
typedef Wesley_System<BoxedCPP_System> Wesley_Engine; typedef Wesley_System<Dispatch_Engine> Wesley_Engine;
#endif /* WESLEY_ENGINE_HPP_ */ #endif /* WESLEY_ENGINE_HPP_ */

View File

@@ -206,11 +206,11 @@ Boxed_Value eval_token(Eval_System &ss, TokenPtr node) {
break; break;
case (TokenType::Fun_Call) : { case (TokenType::Fun_Call) : {
std::vector<std::pair<std::string, BoxedCPP_System::Function_Map::mapped_type> > fn; std::vector<std::pair<std::string, Dispatch_Engine::Function_Map::mapped_type> > fn;
BoxedCPP_System::Stack prev_stack = ss.get_stack(); Dispatch_Engine::Stack prev_stack = ss.get_stack();
BoxedCPP_System::Stack new_stack; Dispatch_Engine::Stack new_stack;
new_stack.push_back(BoxedCPP_System::Scope()); new_stack.push_back(Dispatch_Engine::Scope());
Param_List_Builder plb; Param_List_Builder plb;
for (i = 1; i < node->children.size(); ++i) { for (i = 1; i < node->children.size(); ++i) {
@@ -237,11 +237,11 @@ Boxed_Value eval_token(Eval_System &ss, TokenPtr node) {
} }
break; break;
case (TokenType::Method_Call) : { case (TokenType::Method_Call) : {
std::vector<std::pair<std::string, BoxedCPP_System::Function_Map::mapped_type> > fn; std::vector<std::pair<std::string, Dispatch_Engine::Function_Map::mapped_type> > fn;
BoxedCPP_System::Stack prev_stack = ss.get_stack(); Dispatch_Engine::Stack prev_stack = ss.get_stack();
BoxedCPP_System::Stack new_stack; Dispatch_Engine::Stack new_stack;
new_stack.push_back(BoxedCPP_System::Scope()); new_stack.push_back(Dispatch_Engine::Scope());
retval = eval_token(ss, node->children[0]); retval = eval_token(ss, node->children[0]);
if (node->children.size() > 1) { if (node->children.size() > 1) {