Skip to content

Commit 16c391c

Browse files
committed
enable operators.hpp for v2
eliminate dependence on full boost/function.hpp [SVN r14071]
1 parent 92aae63 commit 16c391c

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

include/boost/python/errors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# include <boost/python/detail/config.hpp>
1313
# include <boost/python/detail/wrap_python.hpp>
14-
# include <boost/function.hpp>
14+
# include <boost/function/function0.hpp>
1515

1616
namespace boost { namespace python {
1717

include/boost/python/make_function.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# include <boost/python/detail/caller.hpp>
1212
# include <boost/python/detail/arg_tuple_size.hpp>
1313
# include <boost/mpl/size.hpp>
14-
# include <boost/function.hpp>
1514
# include <boost/bind.hpp>
1615
# include <boost/python/default_call_policies.hpp>
1716

include/boost/python/object/function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# include <boost/python/detail/wrap_python.hpp>
1010
# include <boost/python/detail/config.hpp>
1111
# include <boost/python/reference.hpp>
12-
# include <boost/function.hpp>
12+
# include <boost/function/function2.hpp>
1313

1414
namespace boost { namespace python { namespace objects {
1515

include/boost/python/operators.hpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,28 @@
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

3237
namespace 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_ */

test/operators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// "as is" without express or implied warranty, and with no claim as
55
// to its suitability for any purpose.
66
#include <string>
7-
#include <boost/python/operators2.hpp>
7+
#include <boost/python/operators.hpp>
88
#include <boost/python/class.hpp>
99
#include <boost/python/module.hpp>
1010
#include "test_class.hpp"

0 commit comments

Comments
 (0)