diff --git a/include/chaiscript/dispatchkit/boxed_cast.hpp b/include/chaiscript/dispatchkit/boxed_cast.hpp index e172d32..b2fd0d7 100644 --- a/include/chaiscript/dispatchkit/boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast.hpp @@ -68,7 +68,7 @@ namespace chaiscript /// assert(i == 5); /// \endcode template - typename detail::Cast_Helper::Result_Type boxed_cast(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions = Dynamic_Cast_Conversions()) + typename detail::Cast_Helper::Result_Type boxed_cast(const Boxed_Value &bv, const Dynamic_Cast_Conversions *t_conversions = 0) { try { return detail::Cast_Helper::cast(bv, t_conversions); @@ -81,12 +81,12 @@ namespace chaiscript #pragma warning(disable : 4127) #endif - if (boost::is_polymorphic::type>::value) + if (boost::is_polymorphic::type>::value && t_conversions) { try { // We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it // either way, we are not responsible if it doesn't work - return detail::Cast_Helper::cast(t_conversions.boxed_dynamic_cast(bv), t_conversions); + return detail::Cast_Helper::cast(t_conversions->boxed_dynamic_cast(bv), t_conversions); } catch (const boost::bad_any_cast &) { throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type)); } diff --git a/include/chaiscript/dispatchkit/boxed_cast_helper.hpp b/include/chaiscript/dispatchkit/boxed_cast_helper.hpp index 8c9ed44..54bb90d 100644 --- a/include/chaiscript/dispatchkit/boxed_cast_helper.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast_helper.hpp @@ -31,7 +31,7 @@ namespace chaiscript { typedef typename boost::reference_wrapper::type > Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { if (ob.is_ref()) { @@ -73,7 +73,7 @@ namespace chaiscript { typedef const Result * Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { if (ob.is_ref()) { @@ -102,7 +102,7 @@ namespace chaiscript { typedef Result * Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { if (ob.is_ref()) { @@ -121,7 +121,7 @@ namespace chaiscript { typedef typename boost::reference_wrapper Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { if (ob.is_ref()) { @@ -140,7 +140,7 @@ namespace chaiscript { typedef typename boost::shared_ptr Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { return boost::any_cast >(ob.get()); } @@ -154,7 +154,7 @@ namespace chaiscript { typedef typename boost::shared_ptr Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { if (!ob.get_type_info().is_const()) { @@ -202,7 +202,7 @@ namespace chaiscript { typedef const Boxed_Value & Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { return ob; } @@ -263,7 +263,7 @@ namespace chaiscript { typedef typename Cast_Helper_Inner::Result_Type Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &t_conversions) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions) { return Cast_Helper_Inner::cast(ob, t_conversions); } diff --git a/include/chaiscript/dispatchkit/boxed_number.hpp b/include/chaiscript/dispatchkit/boxed_number.hpp index 07522cd..dccd460 100644 --- a/include/chaiscript/dispatchkit/boxed_number.hpp +++ b/include/chaiscript/dispatchkit/boxed_number.hpp @@ -820,7 +820,7 @@ namespace chaiscript { typedef Boxed_Number Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *) { return Boxed_Number(ob); } diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index c67f24a..7a42aef 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -395,7 +395,7 @@ namespace chaiscript template typename detail::Cast_Helper::Result_Type boxed_cast(const Boxed_Value &bv) const { - return chaiscript::boxed_cast(bv, m_conversions); + return chaiscript::boxed_cast(bv, &m_conversions); } /** diff --git a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp index 7de42bd..841136c 100644 --- a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp +++ b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp @@ -91,7 +91,7 @@ namespace chaiscript if (t_derived.is_const()) { boost::shared_ptr data - = boost::dynamic_pointer_cast(detail::Cast_Helper >::cast(t_derived, Dynamic_Cast_Conversions())); + = boost::dynamic_pointer_cast(detail::Cast_Helper >::cast(t_derived, 0)); if (!data) { throw std::bad_cast(); @@ -100,7 +100,7 @@ namespace chaiscript return Boxed_Value(data); } else { boost::shared_ptr data - = boost::dynamic_pointer_cast(detail::Cast_Helper >::cast(t_derived, Dynamic_Cast_Conversions())); + = boost::dynamic_pointer_cast(detail::Cast_Helper >::cast(t_derived, 0)); if (!data) { @@ -113,11 +113,11 @@ namespace chaiscript // Pull the reference out of the contained boxed value, which we know is the type we want if (t_derived.is_const()) { - const Derived &d = detail::Cast_Helper::cast(t_derived, Dynamic_Cast_Conversions()); + const Derived &d = detail::Cast_Helper::cast(t_derived, 0); const Base &data = dynamic_cast(d); return Boxed_Value(boost::cref(data)); } else { - Derived &d = detail::Cast_Helper::cast(t_derived, Dynamic_Cast_Conversions()); + Derived &d = detail::Cast_Helper::cast(t_derived, 0); Base &data = dynamic_cast(d); return Boxed_Value(boost::ref(data)); } diff --git a/include/chaiscript/dispatchkit/function_call.hpp b/include/chaiscript/dispatchkit/function_call.hpp index 3316c54..69282cb 100644 --- a/include/chaiscript/dispatchkit/function_call.hpp +++ b/include/chaiscript/dispatchkit/function_call.hpp @@ -32,7 +32,7 @@ namespace chaiscript */ template boost::function - functor(const std::vector &funcs, const Dynamic_Cast_Conversions &t_conversions) + functor(const std::vector &funcs, const Dynamic_Cast_Conversions *t_conversions) { FunctionType *p=0; return detail::build_function_caller_helper(p, funcs, t_conversions); @@ -53,7 +53,7 @@ namespace chaiscript */ template boost::function - functor(Const_Proxy_Function func, const Dynamic_Cast_Conversions &t_conversions) + functor(Const_Proxy_Function func, const Dynamic_Cast_Conversions *t_conversions) { std::vector funcs; funcs.push_back(func); @@ -66,7 +66,7 @@ namespace chaiscript */ template boost::function - functor(const Boxed_Value &bv, const Dynamic_Cast_Conversions &t_conversions) + functor(const Boxed_Value &bv, const Dynamic_Cast_Conversions *t_conversions) { return functor(boxed_cast(bv, t_conversions), t_conversions); } @@ -81,7 +81,7 @@ namespace chaiscript { typedef boost::function Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &t_conversions) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions) { if (ob.get_type_info().bare_equal(user_type())) { @@ -100,7 +100,7 @@ namespace chaiscript { typedef boost::function Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &t_conversions) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions) { if (ob.get_type_info().bare_equal(user_type())) { @@ -119,7 +119,7 @@ namespace chaiscript { typedef boost::function Result_Type; - static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions &t_conversions) + static Result_Type cast(const Boxed_Value &ob, const Dynamic_Cast_Conversions *t_conversions) { if (ob.get_type_info().bare_equal(user_type())) { diff --git a/include/chaiscript/dispatchkit/function_call_detail.hpp b/include/chaiscript/dispatchkit/function_call_detail.hpp index f62ea01..7d68915 100644 --- a/include/chaiscript/dispatchkit/function_call_detail.hpp +++ b/include/chaiscript/dispatchkit/function_call_detail.hpp @@ -81,9 +81,9 @@ namespace chaiscript { std::vector params; - BOOST_PP_REPEAT(n, addparam, ~) + BOOST_PP_REPEAT(n, addparam, ~); - return Function_Caller_Ret::call(funcs, params, t_conversions); + return Function_Caller_Ret::call(funcs, params, t_conversions); } /** @@ -92,7 +92,7 @@ namespace chaiscript template boost::function build_function_caller_helper(Ret (BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector &funcs, - const Dynamic_Cast_Conversions &t_conversions) + const Dynamic_Cast_Conversions *t_conversions) { if (funcs.size() == 1) { @@ -108,7 +108,7 @@ namespace chaiscript // we cannot make any other guesses or assumptions really, so continuing } - return boost::bind(&function_caller, funcs, t_conversions + return boost::bind(&function_caller, funcs, (t_conversions?*t_conversions:Dynamic_Cast_Conversions()) BOOST_PP_ENUM_TRAILING(n, curry, ~)); } } diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 2df8a23..272b7c1 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -574,10 +574,10 @@ namespace chaiscript const Boxed_Value &bv = params[0]; if (bv.is_const()) { - const Class *o = boxed_cast(bv, t_conversions); + const Class *o = boxed_cast(bv, &t_conversions); return detail::Handle_Return::type>::handle(o->*m_attr); } else { - Class *o = boxed_cast(bv, t_conversions); + Class *o = boxed_cast(bv, &t_conversions); return detail::Handle_Return::type>::handle(o->*m_attr); } } else { diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index 3c5f480..4494193 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -7,8 +7,8 @@ #include #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], t_conversions) -#define trycast(z,n,text) chaiscript::boxed_cast(params[n], t_conversions); +#define casthelper(z,n,text) BOOST_PP_COMMA_IF(n) chaiscript::boxed_cast< Param ## n >(params[n], &t_conversions) +#define trycast(z,n,text) chaiscript::boxed_cast(params[n], &t_conversions); #ifndef BOOST_PP_IS_ITERATING #ifndef CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_