Providing bindings for Qt was investigated using the QMetaType machinery
(in a similar way to what Ali's FunctionInvoker work does), but the end
result was that it is not possible automatically, since the required
function pointers cannot be fetched via QMetaType. Instead, the
AngelscriptGenerator tool could be used to generate bindings for Qt types,
but there are a number of features to implement to it to make it work.
Using QWidgets on mobile is not much of an option anyways, so alternate
solutions need to be found. One such is Lasse's investigation of
librocket, we'll see how it turns out and what his recommendation will be.
jj
On Thu, 20 Dec 2012 17:44:27 +0200, Jonne Nauha <
jo...@adminotech.com>
wrote:
>> me.placeable.SetOrientation(m.**ToQuat());
>> }
>>
>> and in AS:
>>
>> float time = 0;
>> void update(float dt)
>> {
>> time += dt;
>> float3x3 m;
>> m.SetRotatePartY(time);
>> me.placeable.SetOrientation(m.**ToQuat());
>> }
>>
>> This is a very simple setup that stresses EC attribute write-only
>> modifications and math type creation and attribute set in a simple
>> manner.
>> Both of these scripts are added to the Angelscript branch at
>>
https://github.com/LudoCraft/**Tundra/commit/**
>> 84430c3c928c9b767019e0a5d45029**636e46235d<
https://github.com/LudoCraft/Tundra/commit/84430c3c928c9b767019e0a5d45029636e46235d>if
>> someone wants to try it out manually.
>>
>> In the benchmark, both memory usage and runtime performance was measured
>> in a Windows Release build of Tundra. The figures are as follows:
>>
>> Oulu3D scene without scripts - Memory: 331328 KB Time: 4.13 msecs/frame
>>
>> Oulu3D scene in Javascript - Memory: 502384 KB Time: 13.02 msecs/frame
>> delta over static scene: +171056 KB Time: +8.89 msecs/frame
>>
>> Oulu3D scene in Angelscript - Memory: 356760 KB Time: 5.02 msecs/frame
>> delta over static scene: +25432 KB Time: +0.89 msecs/frame
>>
>>
>> Computed on a per-script instance basis, each Javascript script instance
>> takes up 2443.66 KB of memory, whereas each Angelscript script instance
>> takes up 363.31 KB of memory. Executing the script takes 0.127
>> msecs/instance/frame for Javascript, but only 0.013 msecs/instance/frame
>> for Angelscript.
>>
>> The overall difference is dramatic. Angelscript is ten-fold faster and
>> uses less than a fifth of the memory of what the QtScript engine needs.
>> Impressive!
>>
>> Other observations:
>> - QtScript has gone into deprecated unmaintained state in Qt, they
>> favor
>> a different QML/QtQuick architecture starting from Qt5. (reference:
>>
https://github.com/realXtend/**naali/issues/542<
https://github.com/realXtend/naali/issues/542>)
>> - Angelscript is way more portable than Qt (
>>
http://www.angelcode.com/**
>> angelscript/features.html<
http://www.angelcode.com/angelscript/features.html>)
>> It builds without problems on Windows, Linux, OSX, iOS, Android, NPAPI,
>> NaCl and even Emscripten (see here for a live demo
>>
https://dl.dropbox.com/u/**40949268/emcc/**MathGeoLibTestAS.html<
https://dl.dropbox.com/u/40949268/emcc/MathGeoLibTestAS.html>)
>> - Angelscript is actively developed and looks like a healthy project (
>>
http://www.angelcode.com/**angelscript/users.html<
http://www.angelcode.com/angelscript/users.html>)
>> - Angelscript is statically typed, and offers better error reporting
>> than
>> Qtscript. The biggest problems, namely typoing a (member) variable in
>> Javascript silently creates a new one, and that it's possible to assign
>> to
>> a temporary that will get deleted, are impossible cases in Angelscript.
>>
>> The final verdict is that Angelscript makes QtScript look slow,
>> memory-hogging, bloated, insecure, buggy, unmaintained, unportable and
>> clumsy. Going into development for a mature and maintained Angelscript
>> script engine plugin should be considered a long-term goal.
>>
>> jj
>>
>>
>> On Wed, 19 Dec 2012 19:36:53 +0200, Jukka Jylänki <
>>
jukka....@ludocraft.com> wrote:
>>
>> Here's a short progress report on how the Angelscript research is
>> going.
>>>
>>> - Basic bindings are now in place. Scripts are able to understand
>>> types
>>> 'Scene', 'Entity', 'EC_Placeable', 'Transform', as well as all the
>>> MathGeoLib types. This allows scripts to access the scene object
>>> positions.
>>> See here for a test:
https://github.com/LudoCraft/**
>>> Tundra/blob/angelscript/bin/**scenes/Angelscript/
script.as<
https://github.com/LudoCraft/Tundra/blob/angelscript/bin/scenes/Angelscript/script.as>
>>>
>>> - Boost shared_ptrs work and are wrapped behind a .get() function.
>>> - Enums work (see AttributeChange::Type for example)
>>> - Both value and reference types are available. MathGeoLib types come
>>> as value types, others come as non-refcounted reference types.
>>> Angelscript
>>> does not currently participate in memory management (except via
>>> shared_ptrs), but all objects are owned in containers in Tundra core
>>> APIs.
>>>
>>> Some things that do not yet work are QString and container types. Also
>>> Angelscript does not have an understanding of Qt signals. There is no
>>> delegate support in Angelscript, but it can be simulated on C++ side to
>>> some extent.
>>>
>>> Automatic QObject-based interop has been investigated to be impossible,
>>> since Qt metatype mechanism does not offer the facilities for this that
>>> Angelscript would require. QObject types can naturally be manually
>>> exposed,
>>> but that requires interop code per class.
>>>
>>> The Angelscript bindings generator is available at
>>>
https://github.com/juj/**AngelscriptGenerator<
https://github.com/juj/AngelscriptGenerator>The
>>> generated bindings are committed as part of the Angelscript plugin like
>>> with QtScript, so people don't need to always generate them manually.
>>>
>>> The security of Angelscript itself has been evaluated to be safe for
>>> untrusted script execution. It has a good notion of exceptions,
>>> gracefully
>>> fails on null pointers and handles, and it is possible to limit
>>> long-running scripts (
http://www.angelcode.com/**
>>> angelscript/sdk/docs/manual/**doc_adv_timeout.html<
http://www.angelcode.com/angelscript/sdk/docs/manual/doc_adv_timeout.html>).
>>> Limiting large memory usage needs to be implemented at a higher level,
>>> but at least angelscript codebase does not call C system library
>>> exit(-1)
>>> like Qt does when it runs out of memory. From the current bindings
>>> mechanisms, only raw pointer access needs to be removed for types that
>>> can
>>> be destroyed at runtime, but otherwise things look good.
>>>
>>> The next (final) goal of this research task is to implement the same
>>> script application on both JavaScript and Angelscript, and measure the
>>> memory consumption and performance difference. This will be some kind
>>> of
>>> synthetic test that stresses whole scene manipulation in the order of
>>> ~100-200 scene objects.
>>>
>>> The tests will hopefully be run by the end of this week, since next
>>> week
>>> is holidays already.
>>>
>>> Jukka
>>>
>>
>> --
>>
http://groups.google.com/**group/realxtend-dev<
http://groups.google.com/group/realxtend-dev>
>>
http://wiki.realxtend.org
>>
http://dev.realxtend.org
>>