aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-10 22:04:54 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-12 14:52:50 +0100
commit447844aa25754db7e868469de4537af4331709ac (patch)
tree80245a0d948e87c8cfd7a35eb5fdc93a65105ccd /src/qml/jsruntime
parent56211be8a0429fb3e3fa268c7698e1df079aa04e (diff)
Get rid of Value::engine()
This method is not guaranteed to return an engine. We're safer checking for the value being an object first and then getting the engine from there. Change-Id: I5c95e675337e545f2421613bd31c42d1e58d6f9a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4include.cpp4
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4objectiterator.cpp12
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp4
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4value_inl_p.h6
-rw-r--r--src/qml/jsruntime/qv4value_p.h2
7 files changed, 15 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index 03eb1505f4..2627e26d4b 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -92,9 +92,9 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat
void QV4Include::callback(const QV4::ValueRef callback, const QV4::ValueRef status)
{
- QV4::ExecutionEngine *v4 = callback->engine();
- if (!v4)
+ if (!callback->isObject())
return;
+ QV4::ExecutionEngine *v4 = callback->asObject()->engine();
QV4::Scope scope(v4);
QV4::ScopedFunctionObject f(scope, callback);
if (!f)
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index f320630181..0de2aa7e3b 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -984,9 +984,11 @@ QJsonValue JsonObject::toJsonValue(const ValueRef value,
return QJsonValue(QJsonValue::Null);
else if (value->isUndefined())
return QJsonValue(QJsonValue::Undefined);
+ else if (value->isString())
+ return QJsonValue(value->toQString());
- Q_ASSERT(value->engine());
- Scope scope(value->engine());
+ Q_ASSERT(value->isObject());
+ Scope scope(value->asObject()->engine());
ScopedArrayObject a(scope, value);
if (a)
return toJsonArray(a, visitedObjects);
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp
index f0970d160e..2ce5c98316 100644
--- a/src/qml/jsruntime/qv4objectiterator.cpp
+++ b/src/qml/jsruntime/qv4objectiterator.cpp
@@ -73,7 +73,7 @@ void ObjectIterator::init(Object *o)
#endif
if (object->as<ArgumentsObject>()) {
- Scope scope(object->engine());
+ Scope scope(engine);
Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate();
}
}
@@ -136,7 +136,7 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value)
PropertyAttributes attrs;
uint index;
- Scope scope(object->engine());
+ Scope scope(engine);
ScopedProperty p(scope);
ScopedString name(scope);
next(name.getRef(), &index, p, &attrs);
@@ -158,7 +158,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value)
PropertyAttributes attrs;
uint index;
- Scope scope(object->engine());
+ Scope scope(engine);
ScopedProperty p(scope);
ScopedString name(scope);
next(name.getRef(), &index, p, &attrs);
@@ -170,7 +170,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value)
if (!!name)
return name->asReturnedValue();
assert(index < UINT_MAX);
- return Encode(object->engine()->newString(QString::number(index)));
+ return Encode(engine->newString(QString::number(index)));
}
ReturnedValue ObjectIterator::nextPropertyNameAsString()
@@ -180,7 +180,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString()
PropertyAttributes attrs;
uint index;
- Scope scope(object->engine());
+ Scope scope(engine);
ScopedProperty p(scope);
ScopedString name(scope);
next(name.getRef(), &index, p, &attrs);
@@ -190,7 +190,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString()
if (!!name)
return name->asReturnedValue();
Q_ASSERT(index < UINT_MAX);
- return Encode(object->engine()->newString(QString::number(index)));
+ return Encode(engine->newString(QString::number(index)));
}
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 3f3e49918d..284d20d975 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -96,8 +96,8 @@ static QPair<QObject *, int> extractQtMethod(QV4::FunctionObject *function)
static QPair<QObject *, int> extractQtSignal(const ValueRef value)
{
- QV4::ExecutionEngine *v4 = value->engine();
- if (v4) {
+ if (value->isObject()) {
+ QV4::ExecutionEngine *v4 = value->asObject()->engine();
QV4::Scope scope(v4);
QV4::ScopedFunctionObject function(scope, value);
if (function)
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index a60a44642f..8c6d28305f 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -650,7 +650,7 @@ QVariant SequencePrototype::toVariant(const QV4::ValueRef array, int typeHint, b
*succeeded = false;
return QVariant();
}
- QV4::Scope scope(array->engine());
+ QV4::Scope scope(array->asObject()->engine());
QV4::ScopedArrayObject a(scope, array);
FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); }
diff --git a/src/qml/jsruntime/qv4value_inl_p.h b/src/qml/jsruntime/qv4value_inl_p.h
index ea69c265fd..a551ac7e6b 100644
--- a/src/qml/jsruntime/qv4value_inl_p.h
+++ b/src/qml/jsruntime/qv4value_inl_p.h
@@ -70,12 +70,6 @@ inline String *Value::asString() const
return 0;
}
-inline ExecutionEngine *Value::engine() const
-{
- Managed *m = asManaged();
- return m ? m->engine() : 0;
-}
-
inline void Value::mark(ExecutionEngine *e) const
{
if (!val)
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 526cb01ac4..8fff22ed86 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -379,8 +379,6 @@ struct Q_QML_PRIVATE_EXPORT Value
inline uint asArrayIndex() const;
inline uint asArrayLength(bool *ok) const;
- inline ExecutionEngine *engine() const;
-
ReturnedValue asReturnedValue() const { return val; }
static Value fromReturnedValue(ReturnedValue val) { Value v; v.val = val; return v; }