[Kde-perl] Handling primitive type conversion in bindings (QString, QCString, QByteArray etc)

Adam Treat kde-perl@mail.kde.org
Mon, 2 Dec 2002 12:16:41 -0500


On Wednesday 27 November 2002 02:34 pm, Ashley Winters wrote:
> --- Germain Garand <germain@ebooksfrance.com> wrote:
> > I've thought a bit more about the UTF8/locale discussion.
> > Regarding QStrings, it turns out that having some Do-What-I-Mean in
> > the
> > Perl->Qt way and always UTF-8 in the Qt->Perl way could work nicely.
>
> Thank God someone can test internationalization without me. *whew*
>
> I'm an American, I don't know another language, and it makes me feel
> dumb. :)
>
> As far as the change goes, looks good to me. It's not incompatible with
> a future change I plan, which I might as well outline.
>
> QString, QCString, QByteArray, and any other classes I've forgotten
> which have no class in PerlQt and instead are represented by strings
> will become classes. This will require template support, which is why
> this is a future thing.
>
> For backward compatibility, and plain old usability, all those classes
> will have their "" (stringify) operator overloaded so that if you use
> it like a string, it looks like a string.

Interesting.  You plan on making QString into a bonafied PerlQt class and then 
provide a means for creation with "".  I don't know if this is possible or 
feasible in Qt# (would it inherit System.String?) but it would be a novel new 
strategy to look at.

> This isn't set in stone, because who knows what'll happen? I know that
> $hash{$qstring} will work backward-compatibly, but perhaps something
> else won't. *shrug*
>
> Along with that, I'm going to try to add support to PerlQt for
> conversion constructors in general, rather than just QString. I just
> realized that wasn't clear at all.
>
> Example:
> void foo(const QString &bar);
> foo(QString("bleh"));   // explicit construction
> foo("bleh");     // same as the previous one. can I do this with Perl?

We do this now, but we also switch construct a QString in the body of the ctor 
and pass this to the extern ctor method.