in reply to (tye)Re: Help: 5.6.1: XSUB and AUTOLOAD
in thread Help: 5.6.1: XSUB and AUTOLOAD

Well, the whole story goes like this: there used to be a package PerlQt which I happened to like a lot. However the guy who wrote it seems to have abandoned his baby. So I tried to bring it up to date -- when I found that 99% of the code relies on AUTOLOAD, kinda like I described before. Yes, my first reaction was the same: dispatch from Perl, and this is the fix that works for me now (I am yet to try to get in touch with the author again on this) -- however, it means having tons of "use Qt::ThisAndThat;" statements, whereas XS allowed to have a single AUTOLOAD for everything. I have a few ideas how to patch this, however first I wanted to be sure I am not doing something stupid.

Thanx for reply, anyway. I posted to a couple of newsgroups too, and it looks like not to many people are intimately familiar with the topic.

Best,

Mishka

  • Comment on Re: (tye)Re: Help: 5.6.1: XSUB and AUTOLOAD

Replies are listed 'Best First'.
(tye)Re2: Help: 5.6.1: XSUB and AUTOLOAD
by tye (Sage) on Jul 20, 2001 at 09:47 UTC

    Well, I was thinking more along the lines of:

    sub AUTOLOAD { AutoLoad( $AUTOLOAD, @_ ); }
    and have AutoLoad() be the XS routine. Passing in $AUTOLOAD could be optional since you probably already have code that knows how to fetch that.

    But maybe something that simple wouldn't be enough to overcome the bug you hit. (:

            - tye (but my friends call me "Tye")
      That's exactly what I tried to do.

      As I said, the thing is, PerlQt is "many packages in one", so one needs to define this for, e.g. Qt.pm, Qt/Object.pm, Qt/Application.pm, and so on. Also, simple code like

      use Qt; import Qt::app; $hello = Qt::PushButton->new('Hello'); $hello->resize(100, 30); $app->setMainWidget($hello); $hello->show(); exit $app->exec();

      becomes

      use Qt; use Qt::Object; use Qt::Application; use Qt::PushButton; use Qt::Font; import Qt::app; $hello = Qt::PushButton->new('Hello'); $hello->resize(100, 30); $app->setMainWidget($hello); $hello->show(); exit $app->exec();
      and more complex examples end up having dozens of "use" statements, which is kinda inconvenient. The original piece of code was pretty inventive about this: all Qt::*::AUTOLOAD methods were directed (newXSUB'ed) to the same place, so a single "use Qt" was enough. Right now I am thinking of overloading "new" and "DESTROY" methods of each class with what used to be "AUTOLOAD". In the original code, AUTOLOAD on each object was used only once, and whan it did, it loaded (newXS'ed) the real methods (I think the guy did that for optimization). Since every object in PerlQt has both "new" and "DESTROY", the "fake new" e.g. procedure would be overriden immediately after it is called. This approach seems to work better, although there are some subtleties that I have to take care of.

      This all brings me to one thing: my God, how I wish Perl5 along with perlguts soecs was standartized!

      best,

      Mishka