From d8891234812898b1cab406dae9fab9f818bb1efe Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 21 May 2013 12:33:55 +0200 Subject: Get rid of v8::Integer Change-Id: I6b9ab830c4ff3cbf986dbcf7c056648b5a16a222 Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 6 +-- src/qml/qml/qqmlcomponent.cpp | 2 +- src/qml/qml/qqmlvme.cpp | 2 +- src/qml/qml/qqmlxmlhttprequest.cpp | 34 ++++++++-------- src/qml/qml/v4/qv4serialize.cpp | 2 +- src/qml/qml/v4/qv4v8.cpp | 57 +++++---------------------- src/qml/qml/v4/qv4v8_p.h | 41 +++---------------- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 +- src/qml/qml/v8/qv4domerrors_p.h | 2 +- src/qml/qml/v8/qv8engine.cpp | 10 ++--- src/qml/qml/v8/qv8include.cpp | 16 ++++---- src/qml/qml/v8/qv8listwrapper.cpp | 2 +- src/qml/qml/v8/qv8qobjectwrapper.cpp | 14 +++---- src/qml/qml/v8/qv8qobjectwrapper_p.h | 2 +- src/qml/qml/v8/qv8sequencewrapper.cpp | 2 +- src/qml/qml/v8/qv8sequencewrapper_p_p.h | 4 +- src/qml/qml/v8/qv8typewrapper.cpp | 4 +- src/qml/qml/v8/qv8valuetypewrapper.cpp | 2 +- src/qml/types/qqmldelegatemodel.cpp | 30 +++++++------- src/qml/util/qqmladaptormodel.cpp | 4 +- src/quick/items/context2d/qquickcontext2d.cpp | 18 ++++----- 21 files changed, 95 insertions(+), 163 deletions(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 998155d29a..0d9dec3b64 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -62,7 +62,7 @@ #define V8THROW_SQL(error, desc) \ { \ v8::Handle v = v8::Exception::Error(engine->toString(desc)); \ - v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \ + v->ToObject()->Set(v8::String::New("code"), QV4::Value::fromInt32(error)); \ v8::ThrowException(v); \ return v8::Handle(); \ } @@ -78,7 +78,7 @@ #define V8THROW_SQL_VOID(error, desc) \ { \ v8::Handle v = v8::Exception::Error(engine->toString(desc)); \ - v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \ + v->ToObject()->Set(v8::String::New("code"), QV4::Value::fromInt32(error)); \ v8::ThrowException(v); \ return; \ } @@ -157,7 +157,7 @@ static v8::Handle qmlsqldatabase_rows_length(v8::Handle / s = 0; } } - return v8::Integer::New(s); + return QV4::Value::fromInt32(s); } static v8::Handle qmlsqldatabase_rows_forwardOnly(v8::Handle /* property */, diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index a3f85e243a..6c9e925d30 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1423,7 +1423,7 @@ v8::Handle QV8IncubatorResource::StatusGetter(v8::Handle, const v8::AccessorInfo& info) { QV8IncubatorResource *r = v8_resource_check(info.This()); - return v8::Integer::NewFromUnsigned(r->status()); + return QV4::Value::fromUInt32(r->status()); } v8::Handle QV8IncubatorResource::StatusChangedGetter(v8::Handle, diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 6636e602af..59b93366d0 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -420,7 +420,7 @@ QObject *QQmlVME::run(QList *errors, // Store a literal value in a var property. // We deliberately do not use string converters here QML_STORE_VAR(StoreVar, ep->v8engine()->fromVariant(PRIMITIVES.at(instr.value))); - QML_STORE_VAR(StoreVarInteger, v8::Integer::New(instr.value)); + QML_STORE_VAR(StoreVarInteger, QV4::Value::fromInt32(instr.value)); QML_STORE_VAR(StoreVarDouble, v8::Number::New(instr.value)); QML_STORE_VAR(StoreVarBool, v8::Boolean::New(instr.value)); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 938a7e5a8f..6b31ecf39a 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -395,7 +395,7 @@ v8::Handle Node::nodeType(v8::Handle, const v8::AccessorI { QQmlDOMNodeResource *r = v8_resource_cast(args.This()); if (!r) return QV4::Value::undefinedValue(); - return v8::Integer::New(r->d->type); + return QV4::Value::fromInt32(r->d->type); } v8::Handle Node::parentNode(v8::Handle, const v8::AccessorInfo &args) @@ -618,7 +618,7 @@ v8::Handle CharacterData::length(v8::Handle, const v8::Ac if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); Q_UNUSED(engine) - return v8::Integer::New(r->d->data.length()); + return QV4::Value::fromInt32(r->d->data.length()); } v8::Handle CharacterData::prototype(QV8Engine *engine) @@ -819,7 +819,7 @@ v8::Handle NamedNodeMap::length(v8::Handle, const v8::Acc if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); Q_UNUSED(engine) - return v8::Integer::New(r->list->count()); + return QV4::Value::fromInt32(r->list->count()); } v8::Handle NamedNodeMap::indexed(uint32_t index, const v8::AccessorInfo& args) @@ -897,7 +897,7 @@ v8::Handle NodeList::length(v8::Handle, const v8::Accesso if (!r) return QV4::Value::undefinedValue(); QV8Engine *engine = V8ENGINE(); Q_UNUSED(engine) - return v8::Integer::New(r->d->children.count()); + return QV4::Value::fromInt32(r->d->children.count()); } v8::Handle NodeList::prototype(QV8Engine *engine) @@ -1664,7 +1664,7 @@ static v8::Handle qmlxmlhttprequest_readyState(v8::Handle if (!r) V8THROW_REFERENCE("Not an XMLHttpRequest object"); - return v8::Integer::NewFromUnsigned(r->readyState()); + return QV4::Value::fromUInt32(r->readyState()); } static v8::Handle qmlxmlhttprequest_status(v8::Handle /* property */, @@ -1679,9 +1679,9 @@ static v8::Handle qmlxmlhttprequest_status(v8::Handle /* V8THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); if (r->errorFlag()) - return v8::Integer::New(0); + return QV4::Value::fromInt32(0); else - return v8::Integer::New(r->replyStatus()); + return QV4::Value::fromInt32(r->replyStatus()); } static v8::Handle qmlxmlhttprequest_statusText(v8::Handle /* property */, @@ -1783,18 +1783,18 @@ void *qt_add_qmlxmlhttprequest(QV8Engine *engine) xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseXML"),qmlxmlhttprequest_responseXML, 0, v8::Handle(), v8::DEFAULT, attributes); // State values - xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes); - xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes); - xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes); - xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes); - xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes); + xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("UNSENT"), QV4::Value::fromInt32(0), attributes); + xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("OPENED"), QV4::Value::fromInt32(1), attributes); + xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("HEADERS_RECEIVED"), QV4::Value::fromInt32(2), attributes); + xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("LOADING"), QV4::Value::fromInt32(3), attributes); + xmlhttprequest->PrototypeTemplate()->Set(v8::String::New("DONE"), QV4::Value::fromInt32(4), attributes); // Constructor - xmlhttprequest->Set(v8::String::New("UNSENT"), v8::Integer::New(0), attributes); - xmlhttprequest->Set(v8::String::New("OPENED"), v8::Integer::New(1), attributes); - xmlhttprequest->Set(v8::String::New("HEADERS_RECEIVED"), v8::Integer::New(2), attributes); - xmlhttprequest->Set(v8::String::New("LOADING"), v8::Integer::New(3), attributes); - xmlhttprequest->Set(v8::String::New("DONE"), v8::Integer::New(4), attributes); + xmlhttprequest->Set(v8::String::New("UNSENT"), QV4::Value::fromInt32(0), attributes); + xmlhttprequest->Set(v8::String::New("OPENED"), QV4::Value::fromInt32(1), attributes); + xmlhttprequest->Set(v8::String::New("HEADERS_RECEIVED"), QV4::Value::fromInt32(2), attributes); + xmlhttprequest->Set(v8::String::New("LOADING"), QV4::Value::fromInt32(3), attributes); + xmlhttprequest->Set(v8::String::New("DONE"), QV4::Value::fromInt32(4), attributes); v8::Handle(engine->global())->Set(v8::String::New("XMLHttpRequest"), xmlhttprequest->GetFunction()); QQmlXMLHttpRequestData *data = new QQmlXMLHttpRequestData; diff --git a/src/qml/qml/v4/qv4serialize.cpp b/src/qml/qml/v4/qv4serialize.cpp index 142ef9caa7..eda9349a6a 100644 --- a/src/qml/qml/v4/qv4serialize.cpp +++ b/src/qml/qml/v4/qv4serialize.cpp @@ -250,7 +250,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, QV8Engine *engi } reserve(data, sizeof(quint32) + length * sizeof(quint32)); push(data, valueheader(WorkerSequence, length)); - serialize(data, v8::Integer::New(sequenceVariant.userType())->v4Value(), engine); // sequence type + serialize(data, QV4::Value::fromInt32(sequenceVariant.userType()), engine); // sequence type for (uint32_t ii = 0; ii < seqLength; ++ii) { serialize(data, v8object->Get(ii)->v4Value(), engine); // sequence elements } diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp index 04bcb7333d..1b888ac729 100644 --- a/src/qml/qml/v4/qv4v8.cpp +++ b/src/qml/qml/v4/qv4v8.cpp @@ -170,11 +170,11 @@ protected: DEFINE_MANAGED_VTABLE(V8AccessorSetter); -ScriptOrigin::ScriptOrigin(Handle resource_name, Handle resource_line_offset, Handle resource_column_offset) +ScriptOrigin::ScriptOrigin(Handle resource_name, int resource_line_offset, int resource_column_offset) { m_fileName = resource_name->ToString()->asQString(); - m_lineNumber = resource_line_offset->ToInt32()->Value(); - m_columnNumber = resource_column_offset->ToInt32()->Value(); + m_lineNumber = resource_line_offset; + m_columnNumber = resource_column_offset; } Handle ScriptOrigin::ResourceName() const @@ -182,14 +182,14 @@ Handle ScriptOrigin::ResourceName() const return Value::fromV4Value(QV4::Value::fromString(currentEngine()->current, m_fileName)); } -Handle ScriptOrigin::ResourceLineOffset() const +int ScriptOrigin::ResourceLineOffset() const { - return Integer::New(m_lineNumber); + return m_lineNumber; } -Handle ScriptOrigin::ResourceColumnOffset() const +int ScriptOrigin::ResourceColumnOffset() const { - return Integer::New(m_columnNumber); + return m_columnNumber; } @@ -470,16 +470,6 @@ Handle Value::ToObject() const return QV4::Value::fromObject(ConstValuePtr(this)->toObject(currentEngine()->current)); } -Handle Value::ToInteger() const -{ - return QV4::Value::fromDouble(ConstValuePtr(this)->toInteger()); -} - -Handle Value::ToInt32() const -{ - return QV4::Value::fromInt32(ConstValuePtr(this)->toInt32()); -} - bool Value::BooleanValue() const { return ConstValuePtr(this)->toBoolean(); @@ -673,35 +663,6 @@ Number *Number::Cast(v8::Value *obj) return static_cast(obj); } -Handle Integer::New(int32_t value) -{ - return QV4::Value::fromInt32(value); -} - -Handle Integer::NewFromUnsigned(uint32_t value) -{ - return QV4::Value::fromUInt32(value); -} - -int64_t Integer::Value() const -{ - const QV4::Value *v = ConstValuePtr(this); - assert(v->isNumber()); - return (int64_t)v->asDouble(); -} - -Integer *Integer::Cast(v8::Value *obj) -{ - return static_cast(obj); -} - -int32_t Int32::Value() const -{ - const QV4::Value *v = ConstValuePtr(this); - assert(v->isInteger()); - return v->int_32; -} - struct ExternalResourceWrapper : public QV4::Object::ExternalResource { ExternalResourceWrapper(v8::Object::ExternalResource *wrapped) @@ -1294,7 +1255,7 @@ public: static QV4::PropertyAttributes queryDynamicProperty(const QV4::Object *object, QV4::String *string) { const V4V8Object *that = static_cast *>(object); - Handle result = that->m_template->m_fallbackPropertyQuery(String::New(string), that->namedAccessorInfo()); + Handle result = that->m_template->m_fallbackPropertyQuery(String::New(string), that->namedAccessorInfo()); if (result.IsEmpty()) return QV4::PropertyAttributes(); return propertyAttributesToFlags(result); @@ -1412,7 +1373,7 @@ protected: static PropertyAttributes propertyAttributesToFlags(const Handle &attr) { PropertyAttributes flags; - int intAttr = attr->ToInt32()->Value(); + int intAttr = attr->v4Value().toInt32(); flags.setWritable(!(intAttr & ReadOnly)); flags.setEnumerable(!(intAttr & DontEnum)); flags.setConfigurable(!(intAttr & DontDelete)); diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h index 6143457c0c..f6aae840be 100644 --- a/src/qml/qml/v4/qv4v8_p.h +++ b/src/qml/qml/v4/qv4v8_p.h @@ -112,13 +112,9 @@ class Number; class NumberObject; class Object; class Array; -class Int32; -class Uint32; class External; class Primitive; class Boolean; -class BooleanObject; -class Integer; class Function; class Date; class ImplementationUtilities; @@ -432,11 +428,11 @@ public: ScriptOrigin( Handle resource_name, - Handle resource_line_offset = Handle(), - Handle resource_column_offset = Handle()); + int resource_line_offset = -1, + int resource_column_offset = -1); Handle ResourceName() const; - Handle ResourceLineOffset() const; - Handle ResourceColumnOffset() const; + int ResourceLineOffset() const; + int ResourceColumnOffset() const; private: QString m_fileName; int m_lineNumber, m_columnNumber; @@ -779,8 +775,6 @@ class V8EXPORT Value { Handle ToNumber() const; Handle ToString() const; Handle ToObject() const; - Handle ToInteger() const; - Handle ToInt32() const; bool BooleanValue() const; double NumberValue() const; @@ -1029,29 +1023,6 @@ class V8EXPORT Number : public Primitive { }; -/** - * A JavaScript value representing a signed integer. - */ -class V8EXPORT Integer : public Number { - public: - static Handle New(int32_t value); - static Handle NewFromUnsigned(uint32_t value); - int64_t Value() const; - static Integer* Cast(v8::Value* obj); -}; - - -/** - * A JavaScript value representing a 32-bit signed integer. - */ -class V8EXPORT Int32 : public Integer { - public: - int32_t Value() const; - private: - Int32(); -}; - - enum PropertyAttribute { None = 0, ReadOnly = 1 << 0, @@ -1381,7 +1352,7 @@ typedef Handle (*NamedPropertySetter)(Handle property, * The result is an integer encoding property attributes (like v8::None, * v8::DontEnum, etc.) */ -typedef Handle (*NamedPropertyQuery)(Handle property, +typedef Handle (*NamedPropertyQuery)(Handle property, const AccessorInfo& info); @@ -1421,7 +1392,7 @@ typedef Handle (*IndexedPropertySetter)(uint32_t index, * Returns a non-empty handle if the interceptor intercepts the request. * The result is an integer encoding property attributes. */ -typedef Handle (*IndexedPropertyQuery)(uint32_t index, +typedef Handle (*IndexedPropertyQuery)(uint32_t index, const AccessorInfo& info); /** diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index bac0c231e2..c1995599be 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1134,8 +1134,8 @@ QV4::Value createQmlObject(const v8::Arguments &args) const QQmlError &error = errors.at(ii); errorstr += QLatin1String("\n ") + error.toString(); v8::Handle qmlerror = v8::Object::New(); - qmlerror->Set(v8::String::New("lineNumber"), v8::Integer::New(error.line())); - qmlerror->Set(v8::String::New("columnNumber"), v8::Integer::New(error.column())); + qmlerror->Set(v8::String::New("lineNumber"), QV4::Value::fromInt32(error.line())); + qmlerror->Set(v8::String::New("columnNumber"), QV4::Value::fromInt32(error.column())); qmlerror->Set(v8::String::New("fileName"), engine->toString(error.url().toString())); qmlerror->Set(v8::String::New("message"), engine->toString(error.description())); qmlerrors->Set(ii, qmlerror); diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index 3d612cb397..268df7e26e 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE #define V8THROW_DOM(error, string) { \ v8::Handle v = v8::Exception::Error(v8::String::New(string)); \ - v->ToObject()->Set(v8::String::New("code"), v8::Integer::New(error)); \ + v->ToObject()->Set(v8::String::New("code"), QV4::Value::fromInt32(error)); \ v8::ThrowException(v); \ return v8::Handle(); \ } diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 59d3ca9b3b..513b30aec1 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -431,7 +431,7 @@ v8::Handle QV8Engine::qmlModeCompile(const QString &source, v8::Handle v8source = QV4::Value::fromString(m_v4Engine->newString(source)); v8::Handle v8fileName = QV4::Value::fromString(m_v4Engine->newString(fileName)); - v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1)); + v8::ScriptOrigin origin(v8fileName, lineNumber - 1); v8::Handle script = v8::Script::Compile(v8source, &origin, 0, v8::Handle(), v8::Script::QmlMode); @@ -451,7 +451,7 @@ v8::Handle QV8Engine::qmlModeCompile(const char *source, int sourceL v8::Handle v8source = QV4::Value::fromString(m_v4Engine->newString(QString::fromUtf8(source, sourceLength))); v8::Handle v8fileName = QV4::Value::fromString(m_v4Engine->newString(fileName)); - v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1)); + v8::ScriptOrigin origin(v8fileName, lineNumber - 1); v8::Handle script = v8::Script::Compile(v8source, &origin, 0, v8::Handle(), v8::Script::QmlMode); @@ -570,11 +570,11 @@ void QV8Engine::initializeGlobal(v8::Handle global) for (int ii = 0; ii < qtMetaObject->enumeratorCount(); ++ii) { QMetaEnum enumerator = qtMetaObject->enumerator(ii); for (int jj = 0; jj < enumerator.keyCount(); ++jj) { - qt->Set(v8::String::New(enumerator.key(jj)), v8::Integer::New(enumerator.value(jj))); + qt->Set(v8::String::New(enumerator.key(jj)), QV4::Value::fromInt32(enumerator.value(jj))); } } - qt->Set(v8::String::New("Asynchronous"), v8::Integer::New(0)); - qt->Set(v8::String::New("Synchronous"), v8::Integer::New(1)); + qt->Set(v8::String::New("Asynchronous"), QV4::Value::fromInt32(0)); + qt->Set(v8::String::New("Synchronous"), QV4::Value::fromInt32(1)); qt->Set(v8::String::New("include"), V8FUNCTION(QV8Include::include, this)); qt->Set(v8::String::New("isQtObject"), V8FUNCTION(isQtObject, this)); diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp index 90c1f5928c..018aaf5823 100644 --- a/src/qml/qml/v8/qv8include.cpp +++ b/src/qml/qml/v8/qv8include.cpp @@ -81,12 +81,12 @@ v8::Handle QV8Include::resultValue(Status status) { // XXX It seems inefficient to create this object from scratch each time. v8::Handle result = v8::Object::New(); - result->Set(v8::String::New("OK"), v8::Integer::New(Ok)); - result->Set(v8::String::New("LOADING"), v8::Integer::New(Loading)); - result->Set(v8::String::New("NETWORK_ERROR"), v8::Integer::New(NetworkError)); - result->Set(v8::String::New("EXCEPTION"), v8::Integer::New(Exception)); + result->Set(v8::String::New("OK"), QV4::Value::fromInt32(Ok)); + result->Set(v8::String::New("LOADING"), QV4::Value::fromInt32(Loading)); + result->Set(v8::String::New("NETWORK_ERROR"), QV4::Value::fromInt32(NetworkError)); + result->Set(v8::String::New("EXCEPTION"), QV4::Value::fromInt32(Exception)); - result->Set(v8::String::New("status"), v8::Integer::New(status)); + result->Set(v8::String::New("status"), QV4::Value::fromInt32(status)); return result; } @@ -151,14 +151,14 @@ void QV8Include::finished() //m_engine->contextWrapper()->addSubContext(m_qmlglobal.value(), script, importContext); try { script->Run(m_qmlglobal.value()); - v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Ok)); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(Ok)); } catch (QV4::Exception &e) { e.accept(ctx); - v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Exception)); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(Exception)); v8::Handle(m_resultObject)->Set(v8::String::New("exception"), e.value()); } } else { - v8::Handle(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(NetworkError)); + v8::Handle(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(NetworkError)); } callback(m_engine, m_callbackFunction.value(), m_resultObject.value()); diff --git a/src/qml/qml/v8/qv8listwrapper.cpp b/src/qml/qml/v8/qv8listwrapper.cpp index c2e821dbcc..0955135b81 100644 --- a/src/qml/qml/v8/qv8listwrapper.cpp +++ b/src/qml/qml/v8/qv8listwrapper.cpp @@ -173,7 +173,7 @@ v8::Handle QV8ListWrapper::LengthGetter(v8::Handle proper quint32 count = resource->property.count?resource->property.count(&resource->property):0; - return v8::Integer::NewFromUnsigned(count); + return QV4::Value::fromUInt32(count); } v8::Handle QV8ListWrapper::Enumerator(const v8::AccessorInfo &info) diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 2030bf775c..7be150f5e8 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -247,9 +247,9 @@ struct ReadAccessor { }; static inline v8::Handle valueToHandle(QV8Engine *, int v) -{ return v8::Integer::New(v); } +{ return QV4::Value::fromInt32(v); } static inline v8::Handle valueToHandle(QV8Engine *, uint v) -{ return v8::Integer::NewFromUnsigned(v); } +{ return QV4::Value::fromUInt32(v); } static inline v8::Handle valueToHandle(QV8Engine *, bool v) { return v8::Boolean::New(v); } static inline v8::Handle valueToHandle(QV8Engine *e, const QString &v) @@ -819,13 +819,13 @@ v8::Handle QV8QObjectWrapper::Setter(v8::Handle property, return value; } -v8::Handle QV8QObjectWrapper::Query(v8::Handle property, +v8::Handle QV8QObjectWrapper::Query(v8::Handle property, const v8::AccessorInfo &info) { QV8QObjectResource *resource = v8_resource_check(info.This()); if (resource->object.isNull()) - return v8::Handle(); + return v8::Handle(); QV8Engine *engine = resource->engine; QObject *object = resource->object; @@ -838,11 +838,11 @@ v8::Handle QV8QObjectWrapper::Query(v8::Handle property result = QQmlPropertyCache::property(engine->engine(), object, propertystring, context, local); if (!result) - return v8::Handle(); + return v8::Handle(); else if (!result->isWritable() && !result->isQList()) - return v8::Integer::New(v8::ReadOnly | v8::DontDelete); + return QV4::Value::fromInt32(v8::ReadOnly | v8::DontDelete); else - return v8::Integer::New(v8::DontDelete); + return QV4::Value::fromInt32(v8::DontDelete); } v8::Handle QV8QObjectWrapper::Enumerator(const v8::AccessorInfo &info) diff --git a/src/qml/qml/v8/qv8qobjectwrapper_p.h b/src/qml/qml/v8/qv8qobjectwrapper_p.h index f1f09ddf8a..f25bec0eb7 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper_p.h +++ b/src/qml/qml/v8/qv8qobjectwrapper_p.h @@ -131,7 +131,7 @@ private: static v8::Handle Setter(v8::Handle property, v8::Handle value, const v8::AccessorInfo &info); - static v8::Handle Query(v8::Handle property, + static v8::Handle Query(v8::Handle property, const v8::AccessorInfo &info); static v8::Handle Enumerator(const v8::AccessorInfo &info); static QV4::Value Connect(const v8::Arguments &args); diff --git a/src/qml/qml/v8/qv8sequencewrapper.cpp b/src/qml/qml/v8/qv8sequencewrapper.cpp index eba42b2a8d..5f20bbe6cb 100644 --- a/src/qml/qml/v8/qv8sequencewrapper.cpp +++ b/src/qml/qml/v8/qv8sequencewrapper.cpp @@ -261,7 +261,7 @@ v8::Handle QV8SequenceWrapper::LengthGetter(v8::Handle pr Q_UNUSED(property); QV8SequenceResource *sr = v8_resource_cast(info.This()); Q_ASSERT(sr); - return v8::Integer::NewFromUnsigned(sr->lengthGetter()); + return QV4::Value::fromUInt32(sr->lengthGetter()); } void QV8SequenceWrapper::LengthSetter(v8::Handle property, v8::Handle value, const v8::AccessorInfo &info) diff --git a/src/qml/qml/v8/qv8sequencewrapper_p_p.h b/src/qml/qml/v8/qv8sequencewrapper_p_p.h index 9ed5628c4a..51be2312d2 100644 --- a/src/qml/qml/v8/qv8sequencewrapper_p_p.h +++ b/src/qml/qml/v8/qv8sequencewrapper_p_p.h @@ -131,7 +131,7 @@ static int convertV8ValueToInt(QV8Engine *, v8::Handle v) static v8::Handle convertIntToV8Value(QV8Engine *, int v) { - return v8::Integer::New(v); + return QV4::Value::fromInt32(v); } static QString convertIntToString(QV8Engine *, int v) @@ -440,7 +440,7 @@ static QString convertUrlToString(QV8Engine *, const QUrl &v) qint32 count = c.count(); \ v8::Handle retn = v8::Array::New(count); \ for (qint32 i = 0; i < count; ++i) { \ - retn->Set(static_cast(i), v8::Integer::NewFromUnsigned(static_cast(i))); \ + retn->Set(static_cast(i), QV4::Value::fromUInt32(static_cast(i))); \ } \ return retn; \ } \ diff --git a/src/qml/qml/v8/qv8typewrapper.cpp b/src/qml/qml/v8/qv8typewrapper.cpp index bc2ac0d97b..e7660f7306 100644 --- a/src/qml/qml/v8/qv8typewrapper.cpp +++ b/src/qml/qml/v8/qv8typewrapper.cpp @@ -186,7 +186,7 @@ v8::Handle QV8TypeWrapper::Getter(v8::Handle property, bool ok; int value = e.keyToValue(enumName.constData(), &ok); if (ok) - return v8::Integer::New(value); + return QV4::Value::fromInt32(value); } } } @@ -211,7 +211,7 @@ v8::Handle QV8TypeWrapper::Getter(v8::Handle property, bool ok = false; int value = type->enumValue(propertystring, &ok); if (ok) - return v8::Integer::New(value); + return QV4::Value::fromInt32(value); // Fall through to return empty handle diff --git a/src/qml/qml/v8/qv8valuetypewrapper.cpp b/src/qml/qml/v8/qv8valuetypewrapper.cpp index dd669fc97a..0ca48cf5c2 100644 --- a/src/qml/qml/v8/qv8valuetypewrapper.cpp +++ b/src/qml/qml/v8/qv8valuetypewrapper.cpp @@ -338,7 +338,7 @@ v8::Handle QV8ValueTypeWrapper::Getter(v8::Handle propert // These four types are the most common used by the value type wrappers VALUE_TYPE_LOAD(QMetaType::QReal, qreal, v8::Number::New); - VALUE_TYPE_LOAD(QMetaType::Int, int, v8::Integer::New); + VALUE_TYPE_LOAD(QMetaType::Int, int, QV4::Value::fromInt32); VALUE_TYPE_LOAD(QMetaType::QString, QString, r->engine->toString); VALUE_TYPE_LOAD(QMetaType::Bool, bool, v8::Boolean::New); diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 6242af8fcd..87d3429981 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1399,9 +1399,9 @@ QQmlDelegateModelPrivate::buildChangeList(const QVector &changes) for (int i = 0; i < changes.count(); ++i) { v8::Handle object = v8::Object::New(); - object->Set(indexKey, v8::Integer::New(changes.at(i).index)); - object->Set(countKey, v8::Integer::New(changes.at(i).count)); - object->Set(moveIdKey, changes.at(i).moveId != -1 ? v8::Integer::New(changes.at(i).count) : QV4::Value::undefinedValue()); + object->Set(indexKey, QV4::Value::fromInt32(changes.at(i).index)); + object->Set(countKey, QV4::Value::fromInt32(changes.at(i).count)); + object->Set(moveIdKey, changes.at(i).moveId != -1 ? QV4::Value::fromInt32(changes.at(i).count) : QV4::Value::undefinedValue()); indexes->Set(i, object); } return indexes; @@ -1628,22 +1628,22 @@ void QQmlDelegateModelItemMetaType::initializeConstructor() constructor->SetHasExternalResource(true); constructor->SetAccessor(data->model(), get_model); constructor->SetAccessor(data->groups(), get_groups, set_groups); - constructor->SetAccessor(data->isUnresolved(), get_member, 0, v8::Int32::New(30)); - constructor->SetAccessor(data->inItems(), get_member, set_member, v8::Int32::New(1)); - constructor->SetAccessor(data->inPersistedItems(), get_member, set_member, v8::Int32::New(2)); - constructor->SetAccessor(data->itemsIndex(), get_index, 0, v8::Int32::New(1)); - constructor->SetAccessor(data->persistedItemsIndex(), get_index, 0, v8::Int32::New(2)); + constructor->SetAccessor(data->isUnresolved(), get_member, 0, QV4::Value::fromInt32(30)); + constructor->SetAccessor(data->inItems(), get_member, set_member, QV4::Value::fromInt32(1)); + constructor->SetAccessor(data->inPersistedItems(), get_member, set_member, QV4::Value::fromInt32(2)); + constructor->SetAccessor(data->itemsIndex(), get_index, 0, QV4::Value::fromInt32(1)); + constructor->SetAccessor(data->persistedItemsIndex(), get_index, 0, QV4::Value::fromInt32(2)); for (int i = 2; i < groupNames.count(); ++i) { QString propertyName = QStringLiteral("in") + groupNames.at(i); propertyName.replace(2, 1, propertyName.at(2).toUpper()); constructor->SetAccessor( - v8Engine->toString(propertyName), get_member, set_member, v8::Int32::New(i + 1)); + v8Engine->toString(propertyName), get_member, set_member, QV4::Value::fromInt32(i + 1)); } for (int i = 2; i < groupNames.count(); ++i) { const QString propertyName = groupNames.at(i) + QStringLiteral("Index"); constructor->SetAccessor( - v8Engine->toString(propertyName), get_index, 0, v8::Int32::New(i + 1)); + v8Engine->toString(propertyName), get_index, 0, QV4::Value::fromInt32(i + 1)); } } @@ -1759,7 +1759,7 @@ v8::Handle QQmlDelegateModelItemMetaType::get_index( QQmlDelegateModelItem *cacheItem = v8_resource_cast(info.This()); V8ASSERT_TYPE(cacheItem, "Not a valid VisualData object"); - return v8::Integer::New(cacheItem->groupIndex(Compositor::Group(info.Data()->Int32Value()))); + return QV4::Value::fromInt32(cacheItem->groupIndex(Compositor::Group(info.Data()->Int32Value()))); } @@ -3109,10 +3109,10 @@ public: const QQmlChangeSet::Change &change = array->at(index); v8::Handle object = engineData(array->engine)->constructorChange.value().asFunctionObject()->newInstance(); - object->SetInternalField(0, v8::Int32::New(change.index)); - object->SetInternalField(1, v8::Int32::New(change.count)); + object->SetInternalField(0, QV4::Value::fromInt32(change.index)); + object->SetInternalField(1, QV4::Value::fromInt32(change.count)); if (change.isMove()) - object->SetInternalField(2, v8::Int32::New(change.moveId)); + object->SetInternalField(2, QV4::Value::fromInt32(change.moveId)); return object; } @@ -3122,7 +3122,7 @@ public: QQmlDelegateModelGroupChangeArray *array = v8_resource_cast(info.This()); V8ASSERT_TYPE(array, "Not a valid change array"); - return v8::Integer::New(array->count()); + return QV4::Value::fromInt32(array->count()); } static v8::Handle constructor() diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index a428029bad..956f591b81 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -92,7 +92,7 @@ static v8::Handle get_index(v8::Handle, const v8::Accesso QQmlDelegateModelItem *data = v8_resource_cast(info.This()); V8ASSERT_TYPE(data, "Not a valid VisualData object"); - return v8::Int32::New(data->index); + return QV4::Value::fromInt32(data->index); } template static void setModelDataType(QMetaObjectBuilder *builder, M *metaType) @@ -233,7 +233,7 @@ public: v8::String::New(propertyName.constData(), propertyName.length()), QQmlDMCachedModelData::get_property, QQmlDMCachedModelData::set_property, - v8::Int32::New(propertyId)); + QV4::Value::fromInt32(propertyId)); } } diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index a0c8c175c5..65a5780013 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -2436,8 +2436,8 @@ v8::Handle ctx2d_imageData_width(v8::Handle, const v8::Ac { QV8Context2DPixelArrayResource *r = v8_resource_cast(args.This()->GetInternalField(0)->ToObject()); if (!r) - return v8::Integer::New(0); - return v8::Integer::New(r->image.width()); + return QV4::Value::fromInt32(0); + return QV4::Value::fromInt32(r->image.width()); } /*! @@ -2448,9 +2448,9 @@ v8::Handle ctx2d_imageData_height(v8::Handle, const v8::A { QV8Context2DPixelArrayResource *r = v8_resource_cast(args.This()->GetInternalField(0)->ToObject()); if (!r) - return v8::Integer::New(0); + return QV4::Value::fromInt32(0); - return v8::Integer::New(r->image.height()); + return QV4::Value::fromInt32(r->image.height()); } /*! @@ -2485,7 +2485,7 @@ v8::Handle ctx2d_pixelArray_length(v8::Handle, const v8:: QV8Context2DPixelArrayResource *r = v8_resource_cast(args.This()); if (!r || r->image.isNull()) return QV4::Value::undefinedValue(); - return v8::Integer::New(r->image.width() * r->image.height() * 4); + return QV4::Value::fromInt32(r->image.width() * r->image.height() * 4); } v8::Handle ctx2d_pixelArray_indexed(uint32_t index, const v8::AccessorInfo& args) @@ -2500,13 +2500,13 @@ v8::Handle ctx2d_pixelArray_indexed(uint32_t index, const v8::Accesso pixel += col; switch (index % 4) { case 0: - return v8::Integer::New(qRed(*pixel)); + return QV4::Value::fromInt32(qRed(*pixel)); case 1: - return v8::Integer::New(qGreen(*pixel)); + return QV4::Value::fromInt32(qGreen(*pixel)); case 2: - return v8::Integer::New(qBlue(*pixel)); + return QV4::Value::fromInt32(qBlue(*pixel)); case 3: - return v8::Integer::New(qAlpha(*pixel)); + return QV4::Value::fromInt32(qAlpha(*pixel)); } } return QV4::Value::undefinedValue(); -- cgit v1.2.3