diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-21 12:33:55 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-21 12:54:18 +0200 |
commit | d8891234812898b1cab406dae9fab9f818bb1efe (patch) | |
tree | 24dfbdd53386ba7c97d4e17fb6c04c4b8c38e56a | |
parent | 15db69e5066a6535532744186e11f3098800f0ba (diff) |
Get rid of v8::Integer
Change-Id: I6b9ab830c4ff3cbf986dbcf7c056648b5a16a222
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 34 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4serialize.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8.cpp | 57 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8_p.h | 41 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv4domerrors_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8include.cpp | 16 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8listwrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8sequencewrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8sequencewrapper_p_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8typewrapper.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8valuetypewrapper.cpp | 2 | ||||
-rw-r--r-- | src/qml/types/qqmldelegatemodel.cpp | 30 | ||||
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 4 | ||||
-rw-r--r-- | 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<v8::Value> 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<v8::Value>(); \ } @@ -78,7 +78,7 @@ #define V8THROW_SQL_VOID(error, desc) \ { \ v8::Handle<v8::Value> 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<v8::Value> qmlsqldatabase_rows_length(v8::Handle<v8::String> / s = 0; } } - return v8::Integer::New(s); + return QV4::Value::fromInt32(s); } static v8::Handle<v8::Value> qmlsqldatabase_rows_forwardOnly(v8::Handle<v8::String> /* 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<v8::Value> QV8IncubatorResource::StatusGetter(v8::Handle<v8::String>, const v8::AccessorInfo& info) { QV8IncubatorResource *r = v8_resource_check<QV8IncubatorResource>(info.This()); - return v8::Integer::NewFromUnsigned(r->status()); + return QV4::Value::fromUInt32(r->status()); } v8::Handle<v8::Value> QV8IncubatorResource::StatusChangedGetter(v8::Handle<v8::String>, 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<QQmlError> *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<v8::Value> Node::nodeType(v8::Handle<v8::String>, const v8::AccessorI { QQmlDOMNodeResource *r = v8_resource_cast<QQmlDOMNodeResource>(args.This()); if (!r) return QV4::Value::undefinedValue(); - return v8::Integer::New(r->d->type); + return QV4::Value::fromInt32(r->d->type); } v8::Handle<v8::Value> Node::parentNode(v8::Handle<v8::String>, const v8::AccessorInfo &args) @@ -618,7 +618,7 @@ v8::Handle<v8::Value> CharacterData::length(v8::Handle<v8::String>, 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<v8::Object> CharacterData::prototype(QV8Engine *engine) @@ -819,7 +819,7 @@ v8::Handle<v8::Value> NamedNodeMap::length(v8::Handle<v8::String>, 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<v8::Value> NamedNodeMap::indexed(uint32_t index, const v8::AccessorInfo& args) @@ -897,7 +897,7 @@ v8::Handle<v8::Value> NodeList::length(v8::Handle<v8::String>, 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<v8::Object> NodeList::prototype(QV8Engine *engine) @@ -1664,7 +1664,7 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_readyState(v8::Handle<v8::String> if (!r) V8THROW_REFERENCE("Not an XMLHttpRequest object"); - return v8::Integer::NewFromUnsigned(r->readyState()); + return QV4::Value::fromUInt32(r->readyState()); } static v8::Handle<v8::Value> qmlxmlhttprequest_status(v8::Handle<v8::String> /* property */, @@ -1679,9 +1679,9 @@ static v8::Handle<v8::Value> qmlxmlhttprequest_status(v8::Handle<v8::String> /* 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<v8::Value> qmlxmlhttprequest_statusText(v8::Handle<v8::String> /* property */, @@ -1783,18 +1783,18 @@ void *qt_add_qmlxmlhttprequest(QV8Engine *engine) xmlhttprequest->PrototypeTemplate()->SetAccessor(v8::String::New("responseXML"),qmlxmlhttprequest_responseXML, 0, v8::Handle<v8::Value>(), 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<v8::Object>(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<Value> resource_name, Handle<Integer> resource_line_offset, Handle<Integer> resource_column_offset) +ScriptOrigin::ScriptOrigin(Handle<Value> 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<Value> ScriptOrigin::ResourceName() const @@ -182,14 +182,14 @@ Handle<Value> ScriptOrigin::ResourceName() const return Value::fromV4Value(QV4::Value::fromString(currentEngine()->current, m_fileName)); } -Handle<Integer> ScriptOrigin::ResourceLineOffset() const +int ScriptOrigin::ResourceLineOffset() const { - return Integer::New(m_lineNumber); + return m_lineNumber; } -Handle<Integer> ScriptOrigin::ResourceColumnOffset() const +int ScriptOrigin::ResourceColumnOffset() const { - return Integer::New(m_columnNumber); + return m_columnNumber; } @@ -470,16 +470,6 @@ Handle<Object> Value::ToObject() const return QV4::Value::fromObject(ConstValuePtr(this)->toObject(currentEngine()->current)); } -Handle<Integer> Value::ToInteger() const -{ - return QV4::Value::fromDouble(ConstValuePtr(this)->toInteger()); -} - -Handle<Int32> 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<Number *>(obj); } -Handle<Integer> Integer::New(int32_t value) -{ - return QV4::Value::fromInt32(value); -} - -Handle<Integer> 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<Integer *>(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<BaseClass> *that = static_cast<const V4V8Object<BaseClass> *>(object); - Handle<Integer> result = that->m_template->m_fallbackPropertyQuery(String::New(string), that->namedAccessorInfo()); + Handle<Value> 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<Value> &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<Value> resource_name, - Handle<Integer> resource_line_offset = Handle<Integer>(), - Handle<Integer> resource_column_offset = Handle<Integer>()); + int resource_line_offset = -1, + int resource_column_offset = -1); Handle<Value> ResourceName() const; - Handle<Integer> ResourceLineOffset() const; - Handle<Integer> 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<Number> ToNumber() const; Handle<String> ToString() const; Handle<Object> ToObject() const; - Handle<Integer> ToInteger() const; - Handle<Int32> 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<Integer> New(int32_t value); - static Handle<Integer> 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<Value> (*NamedPropertySetter)(Handle<String> property, * The result is an integer encoding property attributes (like v8::None, * v8::DontEnum, etc.) */ -typedef Handle<Integer> (*NamedPropertyQuery)(Handle<String> property, +typedef Handle<Value> (*NamedPropertyQuery)(Handle<String> property, const AccessorInfo& info); @@ -1421,7 +1392,7 @@ typedef Handle<Value> (*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<Integer> (*IndexedPropertyQuery)(uint32_t index, +typedef Handle<Value> (*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<v8::Object> 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<v8::Value> 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<v8::Value>(); \ } 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<v8::Script> QV8Engine::qmlModeCompile(const QString &source, v8::Handle<v8::String> v8source = QV4::Value::fromString(m_v4Engine->newString(source)); v8::Handle<v8::String> 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<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(), v8::Script::QmlMode); @@ -451,7 +451,7 @@ v8::Handle<v8::Script> QV8Engine::qmlModeCompile(const char *source, int sourceL v8::Handle<v8::String> v8source = QV4::Value::fromString(m_v4Engine->newString(QString::fromUtf8(source, sourceLength))); v8::Handle<v8::String> 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<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(), v8::Script::QmlMode); @@ -570,11 +570,11 @@ void QV8Engine::initializeGlobal(v8::Handle<v8::Object> 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<v8::Object> QV8Include::resultValue(Status status) { // XXX It seems inefficient to create this object from scratch each time. v8::Handle<v8::Object> 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<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Ok)); + v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(Ok)); } catch (QV4::Exception &e) { e.accept(ctx); - v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(Exception)); + v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(Exception)); v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("exception"), e.value()); } } else { - v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), v8::Integer::New(NetworkError)); + v8::Handle<v8::Object>(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<v8::Value> QV8ListWrapper::LengthGetter(v8::Handle<v8::String> proper quint32 count = resource->property.count?resource->property.count(&resource->property):0; - return v8::Integer::NewFromUnsigned(count); + return QV4::Value::fromUInt32(count); } v8::Handle<v8::Array> 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<v8::Value> valueToHandle(QV8Engine *, int v) -{ return v8::Integer::New(v); } +{ return QV4::Value::fromInt32(v); } static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, uint v) -{ return v8::Integer::NewFromUnsigned(v); } +{ return QV4::Value::fromUInt32(v); } static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *, bool v) { return v8::Boolean::New(v); } static inline v8::Handle<v8::Value> valueToHandle(QV8Engine *e, const QString &v) @@ -819,13 +819,13 @@ v8::Handle<v8::Value> QV8QObjectWrapper::Setter(v8::Handle<v8::String> property, return value; } -v8::Handle<v8::Integer> QV8QObjectWrapper::Query(v8::Handle<v8::String> property, +v8::Handle<v8::Value> QV8QObjectWrapper::Query(v8::Handle<v8::String> property, const v8::AccessorInfo &info) { QV8QObjectResource *resource = v8_resource_check<QV8QObjectResource>(info.This()); if (resource->object.isNull()) - return v8::Handle<v8::Integer>(); + return v8::Handle<v8::Value>(); QV8Engine *engine = resource->engine; QObject *object = resource->object; @@ -838,11 +838,11 @@ v8::Handle<v8::Integer> QV8QObjectWrapper::Query(v8::Handle<v8::String> property result = QQmlPropertyCache::property(engine->engine(), object, propertystring, context, local); if (!result) - return v8::Handle<v8::Integer>(); + return v8::Handle<v8::Value>(); 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<v8::Array> 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<v8::Value> Setter(v8::Handle<v8::String> property, v8::Handle<v8::Value> value, const v8::AccessorInfo &info); - static v8::Handle<v8::Integer> Query(v8::Handle<v8::String> property, + static v8::Handle<v8::Value> Query(v8::Handle<v8::String> property, const v8::AccessorInfo &info); static v8::Handle<v8::Array> 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<v8::Value> QV8SequenceWrapper::LengthGetter(v8::Handle<v8::String> pr Q_UNUSED(property); QV8SequenceResource *sr = v8_resource_cast<QV8SequenceResource>(info.This()); Q_ASSERT(sr); - return v8::Integer::NewFromUnsigned(sr->lengthGetter()); + return QV4::Value::fromUInt32(sr->lengthGetter()); } void QV8SequenceWrapper::LengthSetter(v8::Handle<v8::String> property, v8::Handle<v8::Value> 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<v8::Value> v) static v8::Handle<v8::Value> 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<v8::Array> retn = v8::Array::New(count); \ for (qint32 i = 0; i < count; ++i) { \ - retn->Set(static_cast<quint32>(i), v8::Integer::NewFromUnsigned(static_cast<quint32>(i))); \ + retn->Set(static_cast<quint32>(i), QV4::Value::fromUInt32(static_cast<quint32>(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<v8::Value> QV8TypeWrapper::Getter(v8::Handle<v8::String> 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<v8::Value> QV8TypeWrapper::Getter(v8::Handle<v8::String> 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<v8::Value> QV8ValueTypeWrapper::Getter(v8::Handle<v8::String> 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<T> &changes) for (int i = 0; i < changes.count(); ++i) { v8::Handle<v8::Object> 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<v8::Value> QQmlDelegateModelItemMetaType::get_index( QQmlDelegateModelItem *cacheItem = v8_resource_cast<QQmlDelegateModelItem>(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<v8::Object> 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<QQmlDelegateModelGroupChangeArray>(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<v8::Function> 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<v8::Value> get_index(v8::Handle<v8::String>, const v8::Accesso QQmlDelegateModelItem *data = v8_resource_cast<QQmlDelegateModelItem>(info.This()); V8ASSERT_TYPE(data, "Not a valid VisualData object"); - return v8::Int32::New(data->index); + return QV4::Value::fromInt32(data->index); } template <typename T, typename M> 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<v8::Value> ctx2d_imageData_width(v8::Handle<v8::String>, const v8::Ac { QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(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<v8::Value> ctx2d_imageData_height(v8::Handle<v8::String>, const v8::A { QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(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<v8::Value> ctx2d_pixelArray_length(v8::Handle<v8::String>, const v8:: QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(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<v8::Value> ctx2d_pixelArray_indexed(uint32_t index, const v8::AccessorInfo& args) @@ -2500,13 +2500,13 @@ v8::Handle<v8::Value> 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(); |