From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-05 09:02:46
----- Original Message -----
From: "jefflholle" <jeff.holle_at_[hidden]>
> I'm failing to understand examples of this in boost_1_24_0
> Basically, my problem is in obtaining the PyObject * value needed to
> make a callback.
> The simplest example of this is abstract.cpp/test_abstract.py.
> It is more complicated that what I'm after since it involves an
> abstract C++ class that is interfaced to python.
> I've modified this module to reflect what I'm really after
What /are/ you really after? Please spell it out carefully and precisely...
> and gotten
> it to behave in the manner that my code is. It follows:
> // Example by Ullrich Koethe
> boost::python::module_builder a("abstract");
> boost::python::class_builder<Abstract_callback> a_class
> (a, "Abstract");
> a_class.def(boost::python::constructor<>()); // wrap a constructor
> a_class.def(&Abstract_callback::test, "test");
> This module doesn't compile for want of a default constructor in
Because you changed the class_builder declaration (why?) from:
> It doesn't exist because I want to make the
> constructor of this class provide the needed PyObject,
How would the constructor "provide" it? Are you planning to do a PyList_New
> so a callback
> can be done.
> If I modify the "boost::python::constructor<>());"
> to "boost::python::constructor<Python *>());" I run into conversion
What sort of conversion problems?
> Actually, I've found that I run into such trouble passing
> any pointer and a lot of complex things.
I don't understand the above sentence.
> How do I do this?
> One more thing. I've tried just adding another method to deliver the
> self pointer of the class and get a runtime error saying that a
> string or unicode object expected but an instance was found when
> calling it from python.
That's description is open to lots of interpretations; code helps.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk