|
Re: registering simple conversions from/to python: msg#00298python.c++
"Ralf W. Grosse-Kunstleve" <rwgk@xxxxxxxxx> wrote: > > Is there a simple recipe for registering these conversions? > > I do something like this all the time, although I wouldn't claim that > it is "simple." There are some hints here: > > http://www.boost.org/libs/python/doc/v2/faq.html#question2 > > Alternative 2 seem most appropriate in your case. I would use > boost:array<double, 2> as the vehicle for your data. Look here for a > complete example: > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/scitbx/array_family/boost_python/regression_test_ext.cpp?rev=1.3&content-type=text/vnd.viewcvs-markup > > Look for: > > boost::python::to_python_converter< > boost::array<int, 2>, > scitbx::boost_python::container_conversions::to_tuple< > boost::array<int, 2> > >(); > > And: > > scitbx::boost_python::container_conversions::from_python_sequence< > boost::array<double, 3>, > scitbx::boost_python::container_conversions::fixed_size_policy>(); > > To be able to use this copy the header file > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/scitbx/include/scitbx/boost_python/container_conversions.h?rev=1.10&content-type=text/vnd.viewcvs-markup > > to your own project. There are no dependencies for this file other > than boost. > Thanks, that looks like it will do the job. I had looked at this code actually but I needed you to point out the relevant bits :) Thanks for letting me plunder the code -- is something like this worth putting back into the boost-python library? Cheers, Brett |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: registering simple conversions from/to python: 00298, Brett Calcott |
|---|---|
| Next by Date: | Re: instantiating python objects within C++: 00298, David Abrahams |
| Previous by Thread: | Re: registering simple conversions from/to pythoni: 00298, Ralf W. Grosse-Kunstleve |
| Next by Thread: | Re: Re: registering simple conversions from/to python: 00298, Ralf W. Grosse-Kunstleve |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |