From db348992252917a5dd3dd17d570b71abd2b67423 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 18 Apr 2015 20:51:45 -0600 Subject: [PATCH] Address msvc issues with #167 #165 The best we can get it down to is 2 moves in MSVC, it does not elide the moves/copies as well as GCC and Clang do It's not possible for us to support registering of array types in MSVC12, but we can in MSVC14 with the latest release of the compiler. --- include/chaiscript/dispatchkit/proxy_functions.hpp | 11 ++++++++++- src/test_module.cpp | 4 ++++ unittests/object_copy_count_test.cpp | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/chaiscript/dispatchkit/proxy_functions.hpp b/include/chaiscript/dispatchkit/proxy_functions.hpp index 1f71ad5..db853a0 100644 --- a/include/chaiscript/dispatchkit/proxy_functions.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions.hpp @@ -490,8 +490,17 @@ namespace chaiscript std::vector types = t_f->get_param_types(); assert(types.size() == t_args.size() + 1); +#ifdef CHAISCRIPT_MSVC_12 +#pragma warning(push) +#pragma warning(disable : 6011) +#endif + // this analysis warning is invalid in MSVC12 and doesn't exist in MSVC14 std::vector retval{types[0]}; - for (size_t i = 0; i < types.size()-1; ++i) +#ifdef CHAISCRIPT_MSVC_12 +#pragma warning(pop) +#endif + + for (size_t i = 0; i < types.size() - 1; ++i) { if (t_args[i].get_type_info() == chaiscript::detail::Get_Type_Info::get()) { diff --git a/src/test_module.cpp b/src/test_module.cpp index 5609775..293562c 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -162,12 +162,16 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo m->add(chaiscript::fun(&TestBaseType::const_val), "const_val"); m->add(chaiscript::fun(&TestBaseType::base_only_func), "base_only_func"); +#ifndef CHAISCRIPT_MSVC_12 + // we cannot support these in MSVC_12 because of a bug in the implementation of + // std::reference_wrapper // Array types m->add(chaiscript::fun(&TestBaseType::mdarray), "mdarray"); m->add(chaiscript::bootstrap::array("IntArray_2_3_5")); m->add(chaiscript::bootstrap::array("IntArray_3_5")); m->add(chaiscript::bootstrap::array("IntArray_5")); // end array types +#endif m->add(chaiscript::fun(&get_new_int), "get_new_int"); diff --git a/unittests/object_copy_count_test.cpp b/unittests/object_copy_count_test.cpp index 8b75d3e..41192c1 100644 --- a/unittests/object_copy_count_test.cpp +++ b/unittests/object_copy_count_test.cpp @@ -71,10 +71,19 @@ int main() chai.eval(" { auto i = create(); } "); +#ifdef CHAISCRIPT_MSVC + if (Test::destructcount() == 3 && Test::copycount() == 0 && Test::movecount() == 2 && Test::constructcount() == 1) + { + return EXIT_SUCCESS; + } else { + return EXIT_FAILURE; + } +#else if (Test::destructcount() == 2 && Test::copycount() == 0 && Test::movecount() == 1 && Test::constructcount() == 1) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } +#endif }