diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index ac453c58..84ac59db 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -211,14 +211,16 @@ class class_ : public objects::class_base typedef class_ self; BOOST_STATIC_CONSTANT(bool, is_copyable = (!detail::has_noncopyable::value)); + // held_type - either T, a class derived from T or a smart pointer + // to a (class derived from) T. typedef typename detail::select_held_type< X1, typename detail::select_held_type< X2, typename detail::select_held_type< X3 >::type>::type>::type held_type; - typedef objects::select_holder holder_selector; - + typedef objects::select_holder select_holder; + private: // types typedef typename detail::select_bases const& i) : base(name, id_vector::size, id_vector().ids) { - this->register_(); + this->register_holder(); this->def(i); - this->set_instance_size(holder_selector::additional_size()); } // Construct with class name, docstring and init<> function @@ -274,9 +275,8 @@ class class_ : public objects::class_base inline class_(char const* name, char const* doc, init_base const& i) : base(name, id_vector::size, id_vector().ids, doc) { - this->register_(); + this->register_holder(); this->def(i); - this->set_instance_size(holder_selector::additional_size()); } public: // member functions @@ -475,7 +475,8 @@ class class_ : public objects::class_base } inline void register_() const; - + inline void register_holder(); + // // These two overloads discriminate between def() as applied to a // generic visitor and everything else. @@ -584,14 +585,22 @@ inline void class_::register_() const { objects::register_class_from_python(); - typedef BOOST_DEDUCED_TYPENAME holder_selector::type select_holder; typedef BOOST_DEDUCED_TYPENAME select_holder::held_type held_t; - detail::register_wrapper_class(); - + detail::register_class_to_python( mpl::bool_() - , BOOST_DEDUCED_TYPENAME holder_selector::type() + , select_holder() + ); +} + +template +inline void class_::register_holder() +{ + this->register_(); + typedef typename select_holder::type holder; + this->set_instance_size( + objects::additional_instance_size::value ); } @@ -599,9 +608,8 @@ template inline class_::class_(char const* name, char const* doc) : base(name, id_vector::size, id_vector().ids, doc) { - this->register_(); - this->set_instance_size(holder_selector::additional_size()); - holder_selector::type::assert_default_constructible(); + this->register_holder(); + select_holder::assert_default_constructible(); this->def(init<>()); } @@ -633,18 +641,18 @@ namespace detail {}; - template - struct select_held_type - : mpl::if_< - mpl::or_< - specifies_bases - , is_same - > - , Prev - , T - > - { - }; + template + struct select_held_type + : mpl::if_< + mpl::or_< + specifies_bases + , is_same + > + , Prev + , T + > + { + }; } }} // namespace boost::python