Re: [pygccxml-development] virtual functions without wrappers
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-08-25 08:44:43
|
Neal Becker wrote: > I am playing with pyplusplus, trying out pypp_api. I noticed that a class > with virtual functions and inheritance used wrappers, as shown in the > boost::python tutorial. > > I would like to have to option to bypass these wrappers. IIUC, wrappers are > only needed if the function will be overidden in python and then called from > c++. My intention is a class hierarchy implemented in c++ only that is > called from python. > > Here is a typical example: > > struct base { virtual void F() = 0; }; > > struct impl_1 : base { virtual void F() { do something; } }; > > struct X { > X (boost::shared_ptr<base> _p) : p (_p) {} > boost::shared_ptr<base> p; > void use_F () { (*p)->F(); } > }; > > In python then: > > i = impl_1() > x = X (i) > x.use_F() I think what you're looking for is the "finalize" functionality which would tell Py++ that wrappers are not required. I'm not entirely sure, but I believe this functionality is currently not properly supported by Py++ (Roman has to give a definite answer here). If you don't have to call F() from Python then a simple workaround would be to ignore that method (but again, I'm not sure if this will prevent Py++ from generating the wrapper class). - Matthias - |