Description
I have only tested this in the 4.6 beta for mac.
in QT 4.5, in the following code:
val=engine.evaluate("function()
val would equal a QScriptValue containing the function. This is not the case in qt 4.6 beta. Instead it now throws a syntax error. There does not seem to be a way to get a function returned from evaluate.
test case:
#include <QtCore/QCoreApplication>
#include <QScriptEngine>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QScriptEngine engine;
QScriptValue val;
val=engine.evaluate("return true;");
qDebug() << val.toString();
val=engine.evaluate("function(){return true}
");
qDebug() << val.toString();
val=engine.evaluate("var myfunc=function()
qDebug() << val.toString();
val=engine.evaluate("var myfunc=function(){return true}
;return myfunc;");
qDebug() << val.toString();
val=engine.evaluate("2+2");
qDebug() << val.toString();
return a.exec();
}
The output I receive:
"SyntaxError: Invalid return statement."
"SyntaxError: Parse error"
"undefined"
"SyntaxError: Invalid return statement."
"4"