|
Boost : |
From: Ullrich Koethe (koethe_at_[hidden])
Date: 2000-11-29 18:42:55
Anton Gluck wrote:
>
> Just one more question: Did you add the auxiliary class and the magic in
> my_module.def_cursor_for(), or is this part of py_cpp/boost already? If
> so, how did you know (I'd like to acquire some of _your_ magic :-)? If
> not, will I be able to try this with the code you provided here, or does
> this require an update of py_cpp?
>
The cursor feature didn't make it into the BPL release version because I
invented it after the deadline :-( For now, you can work with the code I
provided in the previous posting, but you will have to emulate the
effect of "def_cursor_for()" manually. Here is what you need to do:
cursor<FooList> FooList_get_cursor(FooList const & foo_list)
{
return cursor<FooList>(const_cast<FooList &>(foo_list));
}
boost::python::class_builder<FooList>
foolist_class(my_module, "FooList");
foolist_class.def(&FooList_get_cursor, "cursor");
...// other FooList methods
boost::python::class_builder<cursor<FooList> >
foolist_cursor_class(my_module, "FooList_cursor");
foolist_cursor_class.def(&cursor<FooList>::get_item, "__getitem__");
foolist_cursor_class.def(&cursor<FooList>::set_item, "__setitem__");
foolist_cursor_class.def(&cursor<FooList>::len, "__len__");
That's all my magic.
Viel Spass
Ulli
-- ________________________________________________________________ | | | Ullrich Koethe Universität Hamburg / University of Hamburg | | FB Informatik / Dept. of Computer Science | | AB Kognitive Systeme / Cognitive Systems Group | | | | Phone: +49 (0)40 42883-2573 Vogt-Koelln-Str. 30 | | Fax: +49 (0)40 42883-2572 D - 22527 Hamburg | | Email: u.koethe_at_[hidden] Germany | | koethe_at_[hidden] | | WWW: http://kogs-www.informatik.uni-hamburg.de/~koethe/ | |________________________________________________________________|
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk