On 05/08/2013 05:48 PM, Jim Bosch wrote:
On 05/08/2013 04:33 PM, Wichert Akkerman wrote:
I am trying to expose a class with a boost::uuids::uuid member to Python. The class is pretty simple:
class Article { public: boost::uuids::uuid uuid; };
which is exposed like this:
article .def(init<boost::uuids::uuid, Article::Type>((arg("uuid"))) .def_readwrite("uuid", &Article::uuid);
and I have basic converter registered (see https://gist.github.com/wichert/5543390 , it is a bit large to include in this email). This compiles fine and the uuid convertor works correctly when trying converting from python to C++, but trying to access the uuid property results in "TypeError: No Python class registered for C++ class boost::uuids::uuid". I don't understand why that doesn't work; does anyone see what I missed?
I suspect that def_readwrite requires lvalue converters, and I see that you've only implemented an rvalue converter. I think in this case you're better off just writing a getter and setter, and wrapping those using add_property.
Ah, sorry, that didn't make any sense. There's no such thing as an lvalue to-Python converter, and to-Python is the problem here. You may want to try also registering your to-Python converter for the pointers and/or references to uuid. I ran into a similar problem with getting def_readwrite to work a while back, and specializing for pointer/reference/const variants made it go away, though I was using a different converter mechanism (by partial specialization of some template classes - not something I'd recommend here). Jim