(this is a very late reply, but hopefully it will still be useful)
Your patch looks fine to me, but I'm not really sure who is responsible for approving patches and committing them to the Boost.Python codebase these days. I suspect the procedure for doing so is a little bit in flux, as boost is in the process of a move from SVN to git. I'd be willing to take on some of that responsibility myself, especially after the move to git is complete, with the caveat that I really won't have much time to devote to it. First, however... On 02/13/2013 03:22 PM, Aaron Wishnick wrote:
I'd also be happy (and interested!) to discuss any alternate ways to accomplish what I want. To reiterate, it's really important to us that we be able to do this for all subclasses of a certain class, automatically, and this was the only apparent mechanism to me.
...I do have a possible alternative to propose: could you wrap all of your classes with a different "HeldType", as described here: http://www.boost.org/doc/libs/1_53_0/libs/python/doc/v2/class.html I'm imagining something like this: template <typename Base> class HookWrapper : public Base { public: HookWrapper(PyObject * self, Base const & other); // this is invoked whenever an object is returned by value or copy-constructed in Python. HookWrapper(PyObject * self, ...); // need to expose other constructors of Base, but with PyObject* as first argument. }; When an object is *not* constructed in Python, it will just be a Base, not a Hookwrapper<Base>; that will be true for objects constructed in C++ and passed by pointer or reference to Python as well, which is (I think) what you want. The obvious problem is that HookWrapper would have to be support all possible constructor signatures for the classes it would be used with (or at least those that need to be accessible from Python). That's relatively easy in C++11 using variadic templates, but a giant pain in C++98. Is there any chance this could work for you anyway? Jim Bosch _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig