aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-17 18:16:35 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit21198a676128a52e892557bc434035bcd1ddfaac (patch)
tree10b165b797a7723507b8da375444549a5420e1e8 /src/qml/jsruntime
parente441692b0b8f8fffdfdfa8a21c570adcd5cbae7a (diff)
Don't use Value::emptyValue() anymore.
emptyValue is special and reserved for usage inside the engine to mark missing values. The main to use cases are when converting property descriptors, and to mark holes in array data. Change-Id: I0ed357e65102b1041bf9a878e6e9a4ae0657523b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp26
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp6
-rw-r--r--src/qml/jsruntime/qv4script.cpp2
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp1
-rw-r--r--src/qml/jsruntime/qv4value.cpp6
-rw-r--r--src/qml/jsruntime/qv4value_p.h10
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp2
7 files changed, 30 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index d774014073..a779a41293 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -544,10 +544,10 @@ ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
Scope scope(engine);
- if (ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isEmpty()) {
+ if (ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined()) {
// We own the JS object
return ddata->jsWrapper.value().asReturnedValue();
- } else if (ddata->jsWrapper.isEmpty() &&
+ } else if (ddata->jsWrapper.isUndefined() &&
(ddata->jsEngineId == engine->m_engineId || // We own the QObject
ddata->jsEngineId == 0 || // No one owns the QObject
!ddata->hasTaintedV8Object)) { // Someone else has used the QObject, but it isn't tainted
@@ -566,7 +566,7 @@ ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object)
// If our tainted handle doesn't exist or has been collected, and there isn't
// a handle in the ddata, we can assume ownership of the ddata->v8object
- if (ddata->jsWrapper.isEmpty() && !alternateWrapper) {
+ if (ddata->jsWrapper.isUndefined() && !alternateWrapper) {
QV4::ScopedValue result(scope, create(engine, ddata, object));
ddata->jsWrapper = result;
ddata->jsEngineId = engine->m_engineId;
@@ -698,7 +698,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
Scope scope(v4);
QV4::ScopedCallData callData(scope, argCount);
- callData->thisObject = This->thisObject.isEmpty() ? Value::fromObject(v4->globalObject) : This->thisObject.value();
+ callData->thisObject = This->thisObject.isUndefined() ? Value::fromObject(v4->globalObject) : This->thisObject.value();
for (int ii = 0; ii < argCount; ++ii) {
int type = argsTypes[ii + 1];
if (type == qMetaTypeId<QVariant>()) {
@@ -722,7 +722,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
break;
case Compare: {
QObjectSlotDispatcher *connection = static_cast<QObjectSlotDispatcher*>(this_);
- if (connection->function.isEmpty()) {
+ if (connection->function.isUndefined()) {
*ret = false;
return;
}
@@ -744,8 +744,8 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
if (slotIndexToDisconnect != -1) {
// This is a QObject function wrapper
- if (connection->thisObject.isEmpty() == thisObject->isEmpty() &&
- (connection->thisObject.isEmpty() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
+ if (connection->thisObject.isUndefined() == thisObject->isUndefined() &&
+ (connection->thisObject.isUndefined() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
QPair<QObject *, int> connectedFunctionData = extractQtMethod(connection->function.value().asFunctionObject());
if (connectedFunctionData.first == receiverToDisconnect &&
@@ -757,8 +757,8 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
} else {
// This is a normal JS function
if (__qmljs_strict_equal(connection->function, function) &&
- connection->thisObject.isEmpty() == thisObject->isEmpty() &&
- (connection->thisObject.isEmpty() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
+ connection->thisObject.isUndefined() == thisObject->isUndefined() &&
+ (connection->thisObject.isUndefined() || __qmljs_strict_equal(connection->thisObject, thisObject))) {
*ret = true;
return;
}
@@ -806,7 +806,7 @@ ReturnedValue QObjectWrapper::method_connect(SimpleCallContext *ctx)
if (!slot->function.value().asFunctionObject())
V4THROW_ERROR("Function.prototype.connect: target is not a function");
- if (!slot->thisObject.isEmpty() && !slot->thisObject.value().isObject())
+ if (!slot->thisObject.isUndefined() && !slot->thisObject.value().isObject())
V4THROW_ERROR("Function.prototype.connect: target this is not an object");
QObjectPrivate::connect(signalObject, signalIndex, slot, Qt::AutoConnection);
@@ -832,8 +832,8 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx)
if (signalIndex < 0 || signalObject->metaObject()->method(signalIndex).methodType() != QMetaMethod::Signal)
V4THROW_ERROR("Function.prototype.disconnect: this object is not a signal");
- QV4::Value functionValue = QV4::Value::emptyValue();
- QV4::Value functionThisValue = QV4::Value::emptyValue();
+ QV4::Value functionValue = QV4::Value::undefinedValue();
+ QV4::Value functionThisValue = QV4::Value::undefinedValue();
if (ctx->argumentCount == 1) {
functionValue = ctx->arguments[0];
@@ -845,7 +845,7 @@ ReturnedValue QObjectWrapper::method_disconnect(SimpleCallContext *ctx)
if (!functionValue.asFunctionObject())
V4THROW_ERROR("Function.prototype.disconnect: target is not a function");
- if (!functionThisValue.isEmpty() && !functionThisValue.isObject())
+ if (!functionThisValue.isUndefined() && !functionThisValue.isObject())
V4THROW_ERROR("Function.prototype.disconnect: target this is not an object");
QPair<QObject *, int> functionData = extractQtMethod(functionValue.asFunctionObject());
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 446ea9df3a..f440ade430 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -616,8 +616,9 @@ Returned<Object> *__qmljs_convert_to_object(ExecutionContext *ctx, const ValueRe
Returned<String> *__qmljs_convert_to_string(ExecutionContext *ctx, const ValueRef value)
{
switch (value->type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return ctx->engine->id_undefined->asReturned<String>();
case Value::Null_Type:
return ctx->engine->id_null->asReturned<String>();
@@ -970,7 +971,8 @@ ReturnedValue __qmljs_call_property(ExecutionContext *context, String *name, Cal
Scope scope(context);
Scoped<Object> baseObject(scope, callData->thisObject);
if (!baseObject) {
- if (callData->thisObject.isNullOrUndefined() || callData->thisObject.isEmpty()) {
+ Q_ASSERT(!callData->thisObject.isEmpty());
+ if (callData->thisObject.isNullOrUndefined()) {
QString message = QStringLiteral("Cannot call method '%1' of %2").arg(name->toQString()).arg(callData->thisObject.toQStringNoThrow());
context->throwTypeError(message);
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 7dd3bbeb66..fe61168d3c 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -221,7 +221,7 @@ ReturnedValue Script::run()
QV4::ExecutionEngine *engine = scope->engine;
QV4::Scope valueScope(engine);
- if (qml.isEmpty()) {
+ if (qml.isUndefined()) {
TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
bool strict = scope->strictMode;
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index 35022acfd5..390c3382f2 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -153,6 +153,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, QV8Engine *engi
QV4::Scope scope(v4);
if (v.isEmpty()) {
+ Q_ASSERT(!"Serialize: got empty value");
} else if (v.isUndefined()) {
push(data, valueheader(WorkerUndefined));
} else if (v.isNull()) {
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 570ba9e82e..197b1c2ee5 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -107,8 +107,9 @@ double Value::toNumberImpl() const
QString Value::toQStringNoThrow() const
{
switch (type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return QStringLiteral("undefined");
case Value::Null_Type:
return QStringLiteral("null");
@@ -156,8 +157,9 @@ QString Value::toQStringNoThrow() const
QString Value::toQString() const
{
switch (type()) {
- case Value::Undefined_Type:
case Value::Empty_Type:
+ Q_ASSERT(!"empty Value encountered");
+ case Value::Undefined_Type:
return QStringLiteral("undefined");
case Value::Null_Type:
return QStringLiteral("null");
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 6cefe13ae6..bfad395b3b 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -391,7 +391,7 @@ public:
~PersistentValue();
Value value() const {
- return d ? d->value : Value::emptyValue();
+ return d ? d->value : Value::undefinedValue();
}
ExecutionEngine *engine() {
@@ -403,7 +403,8 @@ public:
operator Value() const { return value(); }
- bool isEmpty() const { return !d || d->value.isEmpty(); }
+ bool isUndefined() const { return !d || d->value.isUndefined(); }
+ bool isNullOrUndefined() const { return !d || d->value.isNullOrUndefined(); }
void clear() {
*this = PersistentValue();
}
@@ -431,7 +432,7 @@ public:
~WeakValue();
Value value() const {
- return d ? d->value : Value::emptyValue();
+ return d ? d->value : Value::undefinedValue();
}
ExecutionEngine *engine() {
@@ -443,7 +444,8 @@ public:
operator Value() const { return value(); }
- bool isEmpty() const { return !d || d->value.isEmpty(); }
+ bool isUndefined() const { return !d || d->value.isUndefined(); }
+ bool isNullOrUndefined() const { return !d || d->value.isNullOrUndefined(); }
void clear() {
*this = WeakValue();
}
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index ed3342aa58..cea946b66b 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -86,7 +86,7 @@ QVariant VariantObject::toVariant(const QV4::Value &v)
}
if (v.isNull())
return QVariant(QMetaType::VoidStar, 0);
- assert (v.isUndefined() || v.isEmpty());
+ Q_ASSERT(v.isUndefined());
return QVariant();
}