[C++-sig] Custom smart pointer and bp::wrapper (original) (raw)
Paul Melis pyplusplus at assumetheposition.nl
Sun Jan 18 11:58:46 CET 2009
- Previous message: [C++-sig] Custom smart pointer and bp::wrapper
- Next message: [C++-sig] Custom smart pointer and bp::wrapper
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Roman Yakovenko wrote:
2009/1/17 Paul Melis <pyplusplus at assumetheposition.nl>:
But when trying to run
import doh class MyCallback(doh.Callback): def execute(self, t): print t return 1 m = MyCallback() t = doh.Thing() t.setCallback(m) t.update() i'm getting Traceback (most recent call last): File "notopythonconverter.py", line 12, in t.update() TypeError: No topython (by-value) converter found for C++ type: Thing". And I fail to see why... Mu guess: you need to use boost::python::registerptrtopython< Thin >(); ( http://www.boost.org/doc/libs/1370/libs/python/doc/v2/registerptrtopython.html ) Well, that only seems to work on smart pointers, i.e. ref_ptr. From the docs: "|<boost/python/register_ptr_to_python.hpp>| supplies |registerptrtopython|, a function template which registers a conversion for smart pointers to Python" I have more or less complete example, which exports custom pointer class and its usage to Python: http://www.language-binding.net/pyplusplus/troubleshootingguide/smartptrs/smartptrs.html Right, I did find it while trying to solve the above. But where our code differs is that my wrapper class (CallbackWrap) needs to pass a Thing* to Python and that's where it goes wrong. Your wrapper only returns an integer and doesn't pass any parameters to Python. I think that is the crucial difference here.
Regards, Paul
- Previous message: [C++-sig] Custom smart pointer and bp::wrapper
- Next message: [C++-sig] Custom smart pointer and bp::wrapper
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]