On Monday 22 September 2003 6:11 am, Patrick Stinson wrote:
> I've been having a never-ending struggle with virtual methods. It seems
> that virtual methods wrapped by sip don't always work - that is they
> actually end up working like non-virtual functions. This isn't consistent,
> and I've never found a solution besides fiddling with it until the _same
> exact_ code ends up functioning differently after a number of print-out
> style debugging.
>
> Consider this:
>
> media = PK.CreateMediaLayer("./track.ogg")
> while not media.AtEnd():
>   media.Read()

What do you get when you "print media"? If you get a PK_MediaLayer instance 
then maybe you haven't implemented %ConvertToSubClassCode properly.

> All of these methods are C++ wrapped methods. PK::CreateMediaLayer()
> returns a PK_MediaLayer *, which may be an instance of either
> PK_WaveDecoder or PK_OggDecoder. All PK_Media:Layer methods are [not pure]
> virtual in sip and C++, are reimplemented in the respective subclasses, are
> are not inline.
>
> In the above example, media.AtEnd() is supposed to call
> PK_OggDecoder::AtEnd(), but it really calls PK_MediaLayer::AtEnd(). Why is
> that? Are there certain caveats with C++ virtual functions that I have
> naively overlooked? What is the relationship to methods declared virtual in
> sip and those declared virtual in C++? Is virtual really needed in sip?

Yes, so that code is generated to "catch" the virtual call and check for (and 
execute) any Python reimplementation.

What versions are you using?

Phil

_______________________________________________
PyKDE mailing list    [EMAIL PROTECTED]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to