extragear/multimedia/amarok/src

Ian Monroe ian at monroe.nu
Mon Aug 11 23:00:08 CEST 2008


On Mon, Aug 11, 2008 at 2:55 PM, Peter Zhou <peterzhoulei at gmail.com> wrote:
> SVN commit 845479 by peterzl:
>
> scriptable service API++
>
>  M  +1 -1      dialogs/ScriptManager.cpp
>  M  +40 -10    scriptengine/AmarokScriptableServiceScript.cpp
>  M  +3 -3      scriptengine/AmarokScriptableServiceScript.h
>  M  +13 -17    scripts/radio_station_service/main.js
[snip]
>  QString ScriptableServiceScript::serviceName() const
>  {
> -    return QString();
> +    ScriptableServiceScript* item = qscriptvalue_cast<ScriptableServiceScript*>( thisObject() );
> +    if ( item )

I don't think its really necessary to use the QScriptable prototype
thing. Thats really more for classes that you've already implemented
in C++ that aren't QObjects. You could just create a QObject and
define a constructor I believe.

However you could use it. But you can see that the code above doesn't
make sense: your casting thisObject() to be the same type as just
plain "this" would be.

The QScriptable object is supposed to be a prototype for a /different/
C++ class. There is only going to be *one* prototype for the entire
engine, so it doesn't make any sense for that class to have any of its
own m_ data members. (Or if it does, they are effectively static data
members, since they will be the same for all JavaScript objects of
that class).

Ian


More information about the Amarok-devel mailing list