Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions include/boost/python/args_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ namespace detail
BOOST_STATIC_CONSTANT(std::size_t, size = 0);
static keyword_range range() { return keyword_range(); }
};

namespace error
{
template <int keywords, int function_args>
struct more_keywords_than_function_arguments
{
typedef char too_many_keywords[keywords > function_args ? -1 : 1];
};
}
}

}} // namespace boost::python
Expand Down
3 changes: 2 additions & 1 deletion include/boost/python/cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# include <boost/type.hpp>
# include <boost/python/base_type_traits.hpp>
# include <boost/python/detail/convertible.hpp>
# include <boost/mpl/assert.hpp>

namespace boost { namespace python {

Expand Down Expand Up @@ -70,7 +71,7 @@ namespace detail
template <class T>
inline void assert_castable(boost::type<T>* = 0)
{
typedef char must_be_a_complete_type[sizeof(T)];
BOOST_MPL_ASSERT_MSG(sizeof(T) == sizeof(T), T_MUST_BE_A_COMPLETE_TYPE, (T));
}

template <class Source, class Target>
Expand Down
26 changes: 6 additions & 20 deletions include/boost/python/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# include <boost/mpl/for_each.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/not.hpp>
# include <boost/mpl/assert.hpp>

# include <boost/detail/workaround.hpp>

Expand Down Expand Up @@ -105,23 +106,6 @@ namespace detail

namespace error
{
//
// A meta-assertion mechanism which prints nice error messages and
// backtraces on lots of compilers. Usage:
//
// assertion<C>::failed
//
// where C is an MPL metafunction class
//

template <class C> struct assertion_failed { };
template <class C> struct assertion_ok { typedef C failed; };

template <class C>
struct assertion
: mpl::if_<C, assertion_ok<C>, assertion_failed<C> >::type
{};

//
// Checks for validity of arguments used to define virtual
// functions with default implementations.
Expand All @@ -140,9 +124,11 @@ namespace detail
// https://svn.boost.org/trac/boost/ticket/5803
//typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
typedef typename assertion<is_polymorphic<T> >::failed test1;
# endif
typedef typename assertion<is_member_function_pointer<Fn> >::failed test2;
BOOST_MPL_ASSERT_MSG(is_polymorphic<T>::value,
NOT_POLYMORPHIC, (T));
# endif
BOOST_MPL_ASSERT_MSG(is_member_function_pointer<Fn>::value,
NOT_MEMBER_FUNCTION_POINTER, (Fn));
not_a_derived_class_member<Default>(Fn());
}
};
Expand Down
7 changes: 4 additions & 3 deletions include/boost/python/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# include <boost/python/signature.hpp>
# include <boost/python/detail/scope.hpp>

# include <boost/mpl/assert.hpp>

namespace boost { namespace python {

namespace detail
Expand All @@ -35,9 +37,8 @@ namespace detail
char const* name, F const& fn, Helper const& helper)
{
// Must not try to use default implementations except with method definitions.
typedef typename error::multiple_functions_passed_to_def<
Helper::has_default_implementation
>::type assertion;
BOOST_MPL_ASSERT_MSG(!Helper::has_default_implementation,
MULTIPLE_FUNCTIONS_PASSED_TO_DEF, (Helper));

detail::scope_setattr_doc(
name, boost::python::make_function(
Expand Down
11 changes: 5 additions & 6 deletions include/boost/python/detail/defaults_gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/assert.hpp>
#include <cstddef>

namespace boost { namespace python {
Expand Down Expand Up @@ -211,18 +212,16 @@ namespace detail
: ::boost::python::detail::overloads_common<fstubs_name>( \
doc, keywords.range()) \
{ \
typedef typename ::boost::python::detail:: \
error::more_keywords_than_function_arguments< \
N,n_args>::too_many_keywords assertion; \
BOOST_MPL_ASSERT_MSG(N <= n_args, \
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); \
} \
template <std::size_t N> \
fstubs_name(::boost::python::detail::keywords<N> const& keywords, char const* doc = 0) \
: ::boost::python::detail::overloads_common<fstubs_name>( \
doc, keywords.range()) \
{ \
typedef typename ::boost::python::detail:: \
error::more_keywords_than_function_arguments< \
N,n_args>::too_many_keywords assertion; \
BOOST_MPL_ASSERT_MSG(N <= n_args, \
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); \
}

# if defined(BOOST_NO_VOID_RETURNS)
Expand Down
21 changes: 5 additions & 16 deletions include/boost/python/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <boost/mpl/prior.hpp>
#include <boost/mpl/joint_view.hpp>
#include <boost/mpl/back.hpp>

#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

#include <boost/preprocessor/enum_params_with_a_default.hpp>
Expand Down Expand Up @@ -63,15 +63,6 @@ struct optional; // forward declaration

namespace detail
{
namespace error
{
template <int keywords, int init_args>
struct more_keywords_than_init_arguments
{
typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1];
};
}

// is_optional<T>::value
//
// This metaprogram checks if T is an optional
Expand Down Expand Up @@ -222,18 +213,16 @@ class init : public init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> >
init(char const* doc_, detail::keywords<N> const& kw)
: base(doc_, kw.range())
{
typedef typename detail::error::more_keywords_than_init_arguments<
N, n_arguments::value + 1
>::too_many_keywords assertion;
BOOST_MPL_ASSERT_MSG(N <= n_arguments::value + 1,
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ());
}

template <std::size_t N>
init(detail::keywords<N> const& kw, char const* doc_ = 0)
: base(doc_, kw.range())
{
typedef typename detail::error::more_keywords_than_init_arguments<
N, n_arguments::value + 1
>::too_many_keywords assertion;
BOOST_MPL_ASSERT_MSG(N <= n_arguments::value + 1,
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ());
}

template <class CallPoliciesT>
Expand Down
5 changes: 2 additions & 3 deletions include/boost/python/make_constructor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ namespace detail
{
enum { arity = mpl::size<Sig>::value - 1 };

typedef typename detail::error::more_keywords_than_function_arguments<
NumKeywords::value, arity
>::too_many_keywords assertion;

BOOST_MPL_ASSERT_MSG(NumKeywords::value <= arity,
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ());
typedef typename outer_constructor_signature<Sig>::type outer_signature;

typedef constructor_policy<CallPolicies> inner_policy;
Expand Down
5 changes: 2 additions & 3 deletions include/boost/python/make_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ namespace detail
{
enum { arity = mpl::size<Sig>::value - 1 };

typedef typename detail::error::more_keywords_than_function_arguments<
NumKeywords::value, arity
>::too_many_keywords assertion;
BOOST_MPL_ASSERT_MSG(NumKeywords::value <= arity,
MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ());

return objects::function_object(
detail::caller<F,CallPolicies,Sig>(f, p)
Expand Down
10 changes: 3 additions & 7 deletions include/boost/python/object/pickle_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# define BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP

# include <boost/python/detail/prefix.hpp>
# include <boost/mpl/assert.hpp>

namespace boost { namespace python {

Expand All @@ -21,10 +22,6 @@ BOOST_PYTHON_DECL object const& make_instance_reduce_function();
struct pickle_suite;

namespace error_messages {

template <class T>
struct missing_pickle_suite_function_or_incorrect_signature {};

inline void must_be_derived_from_pickle_suite(pickle_suite const&) {}
}

Expand Down Expand Up @@ -105,9 +102,8 @@ namespace detail {
Class_&,
...)
{
typedef typename
error_messages::missing_pickle_suite_function_or_incorrect_signature<
Class_>::error_type error_type;
BOOST_MPL_ASSERT_MSG
(false, MISSING_PICKLE_SUITE_FUNCTION_OR_INCORRECT_SIGNATURE, ());
}
};

Expand Down