You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a necessary step towards full integration of scripts into Tw. It
will enable:
* scripts to connect to Qt events, such as Ui events
* scripts to register multiple menu items, toolbar items, hooks, ...
* scripts to call other scripts' functions, regardless of their language
Original issue reported on code.google.com by st.loeffler on 24 May 2010 at 10:29
The text was updated successfully, but these errors were encountered:
The attached patch should implement this.
Note to script authors: This patch doesn't provide any particularly useful
addition
for you yet, since there is no API yet to connect to events, etc. You can play
around, however, with the new library scripts, putting code in initialize() and
finalize() (e.g. to display messages to get a feeling for what's happening
when).
Changes:
* Allow NULL to be passed to pointers
* Handle Python "None" value (is converted to an empty/invalid QVariant)
* Make scripts thread-safer (though not necessarily totally thread-safe!); i.e.,
every script gets its own engine/thread for execution, which must be destroyed
again
afterwards
* Introduce new script type "library"; this requires that all code (except for
variable declarations, etc.) *must* be wrapped in functions; at least the
functions
"initialize" and "finalize" must be specified. Both take no arguments, and the
TW.target parameter is NULL (i.e., you can't call methods of it). The typical
use
case is that initialize() is called once when the script is first looked at by
Tw,
and should (in the future) register menu items, toolbar items, hooks etc.
finalize()
is called when Tw destroys the script, and should unregister everything that was
registered in initialize().
* The following (new) functions should be implemented/overridden in all TWScript
subclasses:
- bool initializeExecution(TWScriptAPI* tw);
Initialize a new execution environment for the script (e.g. create script engine,
register globals, etc.)
- bool executeScript(TWScriptAPI* tw);
load and run a script (except for *Execution(), this implements the old
functionality)
- void finalizeExecution() = 0;
clean up the execution environment (e.g. destroy script engine, etc.)
- bool canCallFunction(const QString functionName)
return false if the function cannot be called. If in doubt, return true
- bool callFunction(TWScriptAPI* tw, const QString functionName, QVariant & retVal,
const QList<QVariant> & arguments = QList<QVariant>())
call a function. Typically, this will involve initializeExecution();
executeScript(); SPECIFIC_CODE_TO_CALL_FUNCTION; finalizeExecution();
Original comment by st.loeffler on 24 May 2010 at 11:21
Original issue reported on code.google.com by
st.loeffler
on 24 May 2010 at 10:29The text was updated successfully, but these errors were encountered: