From e021ff7ba2b6f017805b8c838b95269ec695def5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 7 May 2013 09:56:09 +0200 Subject: [PATCH] Replace v8::Null() with QV4::Value::nullValue() Change-Id: I7901d5282afd71c1fd66bab223b2811f0d14b5f1 Reviewed-by: Lars Knoll --- src/imports/localstorage/plugin.cpp | 2 +- src/qml/qml/qqmlboundsignal.cpp | 2 +- src/qml/qml/qqmlcomponent.cpp | 10 +++++----- src/qml/qml/qqmlvmemetaobject.cpp | 2 +- src/qml/qml/qqmlxmlhttprequest.cpp | 26 +++++++++++++------------- src/qml/qml/v4/qv4v8.cpp | 7 ------- src/qml/qml/v4/qv4v8_p.h | 1 - src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 20 ++++++++++---------- src/qml/qml/v8/qv8listwrapper.cpp | 2 +- src/qml/qml/v8/qv8qobjectwrapper.cpp | 2 +- src/qml/qml/v8/qv8worker.cpp | 2 +- src/qmltest/quicktestresult.cpp | 2 +- src/quick/items/context2d/qquickcanvasitem.cpp | 14 +++++++------- src/quick/items/context2d/qquickcontext2d.cpp | 2 +- 14 files changed, 43 insertions(+), 51 deletions(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index d1aaafc..7e4b805 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -200,7 +200,7 @@ static v8::Handle qmlsqldatabase_rows_index(QV8SqlDatabaseResource *r for (int ii = 0; ii < record.count(); ++ii) { QVariant v = record.value(ii); if (v.isNull()) { - row->Set(r->engine->toString(record.fieldName(ii)), v8::Null()); + row->Set(r->engine->toString(record.fieldName(ii)), QV4::Value::nullValue()); } else { row->Set(r->engine->toString(record.fieldName(ii)), r->engine->fromVariant(v)); diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 3e952c6..683f528 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -243,7 +243,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) args[ii] = reinterpret_cast(a[ii + 1])->toV8Handle(); } else if (ep->isQObject(type)) { if (!*reinterpret_cast(a[ii + 1])) - args[ii] = v8::Null(); + args[ii] = QV4::Value::nullValue(); else args[ii] = engine->newQObject(*reinterpret_cast(a[ii + 1])); } else { diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 6709ea6..2747cc7 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1193,7 +1193,7 @@ void QQmlComponent::createObject(QQmlV8Function *args) v8::Handle v = (*args)[1]; if (!v->IsObject() || v->IsArray()) { qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } valuemap = v8::Handle::Cast(v); @@ -1208,7 +1208,7 @@ void QQmlComponent::createObject(QQmlV8Function *args) QObject *rv = beginCreate(ctxt); if (!rv) { - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } @@ -1232,7 +1232,7 @@ void QQmlComponent::createObject(QQmlV8Function *args) QQmlData::get(rv)->indestructible = false; if (!rv) - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); else args->returnValue(object); } @@ -1315,7 +1315,7 @@ void QQmlComponent::incubateObject(QQmlV8Function *args) if (v->IsNull()) { } else if (!v->IsObject() || v->IsArray()) { qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } else { valuemap = v8::Handle::Cast(v); @@ -1347,7 +1347,7 @@ void QQmlComponent::incubateObject(QQmlV8Function *args) if (r->status() == QQmlIncubator::Null) { r->dispose(); - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); } else { args->returnValue(o); } diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 1f5d88e..6fc9579 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -69,7 +69,7 @@ void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *) if (m_target && m_index >= 0) { if (m_isVar && m_target->varPropertiesInitialized && !m_target->varProperties.IsEmpty()) { // Set the var property to NULL - m_target->varProperties->Set(m_index - m_target->firstVarPropertyIndex, v8::Null()); + m_target->varProperties->Set(m_index - m_target->firstVarPropertyIndex, QV4::Value::nullValue()); } m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index a28e96e..46ffbb4 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -391,7 +391,7 @@ v8::Handle Node::nodeValue(v8::Handle, const v8::Accessor r->d->type == NodeImpl::Entity || r->d->type == NodeImpl::EntityReference || r->d->type == NodeImpl::Notation) - return v8::Null(); + return QV4::Value::nullValue(); return engine->toString(r->d->data); } @@ -410,7 +410,7 @@ v8::Handle Node::parentNode(v8::Handle, const v8::Accesso QV8Engine *engine = V8ENGINE(); if (r->d->parent) return Node::create(engine, r->d->parent); - else return v8::Null(); + else return QV4::Value::nullValue(); } v8::Handle Node::childNodes(v8::Handle, const v8::AccessorInfo &args) @@ -428,7 +428,7 @@ v8::Handle Node::firstChild(v8::Handle, const v8::Accesso if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); - if (r->d->children.isEmpty()) return v8::Null(); + if (r->d->children.isEmpty()) return QV4::Value::nullValue(); else return Node::create(engine, r->d->children.first()); } @@ -438,7 +438,7 @@ v8::Handle Node::lastChild(v8::Handle, const v8::Accessor if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); - if (r->d->children.isEmpty()) return v8::Null(); + if (r->d->children.isEmpty()) return QV4::Value::nullValue(); else return Node::create(engine, r->d->children.last()); } @@ -448,16 +448,16 @@ v8::Handle Node::previousSibling(v8::Handle, const v8::Ac if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); - if (!r->d->parent) return v8::Null(); + if (!r->d->parent) return QV4::Value::nullValue(); for (int ii = 0; ii < r->d->parent->children.count(); ++ii) { if (r->d->parent->children.at(ii) == r->d) { - if (ii == 0) return v8::Null(); + if (ii == 0) return QV4::Value::nullValue(); else return Node::create(engine, r->d->parent->children.at(ii - 1)); } } - return v8::Null(); + return QV4::Value::nullValue(); } v8::Handle Node::nextSibling(v8::Handle, const v8::AccessorInfo &args) @@ -466,16 +466,16 @@ v8::Handle Node::nextSibling(v8::Handle, const v8::Access if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); - if (!r->d->parent) return v8::Null(); + if (!r->d->parent) return QV4::Value::nullValue(); for (int ii = 0; ii < r->d->parent->children.count(); ++ii) { if (r->d->parent->children.at(ii) == r->d) { - if ((ii + 1) == r->d->parent->children.count()) return v8::Null(); + if ((ii + 1) == r->d->parent->children.count()) return QV4::Value::nullValue(); else return Node::create(engine, r->d->parent->children.at(ii + 1)); } } - return v8::Null(); + return QV4::Value::nullValue(); } v8::Handle Node::attributes(v8::Handle, const v8::AccessorInfo &args) @@ -485,7 +485,7 @@ v8::Handle Node::attributes(v8::Handle, const v8::Accesso QV8Engine *engine = V8ENGINE(); if (r->d->type != NodeImpl::Element) - return v8::Null(); + return QV4::Value::nullValue(); else return NamedNodeMap::create(engine, r->d, &r->d->attributes); } @@ -779,7 +779,7 @@ v8::Handle Document::load(QV8Engine *engine, const QByteArray &data) if (!document || reader.hasError()) { if (document) D(document); - return v8::Null(); + return QV4::Value::nullValue(); } v8::Handle instance = xhrdata(engine)->newNode(); @@ -1744,7 +1744,7 @@ static v8::Handle qmlxmlhttprequest_responseXML(v8::HandlereceivedXml() || (r->readyState() != QQmlXMLHttpRequest::Loading && r->readyState() != QQmlXMLHttpRequest::Done)) { - return v8::Null(); + return QV4::Value::nullValue(); } else { return Document::load(r->engine, r->rawResponseBody()); } diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp index a7e8436..b41e372 100644 --- a/src/qml/qml/v4/qv4v8.cpp +++ b/src/qml/qml/v4/qv4v8.cpp @@ -1822,13 +1822,6 @@ ObjectTemplate::ObjectTemplate() m_useUserComparison = false; } -Handle Null() -{ - Handle val; - val.val = QV4::Value::nullValue().val; - return val; -} - Handle True() { Handle val; diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h index 3f10d2f..2135258 100644 --- a/src/qml/qml/v4/qv4v8_p.h +++ b/src/qml/qml/v4/qv4v8_p.h @@ -2022,7 +2022,6 @@ DEFINE_REFCOUNTED_HANDLE_OPERATIONS(ObjectTemplate) // --- Statics --- -Handle V8EXPORT Null(); Handle V8EXPORT True(); Handle V8EXPORT False(); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index a02ecf5..81f013d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -703,10 +703,10 @@ v8::Handle lighter(const v8::Arguments &args) bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); if (!ok) { - return v8::Null(); + return QV4::Value::nullValue(); } } else if (v.userType() != QVariant::Color) { - return v8::Null(); + return QV4::Value::nullValue(); } qreal factor = 1.5; @@ -741,10 +741,10 @@ v8::Handle darker(const v8::Arguments &args) bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); if (!ok) { - return v8::Null(); + return QV4::Value::nullValue(); } } else if (v.userType() != QVariant::Color) { - return v8::Null(); + return QV4::Value::nullValue(); } qreal factor = 2.0; @@ -789,10 +789,10 @@ v8::Handle tint(const v8::Arguments &args) bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); if (!ok) { - return v8::Null(); + return QV4::Value::nullValue(); } } else if (v1.userType() != QVariant::Color) { - return v8::Null(); + return QV4::Value::nullValue(); } // tint color @@ -801,10 +801,10 @@ v8::Handle tint(const v8::Arguments &args) bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); if (!ok) { - return v8::Null(); + return QV4::Value::nullValue(); } } else if (v2.userType() != QVariant::Color) { - return v8::Null(); + return QV4::Value::nullValue(); } return V8ENGINE()->fromVariant(QQml_colorProvider()->tint(v1, v2)); @@ -1181,7 +1181,7 @@ v8::Handle createQmlObject(const v8::Arguments &args) QString qml = args[0]->v4Value().toQString(); if (qml.isEmpty()) - return v8::Null(); + return QV4::Value::nullValue(); QUrl url; if (args.Length() > 2) @@ -1282,7 +1282,7 @@ v8::Handle createComponent(const v8::Arguments &args) QString arg = args[0]->v4Value().toQString(); if (arg.isEmpty()) - return v8::Null(); + return QV4::Value::nullValue(); QQmlComponent::CompilationMode compileMode = QQmlComponent::PreferSynchronous; QObject *parentArg = 0; diff --git a/src/qml/qml/v8/qv8listwrapper.cpp b/src/qml/qml/v8/qv8listwrapper.cpp index 7ad590a..8dc3576 100644 --- a/src/qml/qml/v8/qv8listwrapper.cpp +++ b/src/qml/qml/v8/qv8listwrapper.cpp @@ -86,7 +86,7 @@ void QV8ListWrapper::destroy() v8::Handle QV8ListWrapper::newList(QObject *object, int propId, int propType) { if (!object || propId == -1) - return v8::Null(); + return QV4::Value::nullValue(); // XXX NewInstance() should be optimized v8::Handle rv = m_constructor->NewInstance(); diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 8166849..e58584b 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -1095,7 +1095,7 @@ released the handle. v8::Handle QV8QObjectWrapper::newQObject(QObject *object) { if (QQmlData::wasDeleted(object)) - return v8::Null(); + return QV4::Value::nullValue(); QQmlData *ddata = QQmlData::get(object, true); if (!ddata) diff --git a/src/qml/qml/v8/qv8worker.cpp b/src/qml/qml/v8/qv8worker.cpp index 1bbe477..9986cee 100644 --- a/src/qml/qml/v8/qv8worker.cpp +++ b/src/qml/qml/v8/qv8worker.cpp @@ -295,7 +295,7 @@ v8::Handle QV8Worker::deserialize(const char *&data, QV8Engine *engin case WorkerUndefined: return QV4::Value::undefinedValue(); case WorkerNull: - return v8::Null(); + return QV4::Value::nullValue(); case WorkerTrue: return v8::True(); case WorkerFalse: diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 35091f8..507ac41 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -475,7 +475,7 @@ bool QuickTestResult::fuzzyCompare(const QVariant &actual, const QVariant &expec void QuickTestResult::stringify(QQmlV8Function *args) { if (args->Length() < 1) - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); v8::Handle value = (*args)[0]; diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index f810c76..f05db38 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -368,7 +368,7 @@ QQmlV4Handle QQuickCanvasItem::context() const if (d->contextInitialized) return QQmlV4Handle::fromV8Handle(d->context->v8value()); - return QQmlV4Handle::fromV8Handle(v8::Null()); + return QQmlV4Handle::fromV8Handle(QV4::Value::nullValue()); } /*! @@ -728,13 +728,13 @@ void QQuickCanvasItem::getContext(QQmlV8Function *args) if (args->Length() < 1 || !(*args)[0]->IsString()) { qmlInfo(this) << "getContext should be called with a string naming the required context type"; - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } if (!d->available) { qmlInfo(this) << "Unable to use getContext() at this time, please wait for available: true"; - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } @@ -747,14 +747,14 @@ void QQuickCanvasItem::getContext(QQmlV8Function *args) } qmlInfo(this) << "Canvas already initialized with a different context type"; - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } if (createContext(contextId)) args->returnValue(d->context->v8value()); else - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); } /*! @@ -768,7 +768,7 @@ void QQuickCanvasItem::requestAnimationFrame(QQmlV8Function *args) { if (args->Length() < 1 || !(*args)[0]->IsFunction()) { qmlInfo(this) << "requestAnimationFrame should be called with an animation callback function"; - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } @@ -794,7 +794,7 @@ void QQuickCanvasItem::cancelRequestAnimationFrame(QQmlV8Function *args) { if (args->Length() < 1 || !(*args)[0]->IsInt32()) { qmlInfo(this) << "cancelRequestAnimationFrame should be called with an animation callback id"; - args->returnValue(v8::Null()); + args->returnValue(QV4::Value::nullValue()); return; } diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 1dadac8..8bf44a2 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -2596,7 +2596,7 @@ static v8::Handle ctx2d_getImageData(const v8::Arguments &args) return imageData; } - return v8::Null(); + return QV4::Value::nullValue(); } /*! -- 2.7.4