[C++-sig] Bug: Pyste and pure virtual functions.
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Sat Aug 16 21:00:50 CEST 2003
>>>>> "N" == nicodemus <nicodemus at globalite.com.br> writes:
N> Hi Prabhu! Prabhu Ramachandran wrote:
>> I just found an obvious way to get around this -- simply call
>> the wrapped function (afterall this is only to satisfy the
>> compiler). Attached is a patch to fix the problem with Pyste
>> from CVS. This works fine for me.
N> I tried this approach too, but then it doesn't link: it
N> complains about the abstract function being referenced inside
N> the default_() method and is unable to resolve find it (I'm
N> using Intel 6 on Windows). 8/ Anyone got other ideas?
Huh? How is that possible? Did you use my patch? I specifically
chose to use method.name and not method.FullName() since method.name
would resolve to the wrapped function. Here is an example:
struct A_Wrapper: A
{
// [ snip ]
// f is a pure virtual function.
unsigned int f() { return call_method< unsigned int >(self, "f"); }
unsigned int default_f() {
PyErr_SetString(PyExc_RuntimeError, "pure virtual function called");
throw_error_already_set();
return A::f(); // <---------- WRONG.
return f(); // <------------- CORRECT.
}
};
As far as I can tell this is perfectly legal and the compiler cannot
complain since f is a valid overridden virtual function. I've also
tested this with my code and it builds everything fine -- no link
problems and everything seems to work ok.
cheers,
prabhu
More information about the Cplusplus-sig
mailing list