summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp391
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp51
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp8
-rw-r--r--src/declarative/qml/qdeclarativecomponent.h2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp30
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp18
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h6
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp18
-rw-r--r--src/declarative/qml/qdeclarativeimport_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp1
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp45
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h4
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp36
-rw-r--r--src/declarative/qml/qdeclarativevaluetypescriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp2
-rw-r--r--src/declarative/qml/qdeclarativewatcher.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp4
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp2
22 files changed, 387 insertions, 248 deletions
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 2e905b9..8230941 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -88,7 +88,7 @@ QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, Q
QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt,
QObject *parent)
-: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), str, obj, *new QDeclarativeBindingPrivate)
+: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate)
{
setParent(parent);
setNotifyOnValueChanged(true);
@@ -96,7 +96,7 @@ QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDecl
QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt,
QObject *parent)
-: QDeclarativeExpression(ctxt, str, obj, *new QDeclarativeBindingPrivate)
+: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate)
{
setParent(parent);
setNotifyOnValueChanged(true);
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index 89f1256..8769122 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -119,7 +119,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons
QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
- m_expression = new QDeclarativeExpression(ctxt, val, scope);
+ m_expression = new QDeclarativeExpression(ctxt, scope, val);
}
QDeclarativeBoundSignal::~QDeclarativeBoundSignal()
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index f55d330..ad05e80 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -64,6 +64,73 @@ DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP);
Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties);
+#ifdef __GNUC__
+# define QML_THREADED_INTERPRETER
+#endif
+
+#define FOR_EACH_QML_INSTR(F) \
+ F(Noop) /* Nop */ \
+ F(BindingId) /* id */ \
+ F(Subscribe) /* subscribe */ \
+ F(SubscribeId) /* subscribe */ \
+ F(FetchAndSubscribe) /* fetchAndSubscribe */ \
+ F(LoadId) /* load */ \
+ F(LoadScope) /* load */ \
+ F(LoadRoot) /* load */ \
+ F(LoadAttached) /* attached */ \
+ F(ConvertIntToReal) /* unaryop */ \
+ F(ConvertRealToInt) /* unaryop */ \
+ F(Real) /* real_value */ \
+ F(Int) /* int_value */ \
+ F(Bool) /* bool_value */ \
+ F(String) /* string_value */ \
+ F(AddReal) /* binaryop */ \
+ F(AddInt) /* binaryop */ \
+ F(AddString) /* binaryop */ \
+ F(MinusReal) /* binaryop */ \
+ F(MinusInt) /* binaryop */ \
+ F(CompareReal) /* binaryop */ \
+ F(CompareString) /* binaryop */ \
+ F(NotCompareReal) /* binaryop */ \
+ F(NotCompareString) /* binaryop */ \
+ F(GreaterThanReal) /* binaryop */ \
+ F(MaxReal) /* binaryop */ \
+ F(MinReal) /* binaryop */ \
+ F(NewString) /* construct */ \
+ F(NewUrl) /* construct */ \
+ F(CleanupUrl) /* cleanup */ \
+ F(CleanupString) /* cleanup */ \
+ F(Copy) /* copy */ \
+ F(Fetch) /* fetch */ \
+ F(Store) /* store */ \
+ F(Skip) /* skip */ \
+ F(Done) /* done */ \
+ /* Speculative property resolution */ \
+ F(InitString) /* initstring */ \
+ F(FindGeneric) /* find */ \
+ F(FindGenericTerminal) /* find */ \
+ F(FindProperty) /* find */ \
+ F(FindPropertyTerminal) /* find */ \
+ F(CleanupGeneric) /* cleanup */ \
+ F(ConvertGenericToReal) /* unaryop */ \
+ F(ConvertGenericToBool) /* unaryop */ \
+ F(ConvertGenericToString) /* unaryop */ \
+ F(ConvertGenericToUrl) /* unaryop */
+
+#define QML_INSTR_ENUM(I) I,
+#define QML_INSTR_ADDR(I) &&op_##I,
+
+#ifdef QML_THREADED_INTERPRETER
+# define QML_BEGIN_INSTR(I) op_##I:
+# define QML_END_INSTR(I) ++instr; goto *instr->common.code;
+# define QML_INSTR_HEADER void *code;
+#else
+# define QML_BEGIN_INSTR(I) case Instr::I:
+# define QML_END_INSTR(I) break;
+# define QML_INSTR_HEADER
+#endif
+
+
using namespace QDeclarativeJS;
namespace {
@@ -328,101 +395,45 @@ namespace {
// This structure is exactly 8-bytes in size
struct Instr {
enum {
- Noop,
- BindingId, // id
-
- Subscribe, // subscribe
- SubscribeId, // subscribe
-
- FetchAndSubscribe, // fetchAndSubscribe
-
- LoadId, // load
- LoadScope, // load
- LoadRoot, // load
- LoadAttached, // attached
-
- ConvertIntToReal, // unaryop
- ConvertRealToInt, // unaryop
-
- Real, // real_value
- Int, // int_value
- Bool, // bool_value
- String, // string_value
-
- AddReal, // binaryop
- AddInt, // binaryop
- AddString, // binaryop
-
- MinusReal, // binaryop
- MinusInt, // binaryop
-
- CompareReal, // binaryop
- CompareString, // binaryop
-
- NotCompareReal, // binaryop
- NotCompareString, // binaryop
-
- GreaterThanReal, // binaryop
- MaxReal, // binaryop
- MinReal, // binaryop
-
- NewString, // construct
- NewUrl, // construct
-
- CleanupUrl, // cleanup
- CleanupString, // cleanup
-
- Copy, // copy
- Fetch, // fetch
- Store, // store
-
- Skip, // skip
-
- Done,
-
- // Speculative property resolution
- InitString, // initstring
- FindGeneric, // find
- FindGenericTerminal, // find
- FindProperty, // find
- FindPropertyTerminal, // find
- CleanupGeneric, // cleanup
- ConvertGenericToReal, // unaryop
- ConvertGenericToBool, // unaryop
- ConvertGenericToString, // unaryop
- ConvertGenericToUrl, // unaryop
+ FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
};
union {
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[7];
} common;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing;
quint16 column;
quint32 line;
} id;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[3];
quint16 subscriptions;
quint16 identifiers;
} init;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint16 offset;
quint32 index;
} subscribe;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
quint32 index;
} load;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 reg;
@@ -430,6 +441,7 @@ struct Instr {
quint32 index;
} attached;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 reg;
@@ -437,6 +449,7 @@ struct Instr {
quint32 index;
} store;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 objectReg;
@@ -445,6 +458,7 @@ struct Instr {
quint16 function;
} fetchAndSubscribe;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 objectReg;
@@ -452,41 +466,48 @@ struct Instr {
quint32 index;
} fetch;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
qint8 src;
quint8 packing[5];
} copy;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[6];
} construct;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
float value;
} real_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
int value;
} int_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
bool value;
quint8 packing[5];
} bool_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint16 length;
quint32 offset;
} string_value;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 src1;
@@ -494,18 +515,21 @@ struct Instr {
quint8 packing[4];
} binaryop;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 output;
qint8 src;
quint8 packing[5];
} unaryop;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[2];
quint32 count;
} skip;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
qint8 src;
@@ -514,11 +538,13 @@ struct Instr {
quint16 subscribeIndex;
} find;
struct {
+ QML_INSTR_HEADER
quint8 type;
qint8 reg;
quint8 packing[6];
} cleanup;
struct {
+ QML_INSTR_HEADER
quint8 type;
quint8 packing[1];
quint16 offset;
@@ -535,7 +561,7 @@ struct Program {
quint16 subscriptions;
quint16 identifiers;
quint16 instructionCount;
- quint16 dummy;
+ quint16 compiled;
const char *data() const { return ((const char *)this) + sizeof(Program); }
const Instr *instructions() const { return (const Instr *)(data() + dataLength); }
@@ -1097,35 +1123,57 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
instr += instrIndex;
const char *data = program->data();
+#ifdef QML_THREADED_INTERPRETER
+ static void *decode_instr[] = {
+ FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
+ };
+
+ if (!program->compiled) {
+ program->compiled = true;
+ const Instr *inop = program->instructions();
+ for (int i = 0; i < program->instructionCount; ++i) {
+ Instr *op = (Instr *) inop++;
+ op->common.code = decode_instr[op->common.type];
+ }
+ }
+
+ goto *instr->common.code;
+#else
// return;
+
#ifdef COMPILEDBINDINGS_DEBUG
qWarning().nospace() << "Begin binding run";
#endif
while (instr) {
+ switch (instr->common.type) {
+
#ifdef COMPILEDBINDINGS_DEBUG
dumpInstruction(instr);
#endif
- switch (instr->common.type) {
- case Instr::Noop:
- case Instr::BindingId:
- break;
+#endif
- case Instr::SubscribeId:
+ QML_BEGIN_INSTR(Noop)
+ QML_END_INSTR(Noop)
+
+ QML_BEGIN_INSTR(BindingId)
+ QML_END_INSTR(BindingId)
+
+ QML_BEGIN_INSTR(SubscribeId)
subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
- break;
+ QML_END_INSTR(SubscribeId)
- case Instr::Subscribe:
+ QML_BEGIN_INSTR(Subscribe)
{
QObject *o = 0;
const Register &object = registers[instr->subscribe.reg];
if (!object.isUndefined()) o = object.getQObject();
subscribe(o, instr->subscribe.index, instr->subscribe.offset);
}
- break;
+ QML_END_INSTR(Subscribe)
- case Instr::FetchAndSubscribe:
+ QML_BEGIN_INSTR(FetchAndSubscribe)
{
const Register &input = registers[instr->fetchAndSubscribe.objectReg];
Register &output = registers[instr->fetchAndSubscribe.output];
@@ -1149,21 +1197,21 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub);
}
}
- break;
+ QML_END_INSTR(FetchAndSubscribe)
- case Instr::LoadId:
+ QML_BEGIN_INSTR(LoadId)
registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
- break;
+ QML_END_INSTR(LoadId)
- case Instr::LoadScope:
+ QML_BEGIN_INSTR(LoadScope)
registers[instr->load.reg].setQObject(scope);
- break;
+ QML_END_INSTR(LoadScope)
- case Instr::LoadRoot:
+ QML_BEGIN_INSTR(LoadRoot)
registers[instr->load.reg].setQObject(context->contextObject);
- break;
+ QML_END_INSTR(LoadRoot)
- case Instr::LoadAttached:
+ QML_BEGIN_INSTR(LoadAttached)
{
const Register &input = registers[instr->attached.reg];
Register &output = registers[instr->attached.output];
@@ -1184,48 +1232,48 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setQObject(attached);
}
}
- break;
+ QML_END_INSTR(LoadAttached)
- case Instr::ConvertIntToReal:
+ QML_BEGIN_INSTR(ConvertIntToReal)
{
const Register &input = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
if (input.isUndefined()) output.setUndefined();
else output.setqreal(qreal(input.getint()));
}
- break;
+ QML_END_INSTR(ConvertIntToReal)
- case Instr::ConvertRealToInt:
+ QML_BEGIN_INSTR(ConvertRealToInt)
{
const Register &input = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
if (input.isUndefined()) output.setUndefined();
- else output.setint(int(input.getqreal()));
+ else output.setint(qRound(input.getqreal()));
}
- break;
+ QML_END_INSTR(ConvertRealToInt)
- case Instr::Real:
+ QML_BEGIN_INSTR(Real)
registers[instr->real_value.reg].setqreal(instr->real_value.value);
- break;
+ QML_END_INSTR(Real)
- case Instr::Int:
+ QML_BEGIN_INSTR(Int)
registers[instr->int_value.reg].setint(instr->int_value.value);
- break;
+ QML_END_INSTR(Int)
- case Instr::Bool:
+ QML_BEGIN_INSTR(Bool)
registers[instr->bool_value.reg].setbool(instr->bool_value.value);
- break;
+ QML_END_INSTR(Bool)
- case Instr::String:
+ QML_BEGIN_INSTR(String)
{
Register &output = registers[instr->string_value.reg];
new (output.getstringptr())
QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
output.settype(QMetaType::QString);
}
- break;
+ QML_END_INSTR(String)
- case Instr::AddReal:
+ QML_BEGIN_INSTR(AddReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1233,9 +1281,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(lhs.getqreal() + rhs.getqreal());
}
- break;
+ QML_END_INSTR(AddReal)
- case Instr::AddInt:
+ QML_BEGIN_INSTR(AddInt)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1243,9 +1291,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setint(lhs.getint() + rhs.getint());
}
- break;
+ QML_END_INSTR(AddInt)
- case Instr::AddString:
+ QML_BEGIN_INSTR(AddString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1265,9 +1313,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.settype(QMetaType::QString);
}
}
- break;
+ QML_END_INSTR(AddString)
- case Instr::MinusReal:
+ QML_BEGIN_INSTR(MinusReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1275,9 +1323,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(lhs.getqreal() - rhs.getqreal());
}
- break;
+ QML_END_INSTR(MinusReal)
- case Instr::MinusInt:
+ QML_BEGIN_INSTR(MinusInt)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1285,9 +1333,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setint(lhs.getint() - rhs.getint());
}
- break;
+ QML_END_INSTR(MinusInt)
- case Instr::CompareReal:
+ QML_BEGIN_INSTR(CompareReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1295,9 +1343,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
else output.setbool(lhs.getqreal() == rhs.getqreal());
}
- break;
+ QML_END_INSTR(CompareReal)
- case Instr::CompareString:
+ QML_BEGIN_INSTR(CompareString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1305,9 +1353,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
}
- break;
+ QML_END_INSTR(CompareString)
- case Instr::NotCompareReal:
+ QML_BEGIN_INSTR(NotCompareReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1315,9 +1363,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
else output.setbool(lhs.getqreal() != rhs.getqreal());
}
- break;
+ QML_END_INSTR(NotCompareReal)
- case Instr::NotCompareString:
+ QML_BEGIN_INSTR(NotCompareString)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1325,9 +1373,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
}
- break;
+ QML_END_INSTR(NotCompareString)
- case Instr::GreaterThanReal:
+ QML_BEGIN_INSTR(GreaterThanReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1335,9 +1383,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false);
else output.setbool(lhs.getqreal() > rhs.getqreal());
}
- break;
+ QML_END_INSTR(GreaterThanReal)
- case Instr::MaxReal:
+ QML_BEGIN_INSTR(MaxReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1345,9 +1393,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal()));
}
- break;
+ QML_END_INSTR(MaxReal)
- case Instr::MinReal:
+ QML_BEGIN_INSTR(MinReal)
{
const Register &lhs = registers[instr->binaryop.src1];
const Register &rhs = registers[instr->binaryop.src2];
@@ -1355,33 +1403,33 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal()));
}
- break;
+ QML_END_INSTR(MinReal)
- case Instr::NewString:
+ QML_BEGIN_INSTR(NewString)
{
Register &output = registers[instr->construct.reg];
new (output.getstringptr()) QString;
output.settype(QMetaType::QString);
}
- break;
+ QML_END_INSTR(NewString)
- case Instr::NewUrl:
+ QML_BEGIN_INSTR(NewUrl)
{
Register &output = registers[instr->construct.reg];
new (output.geturlptr()) QUrl;
output.settype(QMetaType::QUrl);
}
- break;
+ QML_END_INSTR(NewUrl)
- case Instr::CleanupString:
+ QML_BEGIN_INSTR(CleanupString)
registers[instr->cleanup.reg].getstringptr()->~QString();
- break;
+ QML_END_INSTR(CleanupString)
- case Instr::CleanupUrl:
+ QML_BEGIN_INSTR(CleanupUrl)
registers[instr->cleanup.reg].geturlptr()->~QUrl();
- break;
+ QML_END_INSTR(CleanupUrl)
- case Instr::Fetch:
+ QML_BEGIN_INSTR(Fetch)
{
const Register &input = registers[instr->fetch.objectReg];
Register &output = registers[instr->fetch.output];
@@ -1399,9 +1447,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
}
}
- break;
+ QML_END_INSTR(Fetch)
- case Instr::Store:
+ QML_BEGIN_INSTR(Store)
{
Register &data = registers[instr->store.reg];
if (data.isUndefined()) {
@@ -1415,21 +1463,22 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
QMetaObject::metacall(output, QMetaObject::WriteProperty,
instr->store.index, argv);
}
- break;
+ QML_END_INSTR(Store)
- case Instr::Copy:
+ QML_BEGIN_INSTR(Copy)
registers[instr->copy.reg] = registers[instr->copy.src];
- break;
+ QML_END_INSTR(Copy)
- case Instr::Skip:
+ QML_BEGIN_INSTR(Skip)
if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
instr += instr->skip.count;
- break;
+ QML_END_INSTR(Skip)
- case Instr::Done:
+ QML_BEGIN_INSTR(Done)
return;
+ QML_END_INSTR(Done)
- case Instr::InitString:
+ QML_BEGIN_INSTR(InitString)
if (!identifiers[instr->initstring.offset].identifier) {
quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
@@ -1438,10 +1487,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
}
- break;
+ QML_END_INSTR(InitString)
- case Instr::FindGenericTerminal:
- case Instr::FindGeneric:
+ QML_BEGIN_INSTR(FindGenericTerminal)
// We start the search in the parent context, as we know that the
// name is not present in the current context or it would have been
// found during the static compile
@@ -1449,10 +1497,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
context->parent,
identifiers[instr->find.name].identifier,
instr->common.type == Instr::FindGenericTerminal);
- break;
+ QML_END_INSTR(FindGenericTerminal)
- case Instr::FindPropertyTerminal:
- case Instr::FindProperty:
+ QML_BEGIN_INSTR(FindGeneric)
+ // We start the search in the parent context, as we know that the
+ // name is not present in the current context or it would have been
+ // found during the static compile
+ findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
+ context->parent,
+ identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindGenericTerminal);
+ QML_END_INSTR(FindGeneric)
+
+ QML_BEGIN_INSTR(FindPropertyTerminal)
{
const Register &object = registers[instr->find.src];
if (object.isUndefined()) {
@@ -1465,9 +1522,24 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
instr->common.type == Instr::FindPropertyTerminal);
}
- break;
+ QML_END_INSTR(FindPropertyTerminal)
- case Instr::CleanupGeneric:
+ QML_BEGIN_INSTR(FindProperty)
+ {
+ const Register &object = registers[instr->find.src];
+ if (object.isUndefined()) {
+ throwException(instr->find.exceptionId, error, program, context);
+ return;
+ }
+
+ findproperty(object.getQObject(), registers + instr->find.reg,
+ QDeclarativeEnginePrivate::get(context->engine),
+ instr->find.subscribeIndex, identifiers[instr->find.name].identifier,
+ instr->common.type == Instr::FindPropertyTerminal);
+ }
+ QML_END_INSTR(FindProperty)
+
+ QML_BEGIN_INSTR(CleanupGeneric)
{
int type = registers[instr->cleanup.reg].gettype();
if (type == qMetaTypeId<QVariant>()) {
@@ -1478,9 +1550,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
registers[instr->cleanup.reg].geturlptr()->~QUrl();
}
}
- break;
+ QML_END_INSTR(CleanupGeneric)
- case Instr::ConvertGenericToReal:
+ QML_BEGIN_INSTR(ConvertGenericToReal)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1488,9 +1560,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setqreal(toReal(&input, input.gettype(), &ok));
if (!ok) output.setUndefined();
}
- break;
+ QML_END_INSTR(ConvertGenericToReal)
- case Instr::ConvertGenericToBool:
+ QML_BEGIN_INSTR(ConvertGenericToBool)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1498,9 +1570,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
output.setbool(toBool(&input, input.gettype(), &ok));
if (!ok) output.setUndefined();
}
- break;
+ QML_END_INSTR(ConvertGenericToBool)
- case Instr::ConvertGenericToString:
+ QML_BEGIN_INSTR(ConvertGenericToString)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1509,9 +1581,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); }
else { output.setUndefined(); }
}
- break;
+ QML_END_INSTR(ConvertGenericToString)
- case Instr::ConvertGenericToUrl:
+ QML_BEGIN_INSTR(ConvertGenericToUrl)
{
Register &output = registers[instr->unaryop.output];
Register &input = registers[instr->unaryop.src];
@@ -1520,15 +1592,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); }
else { output.setUndefined(); }
}
- break;
+ QML_END_INSTR(ConvertGenericToUrl)
+#ifdef QML_THREADED_INTERPRETER
+ // nothing to do
+#else
default:
qFatal("EEK");
break;
- }
+ } // switch
- instr++;
- }
+ ++instr;
+ } // while
+#endif
}
void QDeclarativeBindingCompiler::dump(const QByteArray &programData)
@@ -2781,6 +2857,7 @@ QByteArray QDeclarativeBindingCompiler::program() const
prog.subscriptions = d->committed.subscriptionIds.count();
prog.identifiers = d->committed.registeredStrings.count();
prog.instructionCount = bytecode.count();
+ prog.compiled = false;
int size = sizeof(Program) + bytecode.count() * sizeof(Instr);
size += prog.dataLength;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index a43b9ac..b5bf972 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -180,7 +180,7 @@ bool QDeclarativeCompiler::isSignalPropertyName(const QByteArray &name)
bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
QDeclarativeParser::Value *v)
{
- QString string = v->value.asScript();
+ QString string = v->value.asString();
if (!prop.isWritable())
COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
@@ -207,31 +207,31 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::UInt:
{
- bool ok;
- string.toUInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(uint(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
}
break;
case QVariant::Int:
{
- bool ok;
- string.toInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(int(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
}
break;
case QMetaType::Float:
- {
- bool ok;
- string.toFloat(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
- }
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
break;
case QVariant::Double:
- {
- bool ok;
- string.toDouble(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
- }
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
break;
case QVariant::Color:
{
@@ -319,7 +319,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
QDeclarativeParser::Value *v)
{
- QString string = v->value.asScript();
+ QString string = v->value.asString();
QDeclarativeInstruction instr;
instr.line = v->location.start.line;
@@ -382,28 +382,28 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
{
instr.type = QDeclarativeInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toUInt();
+ instr.storeInteger.value = uint(v->value.asNumber());
}
break;
case QVariant::Int:
{
instr.type = QDeclarativeInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toInt();
+ instr.storeInteger.value = int(v->value.asNumber());
}
break;
case QMetaType::Float:
{
instr.type = QDeclarativeInstruction::StoreFloat;
instr.storeFloat.propertyIndex = prop.propertyIndex();
- instr.storeFloat.value = string.toFloat();
+ instr.storeFloat.value = float(v->value.asNumber());
}
break;
case QVariant::Double:
{
instr.type = QDeclarativeInstruction::StoreDouble;
instr.storeDouble.propertyIndex = prop.propertyIndex();
- instr.storeDouble.value = string.toDouble();
+ instr.storeDouble.value = v->value.asNumber();
}
break;
case QVariant::Color:
@@ -1187,7 +1187,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (idProp) {
if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
COMPILE_EXCEPTION(idProp, tr("Invalid component id specification"));
- COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()))
QString idVal = idProp->values.first()->primitive();
@@ -1316,6 +1316,9 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
} else {
prop->values.at(0)->type = Value::SignalExpression;
+ if (!prop->values.at(0)->value.isScript())
+ COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)"));
+
QString script = prop->values.at(0)->value.asScript().trimmed();
if (script.isEmpty())
COMPILE_EXCEPTION(prop, tr("Empty signal assignment"));
@@ -1893,7 +1896,7 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert
if (prop->values.count() > 1)
COMPILE_EXCEPTION(prop->values.at(1), tr( "Cannot assign multiple values to a script property"));
- if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript())
+ if (prop->values.at(0)->object)
COMPILE_EXCEPTION(prop->values.at(0), tr( "Invalid property assignment: script expected"));
obj->addScriptStringProperty(prop, ctxt.stack);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index e757675..3f11425 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -246,7 +246,7 @@ QDeclarativeComponent::~QDeclarativeComponent()
\o Component.Ready - the component has been loaded, and can be used to create instances.
\o Component.Loading - the component is currently being loaded
\o Component.Error - an error occurred while loading the component.
- Calling errorsString() will provide a human-readable description of any errors.
+ Calling errorString() will provide a human-readable description of any errors.
\endlist
*/
@@ -492,7 +492,7 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const
}
/*!
- \qmlmethod string Component::errorsString()
+ \qmlmethod string Component::errorString()
Returns a human-readable description of any errors.
@@ -504,9 +504,9 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const
/*!
\internal
- errorsString is only meant as a way to get the errors in script
+ errorString is only meant as a way to get the errors in script
*/
-QString QDeclarativeComponent::errorsString() const
+QString QDeclarativeComponent::errorString() const
{
Q_D(const QDeclarativeComponent);
QString ret;
diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h
index 688e233..1d1fca7 100644
--- a/src/declarative/qml/qdeclarativecomponent.h
+++ b/src/declarative/qml/qdeclarativecomponent.h
@@ -86,7 +86,7 @@ public:
bool isLoading() const;
QList<QDeclarativeError> errors() const;
- Q_INVOKABLE QString errorsString() const;
+ Q_INVOKABLE QString errorString() const;
qreal progress() const;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 79f8a17..0a75532 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1024,14 +1024,14 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
foreach (const QDeclarativeError &error, errors){
errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n");
QScriptValue qmlErrObject = ctxt->engine()->newObject();
- qmlErrObject.setProperty("lineNumber", QScriptValue(error.line()));
- qmlErrObject.setProperty("columnNumber", QScriptValue(error.column()));
- qmlErrObject.setProperty("fileName", QScriptValue(error.url().toString()));
- qmlErrObject.setProperty("message", QScriptValue(error.description()));
+ qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line()));
+ qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column()));
+ qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString()));
+ qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description()));
arr.setProperty(i++, qmlErrObject);
}
QScriptValue err = ctxt->throwError(errstr);
- err.setProperty("qmlErrors",arr);
+ err.setProperty(QLatin1String("qmlErrors"),arr);
return err;
}
@@ -1051,14 +1051,14 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
foreach (const QDeclarativeError &error, errors){
errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n");
QScriptValue qmlErrObject = ctxt->engine()->newObject();
- qmlErrObject.setProperty("lineNumber", QScriptValue(error.line()));
- qmlErrObject.setProperty("columnNumber", QScriptValue(error.column()));
- qmlErrObject.setProperty("fileName", QScriptValue(error.url().toString()));
- qmlErrObject.setProperty("message", QScriptValue(error.description()));
+ qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line()));
+ qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column()));
+ qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString()));
+ qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description()));
arr.setProperty(i++, qmlErrObject);
}
QScriptValue err = ctxt->throwError(errstr);
- err.setProperty("qmlErrors",arr);
+ err.setProperty(QLatin1String("qmlErrors"),arr);
return err;
}
@@ -1550,8 +1550,9 @@ void QDeclarativeEngine::addImportPath(const QString& path)
provided by that module. A \c qmldir file is required for defining the
type version mapping and possibly declarative extensions plugins.
- By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment
- variable, then the builtin \c ImportsPath from QLibraryInfo.
+ By default, the list contains the directory of the application executable,
+ paths specified in the \c QML_IMPORT_PATH environment variable,
+ and the builtin \c ImportsPath from QLibraryInfo.
\sa addImportPath() setImportPathList()
*/
@@ -1565,8 +1566,9 @@ QStringList QDeclarativeEngine::importPathList() const
Sets \a paths as the list of directories where the engine searches for
installed modules in a URL-based directory structure.
- By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment
- variable, then the builtin \c ImportsPath from QLibraryInfo.
+ By default, the list contains the directory of the application executable,
+ paths specified in the \c QML_IMPORT_PATH environment variable,
+ and the builtin \c ImportsPath from QLibraryInfo.
\sa importPathList() addImportPath()
*/
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 69e42f8..7ae0050 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -414,7 +414,7 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QDeclarativeContext *context = qmlContext(object);
QVariant result;
if (object && context) {
- QDeclarativeExpression exprObj(context, expr, object);
+ QDeclarativeExpression exprObj(context, object, expr);
bool undefined = false;
QVariant value = exprObj.evaluate(&undefined);
if (undefined)
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 5ceb918..b1aecfa 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -241,15 +241,17 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, vo
}
/*!
- Create a QDeclarativeExpression object.
+ Create a QDeclarativeExpression object that is a child of \a parent.
The \a expression JavaScript will be executed in the \a ctxt QDeclarativeContext.
If specified, the \a scope object's properties will also be in scope during
the expression's execution.
*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const QString &expression,
- QObject *scope)
-: QObject(*new QDeclarativeExpressionPrivate, 0)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt,
+ QObject *scope,
+ const QString &expression,
+ QObject *parent)
+: QObject(*new QDeclarativeExpressionPrivate, parent)
{
Q_D(QDeclarativeExpression);
d->init(QDeclarativeContextData::get(ctxt), expression, scope);
@@ -258,8 +260,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const
/*!
\internal
*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression,
- QObject *scope)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
+ const QString &expression)
: QObject(*new QDeclarativeExpressionPrivate, 0)
{
Q_D(QDeclarativeExpression);
@@ -267,8 +269,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, co
}
/*! \internal */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression,
- QObject *scope, QDeclarativeExpressionPrivate &dd)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
+ const QString &expression, QDeclarativeExpressionPrivate &dd)
: QObject(dd, 0)
{
Q_D(QDeclarativeExpression);
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
index 6c72e4d..a8c86da 100644
--- a/src/declarative/qml/qdeclarativeexpression.h
+++ b/src/declarative/qml/qdeclarativeexpression.h
@@ -64,7 +64,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject
Q_OBJECT
public:
QDeclarativeExpression();
- QDeclarativeExpression(QDeclarativeContext *, const QString &, QObject *);
+ QDeclarativeExpression(QDeclarativeContext *, QObject *, const QString &, QObject * = 0);
virtual ~QDeclarativeExpression();
QDeclarativeEngine *engine() const;
@@ -92,13 +92,13 @@ Q_SIGNALS:
void valueChanged();
protected:
- QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *,
+ QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &,
QDeclarativeExpressionPrivate &dd);
QDeclarativeExpression(QDeclarativeContextData *, void *, QDeclarativeRefCount *rc,
QObject *me, const QString &, int, QDeclarativeExpressionPrivate &dd);
private:
- QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *);
+ QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &);
Q_DISABLE_COPY(QDeclarativeExpression)
Q_DECLARE_PRIVATE(QDeclarativeExpression)
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 576e048..0c87671 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -576,9 +576,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
{
filePluginPath << QLatin1String(".");
- QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
- if (!builtinPath.isEmpty())
- addImportPath(builtinPath);
+ // Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath
+
+ addImportPath(QLibraryInfo::location(QLibraryInfo::ImportsPath));
// env import paths
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
@@ -592,6 +592,8 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
for (int ii = paths.count() - 1; ii >= 0; --ii)
addImportPath(paths.at(ii));
}
+
+ addImportPath(QCoreApplication::applicationDirPath());
}
QDeclarativeImportDatabase::~QDeclarativeImportDatabase()
@@ -676,11 +678,11 @@ bool QDeclarativeImportDatabase::resolveType(const QDeclarativeImports& imports,
If either return pointer is 0, the corresponding search is not done.
*/
-void QDeclarativeImportDatabase::resolveTypeInNamespace(QDeclarativeImportedNamespace* ns, const QByteArray& type,
+bool QDeclarativeImportDatabase::resolveTypeInNamespace(QDeclarativeImportedNamespace* ns, const QByteArray& type,
QDeclarativeType** type_return, QUrl* url_return,
int *vmaj, int *vmin) const
{
- ns->find(type,vmaj,vmin,type_return,url_return);
+ return ns->find(type,vmaj,vmin,type_return,url_return);
}
/*!
@@ -843,6 +845,9 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path)
if (qmlImportTrace())
qDebug() << "QDeclarativeImportDatabase::addImportPath" << path;
+ if (path.isEmpty())
+ return;
+
QUrl url = QUrl(path);
QString cPath;
@@ -853,7 +858,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path)
cPath = path;
}
- if (!fileImportPath.contains(cPath))
+ if (!cPath.isEmpty()
+ && !fileImportPath.contains(cPath))
fileImportPath.prepend(cPath);
}
diff --git a/src/declarative/qml/qdeclarativeimport_p.h b/src/declarative/qml/qdeclarativeimport_p.h
index 62b0517..88246d4 100644
--- a/src/declarative/qml/qdeclarativeimport_p.h
+++ b/src/declarative/qml/qdeclarativeimport_p.h
@@ -112,7 +112,7 @@ public:
int *version_major, int *version_minor,
QDeclarativeImportedNamespace** ns_return,
QString *errorString = 0) const;
- void resolveTypeInNamespace(QDeclarativeImportedNamespace*, const QByteArray& type,
+ bool resolveTypeInNamespace(QDeclarativeImportedNamespace*, const QByteArray& type,
QDeclarativeType** type_return, QUrl* url_return,
int *version_major, int *version_minor ) const;
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index 619264a..e37b68b 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -140,6 +140,7 @@ void QDeclarativeInclude::finished()
scriptContext->pushScope(m_scope[1]);
scriptContext->setActivationObject(m_scope[1]);
+ QDeclarativeScriptParser::extractPragmas(code);
m_scriptEngine->evaluate(code, urlString, 1);
@@ -230,6 +231,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e
QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5);
scriptContext->pushScope(scope);
scriptContext->setActivationObject(scope);
+ QDeclarativeScriptParser::extractPragmas(code);
engine->evaluate(code, urlString, 1);
@@ -291,6 +293,7 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn
QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -4);
scriptContext->pushScope(scope);
scriptContext->setActivationObject(scope);
+ QDeclarativeScriptParser::extractPragmas(code);
engine->evaluate(code, urlString, 1);
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index 0236950..b86d082 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -60,6 +60,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
break;
case QDeclarativeInstruction::CreateObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
+ break;
case QDeclarativeInstruction::CreateSimpleObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize;
break;
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index b38bd76..8d00ef8 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -57,6 +57,7 @@
#include <QPointF>
#include <QSizeF>
#include <QRectF>
+#include <QStringBuilder>
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -310,6 +311,49 @@ double QDeclarativeParser::Variant::asNumber() const
return d;
}
+//reverse of Lexer::singleEscape()
+QString escapedString(const QString &string)
+{
+ QString tmp = QLatin1String("\"");
+ for (int i = 0; i < string.length(); ++i) {
+ const QChar &c = string.at(i);
+ switch(c.unicode()) {
+ case 0x08:
+ tmp += QLatin1String("\\b");
+ break;
+ case 0x09:
+ tmp += QLatin1String("\\t");
+ break;
+ case 0x0A:
+ tmp += QLatin1String("\\n");
+ break;
+ case 0x0B:
+ tmp += QLatin1String("\\v");
+ break;
+ case 0x0C:
+ tmp += QLatin1String("\\f");
+ break;
+ case 0x0D:
+ tmp += QLatin1String("\\r");
+ break;
+ case 0x22:
+ tmp += QLatin1String("\\\"");
+ break;
+ case 0x27:
+ tmp += QLatin1String("\\\'");
+ break;
+ case 0x5C:
+ tmp += QLatin1String("\\\\");
+ break;
+ default:
+ tmp += c;
+ break;
+ }
+ }
+ tmp += QLatin1Char('\"');
+ return tmp;
+}
+
QString QDeclarativeParser::Variant::asScript() const
{
switch(type()) {
@@ -324,6 +368,7 @@ QString QDeclarativeParser::Variant::asScript() const
else
return s;
case String:
+ return escapedString(s);
case Script:
return s;
}
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index 25777f5..d192f3a 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -307,8 +307,8 @@ namespace QDeclarativeParser
};
Type type;
- // ### Temporary
- QString primitive() const { return value.asScript(); }
+ // ### Temporary (for id only)
+ QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
// Primitive value
Variant value;
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index 3881d0a..071dd07 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -1049,26 +1049,24 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope
} else {
Q_ASSERT(variantType != propertyType);
- QVariant v = value;
- if (v.convert((QVariant::Type)propertyType)) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
- } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
- QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType);
- if (!con)
- return false;
-
- QVariant v = con(value.toString());
- if (v.userType() == propertyType) {
- void *a[] = { (void *)v.constData(), 0, &status, &flags};
- QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
+ bool ok = false;
+ QVariant v;
+ if (variantType == QVariant::String)
+ v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok);
+ if (!ok) {
+ v = value;
+ if (v.convert((QVariant::Type)propertyType)) {
+ ok = true;
+ } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
+ QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType);
+ if (con) {
+ v = con(value.toString());
+ if (v.userType() == propertyType)
+ ok = true;
+ }
}
- } else if (variantType == QVariant::String) {
- bool ok = false;
- QVariant v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok);
- if (!ok)
- return false;
-
+ }
+ if (ok) {
void *a[] = { (void *)v.constData(), 0, &status, &flags};
QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a);
} else {
diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
index cb1f27d..f06d6ae 100644
--- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp
@@ -168,6 +168,8 @@ void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier
ref->type->read(ref->object, ref->property);
QMetaProperty p = ref->type->metaObject()->property(m_lastIndex);
+ if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::QReal)
+ v = v.toInt();
p.write(ref->type, v);
ref->type->write(ref->object, ref->property, 0);
} else {
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 8ba79a6..3247f85 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -627,7 +627,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
- new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context);
+ new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value));
expr->setSourceLocation(comp->name, instr.line);
bs->setExpression(expr);
}
diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp
index 842b3c4..da1419f 100644
--- a/src/declarative/qml/qdeclarativewatcher.cpp
+++ b/src/declarative/qml/qdeclarativewatcher.cpp
@@ -153,7 +153,7 @@ bool QDeclarativeWatcher::addWatch(int id, quint32 objectId, const QString &expr
QObject *object = QDeclarativeDebugService::objectForId(objectId);
QDeclarativeContext *context = qmlContext(object);
if (context) {
- QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, expr, object);
+ QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, object, expr);
exprObj->setNotifyOnValueChanged(true);
QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, exprObj, objectId, this);
exprObj->setParent(proxy);
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 4b687a9..8182998 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -527,7 +527,7 @@ void QDeclarativeWorkerScriptEngine::run()
\snippet doc/src/snippets/declarative/workerscript.qml 0
The above worker script specifies a javascript file, "script.js", that handles
- the operations to be performed in the new thread:
+ the operations to be performed in the new thread. Here is \c script.js:
\qml
WorkerScript.onMessage = function(message) {
@@ -538,7 +538,7 @@ void QDeclarativeWorkerScriptEngine::run()
When the user clicks anywhere within the rectangle, \c sendMessage() is
called, triggering the \tt WorkerScript.onMessage() handler in
- \tt source.js. This in turn sends a reply message that is then received
+ \tt script.js. This in turn sends a reply message that is then received
by the \tt onMessage() handler of \tt myWorker.
*/
QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 80510f8..acd1f51 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -995,7 +995,7 @@ private:
int m_status;
QString m_statusText;
QNetworkRequest m_request;
- QNetworkReply *m_network;
+ QDeclarativeGuard<QNetworkReply> m_network;
void destroyNetwork();
QNetworkAccessManager *m_nam;