Skip to content

Commit

Permalink
Fix warnings and errors on VisualStudio 2013
Browse files Browse the repository at this point in the history
Interestingly, VS2013 with Boost 1.55 exhibited the issues complained
about in issue #92, so I was able to provide an appropriate fix. It would
appear to be bugs in both compilers, which seems very odd.
  • Loading branch information
lefticus committed Feb 22, 2014
1 parent 04131d2 commit af44da9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/chaiscript/dispatchkit/bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ namespace chaiscript
boost::shared_ptr<const dispatch::Dynamic_Proxy_Function> pf = boost::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf)
{
return pf->get_guard();
if (pf->get_guard()) {
return true;
} else {
return false;
}
} else {
return false;
}
Expand Down
24 changes: 24 additions & 0 deletions include/chaiscript/dispatchkit/proxy_functions_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,20 @@ namespace chaiscript
* if any unboxing fails the execution of the function fails and
* the bad_boxed_cast is passed up to the caller.
*/
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4100)
#endif

#ifdef __llvm__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif

template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
Ret call_func(const boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))> &f,
const std::vector<Boxed_Value> &params, const Dynamic_Cast_Conversions & BOOST_PP_IF(n, t_conversions, BOOST_PP_EMPTY))

#ifdef __llvm__
#pragma clang diagnostic pop
#endif
Expand All @@ -105,19 +112,31 @@ namespace chaiscript
}
}

#ifdef BOOST_MSVC
#pragma warning(pop)
#endif

/**
* 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
*/

#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable : 4100)
#endif

#ifdef __llvm__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif

template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param)>
bool compare_types_cast(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param)),
const std::vector<Boxed_Value> & BOOST_PP_IF(n, params, BOOST_PP_EMPTY), const Dynamic_Cast_Conversions &t_conversions)


#ifdef __llvm__
#pragma clang diagnostic pop
#endif
Expand All @@ -131,6 +150,11 @@ namespace chaiscript

return true;
}

#ifdef BOOST_MSVC
#pragma warning(pop)
#endif

}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void *cast_module_symbol(std::string (*t_path)())

std::string default_search_path()
{
#ifdef CHAISCRIPT_WINDOWS // force no unicode
#ifdef BOOST_WINDOWS // force no unicode
CHAR path[4096];
int size = GetModuleFileNameA(0, path, sizeof(path)-1);

Expand All @@ -60,8 +60,8 @@ std::string default_search_path()
return "";
}


#else

std::string exepath;

std::vector<char> buf(2048);
Expand Down
7 changes: 6 additions & 1 deletion src/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
= boost::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf)
{
return pf->get_parse_tree();
if (pf->get_parse_tree())
{
return true;
} else {
return false;
}
} else {
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions src/test_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class TestBaseType

int val;
const int const_val;

private:
TestBaseType &operator=(const TestBaseType &);
};

enum TestEnum
Expand All @@ -32,6 +35,9 @@ class TestDerivedType : public TestBaseType
public:
virtual ~TestDerivedType() {}
virtual int func() { return 1; }

private:
TestDerivedType &operator=(const TestDerivedType &);
};

std::string hello_world()
Expand Down

0 comments on commit af44da9

Please sign in to comment.