aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-11 16:28:17 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 13:13:33 +0200
commitbdb27b96acbd38531879378c48959a5a1cd60963 (patch)
tree056f2c8c35be97a9564dee5d0ea65bed7265b7ce /src/qml/qml
parent8d26084ae56ba5aedd73ab733553dbf9cb3eb672 (diff)
Use ReturnedValue for Managed::get().
Change-Id: Ia8f35d227b69d32e1f6a041283abbbd083aa34ca Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp35
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h2
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp2
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp6
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp18
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp10
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp28
10 files changed, 54 insertions, 53 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index bd0b211403..f84f288770 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -124,21 +124,22 @@ void QmlContextWrapper::takeContextOwnership(const Value &qmlglobal)
}
-Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
{
- QmlContextWrapper *resource = m->as<QmlContextWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
+ QV4::Scope scope(v4);
+ QmlContextWrapper *resource = m->as<QmlContextWrapper>();
if (!resource)
v4->current->throwTypeError();
// In V8 the JS global object would come _before_ the QML global object,
// so simulate that here.
bool hasProp;
- QV4::Value result = v4->globalObject->get(name, &hasProp);
+ QV4::ScopedValue result(scope, v4->globalObject->get(name, &hasProp));
if (hasProp) {
if (hasProperty)
*hasProperty = hasProp;
- return result;
+ return result.asReturnedValue();
}
if (resource->isNullWrapper)
@@ -151,7 +152,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
if (hasProp) {
if (hasProperty)
*hasProperty = hasProp;
- return result;
+ return result.asReturnedValue();
}
// Its possible we could delay the calculation of the "actual" context (in the case
@@ -162,7 +163,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
if (!context) {
if (hasProperty)
*hasProperty = true;
- return result;
+ return result.asReturnedValue();
}
// Search type (attached property/enum/imported scripts) names
@@ -187,13 +188,13 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
if (r.scriptIndex != -1) {
int index = r.scriptIndex;
if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
+ return context->importedScripts.at(index).value().asReturnedValue();
else
- return QV4::Value::undefinedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
} else if (r.type) {
- return QmlTypeWrapper::create(engine, scopeObject, r.type);
+ return QmlTypeWrapper::create(engine, scopeObject, r.type).asReturnedValue();
} else if (r.importNamespace) {
- return QmlTypeWrapper::create(engine, scopeObject, context->imports, r.importNamespace);
+ return QmlTypeWrapper::create(engine, scopeObject, context->imports, r.importNamespace).asReturnedValue();
}
Q_ASSERT(!"Unreachable");
}
@@ -215,7 +216,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
ep->captureProperty(&context->idValues[propertyIdx].bindings);
if (hasProperty)
*hasProperty = true;
- return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]);
+ return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]).asReturnedValue();
} else {
QQmlContextPrivate *cp = context->asQQmlContextPrivate();
@@ -230,9 +231,9 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*) qintptr(propertyIdx),
QQmlContextPrivate::context_count,
QQmlContextPrivate::context_at);
- return QmlListWrapper::create(engine, prop, qMetaTypeId<QQmlListProperty<QObject> >());
+ return QmlListWrapper::create(engine, prop, qMetaTypeId<QQmlListProperty<QObject> >()).asReturnedValue();
} else {
- return engine->fromVariant(cp->propertyValues.at(propertyIdx));
+ return engine->fromVariant(cp->propertyValues.at(propertyIdx)).asReturnedValue();
}
}
}
@@ -245,7 +246,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
if (hasProp) {
if (hasProperty)
*hasProperty = true;
- return result;
+ return result.asReturnedValue();
}
}
scopeObject = 0;
@@ -254,11 +255,11 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
// Search context object
if (context->contextObject) {
bool hasProp = false;
- QV4::Value result = QV4::QObjectWrapper::getQmlProperty(v4->current, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
+ result = QV4::QObjectWrapper::getQmlProperty(v4->current, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
if (hasProp) {
if (hasProperty)
*hasProperty = true;
- return result;
+ return result.asReturnedValue();
}
}
@@ -267,7 +268,7 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
expressionContext->unresolvedNames = true;
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
void QmlContextWrapper::put(Managed *m, String *name, const Value &value)
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 0f44952567..0ed933014b 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -82,7 +82,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
void setReadOnly(bool b) { readOnly = b; }
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static void destroy(Managed *that);
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 4f67a1dd28..12f594ee5f 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -312,7 +312,7 @@ void QQmlJavaScriptExpression::exceptionToError(const QV4::Exception &e, QQmlErr
}
QV4::ErrorObject *errorObj = e.value().asErrorObject();
if (errorObj && errorObj->asSyntaxError())
- error.setDescription(errorObj->get(errorObj->engine()->newString("message")).toQStringNoThrow());
+ error.setDescription(QV4::Value::fromReturnedValue(errorObj->get(errorObj->engine()->newString("message"))).toQStringNoThrow());
else
error.setDescription(e.value().toQStringNoThrow());
}
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 1c1386d5b7..749702b357 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -98,7 +98,7 @@ QVariant QmlListWrapper::toVariant() const
}
-Value QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
QmlListWrapper *w = m->as<QmlListWrapper>();
@@ -107,12 +107,12 @@ Value QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
if (name == v4->id_length && !w->object.isNull()) {
quint32 count = w->property.count ? w->property.count(&w->property) : 0;
- return Value::fromUInt32(count);
+ return Value::fromUInt32(count).asReturnedValue();
}
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
- return getIndexed(m, idx, hasProperty);
+ return getIndexed(m, idx, hasProperty).asReturnedValue();
return Object::get(m, name, hasProperty);
}
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index c87b9b22d5..797e39bedd 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -81,7 +81,7 @@ public:
QVariant toVariant() const;
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static Value getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes);
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 33b8fb8e7a..8f05a877ef 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -112,7 +112,7 @@ Value QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCache *t, co
}
-Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
{
QmlTypeWrapper *w = m->as<QmlTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
@@ -149,13 +149,13 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
bool ok;
int value = e.keyToValue(enumName.constData(), &ok);
if (ok)
- return QV4::Value::fromInt32(value);
+ return QV4::Value::fromInt32(value).asReturnedValue();
}
}
}
// check for property.
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty).asReturnedValue();
} else if (!siinfo->scriptApi(e).isUndefined()) {
QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine);
// NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
@@ -172,14 +172,14 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
bool ok = false;
int value = type->enumValue(name, &ok);
if (ok)
- return QV4::Value::fromInt32(value);
+ return QV4::Value::fromInt32(value).asReturnedValue();
// Fall through to base implementation
} else if (w->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
if (ao)
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty).asReturnedValue();
// Fall through to base implementation
}
@@ -196,16 +196,16 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
if (r.isValid()) {
QQmlContextData *context = v8engine->callingContext();
if (r.type) {
- return create(w->v8, object, r.type, w->mode);
+ return create(w->v8, object, r.type, w->mode).asReturnedValue();
} else if (r.scriptIndex != -1) {
int index = r.scriptIndex;
if (index < context->importedScripts.count())
- return context->importedScripts.at(index).value();
+ return context->importedScripts.at(index).value().asReturnedValue();
} else if (r.importNamespace) {
- return create(w->v8, object, context->imports, r.importNamespace);
+ return create(w->v8, object, context->imports, r.importNamespace).asReturnedValue();
}
- return QV4::Value::undefinedValue();
+ return QV4::Value::undefinedValue().asReturnedValue();
}
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 944621b1d6..c545e1cc3b 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -82,7 +82,7 @@ public:
static QV4::Value create(QV8Engine *, QObject *, QQmlTypeNameCache *, const void *, TypeNameMode = IncludeEnums);
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static PropertyAttributes query(const Managed *, String *name);
static void destroy(Managed *that);
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index f494fba11f..98b2497b0d 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -263,7 +263,7 @@ Value QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
}
}
-Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
{
QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
@@ -275,7 +275,7 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(r);
if (!reference->object || !readReferenceValue(reference))
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
} else {
Q_ASSERT(r->objectType == QmlValueTypeWrapper::Copy);
@@ -301,7 +301,7 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
if (result->isFunction()) {
// calling a Q_INVOKABLE function of a value type
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
- return QV4::QObjectWrapper::getQmlProperty(v4->current, qmlContext, r->type, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, qmlContext, r->type, name, QV4::QObjectWrapper::IgnoreRevision).asReturnedValue();
}
#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
@@ -309,7 +309,7 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
cpptype v; \
void *args[] = { &v, 0 }; \
r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args); \
- return constructor(v); \
+ return constructor(v).asReturnedValue(); \
}
// These four types are the most common used by the value type wrappers
@@ -321,7 +321,7 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
QVariant v(result->propType, (void *)0);
void *args[] = { v.data(), 0 };
r->type->qt_metacall(QMetaObject::ReadProperty, result->coreIndex, args);
- return r->v8->fromVariant(v);
+ return r->v8->fromVariant(v).asReturnedValue();
#undef VALUE_TYPE_ACCESSOR
}
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index f5088a5954..aa9de3330e 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -83,7 +83,7 @@ public:
bool isEqual(const QVariant& value);
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static void destroy(Managed *that);
static bool isEqualTo(Managed *m, Managed *other);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 849e226a37..212f64fcef 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -204,7 +204,7 @@ public:
static void destroy(Managed *that) {
that->as<NamedNodeMap>()->~NamedNodeMap();
}
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static Value getIndexed(Managed *m, uint index, bool *hasProperty);
QList<NodeImpl *> list; // Only used in NamedNodeMap
@@ -235,7 +235,7 @@ public:
static void destroy(Managed *that) {
that->as<NodeList>()->~NodeList();
}
- static Value get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static Value getIndexed(Managed *m, uint index, bool *hasProperty);
// C++ API
@@ -862,7 +862,7 @@ Value NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty)
return Value::undefinedValue();
}
-Value NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
{
NamedNodeMap *r = m->as<NamedNodeMap>();
QV4::ExecutionEngine *v4 = m->engine();
@@ -871,7 +871,7 @@ Value NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
name->makeIdentifier();
if (name->isEqualTo(v4->id_length))
- return Value::fromInt32(r->list.count());
+ return Value::fromInt32(r->list.count()).asReturnedValue();
QV8Engine *engine = v4->v8Engine;
@@ -880,13 +880,13 @@ Value NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
if (r->list.at(ii)->name == str) {
if (hasProperty)
*hasProperty = true;
- return Node::create(engine, r->list.at(ii));
+ return Node::create(engine, r->list.at(ii)).asReturnedValue();
}
}
if (hasProperty)
*hasProperty = false;
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
Value NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QList<NodeImpl *> &list)
@@ -916,7 +916,7 @@ Value NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
return Value::undefinedValue();
}
-Value NodeList::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
NodeList *r = m->as<NodeList>();
@@ -926,7 +926,7 @@ Value NodeList::get(Managed *m, String *name, bool *hasProperty)
name->makeIdentifier();
if (name->isEqualTo(v4->id_length))
- return Value::fromInt32(r->d->children.count());
+ return Value::fromInt32(r->d->children.count()).asReturnedValue();
return Object::get(m, name, hasProperty);
}
@@ -1467,24 +1467,24 @@ void QQmlXMLHttpRequest::dispatchCallback(const Value &me)
if (!o)
ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
- Object *thisObj = o->get(v4->newString(QStringLiteral("ThisObject"))).asObject();
+ Scoped<Object> thisObj(scope, o->get(v4->newString(QStringLiteral("ThisObject"))));
if (!thisObj)
ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
- FunctionObject *callback = thisObj->get(v4->newString(QStringLiteral("onreadystatechange"))).asFunctionObject();
+ Scoped<FunctionObject> callback(scope, thisObj->get(v4->newString(QStringLiteral("onreadystatechange"))));
if (!callback) {
// not an error, but no onreadystatechange function to call.
return;
}
- Value activationObject = o->get(v4->newString(QStringLiteral("ActivationObject")));
- if (!activationObject.asObject())
+ Scoped<Object> activationObject(scope, o->get(v4->newString(QStringLiteral("ActivationObject"))));
+ if (!activationObject)
v4->current->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
- QQmlContextData *callingContext = QmlContextWrapper::getContext(activationObject);
+ QQmlContextData *callingContext = QmlContextWrapper::getContext(activationObject.asValue());
if (callingContext) {
QV4::ScopedCallData callData(scope, 0);
- callData->thisObject = activationObject;
+ callData->thisObject = activationObject.asValue();
callback->call(callData);
}