From a75ee50533e173dcc92a9fd3eba2518df37b7dfd Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Sat, 21 Sep 2002 02:50:29 +0000 Subject: [PATCH] Removed def_init(...) from class_ [SVN r15468] --- include/boost/python/class.hpp | 43 ++++------------------------------ include/boost/python/init.hpp | 10 +++++++- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index 76646b41..59c1f30c 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -102,7 +102,7 @@ template < > class class_ : public objects::class_base { - private: // types + public: // types typedef objects::class_base base; typedef class_ self; @@ -116,12 +116,15 @@ class class_ : public objects::class_base typedef objects::select_holder holder_selector; + private: + typedef typename detail::select_bases::type >::type >::type bases; + // A helper class which will contain an array of id objects to be // passed to the base class constructor struct id_vector @@ -223,42 +226,6 @@ class class_ : public objects::class_base return this->def(op.name(), &op_t::template apply::execute); } - // Define the constructor with the given Args, which should be an - // MPL sequence of types. - template - self& def_init(Args const&) - { - return this->def("__init__", - python::make_constructor( - // Using runtime type selection works around a CWPro7 bug. - holder_selector::execute((held_type*)0).get() - ) - ); - } - - template - self& def_init(Args const&, CallPolicyOrDoc const& policy_or_doc, char const* doc = 0) - { - typedef detail::def_helper helper; - - return this->def( - "__init__", - python::make_constructor( - helper::get_policy(policy_or_doc) - // Using runtime type selection works around a CWPro7 bug. - , holder_selector::execute((held_type*)0).get() - ) - , helper::get_doc(policy_or_doc, doc) - ); - } - - // Define the default constructor. - self& def_init() - { - this->def_init(mpl::list0<>::type()); - return *this; - } - // // Data member access // @@ -400,7 +367,7 @@ inline class_::class_(char const* name, char const* doc) { this->register_(); detail::force_instantiate(sizeof(detail::assert_default_constructible(T()))); - this->def_init(); + this->def(init<>()); this->set_instance_size(holder_selector::additional_size()); } diff --git a/include/boost/python/init.hpp b/include/boost/python/init.hpp index 75c5da84..2efc1094 100644 --- a/include/boost/python/init.hpp +++ b/include/boost/python/init.hpp @@ -269,7 +269,15 @@ namespace detail , mpl::push_front<> >::type args; - cl.def_init(args(), policies, doc); + cl.def( + "__init__", + python::make_constructor( + policies + // Using runtime type selection works around a CWPro7 bug. + , ClassT::holder_selector::execute((ClassT::held_type*)0).get() + ) + , doc + ); } ///////////////////////////////////////////////////////////////////////////////