From 12770b03e8e503dce5bcf56021d670235972dfe5 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 19 Oct 2005 18:17:13 +0000 Subject: [PATCH] Add the ability to easily use new-style polymorphism wrappers with smart pointer held_type. [SVN r31392] --- .../boost/python/object/class_metadata.hpp | 12 +++- test/Jamfile | 12 ++-- test/polymorphism2.cpp | 20 ++++-- test/polymorphism2.py | 19 ++++-- test/polymorphism2_auto_ptr.cpp | 6 ++ test/polymorphism2_auto_ptr.py | 5 ++ test/wrapper_held_type.cpp | 68 +++++++++++++++++++ test/wrapper_held_type.py | 34 ++++++++++ 8 files changed, 160 insertions(+), 16 deletions(-) create mode 100755 test/polymorphism2_auto_ptr.cpp create mode 100644 test/polymorphism2_auto_ptr.py create mode 100755 test/wrapper_held_type.cpp create mode 100644 test/wrapper_held_type.py diff --git a/include/boost/python/object/class_metadata.hpp b/include/boost/python/object/class_metadata.hpp index c29787fb..212abfe4 100755 --- a/include/boost/python/object/class_metadata.hpp +++ b/include/boost/python/object/class_metadata.hpp @@ -30,6 +30,10 @@ # include # include # include + +# include +# include + # include # include @@ -49,6 +53,8 @@ struct register_base_of template inline void operator()(Base*) const { + BOOST_MPL_ASSERT_NOT((is_same)); + // Register the Base class register_dynamic_id(); @@ -58,7 +64,7 @@ struct register_base_of // Register the down-cast, if appropriate. this->register_downcast((Base*)0, is_polymorphic()); } - + private: static inline void register_downcast(void*, mpl::false_) {} @@ -186,7 +192,7 @@ struct class_metadata , mpl::if_< use_value_holder , value_holder - , pointer_holder + , pointer_holder > >::type holder; @@ -253,6 +259,8 @@ struct class_metadata // inline static void maybe_register_callback_class(void*, mpl::false_) {} + inline static void maybe_register_callback_class(wrapped*, mpl::true_) {} + template inline static void maybe_register_callback_class(T2*, mpl::true_) { diff --git a/test/Jamfile b/test/Jamfile index 98e6ca89..a3cb8f93 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -101,6 +101,10 @@ bpl-test crossmod_exception [ bpl-test andreas_beyer ] [ bpl-test polymorphism ] [ bpl-test polymorphism2 ] + +[ bpl-test wrapper_held_type ] +[ bpl-test polymorphism2_auto_ptr ] + [ bpl-test auto_ptr ] [ bpl-test minimal ] [ bpl-test args ] @@ -115,7 +119,7 @@ bpl-test crossmod_exception [ bpl-test keywords : keywords.cpp keywords_test.py ] [ extension builtin_converters : test_builtin_converters.cpp