Skip to content

Commit d8790a3

Browse files
author
Ralf W. Grosse-Kunstleve
committed
boost::python::len() moved to object.hpp
[SVN r32299]
1 parent 3b05818 commit d8790a3

8 files changed

Lines changed: 44 additions & 16 deletions

File tree

doc/v2/object.html

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,16 @@ <h2>Contents</h2>
183183
<dt><a href="#binary-spec">binary operations</a></dt>
184184

185185
<dt><a href="#assignment-spec">assignment operations</a></dt>
186+
186187
</dl>
187188

188189
<dl class="page-index">
189190
<dt><a href="#object_operators-spec">operators</a></dt>
190191
</dl>
192+
193+
<dl class="page-index">
194+
<dt><a href="#len-spec">len()</a></dt>
195+
</dl>
191196
</dd>
192197

193198
<dt><a href="#examples">Example</a></dt>
@@ -918,16 +923,36 @@ <h2><a name="examples"></a>Example</h2>
918923
result += seq[i];
919924
return result;
920925
}
926+
</pre>
927+
928+
<h4><a name="len-spec">len()</a></h4>
929+
<pre>
930+
inline long len(object const&amp; obj);
931+
</pre>
932+
933+
<dl class="function-semantics">
934+
<dt><b>Effects:</b> PyObject_Length(obj.ptr()) </dt>
935+
<dt><b>Returns:</b> len() of object.</dt>
936+
</dl>
937+
938+
<h2><a name="examples"></a>Example</h2>
939+
Python code:
940+
<pre>
941+
len(obj)
942+
</pre>
943+
C++ version:
944+
<pre>
945+
len(obj);
921946
</pre>
922947

923948
<p>Revised
924949
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
925-
13 November, 2002
950+
12 January, 2006
926951
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
927952
</p>
928953

929954
<p><i>&copy; Copyright <a href=
930-
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
955+
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2006.</i></p>
931956
</body>
932957
</html>
933958

include/boost/python/detail/api_placeholder.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
// Distributed under the Boost Software License, Version 1.0. (See
33
// accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
// DEPRECATED HEADER (2006 Jan 12)
7+
// Provided only for backward compatibility.
8+
// The boost::python::len() function is now defined in object.hpp.
9+
510
#ifndef BOOST_PYTHON_API_PLACE_HOLDER_HPP
611
#define BOOST_PYTHON_API_PLACE_HOLDER_HPP
712

8-
namespace boost { namespace python {
9-
10-
inline long len(object const& obj)
11-
{
12-
long result = PyObject_Length(obj.ptr());
13-
if (PyErr_Occurred()) throw_error_already_set();
14-
return result;
15-
}
16-
}} // namespace boost::python
13+
#include <boost/python/object.hpp>
1714

1815
#endif // BOOST_PYTHON_API_PLACE_HOLDER_HPP

include/boost/python/object.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,15 @@
1313
# include <boost/python/object_operators.hpp>
1414
# include <boost/python/converter/arg_to_python.hpp>
1515

16+
namespace boost { namespace python {
17+
18+
inline long len(object const& obj)
19+
{
20+
long result = PyObject_Length(obj.ptr());
21+
if (PyErr_Occurred()) throw_error_already_set();
22+
return result;
23+
}
24+
25+
}} // namespace boost::python
26+
1627
#endif // OBJECT_DWA2002612_HPP

src/object/enum.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <boost/python/str.hpp>
1313
#include <boost/python/extract.hpp>
1414
#include <boost/python/object_protocol.hpp>
15-
#include <boost/python/detail/api_placeholder.hpp>
1615
#include <structmember.h>
1716
#include <cstdio>
1817

src/object/function.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <boost/python/tuple.hpp>
1616
#include <boost/python/list.hpp>
1717

18-
#include <boost/python/detail/api_placeholder.hpp>
1918
#include <boost/python/detail/signature.hpp>
2019
#include <boost/mpl/vector/vector10.hpp>
2120

src/object/pickle_support.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <boost/python/tuple.hpp>
99
#include <boost/python/list.hpp>
1010
#include <boost/python/dict.hpp>
11-
#include <boost/python/detail/api_placeholder.hpp>
1211

1312
namespace boost { namespace python {
1413

test/pickle2.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <boost/python/class.hpp>
2828
#include <boost/python/tuple.hpp>
2929
#include <boost/python/extract.hpp>
30-
#include <boost/python/detail/api_placeholder.hpp>
3130

3231
namespace { // Avoid cluttering the global namespace.
3332

test/pickle3.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <boost/python/tuple.hpp>
2424
#include <boost/python/dict.hpp>
2525
#include <boost/python/extract.hpp>
26-
#include <boost/python/detail/api_placeholder.hpp>
2726
#include <boost/python/back_reference.hpp>
2827

2928
namespace { // Avoid cluttering the global namespace.

0 commit comments

Comments
 (0)