From d22a77503cf89a4852d972cfed3e5d6185bbf543 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 2 Apr 2011 11:21:11 -0600 Subject: [PATCH] Fix build errors and warnings for VS2010 --- .../chaiscript/dispatchkit/handle_return.hpp | 214 +++++++++--------- .../dispatchkit/proxy_functions.hpp | 14 +- .../dispatchkit/proxy_functions_detail.hpp | 108 ++++----- .../chaiscript/language/chaiscript_common.hpp | 9 + .../chaiscript/language/chaiscript_eval.hpp | 12 +- 5 files changed, 187 insertions(+), 170 deletions(-) diff --git a/include/chaiscript/dispatchkit/handle_return.hpp b/include/chaiscript/dispatchkit/handle_return.hpp index a79e5b0..e9fe6ae 100644 --- a/include/chaiscript/dispatchkit/handle_return.hpp +++ b/include/chaiscript/dispatchkit/handle_return.hpp @@ -17,135 +17,137 @@ namespace chaiscript { - namespace detail + namespace dispatch { - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template - struct Handle_Return - { - static Boxed_Value handle(const Ret &r) + namespace detail + { + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template + struct Handle_Return { - return const_var(r); - } - }; + static Boxed_Value handle(const Ret &r) + { + return const_var(r); + } + }; - template - struct Handle_Return &> - { - static Boxed_Value handle(const boost::shared_ptr &r) + template + struct Handle_Return &> { - return Boxed_Value(r); - } - }; + static Boxed_Value handle(const boost::shared_ptr &r) + { + return Boxed_Value(r); + } + }; - template - struct Handle_Return > - { - static Boxed_Value handle(const boost::shared_ptr &r) + template + struct Handle_Return > { - return Boxed_Value(r); - } - }; + static Boxed_Value handle(const boost::shared_ptr &r) + { + return Boxed_Value(r); + } + }; - template - struct Handle_Return &> - { - static Boxed_Value handle(const boost::shared_ptr &r) + template + struct Handle_Return &> { - return Boxed_Value(r); - } - }; + static Boxed_Value handle(const boost::shared_ptr &r) + { + return Boxed_Value(r); + } + }; - template - struct Handle_Return - { - static Boxed_Value handle(const Ret &r) + template + struct Handle_Return { - return Boxed_Value(boost::cref(r)); - } - }; + static Boxed_Value handle(const Ret &r) + { + return Boxed_Value(boost::cref(r)); + } + }; - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template - struct Handle_Return - { - static Boxed_Value handle(Ret &r) + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template + struct Handle_Return { - return Boxed_Value(boost::ref(r)); - } + static Boxed_Value handle(Ret &r) + { + return Boxed_Value(boost::ref(r)); + } - static Boxed_Value handle(const Ret &r) + static Boxed_Value handle(const Ret &r) + { + return Boxed_Value(boost::cref(r)); + } + }; + + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return { - return Boxed_Value(boost::cref(r)); - } - }; + static Boxed_Value handle(const Boxed_Value &r) + { + return r; + } + }; - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template<> - struct Handle_Return - { - static Boxed_Value handle(const Boxed_Value &r) + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return { - return r; - } - }; + static Boxed_Value handle(const Boxed_Value &r) + { + return r; + } + }; - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template<> - struct Handle_Return - { - static Boxed_Value handle(const Boxed_Value &r) + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return { - return r; - } - }; + static Boxed_Value handle(const Boxed_Value &r) + { + return r; + } + }; - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template<> - struct Handle_Return - { - static Boxed_Value handle(const Boxed_Value &r) + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return { - return r; - } - }; + static Boxed_Value handle(const Boxed_Value &r) + { + return r; + } + }; - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template<> - struct Handle_Return - { - static Boxed_Value handle(const Boxed_Value &r) + + /** + * Used internally for handling a return value from a Proxy_Function call + */ + template<> + struct Handle_Return { - return r; - } - }; - - - /** - * Used internally for handling a return value from a Proxy_Function call - */ - template<> - struct Handle_Return - { - static Boxed_Value handle() - { - return Boxed_Value(Boxed_Value::Void_Type()); - } - }; - + static Boxed_Value handle() + { + return Boxed_Value(Boxed_Value::Void_Type()); + } + }; + } } } diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 97ef808..8c1fb52 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -20,7 +20,7 @@ namespace chaiscript { - struct Boxed_POD_Value; + class Boxed_POD_Value; struct AST_Node; typedef boost::shared_ptr AST_NodePtr; @@ -141,7 +141,7 @@ namespace chaiscript || (!bv.get_type_info().is_undef() && (ti.bare_equal(user_type()) || ti.bare_equal(bv.get_type_info()) - || detail::dynamic_cast_converts(ti, bv.get_type_info()) + || chaiscript::detail::dynamic_cast_converts(ti, bv.get_type_info()) || bv.get_type_info().bare_equal(user_type >()) ) ) @@ -289,13 +289,13 @@ namespace chaiscript std::vector types; // For the return type - types.push_back(detail::Get_Type_Info::get()); + types.push_back(chaiscript::detail::Get_Type_Info::get()); if (arity >= 0) { for (int i = 0; i < arity; ++i) { - types.push_back(detail::Get_Type_Info::get()); + types.push_back(chaiscript::detail::Get_Type_Info::get()); } } @@ -371,7 +371,7 @@ namespace chaiscript while (!(parg == params.end() && barg == m_args.end())) { while (barg != m_args.end() - && !(barg->get_type_info() == detail::Get_Type_Info::get())) + && !(barg->get_type_info() == chaiscript::detail::Get_Type_Info::get())) { args.push_back(*barg); ++barg; @@ -384,7 +384,7 @@ namespace chaiscript } if (barg != m_args.end() - && barg->get_type_info() == detail::Get_Type_Info::get()) + && barg->get_type_info() == chaiscript::detail::Get_Type_Info::get()) { ++barg; } @@ -416,7 +416,7 @@ namespace chaiscript retval.push_back(types[0]); for (size_t i = 0; i < types.size()-1; ++i) { - if (t_args[i].get_type_info() == detail::Get_Type_Info::get()) + if (t_args[i].get_type_info() == chaiscript::detail::Get_Type_Info::get()) { retval.push_back(types[i+1]); } diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index 8402959..acd85d2 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -6,7 +6,7 @@ #include -#define gettypeinfo(z,n,text) ti.push_back(detail::Get_Type_Info::get()); +#define gettypeinfo(z,n,text) ti.push_back(chaiscript::detail::Get_Type_Info::get()); #define casthelper(z,n,text) BOOST_PP_COMMA_IF(n) chaiscript::boxed_cast< Param ## n >(params[n]) #define trycast(z,n,text) chaiscript::boxed_cast(params[n]); @@ -62,58 +62,61 @@ namespace chaiscript namespace chaiscript { - namespace detail + namespace dispatch { - /** - * Used by Proxy_Function_Impl to return a list of all param types - * it contains. - */ - template - std::vector build_param_type_list(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param))) - { - std::vector ti; - ti.push_back(detail::Get_Type_Info::get()); - - BOOST_PP_REPEAT(n, gettypeinfo, ~) - - return ti; - } - - /** - * Used by Proxy_Function_Impl to perform typesafe execution of a function. - * The function attempts to unbox each paramter to the expected type. - * if any unboxing fails the execution of the function fails and - * the bad_boxed_cast is passed up to the caller. - */ - template - Ret call_func(const boost::function &f, - const std::vector ¶ms) - { - if (params.size() != n) + namespace detail + { + /** + * Used by Proxy_Function_Impl to return a list of all param types + * it contains. + */ + template + std::vector build_param_type_list(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param))) { - throw exception::arity_error(static_cast(params.size()), n); - } else { - return f(BOOST_PP_REPEAT(n, casthelper, ~)); - } - } + std::vector ti; + ti.push_back(chaiscript::detail::Get_Type_Info::get()); - /** - * Used by Proxy_Function_Impl to determine if it is equivalent to another - * Proxy_Function_Impl object. This function is primarly used to prevent - * registration of two functions with the exact same signatures - */ - template - bool compare_types_cast(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param)), - const std::vector & BOOST_PP_IF(n, params, )) - { - try { - BOOST_PP_REPEAT(n, trycast, ~); - } catch (const exception::bad_boxed_cast &) { - return false; + BOOST_PP_REPEAT(n, gettypeinfo, ~) + + return ti; } - return true; - } + /** + * Used by Proxy_Function_Impl to perform typesafe execution of a function. + * The function attempts to unbox each paramter to the expected type. + * if any unboxing fails the execution of the function fails and + * the bad_boxed_cast is passed up to the caller. + */ + template + Ret call_func(const boost::function &f, + const std::vector ¶ms) + { + if (params.size() != n) + { + throw exception::arity_error(static_cast(params.size()), n); + } else { + return f(BOOST_PP_REPEAT(n, casthelper, ~)); + } + } + + /** + * Used by Proxy_Function_Impl to determine if it is equivalent to another + * Proxy_Function_Impl object. This function is primarly used to prevent + * registration of two functions with the exact same signatures + */ + template + bool compare_types_cast(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param)), + const std::vector & BOOST_PP_IF(n, params, )) + { + try { + BOOST_PP_REPEAT(n, trycast, ~); + } catch (const exception::bad_boxed_cast &) { + return false; + } + + return true; + } + } } } @@ -126,15 +129,17 @@ namespace chaiscript namespace chaiscript { - namespace detail + namespace dispatch { + namespace detail + { template struct Do_Call { template static Boxed_Value go(const boost::function &fun, const std::vector ¶ms) { - return Handle_Return::handle(chaiscript::detail::call_func(fun, params)); + return Handle_Return::handle(call_func(fun, params)); } }; @@ -144,10 +149,11 @@ namespace chaiscript template static Boxed_Value go(const boost::function &fun, const std::vector ¶ms) { - chaiscript::detail::call_func(fun, params); + call_func(fun, params); return Handle_Return::handle(); } }; + } } } diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index 124b052..25dc690 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -163,6 +163,11 @@ namespace chaiscript { throw std::runtime_error("Undispatched ast_node (internal error)"); } + + private: + // Copy and assignment explicitly unimplemented + AST_Node(const AST_Node &); + AST_Node& operator=(const AST_Node &); }; @@ -203,6 +208,10 @@ namespace chaiscript private: + // explicitly unimplemented copy and assignment + Scope_Push_Pop(const Scope_Push_Pop &); + Scope_Push_Pop& operator=(const Scope_Push_Pop &); + chaiscript::detail::Dispatch_Engine &m_de; }; diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index b7609a7..fee19bc 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -70,7 +70,7 @@ namespace chaiscript public: Int_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Int, const boost::shared_ptr &t_fname=boost::shared_ptr(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), - m_value(const_var(int(atoi(this->text.c_str())))) { } + m_value(const_var(int(atoi(t_ast_node_text.c_str())))) { } virtual ~Int_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ return m_value; @@ -85,7 +85,7 @@ namespace chaiscript public: Float_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Float, const boost::shared_ptr &t_fname=boost::shared_ptr(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), - m_value(const_var(double(atof(this->text.c_str())))) { } + m_value(const_var(double(atof(t_ast_node_text.c_str())))) { } virtual ~Float_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ return m_value; @@ -200,7 +200,7 @@ namespace chaiscript throw; } } - catch(exception::eval_error &ee) { + catch(exception::eval_error &) { t_ss.set_stack(prev_stack); throw; } @@ -438,7 +438,7 @@ namespace chaiscript public: Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Quoted_String, const boost::shared_ptr &t_fname=boost::shared_ptr(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), - m_value(const_var(this->text)) { } + m_value(const_var(t_ast_node_text)) { } virtual ~Quoted_String_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &) { return m_value; @@ -453,7 +453,7 @@ namespace chaiscript public: Single_Quoted_String_AST_Node(const std::string &t_ast_node_text = "", int t_id = AST_Node_Type::Single_Quoted_String, const boost::shared_ptr &t_fname=boost::shared_ptr(), int t_start_line = 0, int t_start_col = 0, int t_end_line = 0, int t_end_col = 0) : AST_Node(t_ast_node_text, t_id, t_fname, t_start_line, t_start_col, t_end_line, t_end_col), - m_value(const_var(char(this->text[0]))) { } + m_value(const_var(char(t_ast_node_text.at(0)))) { } virtual ~Single_Quoted_String_AST_Node() {} virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &){ return m_value; @@ -850,7 +850,7 @@ namespace chaiscript try { retval = this->children[0]->eval(t_ss); } - catch (exception::eval_error &ee) { + catch (exception::eval_error &) { if (this->children.back()->identifier == AST_Node_Type::Finally) { this->children.back()->children[0]->eval(t_ss); }