diff --git a/include/chaiscript/dispatchkit/bad_boxed_cast.hpp b/include/chaiscript/dispatchkit/bad_boxed_cast.hpp index 31344d4..c2be40f 100644 --- a/include/chaiscript/dispatchkit/bad_boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/bad_boxed_cast.hpp @@ -36,7 +36,7 @@ namespace chaiscript } bad_boxed_cast(Type_Info t_from, const std::type_info &t_to) - : from(std::move(t_from)), to(&t_to), m_what("Cannot perform boxed_cast") + : from(std::move(t_from)), to(&t_to), m_what("Cannot perform boxed_cast: " + t_from.name() + " to: " + t_to.name()) { } diff --git a/include/chaiscript/dispatchkit/boxed_cast.hpp b/include/chaiscript/dispatchkit/boxed_cast.hpp index 106b9d8..1ddaacc 100644 --- a/include/chaiscript/dispatchkit/boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast.hpp @@ -79,13 +79,6 @@ namespace chaiscript } -#ifdef CHAISCRIPT_MSVC - //Thank you MSVC, yes we know that a constant value is being used in the if - // statment in THIS VERSION of the template instantiation -#pragma warning(push) -#pragma warning(disable : 4127) -#endif - if (t_conversions && t_conversions->convertable_type()) { try { @@ -108,10 +101,6 @@ namespace chaiscript throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type)); } -#ifdef CHAISCRIPT_MSVC -#pragma warning(pop) -#endif - } } diff --git a/include/chaiscript/dispatchkit/function_call_detail.hpp b/include/chaiscript/dispatchkit/function_call_detail.hpp index b558138..4054b59 100644 --- a/include/chaiscript/dispatchkit/function_call_detail.hpp +++ b/include/chaiscript/dispatchkit/function_call_detail.hpp @@ -31,9 +31,9 @@ namespace chaiscript struct Function_Caller_Ret { static Ret call(const std::vector &t_funcs, - const std::vector ¶ms, const Type_Conversions &t_conversions) + const std::vector ¶ms, const Type_Conversions *t_conversions) { - return boxed_cast(dispatch::dispatch(t_funcs, params, t_conversions)); + return boxed_cast(dispatch::dispatch(t_funcs, params, t_conversions?*t_conversions:Type_Conversions()), t_conversions); } }; @@ -44,9 +44,9 @@ namespace chaiscript struct Function_Caller_Ret { static Ret call(const std::vector &t_funcs, - const std::vector ¶ms, const Type_Conversions &t_conversions) + const std::vector ¶ms, const Type_Conversions *t_conversions) { - return Boxed_Number(dispatch::dispatch(t_funcs, params, t_conversions)).get_as(); + return Boxed_Number(dispatch::dispatch(t_funcs, params, t_conversions?*t_conversions:Type_Conversions())).get_as(); } }; @@ -58,9 +58,9 @@ namespace chaiscript struct Function_Caller_Ret { static void call(const std::vector &t_funcs, - const std::vector ¶ms, const Type_Conversions &t_conversions) + const std::vector ¶ms, const Type_Conversions *t_conversions) { - dispatch::dispatch(t_funcs, params, t_conversions); + dispatch::dispatch(t_funcs, params, t_conversions?*t_conversions:Type_Conversions()); } }; @@ -70,7 +70,7 @@ namespace chaiscript template struct Build_Function_Caller_Helper { - Build_Function_Caller_Helper(std::vector t_funcs, const Type_Conversions &t_conversions) + Build_Function_Caller_Helper(std::vector t_funcs, const Type_Conversions *t_conversions) : m_funcs(std::move(t_funcs)), m_conversions(t_conversions) { @@ -107,11 +107,12 @@ namespace chaiscript std::vector m_funcs; - Type_Conversions m_conversions; + const Type_Conversions *m_conversions; }; + /// \todo what happens if t_conversions is deleted out from under us?! template std::function build_function_caller_helper(Ret (Params...), const std::vector &funcs, const Type_Conversions *t_conversions) { @@ -131,7 +132,7 @@ namespace chaiscript } */ - return std::function(Build_Function_Caller_Helper(funcs, t_conversions?*t_conversions:Type_Conversions())); + return std::function(Build_Function_Caller_Helper(funcs, t_conversions)); } } } diff --git a/include/chaiscript/dispatchkit/type_conversions.hpp b/include/chaiscript/dispatchkit/type_conversions.hpp index 34f652d..602d4d9 100644 --- a/include/chaiscript/dispatchkit/type_conversions.hpp +++ b/include/chaiscript/dispatchkit/type_conversions.hpp @@ -337,7 +337,7 @@ namespace chaiscript Type_Conversions(const Type_Conversions &t_other) : m_mutex(), m_conversions(t_other.get_conversions()), - m_convertableTypes(), + m_convertableTypes(t_other.m_convertableTypes), m_num_types(m_conversions.size()), m_thread_cache(this), m_conversion_saves(this) @@ -581,7 +581,6 @@ namespace chaiscript auto func = [](const Boxed_Value &t_bv) -> Boxed_Value { const std::vector &from_vec = detail::Cast_Helper &>::cast(t_bv, nullptr); - To vec; for (const Boxed_Value &bv : from_vec) {