|
Last change
on this file since 44 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
838 bytes
|
| Line | |
|---|
| 1 | // Copyright Eric Niebler 2005. |
|---|
| 2 | // Distributed under the Boost Software License, Version 1.0. (See |
|---|
| 3 | // accompanying file LICENSE_1_0.txt or copy at |
|---|
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 5 | #include <boost/python/module.hpp> |
|---|
| 6 | #include <boost/python/def.hpp> |
|---|
| 7 | #include <boost/python/iterator.hpp> |
|---|
| 8 | #include <boost/python/stl_iterator.hpp> |
|---|
| 9 | #include <list> |
|---|
| 10 | |
|---|
| 11 | using namespace boost::python; |
|---|
| 12 | |
|---|
| 13 | typedef std::list<int> list_int; |
|---|
| 14 | |
|---|
| 15 | void assign(list_int& x, object const& y) |
|---|
| 16 | { |
|---|
| 17 | stl_input_iterator<int> begin(y), end; |
|---|
| 18 | x.clear(); |
|---|
| 19 | for( ; begin != end; ++begin) |
|---|
| 20 | x.push_back(*begin); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | BOOST_PYTHON_MODULE(stl_iterator_ext) |
|---|
| 24 | { |
|---|
| 25 | using boost::python::iterator; // gcc 2.96 bug workaround |
|---|
| 26 | |
|---|
| 27 | class_<list_int>("list_int") |
|---|
| 28 | .def("assign", assign) |
|---|
| 29 | .def("__iter__", iterator<list_int>()) |
|---|
| 30 | ; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | #include "module_tail.cpp" |
|---|
Note: See
TracBrowser
for help on using the repository browser.