From 0f43a2fe9bd01b818db9519c754476572f3f5ae1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 29 Nov 2000 13:42:45 +0000 Subject: [PATCH] changed name of extension_class_coerce to standard_coerce. [SVN r8357] --- .../boost/python/detail/extension_class.hpp | 4 +-- include/boost/python/operators.hpp | 19 +++++++----- src/extension_class.cpp | 29 ++++++++----------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/include/boost/python/detail/extension_class.hpp b/include/boost/python/detail/extension_class.hpp index 20d48796..0e2e3427 100644 --- a/include/boost/python/detail/extension_class.hpp +++ b/include/boost/python/detail/extension_class.hpp @@ -721,8 +721,6 @@ class extension_instance : public instance // Template function implementations // -tuple extension_class_coerce(ref l, ref r); - template extension_class::extension_class() : extension_class_base(typeid(T).name()) @@ -743,7 +741,7 @@ void extension_class::def_standard_coerce() ref coerce_fct = dict().get_item(string("__coerce__")); if(coerce_fct.get() == 0) // not yet defined - this->def(&extension_class_coerce, "__coerce__"); + this->def(&standard_coerce, "__coerce__"); } template diff --git a/include/boost/python/operators.hpp b/include/boost/python/operators.hpp index e76943e8..40400f47 100644 --- a/include/boost/python/operators.hpp +++ b/include/boost/python/operators.hpp @@ -1,17 +1,22 @@ #ifndef OPERATORS_UK112000_H_ #define OPERATORS_UK112000_H_ -#include +# include +# include + // When STLport is used with native streams, _STL::ostringstream().str() is not -// _STL::string, but std::string. -#if defined(__SGI_STL_PORT) ? __SGI_STL_OWN_IOSTREAMS : !defined(__GNUC__) -# include -#else -# include -#endif +// _STL::string, but std::string. This confuses to_python(), so we'll use +// strstream instead. Also, GCC 2.95.2 doesn't have sstream. +# if defined(__SGI_STL_PORT) ? __SGI_STL_OWN_IOSTREAMS : !defined(__GNUC__) || __GNUC__ > 2 +# include +# else +# include +# endif namespace boost { namespace python { +tuple standard_coerce(ref l, ref r); + namespace detail { // helper class for automatic operand type detection diff --git a/src/extension_class.cpp b/src/extension_class.cpp index cde3d836..c15e538b 100644 --- a/src/extension_class.cpp +++ b/src/extension_class.cpp @@ -46,24 +46,19 @@ BOOST_PYTHON_END_CONVERSION_NAMESPACE namespace boost { namespace python { -namespace detail { +tuple standard_coerce(ref l, ref r) +{ + // Introduced sequence points for exception-safety. + ref first(detail::operator_dispatcher::create(l, l)); + + ref second(r->ob_type == &detail::operator_dispatcher::type_obj + ? r + : ref(detail::operator_dispatcher::create(r, ref()))); - tuple extension_class_coerce(ref l, ref r) - { - // Introduced sequence points for exception-safety. - ref first(operator_dispatcher::create(l, l)); - ref second; - - if(r->ob_type == &operator_dispatcher::type_obj) - { - second = r; - } - else - { - second = ref(operator_dispatcher::create(r, ref())); - } - return boost::python::tuple(first, second); - } + return tuple(first, second); +} + +namespace detail { enum { unwrap_exception_code = -1000 };