[C++-sig] C++ compile error on .def from n00b.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[C++-sig] C++ compile error on .def from n00b.

Randy Taylor
I'm a n00b.
I'm trying to expose a C++ class that has a virtual mem fun with an
implementation that I wish to override in Python.  Seems easy enough.  
Compiler disagrees, saying she does not like my def. I must be doing something
wrong. What is it?  Thanks kindly in advance.

Here's my Wrapper:

struct ListenerWrap : tt_stream_ns::VIAmCallback,
python::wrapper<tt_stream_ns::VIAmCallback>
{
    virtual void OnData(tt_stream_ns::VIAmSession *sess,
        const tt_stream_ns::VIAmSubject& subj,
        tt_stream_ns::VIAmSender *sender,
        tt_stream_ns::Streamable& obj,
        tt_stream_ns::VIAmListener *listener)
    {
        if (python::override the_override = this->get_override("OnData")) {
            the_override(sess,subj,sender,obj,listener); // *note*
            return;
        }
        tt_stream_ns::VIAmCallback::OnData(sess,subj,sender,obj,listener);
    }
    void default_OnData(tt_stream_ns::VIAmSession *sess,
        const tt_stream_ns::VIAmSubject& subj,
        tt_stream_ns::VIAmSender *sender,
        tt_stream_ns::Streamable& obj,
        tt_stream_ns::VIAmListener *listener)
    {
        this->tt_stream_ns::VIAmCallback::OnData
(sess,subj,sender,obj,listener);
    }
};


And my def:


BOOST_PYTHON_MODULE(pycore)
{
    python::class_<ListenerWrap, boost::noncopyable>("VIAmCallback")
            .def("OnData"
                ,&tt_stream_ns::VIAmCallback::OnData
                ,&ListenerWrap::default_OnData
                );
}


And here's her complaint:

c:\shi_zero_go\core\api\7_0\dev\pycore\pycore.cpp(81) : error
C2780: 'boost::python::class_<W,X1>::self &boost::python::class_<W,X1>::def
(const char *,Fn,const A1 &,const A2 &,const A3 &)' : expects 5 arguments - 3
provided
        with
        [
            W=ListenerWrap,
            X1=boost::noncopyable
        ]
        c:\shi_zero_go\misc\boost\1_32_0\dev\boost\python\class.hpp(265) : see
declaration of 'boost::python::class_<W,X1>::def'
        with
        [
            W=ListenerWrap,
            X1=boost::noncopyable
        ]
c:\shi_zero_go\core\api\7_0\dev\pycore\pycore.cpp(81) : error
C2780: 'boost::python::class_<W,X1>::self &boost::python::class_<W,X1>::def
(const char *,Fn,const A1 &,const A2 &)' : expects 4 arguments - 3 provided
        with
        [
            W=ListenerWrap,
            X1=boost::noncopyable
        ]
        c:\shi_zero_go\misc\boost\1_32_0\dev\boost\python\class.hpp(249) : see
declaration of 'boost::python::class_<W,X1>::def'
        with
        [
            W=ListenerWrap,
            X1=boost::noncopyable
        ]




Thank you!
Randy Taylor





_______________________________________________
C++-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/c++-sig
Reply | Threaded
Open this post in threaded view
|

Re: [C++-sig] C++ compile error on .def from n00b.

Roman Yakovenko
On 3/31/06, Randy Taylor <[hidden email]> wrote:
> I'm a n00b.
> I'm trying to expose a C++ class that has a virtual mem fun with an
> implementation that I wish to override in Python.  Seems easy enough.
> Compiler disagrees, saying she does not like my def. I must be doing something
> wrong. What is it?  Thanks kindly in advance.
>

Hi. It would be nice if you could provide less source that shows your problem.

Also I think in this case ( noncopyable ) you did not setup class init
method(s).

In order to get more readable errors you can write something like this

typedef boost::python::class_< ... >  my_class_exposer_t;
my_class_exposer_t exposer( ... );
exposer.def( ... );

At least you will be pointed by compiler to the right line.

And an other thing: if you are just start with Boost.Python then try
one of available code
generators: pyplusplus ( has gui ) and/or Pyste. You will be able to
save a lot of time.


--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
_______________________________________________
C++-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/c++-sig