aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-27 16:15:38 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-30 08:05:48 +0200
commite57c2c8a0adef8949f69195573d149237814bed1 (patch)
tree12e15bc037183967cde5278dd1c08d5c2e969977
parent0e36db9f1179d1bdf0710494e98ff7aee1a2d836 (diff)
remove more uses of QV4::Value
Change-Id: I11b0b2b7626297e2c98dc77784574da4b59ba8cf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp37
-rw-r--r--src/qml/types/qqmllistmodel.cpp28
-rw-r--r--src/qml/types/qqmllistmodel_p_p.h4
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp20
-rw-r--r--src/quick/items/qquickloader.cpp9
-rw-r--r--src/quick/items/qquickloader_p_p.h2
-rw-r--r--src/quick/util/qquickglobal.cpp66
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp30
10 files changed, 99 insertions, 101 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index d388622f86..2e45b2cab8 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -214,7 +214,7 @@ static inline QV4::Value *getValueRef(QV4::ExecutionContext *context,
: (param.isLocal() ? static_cast<QV4::CallContext *>(context)->locals + param.index \
: getValueRef(context, stack, param)))
#else
-# define VALUE(param) *getValueRef(context, stack, param, stackSize)
+# define VALUE(param) (*getValueRef(context, stack, param, stackSize))
# define VALUEPTR(param) getValueRef(context, stack, param, stackSize)
#endif
#define STOREVALUE(param, value) VALUE(param) = QV4::Value::fromReturnedValue((value))
@@ -325,7 +325,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
}
}
#endif // DO_TRACE_INSTR
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -335,7 +335,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_BEGIN_INSTR(CallProperty)
TRACE(property name, "%s, args=%u, argc=%u, this=%s", qPrintable(runtimeStrings[instr.name]->toQString()), instr.callData, instr.argc, (VALUE(instr.base)).toString(context)->toQString().toUtf8().constData());
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -344,7 +344,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_END_INSTR(CallProperty)
MOTH_BEGIN_INSTR(CallElement)
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -354,7 +354,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_BEGIN_INSTR(CallActivationProperty)
TRACE(args, "starting at %d, length %d", instr.args, instr.argc);
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -470,7 +470,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_END_INSTR(CallBuiltinSetupArgumentsObject)
MOTH_BEGIN_INSTR(CreateValue)
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -479,7 +479,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_END_INSTR(CreateValue)
MOTH_BEGIN_INSTR(CreateProperty)
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -489,7 +489,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_BEGIN_INSTR(CreateActivationProperty)
TRACE(inline, "property name = %s, args = %d, argc = %d", runtimeStrings[instr.name]->toQString().toUtf8().constData(), instr.args, instr.argc);
- Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value) <= stackSize);
+ Q_ASSERT(instr.callData + instr.argc + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue) <= stackSize);
QV4::CallData *callData = reinterpret_cast<QV4::CallData *>(stack + instr.callData);
callData->tag = QV4::Value::Integer_Type;
callData->argc = instr.argc;
@@ -521,28 +521,27 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *&code,
MOTH_END_INSTR(BinopContext)
MOTH_BEGIN_INSTR(AddNumberParams)
- QV4::Value lhs = VALUE(instr.lhs);
- QV4::Value rhs = VALUE(instr.rhs);
- VALUEPTR(instr.result)->setDouble(lhs.asDouble() + rhs.asDouble());
+ double lhs = VALUE(instr.lhs).asDouble();
+ double rhs = VALUE(instr.rhs).asDouble();
+ VALUEPTR(instr.result)->setDouble(lhs + rhs);
MOTH_END_INSTR(AddNumberParams)
MOTH_BEGIN_INSTR(MulNumberParams)
- QV4::Value lhs = VALUE(instr.lhs);
- QV4::Value rhs = VALUE(instr.rhs);
- VALUEPTR(instr.result)->setDouble(lhs.asDouble() * rhs.asDouble());
+ double lhs = VALUE(instr.lhs).asDouble();
+ double rhs = VALUE(instr.rhs).asDouble();
+ VALUEPTR(instr.result)->setDouble(lhs * rhs);
MOTH_END_INSTR(MulNumberParams)
MOTH_BEGIN_INSTR(SubNumberParams)
- QV4::Value lhs = VALUE(instr.lhs);
- QV4::Value rhs = VALUE(instr.rhs);
- VALUEPTR(instr.result)->setDouble(lhs.asDouble() - rhs.asDouble());
+ double lhs = VALUE(instr.lhs).asDouble();
+ double rhs = VALUE(instr.rhs).asDouble();
+ VALUEPTR(instr.result)->setDouble(lhs - rhs);
MOTH_END_INSTR(SubNumberParams)
MOTH_BEGIN_INSTR(Ret)
context->engine->stackPop(stackSize);
- QV4::Value &result = VALUE(instr.result);
// TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData());
- return result.asReturnedValue();
+ return VALUE(instr.result).asReturnedValue();
MOTH_END_INSTR(Ret)
MOTH_BEGIN_INSTR(LoadThis)
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index e16c8d819a..f5e0e70035 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -606,7 +606,7 @@ int ListModel::setOrCreateProperty(int elementIndex, const QString &key, const Q
return roleIndex;
}
-int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::Value &data, QV8Engine *eng)
+int ListModel::setExistingProperty(int elementIndex, const QString &key, const QV4::ValueRef data, QV8Engine *eng)
{
int roleIndex = -1;
@@ -1162,7 +1162,7 @@ int ListElement::setVariantProperty(const ListLayout::Role &role, const QVariant
return roleIndex;
}
-int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV8Engine *eng)
+int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::ValueRef d, QV8Engine *eng)
{
// Check if this key exists yet
int roleIndex = -1;
@@ -1170,12 +1170,13 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
QV4::Scope scope(QV8Engine::getV4(eng));
// Add the value now
- if (QV4::String *s = d.asString()) {
- QString qstr = s->toQString();
+ if (d->asString()) {
+ QString qstr = d->toQString();
roleIndex = setStringProperty(role, qstr);
- } else if (d.isNumber()) {
- roleIndex = setDoubleProperty(role, d.asDouble());
- } else if (QV4::ArrayObject *a = d.asArrayObject()) {
+ } else if (d->isNumber()) {
+ roleIndex = setDoubleProperty(role, d->asDouble());
+ } else if (d->asArrayObject()) {
+ QV4::ScopedArrayObject a(scope, d);
if (role.type == ListLayout::Role::List) {
QV4::Scope scope(a->engine());
QV4::Scoped<QV4::Object> o(scope);
@@ -1190,12 +1191,13 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
} else {
qmlInfo(0) << QString::fromLatin1("Can't assign to existing role '%1' of different type [%2 -> %3]").arg(role.name).arg(roleTypeName(role.type)).arg(roleTypeName(ListLayout::Role::List));
}
- } else if (d.isBoolean()) {
- roleIndex = setBoolProperty(role, d.booleanValue());
- } else if (QV4::DateObject *dd = d.asDateObject()) {
- QDateTime dt = dd->toQDateTime();;
+ } else if (d->isBoolean()) {
+ roleIndex = setBoolProperty(role, d->booleanValue());
+ } else if (d->asDateObject()) {
+ QV4::Scoped<QV4::DateObject> dd(scope, d);
+ QDateTime dt = dd->toQDateTime();
roleIndex = setDateTimeProperty(role, dt);
- } else if (d.isObject()) {
+ } else if (d->isObject()) {
QV4::ScopedObject o(scope, d);
QV4::QObjectWrapper *wrapper = o->as<QV4::QObjectWrapper>();
if (role.type == ListLayout::Role::QObject && wrapper) {
@@ -1204,7 +1206,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
} else if (role.type == ListLayout::Role::VariantMap) {
roleIndex = setVariantMapProperty(role, o, eng);
}
- } else if (d.isUndefined() || d.isNull()) {
+ } else if (d->isNullOrUndefined()) {
clearProperty(role);
}
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h
index d74299780d..3b15af2d23 100644
--- a/src/qml/types/qqmllistmodel_p_p.h
+++ b/src/qml/types/qqmllistmodel_p_p.h
@@ -253,7 +253,7 @@ private:
int setVariantProperty(const ListLayout::Role &role, const QVariant &d);
- int setJsProperty(const ListLayout::Role &role, const QV4::Value &d, QV8Engine *eng);
+ int setJsProperty(const ListLayout::Role &role, const QV4::ValueRef d, QV8Engine *eng);
int setStringProperty(const ListLayout::Role &role, const QString &s);
int setDoubleProperty(const ListLayout::Role &role, double n);
@@ -308,7 +308,7 @@ public:
void destroy();
int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data);
- int setExistingProperty(int uid, const QString &key, const QV4::Value &data, QV8Engine *eng);
+ int setExistingProperty(int uid, const QString &key, const QV4::ValueRef data, QV8Engine *eng);
QVariant getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV8Engine *eng);
ListModel *getListProperty(int elementIndex, const ListLayout::Role &role);
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 826feeb331..42b74f879e 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -663,7 +663,7 @@ void QQuickCanvasItem::updatePolish()
QV4::ExecutionEngine *v4 = QQmlEnginePrivate::getV4Engine(qmlEngine(this));
QV4::Scope scope(v4);
QV4::ScopedCallData callData(scope, 1);
- callData->thisObject = QV4::Value::fromReturnedValue(QV4::QObjectWrapper::wrap(v4, this));
+ callData->thisObject = QV4::QObjectWrapper::wrap(v4, this);
foreach (int key, animationCallbacks.keys()) {
QV4::ScopedFunctionObject f(scope, animationCallbacks.value(key).value());
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 7be8d0927a..422a827acb 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -127,9 +127,9 @@ static const double Q_PI = 3.14159265358979323846; // pi
V4THROW_ERROR("Not a Context2D object");
#define qClamp(val, min, max) qMin(qMax(val, min), max)
#define CHECK_RGBA(c) (c == '-' || c == '.' || (c >=0 && c <= 9))
-QColor qt_color_from_string(const QV4::Value &name)
+QColor qt_color_from_string(const QV4::ValueRef name)
{
- QByteArray str = name.toQStringNoThrow().toUtf8();
+ QByteArray str = name->toQString().toUtf8();
char *p = str.data();
int len = str.length();
@@ -911,7 +911,7 @@ struct QQuickJSContext2DImageData : public QV4::Object
DEFINE_MANAGED_VTABLE(QQuickJSContext2DImageData);
-static QV4::Value qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image)
+static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV8Engine* engine, const QImage& image)
{
QQuickContext2DEngineData *ed = engineData(engine);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
@@ -928,9 +928,9 @@ static QV4::Value qt_create_image_data(qreal w, qreal h, QV8Engine* engine, cons
pixelData->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32);
}
- QQuickJSContext2DImageData *imageData = new (v4->memoryManager) QQuickJSContext2DImageData(v4);
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, new (v4->memoryManager) QQuickJSContext2DImageData(v4));
imageData->pixelData = pixelData.asValue();
- return QV4::Value::fromObject(imageData);
+ return imageData.asReturnedValue();
}
//static script functions
@@ -3244,11 +3244,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl
if (pa) {
qreal w = pa->image.width();
qreal h = pa->image.height();
- return qt_create_image_data(w, h, engine, QImage()).asReturnedValue();
+ return qt_create_image_data(w, h, engine, QImage());
}
} else if (arg0->isString()) {
QImage image = r->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image();
- return qt_create_image_data(image.width(), image.height(), engine, image).asReturnedValue();
+ return qt_create_image_data(image.width(), image.height(), engine, image);
}
} else if (ctx->callData->argc == 2) {
qreal w = ctx->callData->args[0].toNumber();
@@ -3258,7 +3258,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
if (w > 0 && h > 0)
- return qt_create_image_data(w, h, engine, QImage()).asReturnedValue();
+ return qt_create_image_data(w, h, engine, QImage());
else
V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments");
}
@@ -3288,9 +3288,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::SimpleCa
V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments");
QImage image = r->context->canvas()->toImage(QRectF(x, y, w, h));
- QV4::Value imageData = qt_create_image_data(w, h, engine, image);
-
- return imageData.asReturnedValue();
+ return qt_create_image_data(w, h, engine, image);
}
return QV4::Encode::null();
}
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index a59c308354..48b934e1e1 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -569,13 +569,14 @@ void QQuickLoader::setSource(QQmlV4Function *args)
bool ipvError = false;
args->setReturnValue(QV4::Encode::undefined());
- QV4::Value ipv = d->extractInitialPropertyValues(args, this, &ipvError);
+ QV4::Scope scope(args->v4engine());
+ QV4::ScopedValue ipv(scope, d->extractInitialPropertyValues(args, this, &ipvError));
if (ipvError)
return;
d->clear();
QUrl sourceUrl = d->resolveSourceUrl(args);
- if (!ipv.isUndefined()) {
+ if (!ipv->isUndefined()) {
d->disposeInitialPropertyValues();
d->initialPropertyValues = ipv.asReturnedValue();
d->qmlGlobalForIpv = args->qmlGlobal();
@@ -937,7 +938,7 @@ QUrl QQuickLoaderPrivate::resolveSourceUrl(QQmlV4Function *args)
return context->resolvedUrl(QUrl(arg));
}
-QV4::Value QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error)
+QV4::ReturnedValue QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error)
{
QV4::Scope scope(args->v4engine());
QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue());
@@ -952,7 +953,7 @@ QV4::Value QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Function *arg
}
}
- return valuemap;
+ return valuemap.asReturnedValue();
}
#include <moc_qquickloader_p.cpp>
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index a24bfb892a..825cfc1bd8 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -97,7 +97,7 @@ public:
void setInitialState(QObject *o);
void disposeInitialPropertyValues();
QUrl resolveSourceUrl(QQmlV4Function *args);
- QV4::Value extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error);
+ QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error);
virtual qreal getImplicitWidth() const;
virtual qreal getImplicitHeight() const;
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index ea0b85c9ff..561162aba4 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -328,61 +328,61 @@ public:
QV4::ScopedString s(scope);
- QV4::Value vbold = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("bold")))));
- QV4::Value vcap = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("capitalization")))));
- QV4::Value vfam = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("family")))));
- QV4::Value vital = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("italic")))));
- QV4::Value vlspac = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("letterSpacing")))));
- QV4::Value vpixsz = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("pixelSize")))));
- QV4::Value vpntsz = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("pointSize")))));
- QV4::Value vstrk = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("strikeout")))));
- QV4::Value vundl = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("underline")))));
- QV4::Value vweight = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("weight")))));
- QV4::Value vwspac = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("wordSpacing")))));
+ QV4::ScopedValue vbold(scope, obj->get((s = v4->newString(QStringLiteral("bold")))));
+ QV4::ScopedValue vcap(scope, obj->get((s = v4->newString(QStringLiteral("capitalization")))));
+ QV4::ScopedValue vfam(scope, obj->get((s = v4->newString(QStringLiteral("family")))));
+ QV4::ScopedValue vital(scope, obj->get((s = v4->newString(QStringLiteral("italic")))));
+ QV4::ScopedValue vlspac(scope, obj->get((s = v4->newString(QStringLiteral("letterSpacing")))));
+ QV4::ScopedValue vpixsz(scope, obj->get((s = v4->newString(QStringLiteral("pixelSize")))));
+ QV4::ScopedValue vpntsz(scope, obj->get((s = v4->newString(QStringLiteral("pointSize")))));
+ QV4::ScopedValue vstrk(scope, obj->get((s = v4->newString(QStringLiteral("strikeout")))));
+ QV4::ScopedValue vundl(scope, obj->get((s = v4->newString(QStringLiteral("underline")))));
+ QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight")))));
+ QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing")))));
// pull out the values, set ok to true if at least one valid field is given.
- if (vbold.isBoolean()) {
- retn.setBold(vbold.booleanValue());
+ if (vbold->isBoolean()) {
+ retn.setBold(vbold->booleanValue());
if (ok) *ok = true;
}
- if (vcap.isInt32()) {
- retn.setCapitalization(static_cast<QFont::Capitalization>(vcap.integerValue()));
+ if (vcap->isInt32()) {
+ retn.setCapitalization(static_cast<QFont::Capitalization>(vcap->integerValue()));
if (ok) *ok = true;
}
- if (vfam.isString()) {
- retn.setFamily(vfam.toQStringNoThrow());
+ if (vfam->isString()) {
+ retn.setFamily(vfam->toQString());
if (ok) *ok = true;
}
- if (vital.isBoolean()) {
- retn.setItalic(vital.booleanValue());
+ if (vital->isBoolean()) {
+ retn.setItalic(vital->booleanValue());
if (ok) *ok = true;
}
- if (vlspac.isNumber()) {
- retn.setLetterSpacing(QFont::AbsoluteSpacing, vlspac.asDouble());
+ if (vlspac->isNumber()) {
+ retn.setLetterSpacing(QFont::AbsoluteSpacing, vlspac->asDouble());
if (ok) *ok = true;
}
- if (vpixsz.isInt32()) {
- retn.setPixelSize(vpixsz.integerValue());
+ if (vpixsz->isInt32()) {
+ retn.setPixelSize(vpixsz->integerValue());
if (ok) *ok = true;
}
- if (vpntsz.isNumber()) {
- retn.setPointSize(vpntsz.asDouble());
+ if (vpntsz->isNumber()) {
+ retn.setPointSize(vpntsz->asDouble());
if (ok) *ok = true;
}
- if (vstrk.isBoolean()) {
- retn.setStrikeOut(vstrk.booleanValue());
+ if (vstrk->isBoolean()) {
+ retn.setStrikeOut(vstrk->booleanValue());
if (ok) *ok = true;
}
- if (vundl.isBoolean()) {
- retn.setUnderline(vundl.booleanValue());
+ if (vundl->isBoolean()) {
+ retn.setUnderline(vundl->booleanValue());
if (ok) *ok = true;
}
- if (vweight.isInt32()) {
- retn.setWeight(static_cast<QFont::Weight>(vweight.integerValue()));
+ if (vweight->isInt32()) {
+ retn.setWeight(static_cast<QFont::Weight>(vweight->integerValue()));
if (ok) *ok = true;
}
- if (vwspac.isNumber()) {
- retn.setWordSpacing(vwspac.asDouble());
+ if (vwspac->isNumber()) {
+ retn.setWordSpacing(vwspac->asDouble());
if (ok) *ok = true;
}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index a93aabd266..c6f6de7337 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -1240,7 +1240,7 @@ public:
Q_ASSERT(thisObject);
QQmlData *otherDData = QQmlData::get(other);
- assert(otherDData);
+ Q_ASSERT(otherDData);
QV4::ScopedValue v(scope, otherDData->jsWrapper.value());
thisObject->defineDefaultProperty(QStringLiteral("autoTestStrongRef"), v);
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 4240ed6dcb..0ea6a25afb 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -2261,7 +2261,7 @@ void tst_qqmlecmascript::regExpBug()
}
}
-static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const char *source)
+static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, const char *source)
{
QString functionSource = QLatin1String("(function(object) { return ") +
QLatin1String(source) + QLatin1String(" })");
@@ -2288,7 +2288,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::Value &o, const
}
static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
- const char *source, const QV4::Value &result)
+ const char *source, const QV4::ValueRef result)
{
QString functionSource = QLatin1String("(function(object) { return ") +
QLatin1String(source) + QLatin1String(" })");
@@ -2305,19 +2305,18 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
return false;
QV4::ScopedValue value(scope);
- QV4::ScopedValue res(scope, result);
QV4::ScopedCallData d(scope, 1);
d->args[0] = o;
d->thisObject = engine->global();
value = function->call(d);
- return __qmljs_strict_equal(value, res);
+ return __qmljs_strict_equal(value, result);
} catch (QV4::Exception &e) {
e.accept(ctx);
}
return false;
}
-static inline QV4::Value evaluate(QV8Engine *engine, const QV4::Value & o,
+static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef o,
const char *source)
{
QString functionSource = QLatin1String("(function(object) { return ") +
@@ -2331,16 +2330,15 @@ static inline QV4::Value evaluate(QV8Engine *engine, const QV4::Value & o,
try {
QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
if (!function)
- return QV4::Primitive::undefinedValue();
+ return QV4::Encode::undefined();
QV4::ScopedCallData d(scope, 1);
d->args[0] = o;
d->thisObject = engine->global();
- QV4::ScopedValue value(scope, function->call(d));
- return value;
+ return function->call(d);
} catch (QV4::Exception &e) {
e.accept(ctx);
}
- return QV4::Primitive::undefinedValue();
+ return QV4::Encode::undefined();
}
#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
@@ -2359,7 +2357,8 @@ void tst_qqmlecmascript::callQtInvokables()
QV8Engine *engine = ep->v8engine();
QV4::Scope scope(QV8Engine::getV4(engine));
- QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(QV8Engine::getV4(engine), o));
+ QV4::ScopedValue qobjectwrapper(scope, QV4::QObjectWrapper::wrap(QV8Engine::getV4(engine), o));
+ QV4::ScopedValue object(scope, qobjectwrapper);
// Non-existent methods
o->reset();
@@ -2434,8 +2433,7 @@ void tst_qqmlecmascript::callQtInvokables()
o->reset();
{
- QV4::ScopedValue ret(scope, EVALUATE("object.method_NoArgs_QObject()"));
- QV4::QObjectWrapper *qobjectWrapper = ret->as<QV4::QObjectWrapper>();
+ QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, EVALUATE("object.method_NoArgs_QObject()"));
QVERIFY(qobjectWrapper);
QCOMPARE(qobjectWrapper->object(), (QObject *)o);
QCOMPARE(o->error(), false);
@@ -2451,16 +2449,16 @@ void tst_qqmlecmascript::callQtInvokables()
o->reset();
{
- QV4::Value ret = EVALUATE("object.method_NoArgs_QScriptValue()");
- QVERIFY(ret.isString());
- QCOMPARE(ret.toQStringNoThrow(), QString("Hello world"));
+ QV4::ScopedValue ret(scope, EVALUATE("object.method_NoArgs_QScriptValue()"));
+ QVERIFY(ret->isString());
+ QCOMPARE(ret->toQStringNoThrow(), QString("Hello world"));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 6);
QCOMPARE(o->actuals().count(), 0);
}
o->reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", QV4::Value::fromReturnedValue(engine->toString("QML rocks"))));
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", QV4::ScopedValue(scope, engine->toString("QML rocks"))));
QCOMPARE(o->error(), false);
QCOMPARE(o->invoked(), 7);
QCOMPARE(o->actuals().count(), 0);