Skip to content

Commit

Permalink
Try to be compatible with older Boost versions (#7).
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Aug 14, 2013
1 parent 8a9dffb commit 296a357
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(CMAKE_MODULE_PATH
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.51.0 REQUIRED)
find_package(Boost 1.40.0 REQUIRED) # Better use at least 1.51.
find_package(Lua52 REQUIRED)

if (BUILD_SHARED_LIBS)
Expand Down
6 changes: 6 additions & 0 deletions doc/build-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ to Lua and boost in there as well.
This define will disable all asserts and should be defined in a release
build.

``LUABIND_USE_NOEXCEPT``
If you use Boost <= 1.46 but your compiler is C++11 compliant and marks
destructors as noexcept by default, you need to define LUABIND_USE_NOEXCEPT.
Failing to do so will cause std::terminate() being called if a destructor
throws (e.g. the destructor of the proxy returned by ``call_function`` or
``object::operator()``).

CMake options
~~~~~~~~~~~~~
Expand Down
29 changes: 29 additions & 0 deletions luabind/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,35 @@ namespace std
# define LUABIND_API
#endif

// C++11 features //

#if ( defined(BOOST_NO_CXX11_SCOPED_ENUMS) \
|| defined(BOOST_NO_SCOPED_ENUMS) \
|| defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) \
|| defined(BOOST_NO_0X_HDR_TYPE_TRAITS))
# define LUABIND_NO_SCOPED_ENUM
#endif

#if ( defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \
|| defined(BOOST_NO_RVALUE_REFERENCES))
# define LUABIND_NO_RVALUE_REFERENCES
#endif

// If you use Boost <= 1.46 but your compiler is C++11 compliant and marks
// destructors as noexcept by default, you need to define LUABIND_USE_NOEXCEPT.
#if !defined(BOOST_NO_NOEXCEPT) && !defined(BOOST_NO_CXX11_NOEXCEPT)
# define LUABIND_USE_NOEXCEPT
#endif
#ifndef LUABIND_MAY_THROW
# ifdef BOOST_NOEXCEPT_IF
# define LUABIND_MAY_THROW BOOST_NOEXCEPT_IF(false)
# elif defined(LUABIND_USE_NOEXCEPT)
# define LUABIND_MAY_THROW noexcept(false)
# else
# define LUABIND_MAY_THROW
# endif
#endif

namespace luabind {

LUABIND_API void disable_super_deprecation();
Expand Down
4 changes: 2 additions & 2 deletions luabind/detail/call_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace luabind
rhs.m_called = true;
}

~proxy_function_caller() BOOST_NOEXCEPT_IF(false)
~proxy_function_caller() LUABIND_MAY_THROW
{
if (m_called) return;

Expand Down Expand Up @@ -242,7 +242,7 @@ namespace luabind
rhs.m_called = true;
}

~proxy_function_void_caller() BOOST_NOEXCEPT_IF(false)
~proxy_function_void_caller() LUABIND_MAY_THROW
{
if (m_called) return;

Expand Down
2 changes: 1 addition & 1 deletion luabind/detail/decorate_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace luabind { namespace detail
template<class T>
by_const_reference<T> decorated_type<const T&>::t;

#ifdef BOOST_HAS_RVALUE_REFS
#ifndef LUABIND_NO_RVALUE_REFERENCES
template<class T>
struct decorated_type<T&&>
{
Expand Down
10 changes: 3 additions & 7 deletions luabind/detail/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
#include <string>
#include <typeinfo>

#if ( defined(BOOST_NO_CXX11_SCOPED_ENUMS) \
|| defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS))
# define LUABIND_NO_SCOPED_ENUM
#endif
#ifndef LUABIND_NO_SCOPED_ENUM
# include <type_traits>
#endif
Expand Down Expand Up @@ -677,7 +673,7 @@ lua_Number as_lua_number(T v)
return static_cast<lua_Number>(v);
}

#ifdef BOOST_HAS_RVALUE_REFS
#ifndef LUABIND_NO_RVALUE_REFERENCES

# define LUABIND_NUMBER_CONVERTER(type, kind) \
template <> \
Expand Down Expand Up @@ -806,7 +802,7 @@ struct default_converter<bool const&>
: default_converter<bool>
{};

#ifdef BOOST_HAS_RVALUE_REFS
#ifndef LUABIND_NO_RVALUE_REFERENCES
template <>
struct default_converter<bool&&>
: default_converter<bool>
Expand Down Expand Up @@ -843,7 +839,7 @@ struct default_converter<std::string const&>
: default_converter<std::string>
{};

#ifdef BOOST_HAS_RVALUE_REFS
#ifndef LUABIND_NO_RVALUE_REFERENCES
template <>
struct default_converter<std::string&&>
: default_converter<std::string>
Expand Down
4 changes: 2 additions & 2 deletions luabind/function_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ namespace luabind {
# define N BOOST_PP_ITERATION()

# define TMPL_PARAMS BOOST_PP_ENUM_PARAMS(N, typename A)
# ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
# ifndef LUABIND_NO_RVALUE_REFERENCES
# define TYPED_ARGS BOOST_PP_ENUM_BINARY_PARAMS(N, A, && a)
# else
# define TYPED_ARGS BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a)
# endif
# ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
# ifndef LUABIND_NO_RVALUE_REFERENCES
# define PRINT_FORWARD_ARG(z, n, _) std::forward<BOOST_PP_CAT(A, n)>(BOOST_PP_CAT(a, n))
# define TRAILING_ARGS BOOST_PP_ENUM_TRAILING(N, PRINT_FORWARD_ARG, ~)
# else
Expand Down
2 changes: 1 addition & 1 deletion luabind/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ namespace adl
other.value_wrapper = 0;
}

~call_proxy() BOOST_NOEXCEPT_IF(false)
~call_proxy() LUABIND_MAY_THROW
{
if (value_wrapper)
call(static_cast<detail::null_type*>(0));
Expand Down
1 change: 1 addition & 0 deletions luabind/std_shared_ptr_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <boost/config.hpp>
#if (defined(BOOST_NO_CXX11_SMART_PTR) \
&& !defined(BOOST_HAS_TR1_SHARED_PTR) \
&& (!defined(BOOST_MSVC) || BOOST_MSVC < 1600))
# define LUABIND_NO_STD_SHARED_PTR
#else
Expand Down

0 comments on commit 296a357

Please sign in to comment.