From f03189c16860cfb8e6d80add3083c14aa12c4db0 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 3 Aug 2010 17:21:51 +0000 Subject: [PATCH] Quiet down some irrelevant warnings in MSVC2008, make dynamic_cast conversions work in msvc across modules by applying a kludge that will probably not work long term, but does work now. This may mean that chaiscript needs to move to being a library? --- include/chaiscript/dispatchkit/boxed_cast.hpp | 14 ++++++++++++++ .../dispatchkit/dynamic_cast_conversion.hpp | 11 +++++++++-- include/chaiscript/dispatchkit/proxy_functions.hpp | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/chaiscript/dispatchkit/boxed_cast.hpp b/include/chaiscript/dispatchkit/boxed_cast.hpp index ee7f739..bed5a51 100644 --- a/include/chaiscript/dispatchkit/boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast.hpp @@ -36,6 +36,14 @@ namespace chaiscript try { return detail::Cast_Helper::cast(bv); } catch (const boost::bad_any_cast &) { + +#ifdef BOOST_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 (boost::is_polymorphic::type>::value) { try { @@ -50,6 +58,12 @@ namespace chaiscript // attempted dynamic_cast throw bad_boxed_cast(bv.get_type_info(), typeid(Type)); } + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + + } } diff --git a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp index 0488147..5da9839 100644 --- a/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp +++ b/include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp @@ -120,7 +120,7 @@ namespace chaiscript class Dynamic_Conversions { public: - static Dynamic_Conversions &get() + static inline Dynamic_Conversions &get() { static Dynamic_Conversions obj; return obj; @@ -129,8 +129,15 @@ namespace chaiscript template static boost::shared_ptr create() { - return boost::shared_ptr(new Dynamic_Conversion_Impl()); + boost::shared_ptr conversion(new Dynamic_Conversion_Impl()); + /// \todo this is a hack and a kludge. The idea is to make sure that + /// the conversion is registered both in the module's notion of the static conversion object + /// and in the global notion of the static conversion object + /// someday this will almost certainly have to change. Maybe it is time for ChaiScript + /// to become a library? + Dynamic_Conversions::get().add_conversion(conversion); + return conversion; } template diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index a60ab89..bea6c67 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -20,7 +20,7 @@ namespace chaiscript { - class Boxed_POD_Value; + struct Boxed_POD_Value; /** * Helper for building a list of parameters for calling a Proxy_Function