Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-02-08 08:33:28


Lorien,

This is something I need to add to the documentation. Whenever you write a
callback class FooCallback for a wrapped class Foo, you may need to be sure
that the callback class has a constructor taking 2 arguments, the first
being a PyObject*, the second being a Foo. This constructor is essentially
the "to_python copy constructor" for Foo, and will be used any time you wrap
a function which returns a Foo by value or by const reference. You only need
to supply this constructor if you wrap such a function, though.

-Dave

----- Original Message -----
From: "Lorien Dunn" <l.dunn_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, February 08, 2001 10:18 PM
Subject: [boost] BPL : problems with constructors?

> Hullo,
>
> I'm getting some errors I cant make sense of. They are happening in a set
of
> inter-object Midi reception and transmission classes. These are the only
> classes affected out of about 75. Attached is a file containing the class
> interfaces concerned, and the compiler errors.
>
> I'm using Mandrake7.2 gcc 2.95.3 (prerelease 1991030) - the default
> compiler.
>
> Thanks for any help :)
>
> Lorien Dunn
> http://members.tripod.com/~loriend
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1
>
>
>

----------------------------------------------------------------------------

----
>
////////////////////////////////////////////////////////////////////////////
/////////////////////
> // Reciever classes
>
////////////////////////////////////////////////////////////////////////////
/////////////////////
>
> class Transmitter;
>
> class RecieverPyCallback : public Reciever
> {
> PyObject* _self;
> public:
> RecieverPyCallback(PyObject* self);
> virtual ~RecieverPyCallback();
>
> virtual void Parse(const Event& ev);
> static void DefaultParse(Reciever& self, const Event& ev);
>
> virtual void OnEvent(const Event& ev);
> static void DefaultOnEvent(Reciever& self, const Event& ev);
>
> //Connection callbacks
> virtual void ConnectionMade(Transmitter& from);
> static void DefaultConnectionMade(Reciever& self, Transmitter& from);
>
> virtual void ConnectionBroken(Transmitter& from);
> static void DefaultConnectionBroken(Reciever& self, Transmitter& from);
> };
>
> struct PyReciever : python::class_builder<Reciever,RecieverPyCallback>
> {
> PyReciever(python::module_builder& m) :
> python::class_builder<Reciever,RecieverPyCallback>(m, "Reciever")
> {
> def(python::constructor<>());
> def(&Reciever::Parse,"Parse",&RecieverPyCallback::DefaultParse);
> def(&Reciever::OnEvent,"OnEvent",&RecieverPyCallback::DefaultOnEvent);
>
def(&Reciever::ConnectionMade,"ConnectionMade",&RecieverPyCallback::DefaultC
onnectionMade);
>
def(&Reciever::ConnectionBroken,"ConnectionBroken",&RecieverPyCallback::Defa
ultConnectionBroken);
> def(&Reciever::Parse,"Parse",&RecieverPyCallback::DefaultParse);
> def(&Reciever::OnEvent,"OnEvent",&RecieverPyCallback::DefaultOnEvent);
> };
> virtual ~PyReciever() throw() {};
> };
>
>
////////////////////////////////////////////////////////////////////////////
/////////////////////////
> // Transmitter classes
>
////////////////////////////////////////////////////////////////////////////
//////////////////////////
>
>
> class TransmitterPyCallback : public Transmitter
> {
> PyObject* _self;
> public:
> TransmitterPyCallback(PyObject* self);
> virtual ~TransmitterPyCallback();
>
> virtual void Connect(Reciever& dest);
> static void DefaultConnect(Transmitter& self, Reciever& dest);
>
> virtual void Disconnect(Reciever& dest);
> static void DefaultDisconnect(Transmitter& self, Reciever& dest);
>
> virtual void Emit(const Event& ev));
> static void DefaultEmit(Transmitter& self, const Event& ev);
>
> virtual void ConnectionBroken(Reciever& dest);
> static void DefaultConnectionBroken(Transmitter& self, Reciever& dest);
> };
>
> struct PyTransmitter :  python::class_builder<Transmitter,
TransmitterPyCallback>
> {
> PyTransmitter(python::module_builder& m) :
> python::class_builder<Transmitter, TransmitterPyCallback>(m,
"Transmitter")
> {
> def(python::constructor<>());
> def(&Transmitter::Emit,"Emit",&TransmitterPyCallback::DefaultEmit);
> def(&Transmitter::Connect,"Connect",
&TransmitterPyCallback::DefaultConnect);
> def(&Transmitter::Disconnect,"Disconnect",
&TransmitterPyCallback::DefaultDisconnect);
>
def(&Transmitter::ConnectionBroken,"ConnectionBroken",&TransmitterPyCallback
::DefaultConnectionBroken);
> };
> virtual ~PyTransmitter() throw() {};
> };
>
>
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
> // Error Messages
>
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp: In method
`boost::python::detail::instance_value_holder<Burt::Midi::Transmitter,Burt::
Midi::TransmitterPyCallback>::instance_value_holder<Burt::Midi::Transmitter>
(boost::python::detail::extension_instance *, Burt::Midi::Transmitter)':
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:178:
instantiated from
`python_extension_class_converters<Burt::Midi::Transmitter,Burt::Midi::Trans
mitterPyCallback>::to_python(const Burt::Midi::Transmitter &) const'
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:299:
instantiated from `to_python<Burt::Midi::Transmitter>(const
Burt::Midi::Transmitter &)'
>
> /home/lorien/boost/boost/python/callback.hpp:458:   instantiated from here
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:680: no
matching function for call to
`Burt::Midi::TransmitterPyCallback::TransmitterPyCallback
(boost::python::detail::extension_instance *&, Burt::Midi::Transmitter &)'
>
> PyMidi/PySignals.cpp:349: candidates are:
Burt::Midi::TransmitterPyCallback::TransmitterPyCallback(PyObject *)
>
> PyMidi/PySignals.h:294:
Burt::Midi::TransmitterPyCallback::TransmitterPyCallback(const
Burt::Midi::TransmitterPyCallback &)
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp: In method
`boost::python::detail::instance_value_holder<Burt::Midi::Reciever,Burt::Mid
i::RecieverPyCallback>::instance_value_holder<Burt::Midi::Reciever>(boost::p
ython::detail::extension_instance *, Burt::Midi::Reciever)':
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:178:
instantiated from
`python_extension_class_converters<Burt::Midi::Reciever,Burt::Midi::Reciever
PyCallback>::to_python(const Burt::Midi::Reciever &) const'
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:299:
instantiated from `to_python<Burt::Midi::Reciever>(const
Burt::Midi::Reciever &)'
>
> /home/lorien/boost/boost/python/callback.hpp:458:   instantiated from here
>
> /home/lorien/boost/boost/python/detail/extension_class.hpp:680: no
matching function for call to
`Burt::Midi::RecieverPyCallback::RecieverPyCallback
(boost::python::detail::extension_instance *&, Burt::Midi::Reciever &)'
>
> PyMidi/PySignals.cpp:6: candidates are:
Burt::Midi::RecieverPyCallback::RecieverPyCallback(PyObject *)
>
> PyMidi/PySignals.h:86:
Burt::Midi::RecieverPyCallback::RecieverPyCallback(const
Burt::Midi::RecieverPyCallback &)
>
>
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////
> // EOF
>
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////
>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk