From db0e342a9632fa0e82be1f8002e1e8ac565d0fcd Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 25 Sep 2011 18:34:02 -0600 Subject: [PATCH] Remove little used Param_List_Builder --- .../dispatchkit/proxy_functions.hpp | 31 ------------------- .../chaiscript/language/chaiscript_eval.hpp | 20 ++++++------ 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index e04f000..c14e1e7 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -28,37 +28,6 @@ namespace chaiscript namespace dispatch { - /** - * Helper for building a list of parameters for calling a Proxy_Function - * it does automatic conversion to Boxed_Value types via operator<< - * - * example usage: - * Boxed_Value retval = dispatch(dispatchengine.get_function("+"), - * chaiscript::Param_List_Builder() << 5 << 6); - */ - struct Param_List_Builder - { - Param_List_Builder &operator<<(const Boxed_Value &so) - { - objects.push_back(so); - return *this; - } - - template - Param_List_Builder &operator<<(T t) - { - objects.push_back(Boxed_Value(t)); - return *this; - } - - operator const std::vector &() const - { - return objects; - } - - std::vector objects; - }; - /** * Pure virtual base class for all Proxy_Function implementations * Proxy_Functions are a type erasure of type safe C++ diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 8e2b963..4337e69 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -182,11 +182,11 @@ namespace chaiscript AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } virtual ~Fun_Call_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ - dispatch::Param_List_Builder plb; + std::vector params; if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) { for (size_t i = 0; i < this->children[1]->children.size(); ++i) { - plb << this->children[1]->children[i]->eval(t_ss); + params.push_back(this->children[1]->children[i]->eval(t_ss)); } } @@ -198,7 +198,7 @@ namespace chaiscript try { t_ss.set_stack(new_stack); - const Boxed_Value &retval = (*boxed_cast(fn))(plb); + const Boxed_Value &retval = (*boxed_cast(fn))(params); t_ss.set_stack(prev_stack); return retval; } @@ -230,16 +230,16 @@ namespace chaiscript AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col) { } virtual ~Inplace_Fun_Call_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){ - dispatch::Param_List_Builder plb; + std::vector params; if ((this->children.size() > 1) && (this->children[1]->identifier == AST_Node_Type::Arg_List)) { for (size_t i = 0; i < this->children[1]->children.size(); ++i) { - plb << this->children[1]->children[i]->eval(t_ss); + params.push_back(this->children[1]->children[i]->eval(t_ss)); } } try { - return (*boxed_cast(this->children[0]->eval(t_ss)))(plb); + return (*boxed_cast(this->children[0]->eval(t_ss)))(params); } catch(const exception::dispatch_error &e){ throw exception::eval_error(std::string(e.what()) + " with function '" + this->children[0]->text + "'", e.parameters, t_ss); @@ -458,12 +458,12 @@ namespace chaiscript if (this->children.size() > 1) { for (size_t i = 2; i < this->children.size(); i+=2) { - dispatch::Param_List_Builder plb; - plb << retval; + std::vector params; + params.push_back(retval); if (this->children[i]->children.size() > 1) { for (size_t j = 0; j < this->children[i]->children[1]->children.size(); ++j) { - plb << this->children[i]->children[1]->children[j]->eval(t_ss); + params.push_back(this->children[i]->children[1]->children[j]->eval(t_ss)); } } @@ -480,7 +480,7 @@ namespace chaiscript try { t_ss.set_stack(new_stack); - retval = t_ss.call_function(fun_name, plb); + retval = t_ss.call_function(fun_name, params); t_ss.set_stack(prev_stack); } catch(const exception::dispatch_error &e){