1111// 23 Jan 2001 - Another stupid typo fix by Ralf W. Grosse-Kunstleve (David Abrahams)
1212// 20 Jan 2001 - Added a fix from Ralf W. Grosse-Kunstleve (David Abrahams)
1313#ifndef OPERATORS_UK112000_H_
14- #define OPERATORS_UK112000_H_
14+ # define OPERATORS_UK112000_H_
15+ # ifdef BOOST_PYTHON_V2
1516
16- # include < boost/python/reference.hpp>
17- # include < boost/python/detail/functions.hpp>
17+ # include < boost/python/operators2.hpp>
18+
19+ # else
20+
21+ # include < boost/python/reference.hpp>
22+ # include < boost/python/detail/functions.hpp>
1823
1924// When STLport is used with native streams, _STL::ostringstream().str() is not
2025// _STL::string, but std::string. This confuses to_python(), so we'll use
2126// strstream instead. Also, GCC 2.95.2 doesn't have sstream.
22- # if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
23- # define BOOST_PYTHON_USE_SSTREAM
24- # endif
27+ # if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2)
28+ # define BOOST_PYTHON_USE_SSTREAM
29+ # endif
2530
26- #if defined(BOOST_PYTHON_USE_SSTREAM)
27- # include < sstream>
28- # else
29- # include < strstream>
30- # endif
31+ # if defined(BOOST_PYTHON_USE_SSTREAM)
32+ # include < sstream>
33+ # else
34+ # include < strstream>
35+ # endif
3136
3237namespace boost { namespace python {
3338
@@ -234,7 +239,7 @@ namespace detail
234239// Specializations for most operators follow a standard pattern: execute the expression
235240// that uses the operator in question. This standard pattern is realized by the following
236241// macros so that the actual specialization can be done by just calling a macro.
237- #define PY_DEFINE_BINARY_OPERATORS (id, oper ) \
242+ # define PY_DEFINE_BINARY_OPERATORS (id, oper ) \
238243 template <> \
239244 struct define_operator <op_##id> \
240245 { \
@@ -275,7 +280,7 @@ namespace detail
275280 static const char * rname () { return " __r" #id " __" ; } \
276281 }
277282
278- #define PY_DEFINE_UNARY_OPERATORS (id, oper ) \
283+ # define PY_DEFINE_UNARY_OPERATORS (id, oper ) \
279284 template <> \
280285 struct define_operator <op_##id> \
281286 { \
@@ -322,8 +327,8 @@ namespace detail
322327 PY_DEFINE_UNARY_OPERATORS (long , PyLong_FromLong);
323328 PY_DEFINE_UNARY_OPERATORS (float , double );
324329
325- #undef PY_DEFINE_BINARY_OPERATORS
326- #undef PY_DEFINE_UNARY_OPERATORS
330+ # undef PY_DEFINE_BINARY_OPERATORS
331+ # undef PY_DEFINE_UNARY_OPERATORS
327332
328333// Some operators need special treatment, e.g. because there is no corresponding
329334// expression in C++. These are specialized manually.
@@ -496,15 +501,15 @@ namespace detail
496501 static const char * rname () { return " __rcmp__" ; }
497502 };
498503
499- # ifndef BOOST_PYTHON_USE_SSTREAM
504+ # ifndef BOOST_PYTHON_USE_SSTREAM
500505 class unfreezer {
501506 public:
502507 unfreezer (std::ostrstream& s) : m_stream(s) {}
503508 ~unfreezer () { m_stream.freeze (false ); }
504509 private:
505510 std::ostrstream& m_stream;
506511 };
507- # endif
512+ # endif
508513
509514// str(): Manual specialization needed because the string conversion does not follow
510515// the standard pattern relized by the macros.
@@ -520,16 +525,16 @@ namespace detail
520525
521526// When STLport is used with native streams, _STL::ostringstream().str() is not
522527// _STL::string, but std::string.
523- # ifdef BOOST_PYTHON_USE_SSTREAM
528+ # ifdef BOOST_PYTHON_USE_SSTREAM
524529 std::ostringstream s;
525530 s << BOOST_PYTHON_CONVERSION::from_python (args[0 ].get (), boost::python::type<operand>());
526531 return BOOST_PYTHON_CONVERSION::to_python (s.str ());
527- # else
532+ # else
528533 std::ostrstream s;
529534 s << BOOST_PYTHON_CONVERSION::from_python (args[0 ].get (), boost::python::type<operand>()) << char ();
530535 auto unfreezer unfreeze (s);
531536 return BOOST_PYTHON_CONVERSION::to_python (const_cast <char const *>(s.str ()));
532- # endif
537+ # endif
533538 }
534539
535540 const char * description () const
@@ -545,5 +550,6 @@ namespace detail
545550
546551}} // namespace boost::python
547552
548- # undef BOOST_PYTHON_USE_SSTREAM
553+ # undef BOOST_PYTHON_USE_SSTREAM
554+ # endif
549555#endif /* OPERATORS_UK112000_H_ */
0 commit comments