[PyKDE] SIP and overloaded non-pure virtual functions

Paul F. Kunz Paul_Kunz at SLAC.Stanford.EDU
Thu May 29 20:18:01 BST 2003


>>>>> On Thu, 29 May 2003 18:56:06 +0100, Phil Thompson <phil at riverbankcomputing.co.uk> said:

> On Thursday 29 May 2003 1:15 am, Paul F. Kunz wrote:
>> In my PlotterBase.zip file I have
>> 
>> class PlotterBase {
>> 
>> public:
>> 
>> PlotterBase ( const std::string & ); void setRange ( const
>> std::string &, double, double ); virtual void setBinWidth ( const
>> std::string &, double );
>> 
>> In the C++ code there's an implementation that is overridden by a
>> number of derived classes of PlotterBase.  The Python user gets his
>> handle on them via
>> 
>> class DisplayController {
>> 
>> public:
>> 
>> static DisplayController * instance (); PlotterBase * createDisplay
>> ( const std::string &, const NTuple &, const
>> std::vector<std::string> & ) const;
>> 
>> Where the Python class will have a pinter to a C++ derived class of
>> PlotterBase.
>> 
>> The SIP generated code for setBinWidth member function contains...
>> 
>> PlotterBase *sipCpp;
>> 
>> if
>> (sipParseArgs(&sipArgsParsed,sipArgs,"mM1d",sipThisObj,sipClass_PlotterBase
>> ,&sipCpp,sipConvertTo_std_string,&a0,&a0IsTemp,&a1)) {
>> Py_BEGIN_ALLOW_THREADS sipCpp -> PlotterBase::setBinWidth(*a0,a1);
>> Py_END_ALLOW_THREADS
>> 
>> The C++ call to setBinWidth is scoped, the the virtual function
>> table of the derived class is not used.
>> 
>> Is this a know bug in SIP code generation?

> No, that's what it is supposed to be. Deciding which is the right
> implementation of setBinWidth() to call happens ealier on in the
> process.

   Its not working.   The C++ derived class of this C++ base class is
not being exposed to Python   There's no way for Python to know to
call the virtual function as a virtual function.   The scoping in the
SIP generated code is messing things up.   

   Or, there's something I don't understand.




More information about the PyQt mailing list