[Development] Porting code from QScriptEngine (Qt4) to QJSEngine (Qt5)

a.grandi at gmail.com a.grandi at gmail.com
Mon Jun 25 10:10:27 CEST 2012


Hi,

On 25 June 2012 10:32,  <christopher.adams at nokia.com> wrote:
> Hi Andrea,
>
> My response doesn't relate to EnvJs in particular, although it may be relevant.
>
> In general, support for JavaScript in QML is still lacking (examples: instanceof doesn't work properly, due to the dichotomy between C++ inheritance and JS prototypical inheritance and constructor functions; we don't allow modification of the evaluation context of a script import; etc) and this is probably going to be one of the focuses of QtDeclarative development for 5.1.  Most of those improvements are, however, out of scope for 5.0 due to time limitations.
>
> You can do something like:
>
> // main.qml
> Import QtQuick 2.0
> Import "Compat.js" as JS

yes, importing the code in this way works perfectly and that's what we
have done, for example, with UnderscoreJs javascript code. I've
written unit tests for almost every method provided by that library.

The problem is with EnvJs, because it's not contained everything in a
single source file, but it's splitted in many different files. The
missing "document" object for example could be defined somewhere else
and even importing the code it cannot be used by EnvJs.

> Michael Brasser has written some documentation about the limitations of the JavaScript environment in QML, see http://qt.gitorious.org/qt/qtdeclarative/blobs/master/src/qml/doc/src/javascript/hostenvironment.qdoc for more information.

I've read the limitations, but since I'm not an expert of these
internals I don't know what these limitations can cause in my
particular situation.

I'll keep trying and I'll let you know if I discover something new. I
just hope this will be possible someway, because it would be nice to
be able to use those libraries we're trying to make work.

Regards,

-- 
Andrea Grandi - Nokia-DXM/Tampere / Qt Ambassador
Ubuntu Member: https://launchpad.net/~andreagrandi
website: http://www.andreagrandi.it



More information about the Development mailing list