aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/ftw/qhashedstring.cpp131
-rw-r--r--src/qml/qml/qml.pri2
-rw-r--r--src/qml/qml/qqml.h18
-rw-r--r--src/qml/qml/qqmlabstractbinding.cpp3
-rw-r--r--src/qml/qml/qqmlabstracturlinterceptor.cpp3
-rw-r--r--src/qml/qml/qqmlabstracturlinterceptor_p.h (renamed from src/qml/qml/qqmlabstracturlinterceptor.h)4
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp2
-rw-r--r--src/qml/qml/qqmlbinding.cpp10
-rw-r--r--src/qml/qml/qqmlbinding_p.h8
-rw-r--r--src/qml/qml/qqmlcompiler.cpp90
-rw-r--r--src/qml/qml/qqmlcompiler_p.h12
-rw-r--r--src/qml/qml/qqmlcomponent.cpp64
-rw-r--r--src/qml/qml/qqmlcontext.cpp2
-rw-r--r--src/qml/qml/qqmlcontext_p.h2
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp137
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h25
-rw-r--r--src/qml/qml/qqmldata_p.h5
-rw-r--r--src/qml/qml/qqmldirparser.cpp18
-rw-r--r--src/qml/qml/qqmlengine.cpp26
-rw-r--r--src/qml/qml/qqmlengine_p.h15
-rw-r--r--src/qml/qml/qqmlfileselector.cpp69
-rw-r--r--src/qml/qml/qqmlfileselector.h12
-rw-r--r--src/qml/qml/qqmlfileselector_p.h14
-rw-r--r--src/qml/qml/qqmlimport.cpp11
-rw-r--r--src/qml/qml/qqmlinstruction_p.h11
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp52
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h13
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp6
-rw-r--r--src/qml/qml/qqmllocale.cpp176
-rw-r--r--src/qml/qml/qqmllocale_p.h22
-rw-r--r--src/qml/qml/qqmlmetatype.cpp8
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp27
-rw-r--r--src/qml/qml/qqmlproperty.cpp2
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp2
-rw-r--r--src/qml/qml/qqmlscript.cpp10
-rw-r--r--src/qml/qml/qqmlscript_p.h3
-rw-r--r--src/qml/qml/qqmltypeloader.cpp70
-rw-r--r--src/qml/qml/qqmltypeloader_p.h2
-rw-r--r--src/qml/qml/qqmltypenamecache.cpp2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp30
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h5
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp22
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvme.cpp14
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp21
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp265
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp154
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h106
-rw-r--r--src/qml/qml/v8/qv4domerrors_p.h2
-rw-r--r--src/qml/qml/v8/qv8engine.cpp9
-rw-r--r--src/qml/qml/v8/qv8engine_p.h4
52 files changed, 984 insertions, 741 deletions
diff --git a/src/qml/qml/ftw/qhashedstring.cpp b/src/qml/qml/ftw/qhashedstring.cpp
index 40caaf379f..321e6ccb41 100644
--- a/src/qml/qml/ftw/qhashedstring.cpp
+++ b/src/qml/qml/ftw/qhashedstring.cpp
@@ -209,137 +209,6 @@ static inline bool isUnicodeNonCharacter(uint ucs4)
|| (ucs4 - 0xfdd0U) < 16;
}
-static int utf8LengthFromUtf16(const QChar *uc, int len)
-{
- int length = 0;
-
- int surrogate_high = -1;
-
- const QChar *ch = uc;
- int invalid = 0;
-
- const QChar *end = ch + len;
- while (ch < end) {
- uint u = ch->unicode();
- if (surrogate_high >= 0) {
- if (u >= 0xdc00 && u < 0xe000) {
- u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
- surrogate_high = -1;
- } else {
- // high surrogate without low
- ++ch;
- ++invalid;
- surrogate_high = -1;
- continue;
- }
- } else if (u >= 0xdc00 && u < 0xe000) {
- // low surrogate without high
- ++ch;
- ++invalid;
- continue;
- } else if (u >= 0xd800 && u < 0xdc00) {
- surrogate_high = u;
- ++ch;
- continue;
- }
-
- if (u < 0x80) {
- ++length;
- } else {
- if (u < 0x0800) {
- ++length;
- } else {
- // is it one of the Unicode non-characters?
- if (isUnicodeNonCharacter(u)) {
- ++length;
- ++ch;
- ++invalid;
- continue;
- }
-
- if (u > 0xffff) {
- ++length;
- ++length;
- } else {
- ++length;
- }
- ++length;
- }
- ++length;
- }
- ++ch;
- }
-
- return length;
-}
-
-// Writes the utf8 version of uc to output. uc is of length len.
-// There must be at least utf8LengthFromUtf16(uc, len) bytes in output.
-// A null terminator is not written.
-static void utf8FromUtf16(char *output, const QChar *uc, int len)
-{
- uchar replacement = '?';
- int surrogate_high = -1;
-
- uchar* cursor = (uchar*)output;
- const QChar *ch = uc;
- int invalid = 0;
-
- const QChar *end = ch + len;
- while (ch < end) {
- uint u = ch->unicode();
- if (surrogate_high >= 0) {
- if (u >= 0xdc00 && u < 0xe000) {
- u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
- surrogate_high = -1;
- } else {
- // high surrogate without low
- *cursor = replacement;
- ++ch;
- ++invalid;
- surrogate_high = -1;
- continue;
- }
- } else if (u >= 0xdc00 && u < 0xe000) {
- // low surrogate without high
- *cursor = replacement;
- ++ch;
- ++invalid;
- continue;
- } else if (u >= 0xd800 && u < 0xdc00) {
- surrogate_high = u;
- ++ch;
- continue;
- }
-
- if (u < 0x80) {
- *cursor++ = (uchar)u;
- } else {
- if (u < 0x0800) {
- *cursor++ = 0xc0 | ((uchar) (u >> 6));
- } else {
- // is it one of the Unicode non-characters?
- if (isUnicodeNonCharacter(u)) {
- *cursor++ = replacement;
- ++ch;
- ++invalid;
- continue;
- }
-
- if (u > 0xffff) {
- *cursor++ = 0xf0 | ((uchar) (u >> 18));
- *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f);
- } else {
- *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f);
- }
- *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f);
- }
- *cursor++ = 0x80 | ((uchar) (u&0x3f));
- }
- ++ch;
- }
-}
-
QHashedStringRef QHashedStringRef::mid(int offset, int length) const
{
Q_ASSERT(offset < m_length);
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 3bba6f8e83..f969f5c644 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -126,7 +126,7 @@ HEADERS += \
$$PWD/qqmlplatform_p.h \
$$PWD/qqmlbinding_p.h \
$$PWD/qqmlextensionplugin_p.h \
- $$PWD/qqmlabstracturlinterceptor.h \
+ $$PWD/qqmlabstracturlinterceptor_p.h \
$$PWD/qqmlapplicationengine_p.h \
$$PWD/qqmlapplicationengine.h \
$$PWD/qqmllistwrapper_p.h \
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 6082fcda08..b6c6fe840d 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -485,6 +485,24 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
}
+inline int qmlRegisterSingletonType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ if (url.isRelative()) {
+ // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
+ qWarning("qmlRegisterSingletonType requires absolute URLs.");
+ return 0;
+ }
+
+ QQmlPrivate::RegisterCompositeSingletonType type = {
+ url,
+ uri,
+ versionMajor,
+ versionMinor,
+ qmlName
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::CompositeSingletonRegistration, &type);
+}
inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
diff --git a/src/qml/qml/qqmlabstractbinding.cpp b/src/qml/qml/qqmlabstractbinding.cpp
index c01981b3d2..32762a46bf 100644
--- a/src/qml/qml/qqmlabstractbinding.cpp
+++ b/src/qml/qml/qqmlabstractbinding.cpp
@@ -56,9 +56,8 @@ QQmlAbstractBinding::VTable *QQmlAbstractBinding::vTables[] = {
};
QQmlAbstractBinding::QQmlAbstractBinding(BindingType bt)
-: m_nextBindingPtr(bt)
+ : m_nextBindingPtr(bt)
{
- Q_ASSERT(bt <= 0x03);
}
QQmlAbstractBinding::~QQmlAbstractBinding()
diff --git a/src/qml/qml/qqmlabstracturlinterceptor.cpp b/src/qml/qml/qqmlabstracturlinterceptor.cpp
index 127dad86ce..321698ad8e 100644
--- a/src/qml/qml/qqmlabstracturlinterceptor.cpp
+++ b/src/qml/qml/qqmlabstracturlinterceptor.cpp
@@ -44,6 +44,9 @@
\inmodule QtQml
\brief allows you to control QML file loading.
+ \note This class is not currently public API, due to the risk of being affected
+ by planned engine changes in upcoming releases.
+
QQmlAbstractUrlInterceptor is an interface which can be used to alter URLs
before they are used by the QML engine. This is primarily useful for altering
file urls into other file urls, such as selecting different graphical assets
diff --git a/src/qml/qml/qqmlabstracturlinterceptor.h b/src/qml/qml/qqmlabstracturlinterceptor_p.h
index 4bcaa89b4a..471c837eed 100644
--- a/src/qml/qml/qqmlabstracturlinterceptor.h
+++ b/src/qml/qml/qqmlabstracturlinterceptor_p.h
@@ -43,11 +43,11 @@
#define QQMLABSTRACTURLINTERCEPTOR_H
#include <QtCore/qurl.h>
-#include <QtQml/qtqmlglobal.h>
+#include <private/qtqmlglobal_p.h>
QT_BEGIN_NAMESPACE
-class Q_QML_EXPORT QQmlAbstractUrlInterceptor
+class Q_QML_PRIVATE_EXPORT QQmlAbstractUrlInterceptor
{
Q_FLAGS(InterceptionPoint)
public:
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index 3f13f8a140..b4ace17738 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -77,7 +77,7 @@ void QQmlApplicationEnginePrivate::init()
QCoreApplication::installTranslator(qtTranslator);
translators << qtTranslator;
#endif
- q->setUrlInterceptor(new QQmlFileSelector(q));
+ new QQmlFileSelector(q,q);
QCoreApplication::instance()->setProperty("__qml_using_qqmlapplicationengine", QVariant(true));
}
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index a388178952..557267d808 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -194,16 +194,6 @@ QQmlBinding::~QQmlBinding()
{
}
-void QQmlBinding::setEvaluateFlags(EvaluateFlags flags)
-{
- setRequiresThisObject(flags & RequiresThisObject);
-}
-
-QQmlBinding::EvaluateFlags QQmlBinding::evaluateFlags() const
-{
- return requiresThisObject()?RequiresThisObject:None;
-}
-
void QQmlBinding::setNotifyOnValueChanged(bool v)
{
QQmlJavaScriptExpression::setNotifyOnValueChanged(v);
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index e872482373..9dd63a6e9c 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -76,9 +76,6 @@ class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression,
public QQmlAbstractBinding
{
public:
- enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 };
- Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag)
-
QQmlBinding(const QString &, QObject *, QQmlContext *);
QQmlBinding(const QQmlScriptString &, QObject *, QQmlContext *);
QQmlBinding(const QString &, QObject *, QQmlContextData *);
@@ -91,9 +88,6 @@ public:
void setTarget(QObject *, const QQmlPropertyData &, QQmlContextData *);
QQmlProperty property() const;
- void setEvaluateFlags(EvaluateFlags flags);
- EvaluateFlags evaluateFlags() const;
-
void setNotifyOnValueChanged(bool);
// Inherited from QQmlAbstractExpression
@@ -177,8 +171,6 @@ void QQmlBinding::setEnabledFlag(bool v)
m_ctxt.setFlag2Value(v);
}
-Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlBinding::EvaluateFlags)
-
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QQmlBinding*)
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 2cfb074aae..54fd002f7b 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -61,7 +61,7 @@
#include "qqmlscriptstring.h"
#include "qqmlglobal_p.h"
#include "qqmlbinding_p.h"
-#include "qqmlabstracturlinterceptor.h"
+#include "qqmlabstracturlinterceptor_p.h"
#include "qqmlcodegenerator_p.h"
#include <QDebug>
@@ -583,8 +583,7 @@ void QQmlCompiler::genLiteralAssignment(QQmlScript::Property *prop,
Instruction::StoreTime instr;
QTime time = QQmlStringConverters::timeFromString(v->value.asString());
instr.propertyIndex = prop->index;
- Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
- ::memcpy(&instr.time, &time, sizeof(QTime));
+ instr.time = time.msecsSinceStartOfDay();
output->addInstruction(instr);
}
break;
@@ -595,8 +594,7 @@ void QQmlCompiler::genLiteralAssignment(QQmlScript::Property *prop,
QTime time = dateTime.time();
instr.propertyIndex = prop->index;
instr.date = dateTime.date().toJulianDay();
- Q_ASSERT(sizeof(instr.time) == sizeof(QTime));
- ::memcpy(&instr.time, &time, sizeof(QTime));
+ instr.time = time.msecsSinceStartOfDay();
output->addInstruction(instr);
}
break;
@@ -810,7 +808,7 @@ bool QQmlCompiler::compile(QQmlEngine *engine,
this->unit = unit;
this->unitRoot = root;
this->output = out;
- this->jsModule.reset(new QQmlJS::V4IR::Module);
+ this->jsModule.reset(new QQmlJS::V4IR::Module(enginePrivate->v4engine()->debugger));
this->jsModule->isQmlModule = true;
// Compile types
@@ -921,7 +919,7 @@ void QQmlCompiler::compileTree(QQmlScript::Object *tree)
if (!jsModule->functions.isEmpty()) {
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Compiler::JSUnitGenerator jsUnitGenerator(jsModule.data());
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(v4->executableAllocator, jsModule.data(), &jsUnitGenerator));
+ QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(enginePrivate, v4->executableAllocator, jsModule.data(), &jsUnitGenerator));
isel->setUseFastLookups(false);
QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/true);
output->compilationUnit = jsUnit;
@@ -1336,7 +1334,7 @@ void QQmlCompiler::genObjectBody(QQmlScript::Object *obj)
} else if (v->type == Value::SignalExpression) {
Instruction::StoreSignal store;
- store.runtimeFunctionIndex = compileState->runtimeFunctionIndices.at(v->signalData.functionIndex);
+ store.runtimeFunctionIndex = compileState->jsCompileData[v->signalData.signalScopeObject].runtimeFunctionIndices.at(v->signalData.functionIndex);
store.handlerName = output->indexForString(prop->name().toString());
store.parameters = output->indexForString(obj->metatype->signalParameterStringForJS(prop->index));
store.signalIndex = prop->index;
@@ -1738,12 +1736,15 @@ bool QQmlCompiler::buildSignal(QQmlScript::Property *prop, QQmlScript::Object *o
//to ensure all parameters are available (see qqmlboundsignal constructor for more details)
prop->index = obj->metatype->originalClone(prop->index);
prop->values.first()->signalData.signalExpressionContextStack = ctxt.stack;
+ prop->values.first()->signalData.signalScopeObject = ctxt.object;
QList<QByteArray> parameters = obj->metatype->signalParameterNames(prop->index);
AST::FunctionDeclaration *funcDecl = convertSignalHandlerExpressionToFunctionDeclaration(unit->parser().jsEngine(), prop->values.first()->value.asAST(), propName.toString(), parameters);
- compileState->functionsToCompile.append(funcDecl);
- prop->values.first()->signalData.functionIndex = compileState->functionsToCompile.count() - 1;
+
+ ComponentCompileState::PerObjectCompileData *cd = &compileState->jsCompileData[ctxt.object];
+ cd->functionsToCompile.append(funcDecl);
+ prop->values.first()->signalData.functionIndex = cd->functionsToCompile.count() - 1;
QString errorString;
obj->metatype->signalParameterStringForJS(prop->index, &errorString);
@@ -3250,12 +3251,13 @@ bool QQmlCompiler::buildDynamicMeta(QQmlScript::Object *obj, DynamicMetaMode mod
vmd->methodCount++;
md = methodData;
- QQmlCompilerTypes::ComponentCompileState::CompiledMetaMethod cmm;
- cmm.obj = obj;
+ ComponentCompileState::PerObjectCompileData *cd = &compileState->jsCompileData[obj];
+
+ ComponentCompileState::CompiledMetaMethod cmm;
cmm.methodIndex = vmd->methodCount - 1;
- compileState->functionsToCompile.append(s->funcDecl);
- cmm.compiledFunctionIndex = compileState->functionsToCompile.count() - 1;
- compileState->compiledMetaMethods.append(cmm);
+ cd->functionsToCompile.append(s->funcDecl);
+ cmm.compiledFunctionIndex = cd->functionsToCompile.count() - 1;
+ cd->compiledMetaMethods.append(cmm);
}
if (aliasCount)
@@ -3641,32 +3643,60 @@ bool QQmlCompiler::completeComponentBuild()
node = new (pool) AST::ExpressionStatement(expr);
}
- compileState->functionsToCompile.append(node);
- binding.compiledIndex = compileState->functionsToCompile.count() - 1;
+ ComponentCompileState::PerObjectCompileData *cd = &compileState->jsCompileData[b->bindingContext.object];
+ cd->functionsToCompile.append(node);
+ binding.compiledIndex = cd->functionsToCompile.count() - 1;
+ cd->expressionNames.insert(binding.compiledIndex, binding.property->name().toString().prepend(QStringLiteral("expression for ")));
if (componentStats)
componentStats->componentStat.scriptBindings.append(b->value->location);
}
- if (!compileState->functionsToCompile.isEmpty()) {
- JSCodeGen jsCodeGen;
-
+ if (!compileState->jsCompileData.isEmpty()) {
const QString &sourceCode = jsEngine->code();
AST::UiProgram *qmlRoot = parser.qmlRoot();
- const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, compileState->functionsToCompile);
- compileState->runtimeFunctionIndices = runtimeFunctionIndices;
+ JSCodeGen jsCodeGen(enginePrivate, unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, output->importCache);
- for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) {
- JSBindingReference &binding = *b;
- binding.compiledIndex = runtimeFunctionIndices[binding.compiledIndex];
+ JSCodeGen::ObjectIdMapping idMapping;
+ if (compileState->ids.count() > 0) {
+ idMapping.reserve(compileState->ids.count());
+ for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) {
+ JSCodeGen::IdMapping m;
+ m.name = o->id;
+ m.idIndex = o->idIndex;
+ m.type = o->metatype;
+ idMapping << m;
+ }
+ }
+
+ jsCodeGen.beginContextScope(idMapping, compileState->root->metatype);
+
+ for (QHash<QQmlScript::Object *, ComponentCompileState::PerObjectCompileData>::Iterator it = compileState->jsCompileData.begin();
+ it != compileState->jsCompileData.end(); ++it) {
+ QQmlScript::Object *scopeObject = it.key();
+ ComponentCompileState::PerObjectCompileData *cd = &it.value();
+
+ jsCodeGen.beginObjectScope(scopeObject->metatype);
+
+ cd->runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(cd->functionsToCompile, cd->expressionNames);
+ QList<QQmlError> errors = jsCodeGen.errors();
+ if (!errors.isEmpty()) {
+ exceptions << errors;
+ return false;
+ }
+
+ foreach (const QQmlCompilerTypes::ComponentCompileState::CompiledMetaMethod &cmm, cd->compiledMetaMethods) {
+ typedef QQmlVMEMetaData VMD;
+ VMD *vmd = (QQmlVMEMetaData *)scopeObject->synthdata.data();
+ VMD::MethodData &md = *(vmd->methodData() + cmm.methodIndex);
+ md.runtimeFunctionIndex = cd->runtimeFunctionIndices.at(cmm.compiledFunctionIndex);
+ }
}
- foreach (const QQmlCompilerTypes::ComponentCompileState::CompiledMetaMethod &cmm, compileState->compiledMetaMethods) {
- typedef QQmlVMEMetaData VMD;
- VMD *vmd = (QQmlVMEMetaData *)cmm.obj->synthdata.data();
- VMD::MethodData &md = *(vmd->methodData() + cmm.methodIndex);
- md.runtimeFunctionIndex = runtimeFunctionIndices.at(cmm.compiledFunctionIndex);
+ for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) {
+ JSBindingReference &binding = *b;
+ binding.compiledIndex = compileState->jsCompileData[binding.bindingContext.object].runtimeFunctionIndices[binding.compiledIndex];
}
}
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h
index 142d8c68b1..3ca4566e41 100644
--- a/src/qml/qml/qqmlcompiler_p.h
+++ b/src/qml/qml/qqmlcompiler_p.h
@@ -302,16 +302,22 @@ namespace QQmlCompilerTypes {
typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
AliasingObjectsList aliasingObjects;
QQmlScript::Object *root;
- QList<QQmlJS::AST::Node*> functionsToCompile;
- QVector<int> runtimeFunctionIndices;
struct CompiledMetaMethod
{
- QQmlScript::Object *obj;
int methodIndex;
int compiledFunctionIndex; // index in functionToCompile
};
+
QList<CompiledMetaMethod> compiledMetaMethods;
+ struct PerObjectCompileData
+ {
+ QList<QQmlJS::AST::Node*> functionsToCompile;
+ QVector<int> runtimeFunctionIndices;
+ QVector<CompiledMetaMethod> compiledMetaMethods;
+ QHash<int, QString> expressionNames;
+ };
+ QHash<QQmlScript::Object *, PerObjectCompileData> jsCompileData;
};
};
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index ab08fb78e3..2973944215 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -218,7 +218,7 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject)
Components are often defined by \l {{QML Documents}}{component files} -
that is, \c .qml files. The \e Component type essentially allows QML components
- to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML file.
+ to be defined inline, within a \l {QML Documents}{QML document}, rather than as a separate QML file.
This may be useful for reusing a small component within a QML file, or for defining
a component that logically belongs with other QML components within a file.
@@ -235,7 +235,7 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject)
two \l Loader objects). Because Component is not derived from Item, you cannot
anchor anything to it.
- Defining a \c Component is similar to defining a \l {QML Document}{QML document}.
+ Defining a \c Component is similar to defining a \l {QML Documents}{QML document}.
A QML document has a single top-level item that defines the behavior and
properties of that component, and cannot define properties or behavior outside
of that top-level item. In the same way, a \c Component definition contains a single
@@ -1113,14 +1113,14 @@ class QmlIncubatorObject : public QV4::Object
public:
QmlIncubatorObject(QV8Engine *engine, QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
- static QV4::ReturnedValue method_get_statusChanged(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_set_statusChanged(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_status(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_object(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_forceCompletion(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_statusChanged(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_set_statusChanged(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_status(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_object(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_forceCompletion(QV4::CallContext *ctx);
static void destroy(Managed *that);
- static void markObjects(Managed *that);
+ static void markObjects(Managed *that, QV4::ExecutionEngine *e);
QScopedPointer<QQmlComponentIncubator> incubator;
QV8Engine *v8;
@@ -1265,7 +1265,6 @@ void QQmlComponent::createObject(QQmlV4Function *args)
Q_ASSERT(object->isObject());
if (!valuemap->isUndefined()) {
- QQmlComponentExtension *e = componentExtension(args->engine());
QV4::ScopedObject qmlglobal(scope, args->qmlGlobal());
QV4::ScopedValue f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlglobal));
Q_ASSERT(f->asFunctionObject());
@@ -1420,7 +1419,6 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu
Q_ASSERT(object->asObject());
if (!valuemap->isUndefined()) {
- QQmlComponentExtension *e = componentExtension(v8engine);
QV4::ScopedObject qmlGlobalObj(scope, qmlGlobal);
QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine),
QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj));
@@ -1446,54 +1444,54 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
incubationProto = proto;
}
-QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return QV4::QObjectWrapper::wrap(ctx->engine, o->incubator->object());
}
-QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
o->incubator->forceCompletion();
return QV4::Encode::undefined();
}
-QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return QV4::Encode(o->incubator->status());
}
-QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return o->m_statusChanged.asReturnedValue();
}
-QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
if (!o || ctx->callData->argc < 1)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
o->m_statusChanged = ctx->callData->args[0];
@@ -1521,8 +1519,6 @@ void QmlIncubatorObject::setInitialState(QObject *o)
QQmlComponent_setQmlParent(o, parent);
if (!valuemap.isUndefined()) {
- QQmlComponentExtension *e = componentExtension(v8);
-
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8);
QV4::Scope scope(v4);
@@ -1542,14 +1538,14 @@ void QmlIncubatorObject::destroy(Managed *that)
o->~QmlIncubatorObject();
}
-void QmlIncubatorObject::markObjects(QV4::Managed *that)
+void QmlIncubatorObject::markObjects(QV4::Managed *that, QV4::ExecutionEngine *e)
{
QmlIncubatorObject *o = that->as<QmlIncubatorObject>();
Q_ASSERT(o);
- o->valuemap.mark();
- o->qmlGlobal.mark();
- o->m_statusChanged.mark();
- Object::markObjects(that);
+ o->valuemap.mark(e);
+ o->qmlGlobal.mark(e);
+ o->m_statusChanged.mark(e);
+ Object::markObjects(that, e);
}
void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
@@ -1567,13 +1563,13 @@ void QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
QV4::ScopedFunctionObject f(scope, m_statusChanged);
if (f) {
QV4::ExecutionContext *ctx = scope.engine->current;
- try {
- QV4::ScopedCallData callData(scope, 1);
- callData->thisObject = this;
- callData->args[0] = QV4::Primitive::fromUInt32(s);
- f->call(callData);
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ QV4::ScopedCallData callData(scope, 1);
+ callData->thisObject = this;
+ callData->args[0] = QV4::Primitive::fromUInt32(s);
+ f->call(callData);
+ if (scope.hasException()) {
+ ctx->catchException();
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(v8->engine()), error);
}
}
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index 78e6650d02..7731935b75 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -48,7 +48,7 @@
#include "qqmlengine_p.h"
#include "qqmlengine.h"
#include "qqmlinfo.h"
-#include "qqmlabstracturlinterceptor.h"
+#include "qqmlabstracturlinterceptor_p.h"
#include <qjsengine.h>
#include <QtCore/qvarlengtharray.h>
diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h
index a5c3886af1..26048b0217 100644
--- a/src/qml/qml/qqmlcontext_p.h
+++ b/src/qml/qml/qqmlcontext_p.h
@@ -158,7 +158,7 @@ public:
QObject *contextObject;
// Any script blocks that exist on this context
- QList<QV4::PersistentValue> importedScripts;
+ QV4::PersistentValue importedScripts; // This is a JS Array
// Context base url
QUrl url;
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index c867b6e126..0b3b282061 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -47,9 +47,10 @@
#include <private/qv4engine_p.h>
#include <private/qv4value_p.h>
-#include <private/qv4functionobject_p.h>
#include <private/qv4objectproto_p.h>
#include <private/qv4mm_p.h>
+#include <private/qv4function_p.h>
+#include <private/qv4compileddata_p.h>
#include <private/qqmltypewrapper_p.h>
#include <private/qqmllistwrapper_p.h>
@@ -62,7 +63,7 @@ DEFINE_MANAGED_VTABLE(QmlContextWrapper);
QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext)
: Object(QV8Engine::getV4(engine)),
v8(engine), readOnly(true), ownsContext(ownsContext), isNullWrapper(false),
- context(context), scopeObject(scopeObject)
+ context(context), scopeObject(scopeObject), idObjectsWrapper(0)
{
vtbl = &static_vtbl;
}
@@ -135,7 +136,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
QV4::Scope scope(v4);
QmlContextWrapper *resource = m->as<QmlContextWrapper>();
if (!resource)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
// In V8 the JS global object would come _before_ the QML global object,
// so simulate that here.
@@ -191,11 +192,8 @@ ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *has
if (hasProperty)
*hasProperty = true;
if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
- else
- return QV4::Primitive::undefinedValue().asReturnedValue();
+ QV4::ScopedObject scripts(scope, context->importedScripts);
+ return scripts->getIndexed(r.scriptIndex);
} else if (r.type) {
return QmlTypeWrapper::create(engine, scopeObject, r.type);
} else if (r.importNamespace) {
@@ -281,9 +279,13 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
{
ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
+ if (scope.hasException())
+ return;
QV4::Scoped<QmlContextWrapper> wrapper(scope, m->as<QmlContextWrapper>());
- if (!wrapper)
+ if (!wrapper) {
v4->current->throwTypeError();
+ return;
+ }
if (wrapper->isNullWrapper) {
if (wrapper && wrapper->readOnly) {
@@ -291,6 +293,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
QLatin1Char('"');
Scoped<String> e(scope, v4->current->engine->newString(error));
v4->current->throwError(e);
+ return;
}
Object::put(m, name, value);
@@ -341,6 +344,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
v4->current->throwError(error);
+ return;
}
Object::put(m, name, value);
@@ -351,4 +355,119 @@ void QmlContextWrapper::destroy(Managed *that)
static_cast<QmlContextWrapper *>(that)->~QmlContextWrapper();
}
+void QmlContextWrapper::markObjects(Managed *m, ExecutionEngine *engine)
+{
+ QmlContextWrapper *This = static_cast<QmlContextWrapper*>(m);
+ if (This->idObjectsWrapper)
+ This->idObjectsWrapper->mark(engine);
+ Object::markObjects(m, engine);
+}
+
+void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const CompiledData::Function *compiledFunction)
+{
+ // Let the caller check and avoid the function call :)
+ Q_ASSERT(compiledFunction->hasQmlDependencies());
+
+ QQmlEnginePrivate *ep = engine->v8Engine->engine() ? QQmlEnginePrivate::get(engine->v8Engine->engine()) : 0;
+ if (!ep)
+ return;
+ QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture;
+ if (!capture)
+ return;
+
+ QV4::Scope scope(engine);
+ QV4::Scoped<QmlContextWrapper> contextWrapper(scope, engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QQmlContextData *qmlContext = contextWrapper->getContext();
+
+ const quint32 *idObjectDependency = compiledFunction->qmlIdObjectDependencyTable();
+ const int idObjectDependencyCount = compiledFunction->nDependingIdObjects;
+ for (int i = 0; i < idObjectDependencyCount; ++i, ++idObjectDependency)
+ capture->captureProperty(&qmlContext->idValues[*idObjectDependency].bindings);
+
+ const quint32 *contextPropertyDependency = compiledFunction->qmlContextPropertiesDependencyTable();
+ const int contextPropertyDependencyCount = compiledFunction->nDependingContextProperties;
+ for (int i = 0; i < contextPropertyDependencyCount; ++i) {
+ const int propertyIndex = *contextPropertyDependency++;
+ const int notifyIndex = *contextPropertyDependency++;
+ capture->captureProperty(qmlContext->contextObject, propertyIndex, notifyIndex);
+ }
+
+ QObject *scopeObject = contextWrapper->getScopeObject();
+ const quint32 *scopePropertyDependency = compiledFunction->qmlScopePropertiesDependencyTable();
+ const int scopePropertyDependencyCount = compiledFunction->nDependingScopeProperties;
+ for (int i = 0; i < scopePropertyDependencyCount; ++i) {
+ const int propertyIndex = *scopePropertyDependency++;
+ const int notifyIndex = *scopePropertyDependency++;
+ capture->captureProperty(scopeObject, propertyIndex, notifyIndex);
+ }
+
+}
+
+ReturnedValue QmlContextWrapper::idObjectsArray()
+{
+ if (!idObjectsWrapper) {
+ ExecutionEngine *v4 = engine();
+ idObjectsWrapper = new (v4->memoryManager) QQmlIdObjectsArray(v4, this);
+ }
+ return idObjectsWrapper->asReturnedValue();
+}
+
+ReturnedValue QmlContextWrapper::qmlSingletonWrapper(const StringRef &name)
+{
+ if (!context->imports)
+ return Encode::undefined();
+ // Search for attached properties, enums and imported scripts
+ QQmlTypeNameCache::Result r = context->imports->query(name);
+
+ Q_ASSERT(r.isValid());
+ Q_ASSERT(r.type);
+ Q_ASSERT(r.type->isSingleton());
+
+ QQmlEngine *e = v8->engine();
+ QQmlType::SingletonInstanceInfo *siinfo = r.type->singletonInstanceInfo();
+ siinfo->init(e);
+
+ QObject *qobjectSingleton = siinfo->qobjectApi(e);
+ return QV4::QObjectWrapper::wrap(engine(), qobjectSingleton);
+}
+
+DEFINE_MANAGED_VTABLE(QQmlIdObjectsArray);
+
+QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QmlContextWrapper *contextWrapper)
+ : Object(engine)
+ , contextWrapper(contextWrapper)
+{
+ vtbl = &static_vtbl;
+}
+
+ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty)
+{
+ QQmlIdObjectsArray *This = static_cast<QQmlIdObjectsArray*>(m);
+ QQmlContextData *context = This->contextWrapper->getContext();
+ if (!context) {
+ if (hasProperty)
+ *hasProperty = false;
+ return Encode::undefined();
+ }
+ if (index >= (uint)context->idValueCount) {
+ if (hasProperty)
+ *hasProperty = false;
+ return Encode::undefined();
+ }
+
+ ExecutionEngine *v4 = m->engine();
+ QQmlEnginePrivate *ep = v4->v8Engine->engine() ? QQmlEnginePrivate::get(v4->v8Engine->engine()) : 0;
+ if (ep)
+ ep->captureProperty(&context->idValues[index].bindings);
+
+ return QObjectWrapper::wrap(This->engine(), context->idValues[index].data());
+}
+
+void QQmlIdObjectsArray::markObjects(Managed *that, ExecutionEngine *engine)
+{
+ QQmlIdObjectsArray *This = static_cast<QQmlIdObjectsArray*>(that);
+ This->contextWrapper->mark(engine);
+ Object::markObjects(that, engine);
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 86ad4e5616..89ace7090c 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -59,11 +59,18 @@
#include <private/qv4value_p.h>
#include <private/qv4object_p.h>
#include <private/qqmlcontext_p.h>
+#include <private/qv4functionobject_p.h>
QT_BEGIN_NAMESPACE
namespace QV4 {
+namespace CompiledData {
+struct Function;
+}
+
+struct QQmlIdObjectsArray;
+
struct Q_QML_EXPORT QmlContextWrapper : Object
{
Q_MANAGED
@@ -85,7 +92,12 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, const StringRef name, const ValueRef value);
static void destroy(Managed *that);
+ static void markObjects(Managed *m, ExecutionEngine *engine);
+ static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
+
+ ReturnedValue idObjectsArray();
+ ReturnedValue qmlSingletonWrapper(const StringRef &name);
QV8Engine *v8; // ### temporary, remove
bool readOnly;
@@ -94,6 +106,19 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
QQmlGuardedContextData context;
QPointer<QObject> scopeObject;
+private:
+ QQmlIdObjectsArray *idObjectsWrapper;
+};
+
+struct QQmlIdObjectsArray : public Object
+{
+ Q_MANAGED
+ QQmlIdObjectsArray(ExecutionEngine *engine, QmlContextWrapper *contextWrapper);
+
+ static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+ static void markObjects(Managed *that, ExecutionEngine *engine);
+
+ QmlContextWrapper *contextWrapper;
};
}
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index 76d03f011e..621b3d3c2e 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -79,7 +79,7 @@ class Q_QML_PRIVATE_EXPORT QQmlData : public QAbstractDeclarativeData
{
public:
QQmlData()
- : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
+ : ownedByQml1(false), ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
hasTaintedV8Object(false), isQueuedForDeletion(false), rootObjectInCreation(false),
hasVMEMetaObject(false), parentFrozen(false), notifyList(0), context(0), outerContext(0),
bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0),
@@ -113,6 +113,7 @@ public:
if (!explicitIndestructibleSet) indestructible = false;
}
+ quint32 ownedByQml1:1; // This bit is shared with QML1's QDeclarativeData.
quint32 ownMemory:1;
quint32 ownContext:1;
quint32 indestructible:1;
@@ -126,7 +127,7 @@ public:
quint32 rootObjectInCreation:1;
quint32 hasVMEMetaObject:1;
quint32 parentFrozen:1;
- quint32 dummy:23;
+ quint32 dummy:22;
struct NotifyList {
quint64 connectionMask;
diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp
index b23b760b78..c1d0132c61 100644
--- a/src/qml/qml/qqmldirparser.cpp
+++ b/src/qml/qml/qqmldirparser.cpp
@@ -142,7 +142,7 @@ bool QQmlDirParser::parse(const QString &source)
if (invalidLine) {
reportError(lineNumber, 0,
- QString::fromUtf8("invalid qmldir directive contains too many tokens"));
+ QString::fromLatin1("invalid qmldir directive contains too many tokens"));
continue;
} else if (sectionCount == 0) {
continue; // no sections, no party.
@@ -150,17 +150,17 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("module")) {
if (sectionCount != 2) {
reportError(lineNumber, 0,
- QString::fromUtf8("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1));
+ QString::fromLatin1("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1));
continue;
}
if (!_typeNamespace.isEmpty()) {
reportError(lineNumber, 0,
- QString::fromUtf8("only one module identifier directive may be defined in a qmldir file"));
+ QString::fromLatin1("only one module identifier directive may be defined in a qmldir file"));
continue;
}
if (!firstLine) {
reportError(lineNumber, 0,
- QString::fromUtf8("module identifier directive must be the first directive in a qmldir file"));
+ QString::fromLatin1("module identifier directive must be the first directive in a qmldir file"));
continue;
}
@@ -169,7 +169,7 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("plugin")) {
if (sectionCount < 2 || sectionCount > 3) {
reportError(lineNumber, 0,
- QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));
+ QString::fromLatin1("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
@@ -181,7 +181,7 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("internal")) {
if (sectionCount != 3) {
reportError(lineNumber, 0,
- QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
+ QString::fromLatin1("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
}
Component entry(sections[1], sections[2], -1, -1);
@@ -190,7 +190,7 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("singleton")) {
if (sectionCount < 3 || sectionCount > 4) {
reportError(lineNumber, 0,
- QString::fromUtf8("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1));
+ QString::fromLatin1("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1));
continue;
} else if (sectionCount == 3) {
// handle qmldir directory listing case where singleton is defined in the following pattern:
@@ -227,7 +227,7 @@ bool QQmlDirParser::parse(const QString &source)
} else if (sections[0] == QLatin1String("typeinfo")) {
if (sectionCount != 2) {
reportError(lineNumber, 0,
- QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
+ QString::fromLatin1("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
continue;
}
#ifdef QT_CREATOR
@@ -270,7 +270,7 @@ bool QQmlDirParser::parse(const QString &source)
}
} else {
reportError(lineNumber, 0,
- QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
+ QString::fromLatin1("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
}
firstLine = false;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 64cde85913..1eec710c84 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -66,7 +66,7 @@
#include <private/qv4debugservice_p.h>
#include <private/qdebugmessageservice_p.h>
#include "qqmlincubator.h"
-#include "qqmlabstracturlinterceptor.h"
+#include "qqmlabstracturlinterceptor_p.h"
#include <private/qv8profilerservice_p.h>
#include <private/qqmlboundsignal_p.h>
@@ -556,7 +556,7 @@ QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
workerScriptEngine(0), activeVME(0),
activeObjectCreator(0),
networkAccessManager(0), networkAccessManagerFactory(0), urlInterceptor(0),
- scarceResourcesRefCount(0), typeLoader(e), importDatabase(e), uniqueId(1),
+ scarceResourcesRefCount(0), importDatabase(e), typeLoader(e), uniqueId(1),
incubatorCount(0), incubationController(0), mutex(QMutex::Recursive)
{
useNewCompiler = qmlUseNewCompiler();
@@ -615,12 +615,18 @@ void QQmlPrivate::qdeclarativeelement_destructor(QObject *o)
void QQmlData::destroyed(QAbstractDeclarativeData *d, QObject *o)
{
- static_cast<QQmlData *>(d)->destroyed(o);
+ QQmlData *ddata = static_cast<QQmlData *>(d);
+ if (ddata->ownedByQml1)
+ return;
+ ddata->destroyed(o);
}
void QQmlData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
{
- static_cast<QQmlData *>(d)->parentChanged(o, p);
+ QQmlData *ddata = static_cast<QQmlData *>(d);
+ if (ddata->ownedByQml1)
+ return;
+ ddata->parentChanged(o, p);
}
class QQmlThreadNotifierProxyObject : public QObject
@@ -649,6 +655,7 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in
{
QQmlData *ddata = QQmlData::get(object, false);
if (!ddata) return; // Probably being deleted
+ if (ddata->ownedByQml1) return;
// In general, QML only supports QObject's that live on the same thread as the QQmlEngine
// that they're exposed to. However, to make writing "worker objects" that calculate data
@@ -706,12 +713,18 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in
int QQmlData::receivers(QAbstractDeclarativeData *d, const QObject *, int index)
{
- return static_cast<QQmlData *>(d)->endpointCount(index);
+ QQmlData *ddata = static_cast<QQmlData *>(d);
+ if (ddata->ownedByQml1)
+ return 0;
+ return ddata->endpointCount(index);
}
bool QQmlData::isSignalConnected(QAbstractDeclarativeData *d, const QObject *, int index)
{
- return static_cast<QQmlData *>(d)->signalHasEndpoint(index);
+ QQmlData *ddata = static_cast<QQmlData *>(d);
+ if (ddata->ownedByQml1)
+ return false;
+ return ddata->signalHasEndpoint(index);
}
int QQmlData::endpointCount(int index)
@@ -1761,7 +1774,6 @@ void QQmlEnginePrivate::warning(const QList<QQmlError> &errors)
void QQmlEnginePrivate::warning(QQmlDelayedError *error)
{
- Q_Q(QQmlEngine);
warning(error->error());
}
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 5a2d6c4e00..19eb320fbe 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -186,8 +186,8 @@ public:
void referenceScarceResources();
void dereferenceScarceResources();
- QQmlTypeLoader typeLoader;
QQmlImportDatabase importDatabase;
+ QQmlTypeLoader typeLoader;
QString offlineStoragePath;
@@ -257,6 +257,7 @@ public:
inline static QQmlEnginePrivate *get(QQmlContext *c);
inline static QQmlEnginePrivate *get(QQmlContextData *c);
inline static QQmlEngine *get(QQmlEnginePrivate *p);
+ inline static QQmlEnginePrivate *get(QV4::ExecutionEngine *e);
static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor);
static void registerQtQuick2Types(const char *uri, int versionMajor, int versionMinor);
@@ -516,7 +517,17 @@ QQmlEngine *QQmlEnginePrivate::get(QQmlEnginePrivate *p)
{
Q_ASSERT(p);
- return p->q_func();
+ return p->q_func();
+}
+
+QQmlEnginePrivate *QQmlEnginePrivate::get(QV4::ExecutionEngine *e)
+{
+ if (!e->v8Engine)
+ return 0;
+ QQmlEngine *qmlEngine = e->v8Engine->engine();
+ if (!qmlEngine)
+ return 0;
+ return get(qmlEngine);
}
void QQmlEnginePrivate::captureProperty(QQmlNotifier *n)
diff --git a/src/qml/qml/qqmlfileselector.cpp b/src/qml/qml/qqmlfileselector.cpp
index 5810e269eb..7f2007ec00 100644
--- a/src/qml/qml/qqmlfileselector.cpp
+++ b/src/qml/qml/qqmlfileselector.cpp
@@ -40,26 +40,30 @@
****************************************************************************/
#include <QtCore/QFileSelector>
+#include <qobjectdefs.h>
#include "qqmlfileselector.h"
#include "qqmlfileselector_p.h"
+#include "qqmlabstracturlinterceptor_p.h"
+#include <QDebug>
QT_BEGIN_NAMESPACE
+typedef QHash<QQmlAbstractUrlInterceptor*, QQmlFileSelector*> interceptorSelectorMap;
+Q_GLOBAL_STATIC(interceptorSelectorMap, interceptorInstances);
/*!
\class QQmlFileSelector
\since 5.2
\inmodule QtQml
- \brief A convenience class for applying a QFileSelector to QML file loading
+ \brief A class for applying a QFileSelector to QML file loading
- QQmlFileSelector is a QQmlAbstractUrlInterceptor which will automatically apply a QFileSelector to
+ QQmlFileSelector will automatically apply a QFileSelector to
qml file and asset paths.
It is used as follows:
\code
QQmlEngine engine;
- QQmlFileSelector selector;
- engine.setUrlInterceptor(&selector);
+ QQmlFileSelector* selector = new QQmlFileSelector(&engine);
\endcode
Then you can swap out files like so:
@@ -86,15 +90,34 @@ QT_BEGIN_NAMESPACE
Your platform may also provide additional selectors for you to use. As specified by QFileSelector,
directories used for selection must start with a '+' character, so you will not accidentally
trigger this feature unless you have directories with such names inside your project.
+
+ If a new QQmlFileSelector is set on the engine, the old one will be replaced. Use
+ \l QQmlFileSelector::get to query or use the existing instance.
*/
/*!
Creates a new QQmlFileSelector, which includes its own QFileSelector.
+ \a engine is the QQmlEngine you wish to apply file selectors too. It will
+ also take ownership of the QQmlFileSelector.
*/
-QQmlFileSelector::QQmlFileSelector(QObject* parent)
+QQmlFileSelector::QQmlFileSelector(QQmlEngine* engine, QObject* parent)
: QObject(*(new QQmlFileSelectorPrivate), parent)
{
+ Q_D(QQmlFileSelector);
+ d->engine = engine;
+ interceptorInstances()->insert(d->myInstance, this);
+ d->engine->setUrlInterceptor(d->myInstance);
+}
+
+QQmlFileSelector::~QQmlFileSelector()
+{
+ Q_D(QQmlFileSelector);
+ if (d->engine && QQmlFileSelector::get(d->engine) == this) {
+ d->engine->setUrlInterceptor(0);
+ d->engine = 0;
+ }
+ interceptorInstances()->remove(d->myInstance);
}
QQmlFileSelectorPrivate::QQmlFileSelectorPrivate()
@@ -102,6 +125,7 @@ QQmlFileSelectorPrivate::QQmlFileSelectorPrivate()
Q_Q(QQmlFileSelector);
ownSelector = true;
selector = new QFileSelector(q);
+ myInstance = new QQmlFileSelectorInterceptor(this);
}
/*!
@@ -127,9 +151,42 @@ void QQmlFileSelector::setSelector(QFileSelector *selector)
}
}
-QUrl QQmlFileSelector::intercept(const QUrl &path, DataType type)
+/*!
+ Adds extra selectors to the current QFileSelector being used. Use this when
+ extra selectors are all you need to avoid having to create your own
+ QFileSelector instance.
+*/
+void QQmlFileSelector::setExtraSelectors(QStringList &strings)
{
Q_D(QQmlFileSelector);
+ d->selector->setExtraSelectors(strings);
+}
+
+/*!
+ Gets the QQmlFileSelector currently active on the target engine.
+*/
+QQmlFileSelector* QQmlFileSelector::get(QQmlEngine* engine)
+{
+ //Since I think we still can't use dynamic_cast inside Qt...
+ QQmlAbstractUrlInterceptor* current = engine->urlInterceptor();
+ if (current && interceptorInstances()->contains(current))
+ return interceptorInstances()->value(current);
+ return 0;
+}
+
+/*!
+ \internal
+*/
+QQmlFileSelectorInterceptor::QQmlFileSelectorInterceptor(QQmlFileSelectorPrivate* pd)
+ : d(pd)
+{
+}
+
+/*!
+ \internal
+*/
+QUrl QQmlFileSelectorInterceptor::intercept(const QUrl &path, DataType type)
+{
if ( type == QQmlAbstractUrlInterceptor::QmldirFile ) //Don't intercept qmldir files, to prevent double interception
return path;
return d->selector->select(path);
diff --git a/src/qml/qml/qqmlfileselector.h b/src/qml/qml/qqmlfileselector.h
index 2be221e0e4..ec9bbc77db 100644
--- a/src/qml/qml/qqmlfileselector.h
+++ b/src/qml/qml/qqmlfileselector.h
@@ -44,23 +44,23 @@
#include <QtCore/QObject>
#include <QtCore/QUrl>
-#include <QtQml/QQmlAbstractUrlInterceptor>
+#include <QtQml/QQmlEngine>
#include <QtQml/qtqmlglobal.h>
QT_BEGIN_NAMESPACE
class QFileSelector;
class QQmlFileSelectorPrivate;
-class Q_QML_EXPORT QQmlFileSelector : public QObject, public QQmlAbstractUrlInterceptor
+class Q_QML_EXPORT QQmlFileSelector : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QQmlFileSelector)
public:
- QQmlFileSelector(QObject* parent=0);
+ QQmlFileSelector(QQmlEngine* engine, QObject* parent=0);
+ ~QQmlFileSelector();
void setSelector(QFileSelector *selector);
-
-protected:
- virtual QUrl intercept(const QUrl &path, DataType type);
+ void setExtraSelectors(QStringList &strings);
+ static QQmlFileSelector* get(QQmlEngine*);
private:
Q_DISABLE_COPY(QQmlFileSelector)
diff --git a/src/qml/qml/qqmlfileselector_p.h b/src/qml/qml/qqmlfileselector_p.h
index 60d6072c8c..fe3679e08d 100644
--- a/src/qml/qml/qqmlfileselector_p.h
+++ b/src/qml/qml/qqmlfileselector_p.h
@@ -54,19 +54,33 @@
//
#include "qqmlfileselector.h"
+#include "qqmlabstracturlinterceptor_p.h"
+#include <QSet>
#include <private/qobject_p.h>
#include <private/qtqmlglobal_p.h>
QT_BEGIN_NAMESPACE
class QFileSelector;
+class QQmlFileSelectorInterceptor;
class Q_QML_PRIVATE_EXPORT QQmlFileSelectorPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QQmlFileSelector)
public:
QQmlFileSelectorPrivate();
QFileSelector* selector;
+ QPointer<QQmlEngine> engine;
bool ownSelector;
+ QQmlFileSelectorInterceptor* myInstance;
+};
+
+class Q_QML_PRIVATE_EXPORT QQmlFileSelectorInterceptor : public QQmlAbstractUrlInterceptor
+{
+public:
+ QQmlFileSelectorInterceptor(QQmlFileSelectorPrivate* pd);
+ QQmlFileSelectorPrivate* d;
+protected:
+ virtual QUrl intercept(const QUrl &path, DataType type);
};
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 63151b18bf..30b5abb383 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -839,11 +839,12 @@ bool QQmlImportsPrivate::populatePluginPairVector(QVector<StaticPluginPair> &res
foreach (const QStaticPlugin &plugin, plugins) {
// Since a module can list more than one plugin, we keep iterating even after we found a match.
if (QQmlExtensionPlugin *instance = qobject_cast<QQmlExtensionPlugin *>(plugin.instance())) {
- const QJsonArray metaTagsUriList = plugin.metaData().value("uri").toArray();
+ const QJsonArray metaTagsUriList = plugin.metaData().value(QStringLiteral("uri")).toArray();
if (metaTagsUriList.isEmpty()) {
if (errors) {
QQmlError error;
- error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" has no metadata URI").arg(uri).arg(instance->metaObject()->className()));
+ error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" has no metadata URI")
+ .arg(uri).arg(QString::fromUtf8(instance->metaObject()->className())));
error.setUrl(QUrl::fromLocalFile(qmldirPath));
errors->prepend(error);
}
@@ -945,7 +946,8 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath,
if (errors) {
QQmlError poppedError = errors->takeFirst();
QQmlError error;
- error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" cannot be loaded: %3").arg(uri).arg(instance->metaObject()->className()).arg(poppedError.description()));
+ error.setDescription(QQmlImportDatabase::tr("static plugin for module \"%1\" with name \"%2\" cannot be loaded: %3")
+ .arg(uri).arg(QString::fromUtf8(instance->metaObject()->className())).arg(poppedError.description()));
error.setUrl(QUrl::fromLocalFile(qmldirFilePath));
errors->prepend(error);
}
@@ -1021,7 +1023,8 @@ QString QQmlImportsPrivate::resolvedUri(const QString &dir_arg, QQmlImportDataba
dir.chop(1);
QStringList paths = database->fileImportPath;
- std::sort(paths.begin(), paths.end(), I::greaterThan); // Ensure subdirs preceed their parents.
+ if (!paths.isEmpty())
+ std::sort(paths.begin(), paths.end(), I::greaterThan); // Ensure subdirs preceed their parents.
QString stableRelativePath = dir;
foreach(const QString &path, paths) {
diff --git a/src/qml/qml/qqmlinstruction_p.h b/src/qml/qml/qqmlinstruction_p.h
index 01b6fa41a4..150ee8df19 100644
--- a/src/qml/qml/qqmlinstruction_p.h
+++ b/src/qml/qml/qqmlinstruction_p.h
@@ -345,18 +345,13 @@ union QQmlInstruction
struct instr_storeTime {
QML_INSTR_HEADER
int propertyIndex;
- struct QTime {
- int mds;
-#if defined(Q_OS_WINCE)
- int startTick;
-#endif
- } time;
+ int time; // QTime::fromMSecsSinceStartOfDay
};
struct instr_storeDateTime {
QML_INSTR_HEADER
int propertyIndex;
int date;
- instr_storeTime::QTime time;
+ int time;
};
struct instr_storeRect {
QML_INSTR_HEADER
@@ -540,7 +535,7 @@ struct QQmlInstructionMeta {
enum { Size = QML_INSTR_SIZE(I, FMT) }; \
typedef QQmlInstruction::instr_##FMT DataType; \
static const DataType &data(const QQmlInstruction &instr) { return instr.FMT; } \
- static void setData(QQmlInstruction &instr, const DataType &v) { instr.FMT = v; } \
+ static void setData(QQmlInstruction &instr, const DataType &v) { memcpy(&instr.FMT, &v, Size); } \
};
FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
#undef QML_INSTR_META_TEMPLATE
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 37a9e398f8..3fd0003656 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -86,7 +86,7 @@ void QQmlDelayedError::setErrorObject(QObject *object)
void QQmlDelayedError::catchJavaScriptException(QV4::ExecutionContext *context)
{
- m_error = QV4::ExecutionEngine::convertJavaScriptException(context);
+ m_error = QV4::ExecutionEngine::catchExceptionAsQmlError(context);
}
@@ -148,9 +148,6 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
if (notifyOnValueChanged())
capture.guards.copyAndClearPrepend(activeGuards);
- QQmlContextData *lastSharedContext = 0;
- QObject *lastSharedScope = 0;
-
// All code that follows must check with watcher before it accesses data members
// incase we have been deleted.
DeleteWatcher watcher(this);
@@ -159,28 +156,27 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
QV4::Scope scope(v4);
QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue());
QV4::ExecutionContext *ctx = v4->current;
- try {
- callData->thisObject = ep->v8engine()->global();
- if (scopeObject() && requiresThisObject()) {
- QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject()));
- if (value->isObject())
- callData->thisObject = value;
- }
-
- result = function->asFunctionObject()->call(callData);
-
- if (isUndefined)
- *isUndefined = result->isUndefined();
+ callData->thisObject = v4->globalObject;
+ if (scopeObject()) {
+ QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject()));
+ if (value->isObject())
+ callData->thisObject = value;
+ }
- if (!watcher.wasDeleted() && hasDelayedError())
- delayedError()->clearError();
- } catch (...) {
+ result = function->asFunctionObject()->call(callData);
+ if (scope.hasException()) {
if (watcher.wasDeleted())
ctx->catchException(); // ignore exception
else
delayedError()->catchJavaScriptException(ctx);
if (isUndefined)
*isUndefined = true;
+ } else {
+ if (isUndefined)
+ *isUndefined = result->isUndefined();
+
+ if (!watcher.wasDeleted() && hasDelayedError())
+ delayedError()->clearError();
}
if (capture.errorString) {
@@ -276,6 +272,8 @@ void QQmlJavaScriptExpression::clearError()
QQmlError QQmlJavaScriptExpression::error(QQmlEngine *engine) const
{
+ Q_UNUSED(engine);
+
if (m_vtable.hasValue())
return m_vtable.constValue()->error();
else
@@ -302,11 +300,11 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, scopeObject));
QV4::Script script(v4, qmlScopeObject, code, filename, line);
QV4::ScopedValue result(scope);
- try {
- script.parse();
+ script.parse();
+ if (!v4->hasException)
result = script.run();
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ if (v4->hasException) {
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
if (error.description().isEmpty())
error.setDescription(QLatin1String("Exception occurred during function evaluation"));
if (error.line() == -1)
@@ -336,11 +334,11 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, qmlScope));
QV4::Script script(v4, qmlScopeObject, code, filename, line);
QV4::ScopedValue result(scope);
- try {
- script.parse();
+ script.parse();
+ if (!v4->hasException)
result = script.qmlBinding();
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ if (v4->hasException) {
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
if (error.description().isEmpty())
error.setDescription(QLatin1String("Exception occurred during function evaluation"));
if (error.line() == -1)
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 44357046ee..7d65f1c9cc 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -117,8 +117,6 @@ public:
QV4::ReturnedValue evaluate(QQmlContextData *, const QV4::ValueRef function, bool *isUndefined);
QV4::ReturnedValue evaluate(QQmlContextData *, const QV4::ValueRef function, QV4::CallData *callData, bool *isUndefined);
- inline bool requiresThisObject() const;
- inline void setRequiresThisObject(bool v);
inline bool notifyOnValueChanged() const;
void setNotifyOnValueChanged(bool v);
@@ -183,7 +181,6 @@ private:
QPointerValuePair<VTable, QQmlDelayedError> m_vtable;
// We store some flag bits in the following flag pointers.
- // m_scopeObject:flag1 - requiresThisObject
// activeGuards:flag1 - notifyOnValueChanged
// activeGuards:flag2 - useSharedContext
QBiPointer<QObject, DeleteWatcher> m_scopeObject;
@@ -215,16 +212,6 @@ bool QQmlJavaScriptExpression::DeleteWatcher::wasDeleted() const
return *_w == 0;
}
-bool QQmlJavaScriptExpression::requiresThisObject() const
-{
- return m_scopeObject.flag();
-}
-
-void QQmlJavaScriptExpression::setRequiresThisObject(bool v)
-{
- m_scopeObject.setFlagValue(v);
-}
-
bool QQmlJavaScriptExpression::notifyOnValueChanged() const
{
return activeGuards.flag();
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 0364659ecc..73dc3192aa 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -106,7 +106,7 @@ ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasPro
QV4::ExecutionEngine *v4 = m->engine();
QmlListWrapper *w = m->as<QmlListWrapper>();
if (!w)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
if (name->equals(v4->id_length) && !w->object.isNull()) {
quint32 count = w->property.count ? w->property.count(&w->property) : 0;
@@ -122,10 +122,12 @@ ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasPro
ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
{
+ Q_UNUSED(hasProperty);
+
QV4::ExecutionEngine *e = m->engine();
QmlListWrapper *w = m->as<QmlListWrapper>();
if (!w)
- e->current->throwTypeError();
+ return e->current->throwTypeError();
quint32 count = w->property.count ? w->property.count(&w->property) : 0;
if (index < count && w->property.at)
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index aca18d8ef4..5e8130f407 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -67,40 +67,42 @@ public:
QLocale locale;
- static QLocale &getThisLocale(QV4::SimpleCallContext *ctx) {
+ static QLocale *getThisLocale(QV4::CallContext *ctx) {
QQmlLocaleData *thisObject = ctx->callData->thisObject.asObject()->as<QQmlLocaleData>();
- if (!thisObject)
+ if (!thisObject) {
ctx->throwTypeError();
- return thisObject->locale;
+ return 0;
+ }
+ return &thisObject->locale;
}
- static QV4::ReturnedValue method_currencySymbol(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_dateTimeFormat(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_timeFormat(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_dateFormat(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_monthName(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_standaloneMonthName(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_dayName(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_standaloneDayName(QV4::SimpleCallContext *ctx);
-
- static QV4::ReturnedValue method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_measurementSystem(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_textDirection(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_weekDays(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_uiLanguages(QV4::SimpleCallContext *ctx);
-
- static QV4::ReturnedValue method_get_name(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_nativeLanguageName(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_nativeCountryName(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_decimalPoint(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_groupSeparator(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_percent(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_zeroDigit(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_negativeSign(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_positiveSign(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_exponential(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_amText(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_get_pmText(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_currencySymbol(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_dateTimeFormat(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_timeFormat(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_dateFormat(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_monthName(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_standaloneMonthName(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_dayName(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_standaloneDayName(QV4::CallContext *ctx);
+
+ static QV4::ReturnedValue method_get_firstDayOfWeek(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_measurementSystem(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_textDirection(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_weekDays(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_uiLanguages(QV4::CallContext *ctx);
+
+ static QV4::ReturnedValue method_get_name(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_nativeLanguageName(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_nativeCountryName(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_decimalPoint(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_groupSeparator(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_percent(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_zeroDigit(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_negativeSign(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_positiveSign(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_exponential(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_amText(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_get_pmText(QV4::CallContext *ctx);
private:
static void destroy(Managed *that)
@@ -135,7 +137,7 @@ void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine)
engine->dateCtor.objectValue()->defineDefaultProperty(QStringLiteral("timeZoneUpdated"), method_timeZoneUpdated);
}
-QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ctx)
{
if (ctx->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleString(ctx);
@@ -179,7 +181,7 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::SimpleCallConte
return ctx->engine->newString(formattedDt)->asReturnedValue();
}
-QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext *ctx)
{
if (ctx->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleTimeString(ctx);
@@ -224,7 +226,7 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::SimpleCallC
return ctx->engine->newString(formattedTime)->asReturnedValue();
}
-QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext *ctx)
{
if (ctx->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleDateString(ctx);
@@ -269,7 +271,7 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::SimpleCallC
return ctx->engine->newString(formattedDate)->asReturnedValue();
}
-QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) {
@@ -307,7 +309,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallCon
return QV4::Encode(engine->newDateObject(dt));
}
-QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
@@ -351,7 +353,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCal
return QV4::Encode(engine->newDateObject(dt));
}
-QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
@@ -390,7 +392,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCal
return QV4::Encode(engine->newDateObject(QDateTime(dt)));
}
-QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 0)
V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments");
@@ -410,7 +412,7 @@ void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine)
engine->numberCtor.objectValue()->defineDefaultProperty(QStringLiteral("fromLocaleString"), method_fromLocaleString);
}
-QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::CallContext *ctx)
{
if (ctx->callData->argc > 3)
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
@@ -435,7 +437,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallCon
if (!ctx->callData->args[1].isString())
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
QV4::String *fs = ctx->callData->args[1].toString(ctx);
- if (!fs->isEmpty())
+ if (fs->length())
format = fs->toQString().at(0).unicode();
}
int prec = 2;
@@ -448,7 +450,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallCon
return ctx->engine->newString(r->locale.toString(number, (char)format, prec))->asReturnedValue();
}
-QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallContext *ctx)
{
if (ctx->callData->argc > 2)
V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
@@ -478,7 +480,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::Simpl
return ctx->engine->newString(r->locale.toCurrencyString(number, symbol))->asReturnedValue();
}
-QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
@@ -499,7 +501,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallC
}
QV4::String *ns = ctx->callData->args[numberIdx].toString(ctx);
- if (ns->isEmpty())
+ if (!ns->length())
return QV4::Encode(Q_QNAN);
bool ok = false;
@@ -514,32 +516,42 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallC
//--------------
// Locale object
-QV4::ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(QV4::CallContext *ctx)
{
- QLocale locale = getThisLocale(ctx);
- int fdow = int(locale.firstDayOfWeek());
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+ int fdow = int(locale->firstDayOfWeek());
if (fdow == 7)
fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
return QV4::Encode(fdow);
}
-QV4::ReturnedValue QQmlLocaleData::method_get_measurementSystem(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_measurementSystem(QV4::CallContext *ctx)
{
- QLocale locale = getThisLocale(ctx);
- return QV4::Encode(locale.measurementSystem());
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+ return QV4::Encode(locale->measurementSystem());
}
-QV4::ReturnedValue QQmlLocaleData::method_get_textDirection(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_textDirection(QV4::CallContext *ctx)
{
- QLocale locale = getThisLocale(ctx);
- return QV4::Encode(locale.textDirection());
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+
+ return QV4::Encode(locale->textDirection());
}
-QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QLocale locale = getThisLocale(ctx);
- QList<Qt::DayOfWeek> days = locale.weekdays();
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+
+ QList<Qt::DayOfWeek> days = locale->weekdays();
QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject());
result->arrayReserve(days.size());
@@ -555,11 +567,14 @@ QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *c
return result.asReturnedValue();
}
-QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QLocale locale = getThisLocale(ctx);
- QStringList langs = locale.uiLanguages();
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+
+ QStringList langs = locale->uiLanguages();
QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject());
result->arrayReserve(langs.size());
for (int i = 0; i < langs.size(); ++i) {
@@ -572,9 +587,12 @@ QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext
return result.asReturnedValue();
}
-QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::CallContext *ctx)
{
- QLocale locale = getThisLocale(ctx);
+ QLocale *locale = getThisLocale(ctx);
+ if (!locale)
+ return QV4::Encode::undefined();
+
if (ctx->callData->argc > 1)
V4THROW_ERROR("Locale: currencySymbol(): Invalid arguments");
@@ -584,12 +602,14 @@ QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext
format = QLocale::CurrencySymbolFormat(intFormat);
}
- return ctx->engine->newString(locale.currencySymbol(format))->asReturnedValue();
+ return ctx->engine->newString(locale->currencySymbol(format))->asReturnedValue();
}
#define LOCALE_FORMAT(FUNC) \
-QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx) { \
- QLocale locale = getThisLocale(ctx); \
+QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::CallContext *ctx) { \
+ QLocale *locale = getThisLocale(ctx); \
+ if (!locale) \
+ return QV4::Encode::undefined(); \
if (ctx->callData->argc > 1) \
V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
QLocale::FormatType format = QLocale::LongFormat;\
@@ -597,7 +617,7 @@ QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx)
quint32 intFormat = ctx->callData->args[0].toUInt32(); \
format = QLocale::FormatType(intFormat); \
} \
- return ctx->engine->newString(locale. FUNC (format))->asReturnedValue(); \
+ return ctx->engine->newString(locale-> FUNC (format))->asReturnedValue(); \
}
LOCALE_FORMAT(dateTimeFormat)
@@ -606,8 +626,10 @@ LOCALE_FORMAT(dateFormat)
// +1 added to idx because JS is 0-based, whereas QLocale months begin at 1.
#define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \
-QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
- QLocale locale = getThisLocale(ctx); \
+QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) {\
+ QLocale *locale = getThisLocale(ctx); \
+ if (!locale) \
+ return QV4::Encode::undefined(); \
if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
QLocale::FormatType enumFormat = QLocale::LongFormat; \
@@ -619,20 +641,22 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *
if (ctx->callData->args[1].isNumber()) { \
quint32 intFormat = ctx->callData->args[1].toUInt32(); \
QLocale::FormatType format = QLocale::FormatType(intFormat); \
- name = locale. VARIABLE(idx, format); \
+ name = locale-> VARIABLE(idx, format); \
} else { \
V4THROW_ERROR("Locale: Invalid datetime format"); \
} \
} else { \
- name = locale. VARIABLE(idx, enumFormat); \
+ name = locale-> VARIABLE(idx, enumFormat); \
} \
return ctx->engine->newString(name)->asReturnedValue(); \
}
// 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date
#define LOCALE_FORMATTED_DAYNAME(VARIABLE) \
-QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
- QLocale locale = getThisLocale(ctx); \
+QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) {\
+ QLocale *locale = getThisLocale(ctx); \
+ if (!locale) \
+ return QV4::Encode::undefined(); \
if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
QLocale::FormatType enumFormat = QLocale::LongFormat; \
@@ -645,12 +669,12 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *
if (ctx->callData->args[1].isNumber()) { \
quint32 intFormat = ctx->callData->args[1].toUInt32(); \
QLocale::FormatType format = QLocale::FormatType(intFormat); \
- name = locale. VARIABLE(idx, format); \
+ name = locale-> VARIABLE(idx, format); \
} else { \
V4THROW_ERROR("Locale: Invalid datetime format"); \
} \
} else { \
- name = locale. VARIABLE(idx, enumFormat); \
+ name = locale-> VARIABLE(idx, enumFormat); \
} \
return ctx->engine->newString(name)->asReturnedValue(); \
}
@@ -660,10 +684,12 @@ LOCALE_FORMATTED_MONTHNAME(standaloneMonthName)
LOCALE_FORMATTED_DAYNAME(dayName)
LOCALE_FORMATTED_DAYNAME(standaloneDayName)
-#define LOCALE_STRING_PROPERTY(VARIABLE) QV4::ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (QV4::SimpleCallContext* ctx) \
+#define LOCALE_STRING_PROPERTY(VARIABLE) QV4::ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (QV4::CallContext* ctx) \
{ \
- QLocale locale = getThisLocale(ctx); \
- return ctx->engine->newString(locale. VARIABLE())->asReturnedValue();\
+ QLocale *locale = getThisLocale(ctx); \
+ if (!locale) \
+ return QV4::Encode::undefined(); \
+ return ctx->engine->newString(locale-> VARIABLE())->asReturnedValue();\
}
LOCALE_STRING_PROPERTY(name)
@@ -849,7 +875,7 @@ void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine)
engine->stringClass->prototype->defineDefaultProperty(QStringLiteral("localeCompare"), method_localeCompare);
}
-QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 1 || (!ctx->callData->args[0].isString() && !ctx->callData->args[0].asStringObject()))
return QV4::StringPrototype::method_localeCompare(ctx);
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 8075bd462f..8ca67a8c83 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -58,13 +58,13 @@ public:
static void registerExtension(QV4::ExecutionEngine *engine);
private:
- static QV4::ReturnedValue method_toLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_toLocaleTimeString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_toLocaleDateString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_fromLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_fromLocaleTimeString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_fromLocaleDateString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_timeZoneUpdated(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleTimeString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleDateString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleTimeString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleDateString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_timeZoneUpdated(QV4::CallContext *ctx);
};
@@ -74,9 +74,9 @@ public:
static void registerExtension(QV4::ExecutionEngine *engine);
private:
- static QV4::ReturnedValue method_toLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_fromLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::ReturnedValue method_toLocaleCurrencyString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleString(QV4::CallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleCurrencyString(QV4::CallContext *ctx);
};
@@ -125,7 +125,7 @@ public:
private:
QQmlLocale();
- static QV4::ReturnedValue method_localeCompare(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_localeCompare(QV4::CallContext *ctx);
};
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 342d1dc69c..ed0c0afd6f 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -225,17 +225,21 @@ public:
void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e)
{
QV4::ExecutionEngine *v4 = QV8Engine::getV4(e->handle());
- v4->pushGlobalContext();
if (scriptCallback && scriptApi(e).isUndefined()) {
+ v4->pushGlobalContext();
setScriptApi(e, scriptCallback(e, e));
+ v4->popContext();
} else if (qobjectCallback && !qobjectApi(e)) {
+ v4->pushGlobalContext();
setQObjectApi(e, qobjectCallback(e, e));
+ v4->popContext();
} else if (!url.isEmpty() && !qobjectApi(e)) {
+ v4->pushGlobalContext();
QQmlComponent component(e, url, QQmlComponent::PreferSynchronous);
QObject *o = component.create();
setQObjectApi(e, o);
+ v4->popContext();
}
- v4->popContext();
}
void QQmlType::SingletonInstanceInfo::destroy(QQmlEngine *e)
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 56776dcb82..3798129e8b 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -525,8 +525,14 @@ QObject *QmlObjectCreator::create(int subComponentIndex, QObject *parent)
context->setIdPropertyData(mapping);
if (subComponentIndex == -1) {
- foreach (QQmlScriptData *script, compiledData->scripts)
- context->importedScripts << script->scriptValueForContext(context);
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
+ QV4::Scope scope(v4);
+ QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count()));
+ for (int i = 0; i < compiledData->scripts.count(); ++i) {
+ QQmlScriptData *s = compiledData->scripts.at(i);
+ scripts->putIndexed(i, s->scriptValueForContext(context));
+ }
+ context->importedScripts = scripts;
} else if (parentContext) {
context->importedScripts = parentContext->importedScripts;
}
@@ -1004,8 +1010,7 @@ void QmlObjectCreator::setupBindings()
bool QmlObjectCreator::setPropertyValue(QQmlPropertyData *property, int bindingIndex, const QV4::CompiledData::Binding *binding)
{
if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
- const QV4::CompiledData::Object *obj = qmlUnit->objectAt(binding->value.objectIndex);
- Q_ASSERT(stringAt(obj->inheritedTypeNameIndex).isEmpty());
+ Q_ASSERT(stringAt(qmlUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex).isEmpty());
QQmlType *attachedType = resolvedTypes.value(binding->propertyNameIndex).type;
const int id = attachedType->attachedPropertiesId();
QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject);
@@ -1260,7 +1265,7 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
}
QQmlData *ddata = QQmlData::get(instance, /*create*/true);
- if (index == qmlUnit->indexOfRootObject) {
+ if (static_cast<quint32>(index) == qmlUnit->indexOfRootObject) {
if (ddata->context) {
Q_ASSERT(ddata->context != context);
Q_ASSERT(ddata->outerContext);
@@ -1427,7 +1432,7 @@ bool QQmlComponentAndAliasResolver::resolve()
// when someProperty _is_ a QQmlComponent. In that case the Item {}
// should be implicitly surrounded by Component {}
- for (int i = 0; i < qmlUnit->nObjects; ++i) {
+ for (quint32 i = 0; i < qmlUnit->nObjects; ++i) {
const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i);
if (stringAt(obj->inheritedTypeNameIndex).isEmpty())
continue;
@@ -1511,14 +1516,14 @@ bool QQmlComponentAndAliasResolver::collectIdsAndAliases(int objectIndex)
}
const QV4::CompiledData::Property *property = obj->propertyTable();
- for (int i = 0; i < obj->nProperties; ++i, ++property)
+ for (quint32 i = 0; i < obj->nProperties; ++i, ++property)
if (property->type == QV4::CompiledData::Property::Alias) {
_objectsWithAliases.append(objectIndex);
break;
}
const QV4::CompiledData::Binding *binding = obj->bindingTable();
- for (int i = 0; i < obj->nBindings; ++i, ++binding) {
+ for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) {
if (binding->type != QV4::CompiledData::Binding::Type_Object
&& binding->type != QV4::CompiledData::Binding::Type_AttachedProperty
&& binding->type != QV4::CompiledData::Binding::Type_GroupProperty)
@@ -1694,7 +1699,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(const QUrl &url, const QV4::Compile
bool QQmlPropertyValidator::validate()
{
- for (int i = 0; i < qmlUnit->nObjects; ++i) {
+ for (quint32 i = 0; i < qmlUnit->nObjects; ++i) {
const QV4::CompiledData::Object *obj = qmlUnit->objectAt(i);
if (stringAt(obj->inheritedTypeNameIndex).isEmpty())
continue;
@@ -1718,7 +1723,7 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj,
QQmlPropertyData *defaultProperty = propertyCache->defaultProperty();
const QV4::CompiledData::Binding *binding = obj->bindingTable();
- for (int i = 0; i < obj->nBindings; ++i, ++binding) {
+ for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) {
if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty
|| binding->type == QV4::CompiledData::Binding::Type_GroupProperty)
continue;
@@ -1754,4 +1759,6 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj,
}
}
}
+
+ return true;
}
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 7723404831..3975b88bb0 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -1485,7 +1485,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object,
if (result->isInteger())
QUICK_STORE(int, result->integerValue())
else if (result->isNumber())
- QUICK_STORE(int, qRound(result->doubleValue()))
+ QUICK_STORE(int, result->doubleValue())
break;
case QMetaType::Double:
if (result->isNumber())
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 2cb944d824..6c40557886 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -1154,7 +1154,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(QQmlEngine *engine, const
if (errorString)
*errorString = QCoreApplication::translate("QQmlRewrite", "Signal uses unnamed parameter followed by named parameter.");
return QString();
- } else if (illegalNames.contains(param)) {
+ } else if (illegalNames.contains(QString::fromUtf8(param))) {
if (errorString)
*errorString = QCoreApplication::translate("QQmlRewrite", "Signal parameter \"%1\" hides global variable.").arg(QString::fromUtf8(param));
return QString();
diff --git a/src/qml/qml/qqmlscript.cpp b/src/qml/qml/qqmlscript.cpp
index 9fd06aa934..6cb23ec07c 100644
--- a/src/qml/qml/qqmlscript.cpp
+++ b/src/qml/qml/qqmlscript.cpp
@@ -500,7 +500,7 @@ public:
protected:
- QQmlScript::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
+ QQmlScript::Object *defineObjectBinding(AST::Node *node, AST::UiQualifiedId *propertyName, bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -659,7 +659,8 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
}
QQmlScript::Object *
-ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
+ProcessAST::defineObjectBinding(AST::Node *node,
+ AST::UiQualifiedId *propertyName,
bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
@@ -731,6 +732,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName,
obj->type = _parser->findOrCreateTypeId(objectType, obj);
obj->typeReference = _parser->_refTypes.at(obj->type);
obj->location = location;
+ obj->astNode = node;
if (propertyCount) {
Property *prop = currentProperty();
@@ -1130,7 +1132,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node)
const QString objectType = asString(node->qualifiedTypeNameId);
const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
- defineObjectBinding(/*propertyName = */ 0, false, objectType,
+ defineObjectBinding(node, /*propertyName = */ 0, false, objectType,
typeLocation, l, node->initializer);
return false;
@@ -1146,7 +1148,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node)
const QString objectType = asString(node->qualifiedTypeNameId);
const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken;
- defineObjectBinding(node->qualifiedId, node->hasOnToken, objectType,
+ defineObjectBinding(node, node->qualifiedId, node->hasOnToken, objectType,
typeLocation, l, node->initializer);
return false;
diff --git a/src/qml/qml/qqmlscript_p.h b/src/qml/qml/qqmlscript_p.h
index 86bbc1fb3a..fac31add5c 100644
--- a/src/qml/qml/qqmlscript_p.h
+++ b/src/qml/qml/qqmlscript_p.h
@@ -229,6 +229,7 @@ public:
// Used by compiler
struct SignalData {
int signalExpressionContextStack;
+ Object *signalScopeObject;
int functionIndex; // before gen() index in functionsToCompile, then index in runtime functions
};
union {
@@ -335,6 +336,8 @@ public:
QQmlPropertyCache *metatype;
+ QQmlJS::AST::Node *astNode; // responsible for the creation of this object
+
// The synthesized metaobject, if QML added signals or properties to
// this type. Otherwise null
QByteArray synthdata; // Generated by compiler
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 601c1b8bdc..911761d9fd 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qqmltypeloader_p.h"
-#include "qqmlabstracturlinterceptor.h"
+#include "qqmlabstracturlinterceptor_p.h"
#include "qqmlcontextwrapper_p.h"
#include "qqmlexpression_p.h"
@@ -1341,7 +1341,7 @@ bool QQmlTypeLoader::Blob::addPragma(const QQmlScript::Pragma &pragma, QList<QQm
Q_ASSERT(errors);
if (pragma.type == QQmlScript::Pragma::Singleton) {
- QUrl myUrl = url();
+ QUrl myUrl = finalUrl();
QQmlType *ret = QQmlMetaType::qmlType(myUrl, true);
if (!ret) {
@@ -1369,7 +1369,7 @@ bool QQmlTypeLoader::Blob::addPragma(const QQmlScript::Pragma &pragma, QList<QQm
} else {
QQmlError error;
error.setDescription(QLatin1String("Invalid pragma"));
- error.setUrl(url());
+ error.setUrl(finalUrl());
error.setLine(pragma.location.start.line);
error.setColumn(pragma.location.start.column);
errors->prepend(error);
@@ -1801,9 +1801,25 @@ bool QQmlTypeLoader::directoryExists(const QString &path)
Return a QmldirContent for absoluteFilePath. The QmldirContent may be cached.
\a filePath is either a bundle URL, or a local file path.
+
+It can also be a remote path for a remote directory import, but it will have been cached by now in this case.
*/
-const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString &filePath, const QString &uriHint)
-{
+const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString &filePathIn, const QString &uriHint)
+{
+ QUrl url(filePathIn); //May already contain bundle or http scheme
+ if (url.scheme() == QLatin1String("http") || url.scheme() == QLatin1String("https"))
+ return *(m_importQmlDirCache.value(filePathIn)); //Can't load the remote here, but should be cached
+ else if (!QQmlFile::isBundle(filePathIn))
+ url = QUrl::fromLocalFile(filePathIn);
+ if (engine() && engine()->urlInterceptor())
+ url = engine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::QmldirFile);
+ Q_ASSERT(url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("bundle"));
+ QString filePath;
+ if (url.scheme() == QLatin1String("file"))
+ filePath = url.toLocalFile();
+ else
+ filePath = url.path();
+
QmldirContent *qmldir;
QmldirContent **val = m_importQmlDirCache.value(filePath);
if (!val) {
@@ -1813,13 +1829,10 @@ const QQmlTypeLoader::QmldirContent *QQmlTypeLoader::qmldirContent(const QString
#define NOT_READABLE_ERROR QString(QLatin1String("module \"$$URI$$\" definition \"%1\" not readable"))
#define CASE_MISMATCH_ERROR QString(QLatin1String("cannot load module \"$$URI$$\": File name case mismatch for \"%1\""))
- if (QQmlFile::isBundle(filePath)) {
-
- QUrl url(filePath);
-
+ if (QQmlFile::isBundle(url.toString())) {
QQmlFile file(engine(), url);
if (file.isError()) {
- ERROR(NOT_READABLE_ERROR.arg(filePath));
+ ERROR(NOT_READABLE_ERROR.arg(url.toString()));
} else {
QString content(QString::fromUtf8(file.data(), file.size()));
qmldir->setContent(filePath, content);
@@ -2086,7 +2099,7 @@ void QQmlTypeData::done()
// If the type is CompositeSingleton but there was no pragma Singleton in the
// QML file, lets report an error.
QQmlType *type = QQmlMetaType::qmlType(url(), true);
- if (type && type->isCompositeSingleton() && !m_isSingleton) {
+ if (!isError() && type && type->isCompositeSingleton() && !m_isSingleton) {
QString typeName = type->qmlTypeName();
QQmlError error;
@@ -2141,7 +2154,7 @@ void QQmlTypeData::dataReceived(const Data &data)
if (data.isFile()) preparseData = data.asFile()->metaData(QLatin1String("qml:preparse"));
if (m_useNewCompiler) {
- parsedQML.reset(new QtQml::ParsedQML);
+ parsedQML.reset(new QtQml::ParsedQML(QV8Engine::getV4(typeLoader()->engine())->debugger != 0));
QQmlCodeGenerator compiler;
if (!compiler.generateFromQml(code, finalUrl(), finalUrlString(), parsedQML.data())) {
setError(compiler.errors);
@@ -2307,6 +2320,7 @@ void QQmlTypeData::compile()
m_compiledData->importCache->addref();
QQmlEngine *engine = typeLoader()->engine();
+ QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine);
for (QHash<int, TypeReference>::ConstIterator resolvedType = m_resolvedTypes.constBegin(), end = m_resolvedTypes.constEnd();
resolvedType != end; ++resolvedType) {
@@ -2357,12 +2371,13 @@ void QQmlTypeData::compile()
// Compile JS binding expressions and signal handlers
- JSCodeGen jsCodeGen;
- const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(finalUrlString(), parsedQML.data());
+ JSCodeGen jsCodeGen(enginePrivate, finalUrlString(), parsedQML->code, &parsedQML->jsModule, &parsedQML->jsParserEngine, parsedQML->program, m_compiledData->importCache);
+ QHash<int, QString> expressionNames; // ### TODO
+ const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(parsedQML->functions, expressionNames);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator));
+ QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(enginePrivate, v4->executableAllocator, &parsedQML->jsModule, &parsedQML->jsGenerator));
isel->setUseFastLookups(false);
QV4::CompiledData::CompilationUnit *jsUnit = isel->compile(/*generated unit data*/false);
@@ -2389,7 +2404,7 @@ void QQmlTypeData::compile()
m_compiledData->datas.reserve(qmlUnit->nObjects);
m_compiledData->propertyCaches.reserve(qmlUnit->nObjects);
- QQmlPropertyCacheCreator propertyCacheBuilder(QQmlEnginePrivate::get(m_typeLoader->engine()),
+ QQmlPropertyCacheCreator propertyCacheBuilder(enginePrivate,
qmlUnit, m_compiledData->url,
&m_imports, &m_compiledData->resolvedTypes);
@@ -2689,8 +2704,8 @@ QQmlScriptData::QQmlScriptData()
: importCache(0)
, pragmas(QQmlScript::Object::ScriptBlock::None)
, m_loaded(false)
- , m_program(0)
, m_precompiledScript(0)
+ , m_program(0)
{
}
@@ -2769,9 +2784,15 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620
}
- for (int ii = 0; ii < scripts.count(); ++ii) {
- ctxt->importedScripts << scripts.at(ii)->scriptData()->scriptValueForContext(ctxt);
+ QV4::ScopedObject scriptsArray(scope);
+ if (ctxt->importedScripts.isNullOrUndefined()) {
+ scriptsArray = v4->newArrayObject(scripts.count());
+ ctxt->importedScripts = scriptsArray;
+ } else {
+ scriptsArray = ctxt->importedScripts;
}
+ for (int ii = 0; ii < scripts.count(); ++ii)
+ scriptsArray->putIndexed(ii, scripts.at(ii)->scriptData()->scriptValueForContext(ctxt));
if (!hasEngine())
initialize(parentCtxt->engine);
@@ -2786,11 +2807,10 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->current;
- try {
- m_program->qml = qmlglobal;
- m_program->run();
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ m_program->qml = qmlglobal;
+ m_program->run();
+ if (scope.engine->hasException) {
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
if (error.isValid())
ep->warning(error);
}
@@ -2921,7 +2941,7 @@ void QQmlScriptBlob::done()
QList<QQmlError> errors;
QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
- m_scriptData->m_precompiledScript = QV4::Script::precompile(v4, m_scriptData->url, m_source, /*parseAsBinding*/true, &errors);
+ m_scriptData->m_precompiledScript = QV4::Script::precompile(v4, m_scriptData->url, m_source, &errors);
if (m_scriptData->m_precompiledScript)
m_scriptData->m_precompiledScript->ref();
m_source.clear();
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index b93cf2942d..c9a5edc39e 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -59,7 +59,6 @@
#include <QtQml/qqmlerror.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlfile.h>
-#include <QtQml/qqmlabstracturlinterceptor.h>
#include <private/qhashedstring_p.h>
#include <private/qqmlscript_p.h>
@@ -68,6 +67,7 @@
#include <private/qqmldirparser_p.h>
#include <private/qqmlbundle_p.h>
#include <private/qflagpointer_p.h>
+#include <private/qqmlabstracturlinterceptor_p.h>
#include <private/qv4value_p.h>
#include <private/qv4script_p.h>
diff --git a/src/qml/qml/qqmltypenamecache.cpp b/src/qml/qml/qqmltypenamecache.cpp
index 87764c49ae..a880bbdd58 100644
--- a/src/qml/qml/qqmltypenamecache.cpp
+++ b/src/qml/qml/qqmltypenamecache.cpp
@@ -106,7 +106,7 @@ QQmlTypeNameCache::Result QQmlTypeNameCache::query(const QHashedStringRef &name,
const Import *i = static_cast<const Import *>(importNamespace);
Q_ASSERT(i->scriptIndex == -1);
- Result result = result = typeSearch(i->modules, name);
+ Result result = typeSearch(i->modules, name);
if (!result.isValid())
result = query(i->compositeSingletons, name);
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index de2386daf1..258442bc1d 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -69,6 +69,11 @@ QmlTypeWrapper::~QmlTypeWrapper()
typeNamespace->release();
}
+bool QmlTypeWrapper::isSingleton() const
+{
+ return type && type->isSingleton();
+}
+
QVariant QmlTypeWrapper::toVariant() const
{
if (type && type->isSingleton()) {
@@ -121,7 +126,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
Scoped<QmlTypeWrapper> w(scope, m->as<QmlTypeWrapper>());
if (!w)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
if (hasProperty)
@@ -202,9 +207,8 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasPro
if (r.type) {
return create(w->v8, object, r.type, w->mode);
} else if (r.scriptIndex != -1) {
- int index = r.scriptIndex;
- if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
+ QV4::ScopedObject scripts(scope, context->importedScripts);
+ return scripts->getIndexed(r.scriptIndex);
} else if (r.importNamespace) {
return create(w->v8, object, context->imports, r.importNamespace);
}
@@ -229,8 +233,12 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value)
{
QmlTypeWrapper *w = m->as<QmlTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
- if (!w)
+ if (v4->hasException)
+ return;
+ if (!w) {
v4->current->throwTypeError();
+ return;
+ }
QV4::Scope scope(v4);
QV8Engine *v8engine = v4->v8Engine;
@@ -255,6 +263,7 @@ void QmlTypeWrapper::put(Managed *m, const StringRef name, const ValueRef value)
if (!apiprivate) {
QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"');
v4->current->throwError(error);
+ return;
} else {
apiprivate->put(name, value);
}
@@ -277,4 +286,15 @@ void QmlTypeWrapper::destroy(Managed *that)
static_cast<QmlTypeWrapper *>(that)->~QmlTypeWrapper();
}
+bool QmlTypeWrapper::isEqualTo(Managed *a, Managed *b)
+{
+ QV4::QmlTypeWrapper *qmlTypeWrapperA = a->asObject()->as<QV4::QmlTypeWrapper>();
+ if (QV4::QmlTypeWrapper *qmlTypeWrapperB = b->asObject()->as<QV4::QmlTypeWrapper>())
+ return qmlTypeWrapperA->toVariant() == qmlTypeWrapperB->toVariant();
+ else if (QV4::QObjectWrapper *qobjectWrapper = b->as<QV4::QObjectWrapper>())
+ return qmlTypeWrapperA->toVariant().value<QObject*>() == qobjectWrapper->object();
+
+ return false;
+}
+
QT_END_NAMESPACE
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 9078c184c6..ee462d6479 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -76,6 +76,8 @@ private:
public:
enum TypeNameMode { IncludeEnums, ExcludeEnums };
+ bool isSingleton() const;
+
QVariant toVariant() const;
static ReturnedValue create(QV8Engine *, QObject *, QQmlType *, TypeNameMode = IncludeEnums);
@@ -87,6 +89,9 @@ public:
static PropertyAttributes query(const Managed *, StringRef name);
static void destroy(Managed *that);
+protected:
+ static bool isEqualTo(Managed *that, Managed *o);
+
private:
QV8Engine *v8;
TypeNameMode mode;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 6477f63daf..d733694923 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -208,8 +208,10 @@ PropertyAttributes QmlValueTypeWrapper::query(const Managed *m, StringRef name)
{
const QmlValueTypeWrapper *r = m->as<const QmlValueTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
- if (!r)
+ if (!r) {
v4->current->throwTypeError();
+ return PropertyAttributes();
+ }
QQmlPropertyData local;
QQmlPropertyData *result = 0;
@@ -242,14 +244,14 @@ bool QmlValueTypeWrapper::isEqual(const QVariant& value)
}
}
-ReturnedValue QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
+ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx)
{
Object *o = ctx->callData->thisObject.asObject();
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QmlValueTypeWrapper *w = o->as<QmlValueTypeWrapper>();
if (!w)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
if (w->objectType == QmlValueTypeWrapper::Reference) {
QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(w);
@@ -271,7 +273,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *h
QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
if (!r)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
// Note: readReferenceValue() can change the reference->type.
if (r->objectType == QmlValueTypeWrapper::Reference) {
@@ -332,9 +334,14 @@ void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef v
{
ExecutionEngine *v4 = m->engine();
Scope scope(v4);
+ if (scope.hasException())
+ return;
+
Scoped<QmlValueTypeWrapper> r(scope, m->as<QmlValueTypeWrapper>());
- if (!r)
+ if (!r) {
v4->current->throwTypeError();
+ return;
+ }
QByteArray propName = name->toQString().toUtf8();
if (r->objectType == QmlValueTypeWrapper::Reference) {
@@ -359,6 +366,7 @@ void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef v
QString error = QLatin1String("Cannot assign JavaScript function to value-type property");
Scoped<String> e(scope, r->v8->toString(error));
v4->current->throwError(e);
+ return;
}
QQmlContextData *context = r->v8->callingContext();
@@ -377,8 +385,6 @@ void QmlValueTypeWrapper::put(Managed *m, const StringRef name, const ValueRef v
newBinding = new QQmlBinding(value, reference->object, context,
frame.source, qmlSourceCoordinate(frame.line), qmlSourceCoordinate(frame.column));
newBinding->setTarget(reference->object, cacheData, context);
- newBinding->setEvaluateFlags(newBinding->evaluateFlags() |
- QQmlBinding::RequiresThisObject);
}
QQmlAbstractBinding *oldBinding =
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index f2effc362b..9dd3e8dcbe 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -89,7 +89,7 @@ public:
static bool isEqualTo(Managed *m, Managed *other);
static PropertyAttributes query(const Managed *, StringRef name);
- static QV4::ReturnedValue method_toString(SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toString(CallContext *ctx);
QV8Engine *v8;
ObjectType objectType;
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index c1c05fac11..983136a846 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -400,8 +400,8 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QML_STORE_PROVIDER_VALUE(StoreColor, QMetaType::QColor, instr.value);
QML_STORE_VALUE(StoreDate, QDate, QDate::fromJulianDay(instr.value));
QML_STORE_VALUE(StoreDateTime, QDateTime,
- QDateTime(QDate::fromJulianDay(instr.date), *(QTime *)&instr.time));
- QML_STORE_POINTER(StoreTime, (QTime *)&instr.time);
+ QDateTime(QDate::fromJulianDay(instr.date), QTime::fromMSecsSinceStartOfDay(instr.time)));
+ QML_STORE_VALUE(StoreTime, QTime, QTime::fromMSecsSinceStartOfDay(instr.time));
QML_STORE_POINTER(StorePoint, (QPoint *)&instr.point);
QML_STORE_POINTER(StorePointF, (QPointF *)&instr.point);
QML_STORE_POINTER(StoreSize, (QSize *)&instr.size);
@@ -638,7 +638,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QML_BEGIN_INSTR(CreateSimpleObject)
QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData));
- ::memset(o, 0, instr.typeSize + sizeof(QQmlData));
+ ::memset(static_cast<void *>(o), 0, instr.typeSize + sizeof(QQmlData));
instr.create(o);
QQmlData *ddata = (QQmlData *)(((const char *)o) + instr.typeSize);
@@ -791,7 +791,13 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QML_END_INSTR(StoreSignal)
QML_BEGIN_INSTR(StoreImportedScript)
- CTXT->importedScripts << SCRIPTS.at(instr.value)->scriptValueForContext(CTXT);
+ QV4::Scope scope(v4);
+ QV4::ScopedObject scripts(scope, CTXT->importedScripts.value());
+ if (!scripts) {
+ scripts = v4->newArrayObject();
+ CTXT->importedScripts = scripts;
+ }
+ scripts->putIndexed(instr.value, SCRIPTS.at(instr.value)->scriptValueForContext(CTXT));
QML_END_INSTR(StoreImportedScript)
QML_BEGIN_INSTR(StoreScriptString)
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 5752033744..4b34792421 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -82,7 +82,8 @@ void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *)
}
}
- m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0);
+ if (!QQmlData::wasDeleted(m_target->object))
+ m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0);
}
}
@@ -956,14 +957,14 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
QV4::ScopedValue result(scope);
QV4::ExecutionContext *ctx = function->engine()->current;
- try {
- result = function->call(callData);
- if (a[0]) *(QVariant *)a[0] = ep->v8engine()->toVariant(result, 0);
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ result = function->call(callData);
+ if (scope.hasException()) {
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
if (error.isValid())
ep->warning(error);
if (a[0]) *(QVariant *)a[0] = QVariant();
+ } else {
+ if (a[0]) *(QVariant *)a[0] = ep->v8engine()->toVariant(result, 0);
}
ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
@@ -1231,9 +1232,9 @@ void QQmlVMEMetaObject::ensureQObjectWrapper()
QV4::QObjectWrapper::wrap(v4, object);
}
-void QQmlVMEMetaObject::mark()
+void QQmlVMEMetaObject::mark(QV4::ExecutionEngine *e)
{
- varProperties.markOnce();
+ varProperties.markOnce(e);
// add references created by VMEVariant properties
int maxDataIdx = metaData->propertyCount - metaData->varPropertyCount;
@@ -1244,13 +1245,13 @@ void QQmlVMEMetaObject::mark()
if (ref) {
QQmlData *ddata = QQmlData::get(ref);
if (ddata)
- ddata->jsWrapper.markOnce();
+ ddata->jsWrapper.markOnce(e);
}
}
}
if (QQmlVMEMetaObject *parent = parentVMEMetaObject())
- parent->mark();
+ parent->mark(e);
}
void QQmlVMEMetaObject::allocateVarPropertiesArray()
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 25a577d2e6..a9a0308ded 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -209,7 +209,7 @@ public:
void ensureQObjectWrapper();
- void mark();
+ void mark(QV4::ExecutionEngine *e);
void connectAlias(int aliasId);
QBitArray aConnected;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index aff0cf2b59..18e3e33c4b 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -73,7 +73,7 @@ using namespace QV4;
#define V4THROW_REFERENCE(string) { \
Scoped<Object> error(scope, ctx->engine->newReferenceErrorObject(QStringLiteral(string))); \
- ctx->throwError(error); \
+ return ctx->throwError(error); \
}
QT_BEGIN_NAMESPACE
@@ -189,8 +189,8 @@ class NamedNodeMap : public Object
public:
NamedNodeMap(ExecutionEngine *engine, NodeImpl *data, const QList<NodeImpl *> &list)
: Object(engine)
- , d(data)
, list(list)
+ , d(data)
{
vtbl = &static_vtbl;
@@ -279,24 +279,24 @@ public:
static void initClass(ExecutionEngine *engine);
// JS API
- static ReturnedValue method_get_nodeName(SimpleCallContext *ctx);
- static ReturnedValue method_get_nodeValue(SimpleCallContext *ctx);
- static ReturnedValue method_get_nodeType(SimpleCallContext *ctx);
-
- static ReturnedValue method_get_parentNode(SimpleCallContext *ctx);
- static ReturnedValue method_get_childNodes(SimpleCallContext *ctx);
- static ReturnedValue method_get_firstChild(SimpleCallContext *ctx);
- static ReturnedValue method_get_lastChild(SimpleCallContext *ctx);
- static ReturnedValue method_get_previousSibling(SimpleCallContext *ctx);
- static ReturnedValue method_get_nextSibling(SimpleCallContext *ctx);
- static ReturnedValue method_get_attributes(SimpleCallContext *ctx);
-
- //static ReturnedValue ownerDocument(SimpleCallContext *ctx);
- //static ReturnedValue namespaceURI(SimpleCallContext *ctx);
- //static ReturnedValue prefix(SimpleCallContext *ctx);
- //static ReturnedValue localName(SimpleCallContext *ctx);
- //static ReturnedValue baseURI(SimpleCallContext *ctx);
- //static ReturnedValue textContent(SimpleCallContext *ctx);
+ static ReturnedValue method_get_nodeName(CallContext *ctx);
+ static ReturnedValue method_get_nodeValue(CallContext *ctx);
+ static ReturnedValue method_get_nodeType(CallContext *ctx);
+
+ static ReturnedValue method_get_parentNode(CallContext *ctx);
+ static ReturnedValue method_get_childNodes(CallContext *ctx);
+ static ReturnedValue method_get_firstChild(CallContext *ctx);
+ static ReturnedValue method_get_lastChild(CallContext *ctx);
+ static ReturnedValue method_get_previousSibling(CallContext *ctx);
+ static ReturnedValue method_get_nextSibling(CallContext *ctx);
+ static ReturnedValue method_get_attributes(CallContext *ctx);
+
+ //static ReturnedValue ownerDocument(CallContext *ctx);
+ //static ReturnedValue namespaceURI(CallContext *ctx);
+ //static ReturnedValue prefix(CallContext *ctx);
+ //static ReturnedValue localName(CallContext *ctx);
+ //static ReturnedValue baseURI(CallContext *ctx);
+ //static ReturnedValue textContent(CallContext *ctx);
static ReturnedValue getProto(ExecutionEngine *v4);
@@ -352,12 +352,12 @@ class Attr : public Node
{
public:
// JS API
- static ReturnedValue method_name(SimpleCallContext *ctx);
-// static ReturnedValue specified(SimpleCallContext *);
- static ReturnedValue method_value(SimpleCallContext *ctx);
- static ReturnedValue method_ownerElement(SimpleCallContext *ctx);
-// static ReturnedValue schemaTypeInfo(SimpleCallContext *);
-// static ReturnedValue isId(SimpleCallContext *c);
+ static ReturnedValue method_name(CallContext *ctx);
+// static ReturnedValue specified(CallContext *);
+ static ReturnedValue method_value(CallContext *ctx);
+ static ReturnedValue method_ownerElement(CallContext *ctx);
+// static ReturnedValue schemaTypeInfo(CallContext *);
+// static ReturnedValue isId(CallContext *c);
// C++ API
static ReturnedValue prototype(ExecutionEngine *);
@@ -367,7 +367,7 @@ class CharacterData : public Node
{
public:
// JS API
- static ReturnedValue method_length(SimpleCallContext *ctx);
+ static ReturnedValue method_length(CallContext *ctx);
// C++ API
static ReturnedValue prototype(ExecutionEngine *v4);
@@ -377,8 +377,8 @@ class Text : public CharacterData
{
public:
// JS API
- static ReturnedValue method_isElementContentWhitespace(SimpleCallContext *ctx);
- static ReturnedValue method_wholeText(SimpleCallContext *ctx);
+ static ReturnedValue method_isElementContentWhitespace(CallContext *ctx);
+ static ReturnedValue method_wholeText(CallContext *ctx);
// C++ API
static ReturnedValue prototype(ExecutionEngine *);
@@ -395,10 +395,10 @@ class Document : public Node
{
public:
// JS API
- static ReturnedValue method_xmlVersion(SimpleCallContext *ctx);
- static ReturnedValue method_xmlEncoding(SimpleCallContext *ctx);
- static ReturnedValue method_xmlStandalone(SimpleCallContext *ctx);
- static ReturnedValue method_documentElement(SimpleCallContext *ctx);
+ static ReturnedValue method_xmlVersion(CallContext *ctx);
+ static ReturnedValue method_xmlEncoding(CallContext *ctx);
+ static ReturnedValue method_xmlStandalone(CallContext *ctx);
+ static ReturnedValue method_documentElement(CallContext *ctx);
// C++ API
static ReturnedValue prototype(ExecutionEngine *);
@@ -417,12 +417,12 @@ void NodeImpl::release()
document->release();
}
-ReturnedValue NodePrototype::method_get_nodeName(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QString name;
switch (r->d->type) {
@@ -442,12 +442,12 @@ ReturnedValue NodePrototype::method_get_nodeName(SimpleCallContext *ctx)
return Encode(ctx->engine->newString(name));
}
-ReturnedValue NodePrototype::method_get_nodeValue(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
if (r->d->type == NodeImpl::Document ||
r->d->type == NodeImpl::DocumentFragment ||
@@ -461,22 +461,22 @@ ReturnedValue NodePrototype::method_get_nodeValue(SimpleCallContext *ctx)
return Encode(ctx->engine->newString(r->d->data));
}
-ReturnedValue NodePrototype::method_get_nodeType(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
return Encode(r->d->type);
}
-ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -486,24 +486,24 @@ ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx)
return Encode::null();
}
-ReturnedValue NodePrototype::method_get_childNodes(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
return NodeList::create(engine, r->d);
}
-ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -513,12 +513,12 @@ ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx)
return Node::create(engine, r->d->children.first());
}
-ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -528,12 +528,12 @@ ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx)
return Node::create(engine, r->d->children.last());
}
-ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -552,12 +552,12 @@ ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx)
return Encode::null();
}
-ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -576,12 +576,12 @@ ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx)
return Encode::null();
}
-ReturnedValue NodePrototype::method_get_attributes(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
if (!r)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QV8Engine *engine = ctx->engine->v8Engine;
@@ -608,7 +608,6 @@ ReturnedValue Node::create(QV8Engine *engine, NodeImpl *data)
ExecutionEngine *v4 = QV8Engine::getV4(engine);
Scope scope(v4);
- QQmlXMLHttpRequestData *d = xhrdata(engine);
Scoped<Node> instance(scope, new (v4->memoryManager) Node(v4, data));
ScopedObject p(scope);
@@ -671,7 +670,7 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine)
return d->attrPrototype.value();
}
-ReturnedValue Attr::method_name(SimpleCallContext *ctx)
+ReturnedValue Attr::method_name(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -682,7 +681,7 @@ ReturnedValue Attr::method_name(SimpleCallContext *ctx)
return engine->toString(r->d->name);
}
-ReturnedValue Attr::method_value(SimpleCallContext *ctx)
+ReturnedValue Attr::method_value(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -693,7 +692,7 @@ ReturnedValue Attr::method_value(SimpleCallContext *ctx)
return engine->toString(r->d->data);
}
-ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx)
+ReturnedValue Attr::method_ownerElement(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -704,7 +703,7 @@ ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx)
return Node::create(engine, r->d->parent);
}
-ReturnedValue CharacterData::method_length(SimpleCallContext *ctx)
+ReturnedValue CharacterData::method_length(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -731,7 +730,7 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4)
return d->characterDataPrototype.value();
}
-ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx)
+ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -740,7 +739,7 @@ ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx)
return Encode(r->d->data.trimmed().isEmpty());
}
-ReturnedValue Text::method_wholeText(SimpleCallContext *ctx)
+ReturnedValue Text::method_wholeText(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -907,7 +906,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
QV4::ExecutionEngine *v4 = m->engine();
NamedNodeMap *r = m->as<NamedNodeMap>();
if (!r)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
QV8Engine *engine = v4->v8Engine;
@@ -926,7 +925,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasPrope
NamedNodeMap *r = m->as<NamedNodeMap>();
QV4::ExecutionEngine *v4 = m->engine();
if (!r)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
name->makeIdentifier();
if (name->equals(v4->id_length))
@@ -962,7 +961,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
QV4::ExecutionEngine *v4 = m->engine();
NodeList *r = m->as<NodeList>();
if (!r)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
QV8Engine *engine = v4->v8Engine;
@@ -981,7 +980,7 @@ ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty)
QV4::ExecutionEngine *v4 = m->engine();
NodeList *r = m->as<NodeList>();
if (!r)
- v4->current->throwTypeError();
+ return v4->current->throwTypeError();
name->makeIdentifier();
@@ -992,14 +991,13 @@ ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty)
ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data)
{
- QQmlXMLHttpRequestData *d = xhrdata(engine);
ExecutionEngine *v4 = QV8Engine::getV4(engine);
Scope scope(v4);
Scoped<NodeList> instance(scope, new (v4->memoryManager) NodeList(v4, data));
return instance.asReturnedValue();
}
-ReturnedValue Document::method_documentElement(SimpleCallContext *ctx)
+ReturnedValue Document::method_documentElement(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -1010,7 +1008,7 @@ ReturnedValue Document::method_documentElement(SimpleCallContext *ctx)
return Node::create(engine, static_cast<DocumentImpl *>(r->d)->root);
}
-ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlStandalone(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -1021,7 +1019,7 @@ ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx)
return Encode(static_cast<DocumentImpl *>(r->d)->isStandalone);
}
-ReturnedValue Document::method_xmlVersion(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlVersion(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -1032,7 +1030,7 @@ ReturnedValue Document::method_xmlVersion(SimpleCallContext *ctx)
return engine->toString(static_cast<DocumentImpl *>(r->d)->version);
}
-ReturnedValue Document::method_xmlEncoding(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlEncoding(CallContext *ctx)
{
Scope scope(ctx);
Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
@@ -1108,6 +1106,7 @@ private:
void setMe(const ValueRef me);
PersistentValue m_me;
+ void dispatchCallbackImpl(const ValueRef me);
void dispatchCallback(const ValueRef me);
int m_status;
@@ -1534,45 +1533,57 @@ const QByteArray &QQmlXMLHttpRequest::rawResponseBody() const
return m_responseEntityBody;
}
-void QQmlXMLHttpRequest::dispatchCallback(const ValueRef me)
+void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
{
ExecutionContext *ctx = v4->current;
QV4::Scope scope(v4);
- try {
- Scoped<Object> o(scope, me);
- if (!o)
- ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
-
- ScopedString s(scope, v4->newString(QStringLiteral("ThisObject")));
- Scoped<Object> thisObj(scope, o->get(s));
- if (!thisObj)
- ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
-
- s = v4->newString(QStringLiteral("onreadystatechange"));
- Scoped<FunctionObject> callback(scope, thisObj->get(s));
- if (!callback) {
- // not an error, but no onreadystatechange function to call.
- return;
- }
+ Scoped<Object> o(scope, me);
+ if (!o) {
+ ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
+ return;
+ }
- s = v4->newString(QStringLiteral("ActivationObject"));
- Scoped<Object> activationObject(scope, o->get(s));
- if (!activationObject)
- v4->current->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
+ ScopedString s(scope, v4->newString(QStringLiteral("ThisObject")));
+ Scoped<Object> thisObj(scope, o->get(s));
+ if (!thisObj) {
+ ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
+ return;
+ }
- QQmlContextData *callingContext = QmlContextWrapper::getContext(activationObject);
- if (callingContext) {
- QV4::ScopedCallData callData(scope, 0);
- callData->thisObject = activationObject.asReturnedValue();
- callback->call(callData);
- }
+ s = v4->newString(QStringLiteral("onreadystatechange"));
+ Scoped<FunctionObject> callback(scope, thisObj->get(s));
+ if (!callback) {
+ // not an error, but no onreadystatechange function to call.
+ return;
+ }
+
+ s = v4->newString(QStringLiteral("ActivationObject"));
+ Scoped<Object> activationObject(scope, o->get(s));
+ if (!activationObject) {
+ v4->current->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
+ return;
+ }
+
+ QQmlContextData *callingContext = QmlContextWrapper::getContext(activationObject);
+ if (callingContext) {
+ QV4::ScopedCallData callData(scope, 0);
+ callData->thisObject = activationObject.asReturnedValue();
+ callback->call(callData);
+ }
- // if the callingContext object is no longer valid, then it has been
- // deleted explicitly (e.g., by a Loader deleting the itemContext when
- // the source is changed). We do nothing in this case, as the evaluation
- // cannot succeed.
- } catch (...) {
- QQmlError error = QV4::ExecutionEngine::convertJavaScriptException(ctx);
+ // if the callingContext object is no longer valid, then it has been
+ // deleted explicitly (e.g., by a Loader deleting the itemContext when
+ // the source is changed). We do nothing in this case, as the evaluation
+ // cannot succeed.
+
+}
+
+void QQmlXMLHttpRequest::dispatchCallback(const ValueRef me)
+{
+ ExecutionContext *ctx = v4->current;
+ dispatchCallbackImpl(me);
+ if (v4->hasException) {
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(v4->v8Engine->engine()), error);
}
}
@@ -1635,17 +1646,17 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
static void destroy(Managed *that) {
that->as<QQmlXMLHttpRequestCtor>()->~QQmlXMLHttpRequestCtor();
}
- static void markObjects(Managed *that) {
+ static void markObjects(Managed *that, ExecutionEngine *e) {
QQmlXMLHttpRequestCtor *c = that->as<QQmlXMLHttpRequestCtor>();
if (c->proto)
- c->proto->mark();
+ c->proto->mark(e);
}
static ReturnedValue construct(Managed *that, QV4::CallData *)
{
Scope scope(that->engine());
Scoped<QQmlXMLHttpRequestCtor> ctor(scope, that->as<QQmlXMLHttpRequestCtor>());
if (!ctor)
- that->engine()->current->throwTypeError();
+ return that->engine()->current->throwTypeError();
QV8Engine *engine = that->engine()->v8Engine;
QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager());
@@ -1660,18 +1671,18 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
void setupProto();
- static ReturnedValue method_open(SimpleCallContext *ctx);
- static ReturnedValue method_setRequestHeader(SimpleCallContext *ctx);
- static ReturnedValue method_send(SimpleCallContext *ctx);
- static ReturnedValue method_abort(SimpleCallContext *ctx);
- static ReturnedValue method_getResponseHeader(SimpleCallContext *ctx);
- static ReturnedValue method_getAllResponseHeaders(SimpleCallContext *ctx);
+ static ReturnedValue method_open(CallContext *ctx);
+ static ReturnedValue method_setRequestHeader(CallContext *ctx);
+ static ReturnedValue method_send(CallContext *ctx);
+ static ReturnedValue method_abort(CallContext *ctx);
+ static ReturnedValue method_getResponseHeader(CallContext *ctx);
+ static ReturnedValue method_getAllResponseHeaders(CallContext *ctx);
- static ReturnedValue method_get_readyState(SimpleCallContext *ctx);
- static ReturnedValue method_get_status(SimpleCallContext *ctx);
- static ReturnedValue method_get_statusText(SimpleCallContext *ctx);
- static ReturnedValue method_get_responseText(SimpleCallContext *ctx);
- static ReturnedValue method_get_responseXML(SimpleCallContext *ctx);
+ static ReturnedValue method_get_readyState(CallContext *ctx);
+ static ReturnedValue method_get_status(CallContext *ctx);
+ static ReturnedValue method_get_statusText(CallContext *ctx);
+ static ReturnedValue method_get_responseText(CallContext *ctx);
+ static ReturnedValue method_get_responseXML(CallContext *ctx);
Object *proto;
@@ -1711,7 +1722,7 @@ void QQmlXMLHttpRequestCtor::setupProto()
// XMLHttpRequest methods
-ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1761,7 +1772,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx)
return r->open(meObject, method, url);
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1808,7 +1819,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext
return Encode::undefined();
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1830,7 +1841,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx)
return r->send(meObject, data);
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_abort(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1842,7 +1853,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx)
return r->abort(meObject);
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1863,7 +1874,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext
return engine->toString(r->header(ctx->callData->args[0].toQStringNoThrow()));
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1885,7 +1896,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallCon
}
// XMLHttpRequest properties
-ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1896,7 +1907,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *c
return Encode(r->readyState());
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1914,7 +1925,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx)
return Encode(r->replyStatus());
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1934,7 +1945,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *c
return engine->toString(r->replyStatusText());
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
@@ -1951,7 +1962,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext
return engine->toString(r->responseBody());
}
-ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx)
{
Scope scope(ctx);
Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index f9aca08d5a..c80a742af0 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -102,11 +102,11 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) {
QMetaEnum enumerator = qtMetaObject->enumerator(ii);
for (int jj = 0; jj < enumerator.keyCount(); ++jj) {
- put((str = v4->newString(enumerator.key(jj))), (v = QV4::Primitive::fromInt32(enumerator.value(jj))));
+ put((str = v4->newString(QString::fromUtf8(enumerator.key(jj)))), (v = QV4::Primitive::fromInt32(enumerator.value(jj))));
}
}
- put((str = v4->newString("Asynchronous")), (v = QV4::Primitive::fromInt32(0)));
- put((str = v4->newString("Synchronous")), (v = QV4::Primitive::fromInt32(1)));
+ put((str = v4->newString(QStringLiteral("Asynchronous"))), (v = QV4::Primitive::fromInt32(0)));
+ put((str = v4->newString(QStringLiteral("Synchronous"))), (v = QV4::Primitive::fromInt32(1)));
defineDefaultProperty(QStringLiteral("include"), QV4Include::method_include);
defineDefaultProperty(QStringLiteral("isQtObject"), method_isQtObject);
@@ -158,7 +158,7 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
\qmlmethod bool Qt::isQtObject(object)
Returns true if \c object is a valid reference to a Qt or QML object, otherwise false.
*/
-ReturnedValue QtObject::method_isQtObject(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_isQtObject(QV4::CallContext *ctx)
{
if (ctx->callData->argc == 0)
return QV4::Encode(false);
@@ -172,7 +172,7 @@ ReturnedValue QtObject::method_isQtObject(QV4::SimpleCallContext *ctx)
Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
-ReturnedValue QtObject::method_rgba(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_rgba(QV4::CallContext *ctx)
{
int argCount = ctx->callData->argc;
if (argCount < 3 || argCount > 4)
@@ -201,7 +201,7 @@ ReturnedValue QtObject::method_rgba(QV4::SimpleCallContext *ctx)
Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
-ReturnedValue QtObject::method_hsla(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_hsla(QV4::CallContext *ctx)
{
int argCount = ctx->callData->argc;
if (argCount < 3 || argCount > 4)
@@ -232,7 +232,7 @@ may be either color values or string values. If a string value is supplied it
must be convertible to a color, as described for the \l{colorbasictypedocs}{color}
basic type.
*/
-ReturnedValue QtObject::method_colorEqual(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 2)
V4THROW_ERROR("Qt.colorEqual(): Invalid arguments");
@@ -272,7 +272,7 @@ Returns a \c rect with the top-left corner at \c x, \c y and the specified \c wi
The returned object has \c x, \c y, \c width and \c height attributes with the given values.
*/
-ReturnedValue QtObject::method_rect(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_rect(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 4)
V4THROW_ERROR("Qt.rect(): Invalid arguments");
@@ -289,7 +289,7 @@ ReturnedValue QtObject::method_rect(QV4::SimpleCallContext *ctx)
\qmlmethod point Qt::point(int x, int y)
Returns a Point with the specified \c x and \c y coordinates.
*/
-ReturnedValue QtObject::method_point(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_point(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 2)
V4THROW_ERROR("Qt.point(): Invalid arguments");
@@ -304,7 +304,7 @@ ReturnedValue QtObject::method_point(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::size(int width, int height)
Returns a Size with the specified \c width and \c height.
*/
-ReturnedValue QtObject::method_size(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_size(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 2)
V4THROW_ERROR("Qt.size(): Invalid arguments");
@@ -323,7 +323,7 @@ key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's
subproperty names, and the values are valid values for each subproperty.
Invalid keys will be ignored.
*/
-ReturnedValue QtObject::method_font(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_font(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 1 || !ctx->callData->args[0].isObject())
V4THROW_ERROR("Qt.font(): Invalid arguments");
@@ -342,7 +342,7 @@ ReturnedValue QtObject::method_font(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::vector2d(real x, real y)
Returns a Vector2D with the specified \c x and \c y.
*/
-ReturnedValue QtObject::method_vector2d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector2d(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 2)
V4THROW_ERROR("Qt.vector2d(): Invalid arguments");
@@ -360,7 +360,7 @@ ReturnedValue QtObject::method_vector2d(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::vector3d(real x, real y, real z)
Returns a Vector3D with the specified \c x, \c y and \c z.
*/
-ReturnedValue QtObject::method_vector3d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector3d(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 3)
V4THROW_ERROR("Qt.vector3d(): Invalid arguments");
@@ -379,7 +379,7 @@ ReturnedValue QtObject::method_vector3d(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::vector4d(real x, real y, real z, real w)
Returns a Vector4D with the specified \c x, \c y, \c z and \c w.
*/
-ReturnedValue QtObject::method_vector4d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector4d(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 4)
V4THROW_ERROR("Qt.vector4d(): Invalid arguments");
@@ -399,7 +399,7 @@ ReturnedValue QtObject::method_vector4d(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::quaternion(real scalar, real x, real y, real z)
Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z.
*/
-ReturnedValue QtObject::method_quaternion(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_quaternion(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 4)
V4THROW_ERROR("Qt.quaternion(): Invalid arguments");
@@ -422,7 +422,7 @@ Alternatively, the function may be called with a single argument
where that argument is a JavaScript array which contains the sixteen
matrix values.
*/
-ReturnedValue QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_matrix4x4(QV4::CallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
@@ -473,7 +473,7 @@ by factor and converts the color back to RGB.
If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5).
*/
-ReturnedValue QtObject::method_lighter(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 1 && ctx->callData->argc != 2)
V4THROW_ERROR("Qt.lighter(): Invalid arguments");
@@ -512,7 +512,7 @@ by factor and converts the color back to RGB.
If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0).
*/
-ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_darker(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 1 && ctx->callData->argc != 2)
V4THROW_ERROR("Qt.darker(): Invalid arguments");
@@ -560,7 +560,7 @@ ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx)
Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
*/
-ReturnedValue QtObject::method_tint(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_tint(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 2)
V4THROW_ERROR("Qt.tint(): Invalid arguments");
@@ -610,7 +610,7 @@ If \a format is not specified, \a date is formatted using
\sa Locale
*/
-ReturnedValue QtObject::method_formatDate(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatDate(QV4::CallContext *ctx)
{
if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
V4THROW_ERROR("Qt.formatDate(): Invalid arguments");
@@ -655,7 +655,7 @@ If \a format is not specified, \a time is formatted using
\sa Locale
*/
-ReturnedValue QtObject::method_formatTime(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatTime(QV4::CallContext *ctx)
{
if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
V4THROW_ERROR("Qt.formatTime(): Invalid arguments");
@@ -781,7 +781,7 @@ with the \a format values below to produce the following results:
\sa Locale
*/
-ReturnedValue QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatDateTime(QV4::CallContext *ctx)
{
if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments");
@@ -815,7 +815,7 @@ ReturnedValue QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx)
\qmlmethod bool Qt::openUrlExternally(url target)
Attempts to open the specified \c target url in an external application, based on the user's desktop preferences. Returns true if it succeeds, and false otherwise.
*/
-ReturnedValue QtObject::method_openUrlExternally(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_openUrlExternally(QV4::CallContext *ctx)
{
if (ctx->callData->argc != 1)
return QV4::Encode(false);
@@ -830,7 +830,7 @@ ReturnedValue QtObject::method_openUrlExternally(QV4::SimpleCallContext *ctx)
\qmlmethod url Qt::resolvedUrl(url url)
Returns \a url resolved relative to the URL of the caller.
*/
-ReturnedValue QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_resolvedUrl(QV4::CallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
@@ -853,7 +853,7 @@ ReturnedValue QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx)
\qmlmethod list<string> Qt::fontFamilies()
Returns a list of the font families available to the application.
*/
-ReturnedValue QtObject::method_fontFamilies(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_fontFamilies(CallContext *ctx)
{
if (ctx->callData->argc != 0)
V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments");
@@ -866,7 +866,7 @@ ReturnedValue QtObject::method_fontFamilies(SimpleCallContext *ctx)
\qmlmethod string Qt::md5(data)
Returns a hex string of the md5 hash of \c data.
*/
-ReturnedValue QtObject::method_md5(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_md5(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("Qt.md5(): Invalid arguments");
@@ -880,7 +880,7 @@ ReturnedValue QtObject::method_md5(SimpleCallContext *ctx)
\qmlmethod string Qt::btoa(data)
Binary to ASCII - this function returns a base64 encoding of \c data.
*/
-ReturnedValue QtObject::method_btoa(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_btoa(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("Qt.btoa(): Invalid arguments");
@@ -894,7 +894,7 @@ ReturnedValue QtObject::method_btoa(SimpleCallContext *ctx)
\qmlmethod string Qt::atob(data)
ASCII to binary - this function returns a base64 decoding of \c data.
*/
-ReturnedValue QtObject::method_atob(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_atob(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("Qt.atob(): Invalid arguments");
@@ -911,7 +911,7 @@ Within the \l {Prototyping with qmlscene}, this causes the launcher application
to quit a C++ application when this method is called, connect the
QQmlEngine::quit() signal to the QCoreApplication::quit() slot.
*/
-ReturnedValue QtObject::method_quit(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_quit(CallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
@@ -943,7 +943,7 @@ If this is the case, consider using \l{QtQml::Qt::createComponent()}{Qt.createCo
See \l {Dynamic QML Object Creation from JavaScript} for more information on using this function.
*/
-ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_createQmlObject(CallContext *ctx)
{
Scope scope(ctx);
if (ctx->callData->argc < 2 || ctx->callData->argc > 3)
@@ -962,16 +962,16 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
const QQmlError &error = errors.at(ii);
errorstr += QLatin1String("\n ") + error.toString();
qmlerror = v4->newObject();
- qmlerror->put((s = v4->newString("lineNumber")), (v = QV4::Primitive::fromInt32(error.line())));
- qmlerror->put((s = v4->newString("columnNumber")), (v = QV4::Primitive::fromInt32(error.column())));
- qmlerror->put((s = v4->newString("fileName")), (v = v4->newString(error.url().toString())));
- qmlerror->put((s = v4->newString("message")), (v = v4->newString(error.description())));
+ qmlerror->put((s = v4->newString(QStringLiteral("lineNumber"))), (v = QV4::Primitive::fromInt32(error.line())));
+ qmlerror->put((s = v4->newString(QStringLiteral("columnNumber"))), (v = QV4::Primitive::fromInt32(error.column())));
+ qmlerror->put((s = v4->newString(QStringLiteral("fileName"))), (v = v4->newString(error.url().toString())));
+ qmlerror->put((s = v4->newString(QStringLiteral("message"))), (v = v4->newString(error.description())));
qmlerrors->putIndexed(ii, qmlerror);
}
v = v4->newString(errorstr);
Scoped<Object> errorObject(scope, v4->newErrorObject(v));
- errorObject->put((s = v4->newString("qmlErrors")), qmlerrors);
+ errorObject->put((s = v4->newString(QStringLiteral("qmlErrors"))), qmlerrors);
return errorObject.asReturnedValue();
}
};
@@ -1012,8 +1012,7 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
if (component.isError()) {
ScopedValue v(scope, Error::create(ctx->engine, component.errors()));
- ctx->throwError(v);
- return QV4::Encode::undefined();
+ return ctx->throwError(v);
}
if (!component.isReady())
@@ -1037,8 +1036,7 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
if (component.isError()) {
ScopedValue v(scope, Error::create(ctx->engine, component.errors()));
- ctx->throwError(v);
- return QV4::Encode::undefined();
+ return ctx->throwError(v);
}
Q_ASSERT(obj);
@@ -1077,10 +1075,10 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi
To create a QML object from an arbitrary string of QML (instead of a file),
use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}.
*/
-ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_createComponent(CallContext *ctx)
{
if (ctx->callData->argc < 1 || ctx->callData->argc > 3)
- ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
Scope scope(ctx);
@@ -1108,13 +1106,13 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx)
if (ctx->callData->args[1].isInteger()) {
int mode = ctx->callData->args[1].integerValue();
if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous))
- ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
compileMode = QQmlComponent::CompilationMode(mode);
consumedCount += 1;
} else {
// The second argument could be the parent only if there are exactly two args
if ((ctx->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull()))
- ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
+ return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
}
if (consumedCount < ctx->callData->argc) {
@@ -1123,11 +1121,11 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx)
if (qobjectWrapper)
parentArg = qobjectWrapper->object();
if (!parentArg)
- ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
+ return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
} else if (lastArg->isNull()) {
parentArg = 0;
} else {
- ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
+ return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object"));
}
}
}
@@ -1161,7 +1159,7 @@ ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx)
\sa QtQuick::Locale
*/
-ReturnedValue QtObject::method_locale(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_locale(CallContext *ctx)
{
QString code;
if (ctx->callData->argc > 1)
@@ -1195,11 +1193,11 @@ struct BindingFunction : public QV4::FunctionObject
return This->originalFunction->call(callData);
}
- static void markObjects(Managed *that)
+ static void markObjects(Managed *that, ExecutionEngine *e)
{
BindingFunction *This = static_cast<BindingFunction*>(that);
- This->originalFunction->mark();
- QV4::FunctionObject::markObjects(that);
+ This->originalFunction->mark(e);
+ QV4::FunctionObject::markObjects(that, e);
}
QV4::FunctionObject *originalFunction;
@@ -1255,7 +1253,7 @@ DEFINE_MANAGED_VTABLE(BindingFunction);
\since 5.0
*/
-ReturnedValue QtObject::method_binding(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_binding(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("binding() requires 1 argument");
@@ -1267,15 +1265,15 @@ ReturnedValue QtObject::method_binding(SimpleCallContext *ctx)
}
-ReturnedValue QtObject::method_get_platform(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_platform(CallContext *ctx)
{
// ### inefficient. Should be just a value based getter
Object *o = ctx->callData->thisObject.asObject();
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
if (!qt->m_platform)
// Only allocate a platform object once
@@ -1284,15 +1282,15 @@ ReturnedValue QtObject::method_get_platform(SimpleCallContext *ctx)
return QV4::QObjectWrapper::wrap(ctx->engine, qt->m_platform);
}
-ReturnedValue QtObject::method_get_application(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_application(CallContext *ctx)
{
// ### inefficient. Should be just a value based getter
Object *o = ctx->callData->thisObject.asObject();
if (!o)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt)
- ctx->throwTypeError();
+ return ctx->throwTypeError();
if (!qt->m_application)
// Only allocate an application object once
@@ -1302,7 +1300,7 @@ ReturnedValue QtObject::method_get_application(SimpleCallContext *ctx)
}
#ifndef QT_NO_IM
-ReturnedValue QtObject::method_get_inputMethod(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx)
{
QObject *o = QQml_guiProvider()->inputMethod();
QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership);
@@ -1360,13 +1358,13 @@ static QString jsStack(QV4::ExecutionEngine *engine) {
QString::number(frame.line));
if (i)
- stack += QChar('\n');
+ stack += QLatin1Char('\n');
stack += stackFrame;
}
return stack;
}
-static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, SimpleCallContext *ctx,
+static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *ctx,
bool printStack = false)
{
QString result;
@@ -1408,12 +1406,12 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, SimpleCallCont
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_error(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_error(CallContext *ctx)
{
return writeToConsole(Error, ctx);
}
-QV4::ReturnedValue ConsoleObject::method_log(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_log(CallContext *ctx)
{
//console.log
//console.debug
@@ -1422,7 +1420,7 @@ QV4::ReturnedValue ConsoleObject::method_log(SimpleCallContext *ctx)
return writeToConsole(Log, ctx);
}
-QV4::ReturnedValue ConsoleObject::method_profile(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_profile(CallContext *ctx)
{
//DeclarativeDebugTrace cannot handle nested profiling
//although v8 can handle several profiling at once,
@@ -1445,7 +1443,7 @@ QV4::ReturnedValue ConsoleObject::method_profile(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_profileEnd(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx)
{
//DeclarativeDebugTrace cannot handle nested profiling
//although v8 can handle several profiling at once,
@@ -1473,7 +1471,7 @@ QV4::ReturnedValue ConsoleObject::method_profileEnd(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_time(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
@@ -1485,7 +1483,7 @@ QV4::ReturnedValue ConsoleObject::method_time(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_timeEnd(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
@@ -1501,7 +1499,7 @@ QV4::ReturnedValue ConsoleObject::method_timeEnd(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_count(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_count(CallContext *ctx)
{
// first argument: name to print. Ignore any additional arguments
QString name;
@@ -1525,7 +1523,7 @@ QV4::ReturnedValue ConsoleObject::method_count(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_trace(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_trace(CallContext *ctx)
{
if (ctx->callData->argc != 0)
V4THROW_ERROR("console.trace(): Invalid arguments");
@@ -1542,12 +1540,12 @@ QV4::ReturnedValue ConsoleObject::method_trace(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_warn(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_warn(CallContext *ctx)
{
return writeToConsole(Warn, ctx);
}
-QV4::ReturnedValue ConsoleObject::method_assert(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx)
{
if (ctx->callData->argc == 0)
V4THROW_ERROR("console.assert(): Missing argument");
@@ -1574,7 +1572,7 @@ QV4::ReturnedValue ConsoleObject::method_assert(SimpleCallContext *ctx)
return QV4::Encode::undefined();
}
-QV4::ReturnedValue ConsoleObject::method_exception(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_exception(CallContext *ctx)
{
if (ctx->callData->argc == 0)
V4THROW_ERROR("console.exception(): Missing argument");
@@ -1632,7 +1630,7 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject)
\sa {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx)
{
if (ctx->callData->argc < 2)
V4THROW_ERROR("qsTranslate() requires at least two arguments");
@@ -1688,7 +1686,7 @@ ReturnedValue GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx)
{
if (ctx->callData->argc < 2)
return QV4::Encode::undefined();
@@ -1712,7 +1710,7 @@ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx)
{
if (ctx->callData->argc < 1)
V4THROW_ERROR("qsTr() requires at least one argument");
@@ -1766,7 +1764,7 @@ ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx)
{
if (ctx->callData->argc < 1)
return QV4::Encode::undefined();
@@ -1803,7 +1801,7 @@ ReturnedValue GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx)
\sa QT_TRID_NOOP, {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx)
{
if (ctx->callData->argc < 1)
V4THROW_ERROR("qsTrId() requires at least one argument");
@@ -1835,7 +1833,7 @@ ReturnedValue GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
\sa qsTrId(), {Internationalization and Localization with Qt Quick}
*/
-ReturnedValue GlobalExtensions::method_qsTrIdNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx)
{
if (ctx->callData->argc < 1)
return QV4::Encode::undefined();
@@ -1844,7 +1842,7 @@ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(SimpleCallContext *ctx)
#endif // QT_NO_TRANSLATION
-QV4::ReturnedValue GlobalExtensions::method_gc(SimpleCallContext *ctx)
+QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx)
{
ctx->engine->memoryManager->runGC();
@@ -1853,7 +1851,7 @@ QV4::ReturnedValue GlobalExtensions::method_gc(SimpleCallContext *ctx)
-ReturnedValue GlobalExtensions::method_string_arg(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_string_arg(CallContext *ctx)
{
if (ctx->callData->argc != 1)
V4THROW_ERROR("String.arg(): Invalid arguments");
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index 070796f03c..90536c09dd 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -68,41 +68,41 @@ struct QtObject : Object
Q_MANAGED
QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine);
- static ReturnedValue method_isQtObject(SimpleCallContext *ctx);
- static ReturnedValue method_rgba(SimpleCallContext *ctx);
- static ReturnedValue method_hsla(SimpleCallContext *ctx);
- static ReturnedValue method_colorEqual(SimpleCallContext *ctx);
- static ReturnedValue method_font(SimpleCallContext *ctx);
- static ReturnedValue method_rect(SimpleCallContext *ctx);
- static ReturnedValue method_point(SimpleCallContext *ctx);
- static ReturnedValue method_size(SimpleCallContext *ctx);
- static ReturnedValue method_vector2d(SimpleCallContext *ctx);
- static ReturnedValue method_vector3d(SimpleCallContext *ctx);
- static ReturnedValue method_vector4d(SimpleCallContext *ctx);
- static ReturnedValue method_quaternion(SimpleCallContext *ctx);
- static ReturnedValue method_matrix4x4(SimpleCallContext *ctx);
- static ReturnedValue method_lighter(SimpleCallContext *ctx);
- static ReturnedValue method_darker(SimpleCallContext *ctx);
- static ReturnedValue method_tint(SimpleCallContext *ctx);
- static ReturnedValue method_formatDate(SimpleCallContext *ctx);
- static ReturnedValue method_formatTime(SimpleCallContext *ctx);
- static ReturnedValue method_formatDateTime(SimpleCallContext *ctx);
- static ReturnedValue method_openUrlExternally(SimpleCallContext *ctx);
- static ReturnedValue method_fontFamilies(SimpleCallContext *ctx);
- static ReturnedValue method_md5(SimpleCallContext *ctx);
- static ReturnedValue method_btoa(SimpleCallContext *ctx);
- static ReturnedValue method_atob(SimpleCallContext *ctx);
- static ReturnedValue method_quit(SimpleCallContext *ctx);
- static ReturnedValue method_resolvedUrl(SimpleCallContext *ctx);
- static ReturnedValue method_createQmlObject(SimpleCallContext *ctx);
- static ReturnedValue method_createComponent(SimpleCallContext *ctx);
- static ReturnedValue method_locale(SimpleCallContext *ctx);
- static ReturnedValue method_binding(SimpleCallContext *ctx);
-
- static ReturnedValue method_get_platform(SimpleCallContext *ctx);
- static ReturnedValue method_get_application(SimpleCallContext *ctx);
+ static ReturnedValue method_isQtObject(CallContext *ctx);
+ static ReturnedValue method_rgba(CallContext *ctx);
+ static ReturnedValue method_hsla(CallContext *ctx);
+ static ReturnedValue method_colorEqual(CallContext *ctx);
+ static ReturnedValue method_font(CallContext *ctx);
+ static ReturnedValue method_rect(CallContext *ctx);
+ static ReturnedValue method_point(CallContext *ctx);
+ static ReturnedValue method_size(CallContext *ctx);
+ static ReturnedValue method_vector2d(CallContext *ctx);
+ static ReturnedValue method_vector3d(CallContext *ctx);
+ static ReturnedValue method_vector4d(CallContext *ctx);
+ static ReturnedValue method_quaternion(CallContext *ctx);
+ static ReturnedValue method_matrix4x4(CallContext *ctx);
+ static ReturnedValue method_lighter(CallContext *ctx);
+ static ReturnedValue method_darker(CallContext *ctx);
+ static ReturnedValue method_tint(CallContext *ctx);
+ static ReturnedValue method_formatDate(CallContext *ctx);
+ static ReturnedValue method_formatTime(CallContext *ctx);
+ static ReturnedValue method_formatDateTime(CallContext *ctx);
+ static ReturnedValue method_openUrlExternally(CallContext *ctx);
+ static ReturnedValue method_fontFamilies(CallContext *ctx);
+ static ReturnedValue method_md5(CallContext *ctx);
+ static ReturnedValue method_btoa(CallContext *ctx);
+ static ReturnedValue method_atob(CallContext *ctx);
+ static ReturnedValue method_quit(CallContext *ctx);
+ static ReturnedValue method_resolvedUrl(CallContext *ctx);
+ static ReturnedValue method_createQmlObject(CallContext *ctx);
+ static ReturnedValue method_createComponent(CallContext *ctx);
+ static ReturnedValue method_locale(CallContext *ctx);
+ static ReturnedValue method_binding(CallContext *ctx);
+
+ static ReturnedValue method_get_platform(CallContext *ctx);
+ static ReturnedValue method_get_application(CallContext *ctx);
#ifndef QT_NO_IM
- static ReturnedValue method_get_inputMethod(SimpleCallContext *ctx);
+ static ReturnedValue method_get_inputMethod(CallContext *ctx);
#endif
QObject *m_platform;
@@ -113,17 +113,17 @@ struct ConsoleObject : Object
{
ConsoleObject(ExecutionEngine *v4);
- static ReturnedValue method_error(SimpleCallContext *ctx);
- static ReturnedValue method_log(SimpleCallContext *ctx);
- static ReturnedValue method_profile(SimpleCallContext *ctx);
- static ReturnedValue method_profileEnd(SimpleCallContext *ctx);
- static ReturnedValue method_time(SimpleCallContext *ctx);
- static ReturnedValue method_timeEnd(SimpleCallContext *ctx);
- static ReturnedValue method_count(SimpleCallContext *ctx);
- static ReturnedValue method_trace(SimpleCallContext *ctx);
- static ReturnedValue method_warn(SimpleCallContext *ctx);
- static ReturnedValue method_assert(SimpleCallContext *ctx);
- static ReturnedValue method_exception(SimpleCallContext *ctx);
+ static ReturnedValue method_error(CallContext *ctx);
+ static ReturnedValue method_log(CallContext *ctx);
+ static ReturnedValue method_profile(CallContext *ctx);
+ static ReturnedValue method_profileEnd(CallContext *ctx);
+ static ReturnedValue method_time(CallContext *ctx);
+ static ReturnedValue method_timeEnd(CallContext *ctx);
+ static ReturnedValue method_count(CallContext *ctx);
+ static ReturnedValue method_trace(CallContext *ctx);
+ static ReturnedValue method_warn(CallContext *ctx);
+ static ReturnedValue method_assert(CallContext *ctx);
+ static ReturnedValue method_exception(CallContext *ctx);
};
@@ -131,17 +131,17 @@ struct GlobalExtensions {
static void init(QQmlEngine *qmlEngine, Object *globalObject);
#ifndef QT_NO_TRANSLATION
- static ReturnedValue method_qsTranslate(SimpleCallContext *ctx);
- static ReturnedValue method_qsTranslateNoOp(SimpleCallContext *ctx);
- static ReturnedValue method_qsTr(SimpleCallContext *ctx);
- static ReturnedValue method_qsTrNoOp(SimpleCallContext *ctx);
- static ReturnedValue method_qsTrId(SimpleCallContext *ctx);
- static ReturnedValue method_qsTrIdNoOp(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTranslate(CallContext *ctx);
+ static ReturnedValue method_qsTranslateNoOp(CallContext *ctx);
+ static ReturnedValue method_qsTr(CallContext *ctx);
+ static ReturnedValue method_qsTrNoOp(CallContext *ctx);
+ static ReturnedValue method_qsTrId(CallContext *ctx);
+ static ReturnedValue method_qsTrIdNoOp(CallContext *ctx);
#endif
- static ReturnedValue method_gc(SimpleCallContext *ctx);
+ static ReturnedValue method_gc(CallContext *ctx);
// on String:prototype
- static ReturnedValue method_string_arg(SimpleCallContext *ctx);
+ static ReturnedValue method_string_arg(CallContext *ctx);
};
diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h
index 44662e8cba..faf52ce1ad 100644
--- a/src/qml/qml/v8/qv4domerrors_p.h
+++ b/src/qml/qml/v8/qv4domerrors_p.h
@@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE
QV4::ScopedValue v(scope, ctx->engine->newString(QStringLiteral(string))); \
QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v)); \
ex->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \
- ctx->throwError(ex); \
+ return ctx->throwError(ex); \
}
namespace QV4 {
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 4e8738b826..d0fc1b1295 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -66,6 +66,7 @@
#include <QtCore/qjsonobject.h>
#include <QtCore/qjsonvalue.h>
#include <QtCore/qdatetime.h>
+#include <private/qsimd_p.h>
#include <private/qv4value_p.h>
#include <private/qv4dateobject_p.h>
@@ -93,6 +94,12 @@ QV8Engine::QV8Engine(QJSEngine* qq)
, m_xmlHttpRequestData(0)
, m_listModelData(0)
{
+#ifdef Q_PROCESSOR_X86_32
+ if (!(qCpuFeatures() & SSE2)) {
+ qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer");
+ }
+#endif
+
QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine");
qMetaTypeId<QJSValue>();
qMetaTypeId<QList<int> >();
@@ -141,7 +148,7 @@ QVariant QV8Engine::toVariant(const QV4::ValueRef value, int typeHint)
return QVariant::fromValue(QV4::JsonObject::toJsonObject(object));
} else if (QV4::QObjectWrapper *wrapper = object->as<QV4::QObjectWrapper>()) {
return qVariantFromValue<QObject *>(wrapper->object());
- } else if (QV4::QmlContextWrapper *wrapper = object->as<QV4::QmlContextWrapper>()) {
+ } else if (object->as<QV4::QmlContextWrapper>()) {
return QVariant();
} else if (QV4::QmlTypeWrapper *w = object->as<QV4::QmlTypeWrapper>()) {
return w->toVariant();
diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h
index a92d03ac50..e37b0d4920 100644
--- a/src/qml/qml/v8/qv8engine_p.h
+++ b/src/qml/qml/v8/qv8engine_p.h
@@ -86,10 +86,10 @@ namespace QV4 {
// #define QML_GLOBAL_HANDLE_DEBUGGING
#define V4THROW_ERROR(string) \
- ctx->throwError(QString::fromUtf8(string));
+ return ctx->throwError(QString::fromUtf8(string));
#define V4THROW_TYPE(string) \
- ctx->throwTypeError(QStringLiteral(string));
+ return ctx->throwTypeError(QStringLiteral(string));
#define V8_DEFINE_EXTENSION(dataclass, datafunction) \
static inline dataclass *datafunction(QV8Engine *engine) \