aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/compiler/qv4compileddata.cpp2
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4dateobject_p.h11
-rw-r--r--src/qml/jsruntime/qv4engine.cpp18
-rw-r--r--src/qml/jsruntime/qv4engine_p.h10
-rw-r--r--src/qml/jsruntime/qv4managed_p.h2
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp6
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h4
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp4
-rw-r--r--src/qml/qml/qqmllocale.cpp12
-rw-r--r--src/qml/qml/v8/qv8engine.cpp14
11 files changed, 49 insertions, 40 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index d4004ab7f7..74793d69fd 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -95,7 +95,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
flags |= QQmlJS::V4IR::RegExp::RegExp_IgnoreCase;
if (re->flags & CompiledData::RegExp::RegExp_Multiline)
flags |= QQmlJS::V4IR::RegExp::RegExp_Multiline;
- QV4::RegExpObject *obj = engine->newRegExpObject(data->stringAt(re->stringIndex), flags);
+ QV4::RegExpObject *obj = engine->newRegExpObject(data->stringAt(re->stringIndex), flags)->getPointer();
runtimeRegularExpressions[i] = QV4::Value::fromObject(obj);
}
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 26e9a4af0e..7707d188ee 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -634,9 +634,12 @@ static double getLocalTZA()
#endif
}
+DEFINE_MANAGED_VTABLE(DateObject);
+
DateObject::DateObject(ExecutionEngine *engine, const QDateTime &date)
: Object(engine->dateClass)
{
+ vtbl = &static_vtbl;
type = Type_DateObject;
value = Value::fromDouble(date.toMSecsSinceEpoch());
}
@@ -689,8 +692,7 @@ ReturnedValue DateCtor::construct(Managed *m, CallData *callData)
t = TimeClip(UTC(t));
}
- Object *o = m->engine()->newDateObject(Value::fromDouble(t));
- return Value::fromObject(o).asReturnedValue();
+ return Encode(m->engine()->newDateObject(Value::fromDouble(t)));
}
ReturnedValue DateCtor::call(Managed *m, CallData *)
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h
index b0e85606cb..45a9420a41 100644
--- a/src/qml/jsruntime/qv4dateobject_p.h
+++ b/src/qml/jsruntime/qv4dateobject_p.h
@@ -52,14 +52,21 @@ class QDateTime;
namespace QV4 {
struct DateObject: Object {
+ Q_MANAGED
Value value;
- DateObject(ExecutionEngine *engine, const Value &value): Object(engine->dateClass), value(value) { type = Type_DateObject; }
+ DateObject(ExecutionEngine *engine, const Value &value): Object(engine->dateClass), value(value) {
+ vtbl = &static_vtbl;
+ type = Type_DateObject;
+ }
DateObject(ExecutionEngine *engine, const QDateTime &value);
QDateTime toQDateTime() const;
protected:
- DateObject(InternalClass *ic): Object(ic), value(Value::fromDouble(qSNaN())) { type = Type_DateObject; }
+ DateObject(InternalClass *ic): Object(ic), value(Value::fromDouble(qSNaN())) {
+ vtbl = &static_vtbl;
+ type = Type_DateObject;
+ }
};
struct DateCtor: FunctionObject
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 1d3087577d..875ab84cf5 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -418,19 +418,19 @@ ArrayObject *ExecutionEngine::newArrayObject(InternalClass *ic)
}
-DateObject *ExecutionEngine::newDateObject(const Value &value)
+Returned<DateObject> *ExecutionEngine::newDateObject(const Value &value)
{
DateObject *object = new (memoryManager) DateObject(this, value);
- return object;
+ return object->asReturned<DateObject>();
}
-DateObject *ExecutionEngine::newDateObject(const QDateTime &dt)
+Returned<DateObject> *ExecutionEngine::newDateObject(const QDateTime &dt)
{
DateObject *object = new (memoryManager) DateObject(this, dt);
- return object;
+ return object->asReturned<DateObject>();
}
-RegExpObject *ExecutionEngine::newRegExpObject(const QString &pattern, int flags)
+Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QString &pattern, int flags)
{
bool global = (flags & QQmlJS::V4IR::RegExp::RegExp_Global);
bool ignoreCase = false;
@@ -443,16 +443,16 @@ RegExpObject *ExecutionEngine::newRegExpObject(const QString &pattern, int flags
return newRegExpObject(RegExp::create(this, pattern, ignoreCase, multiline), global);
}
-RegExpObject *ExecutionEngine::newRegExpObject(RegExp* re, bool global)
+Returned<RegExpObject> *ExecutionEngine::newRegExpObject(RegExp* re, bool global)
{
RegExpObject *object = new (memoryManager) RegExpObject(this, re, global);
- return object;
+ return object->asReturned<RegExpObject>();
}
-RegExpObject *ExecutionEngine::newRegExpObject(const QRegExp &re)
+Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QRegExp &re)
{
RegExpObject *object = new (memoryManager) RegExpObject(this, re);
- return object;
+ return object->asReturned<RegExpObject>();
}
Object *ExecutionEngine::newErrorObject(const Value &value)
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 4ec4c2dad1..a59a837499 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -278,12 +278,12 @@ struct Q_QML_EXPORT ExecutionEngine
ArrayObject *newArrayObject(const QStringList &list);
ArrayObject *newArrayObject(InternalClass *ic);
- DateObject *newDateObject(const Value &value);
- DateObject *newDateObject(const QDateTime &dt);
+ Returned<DateObject> *newDateObject(const Value &value);
+ Returned<DateObject> *newDateObject(const QDateTime &dt);
- RegExpObject *newRegExpObject(const QString &pattern, int flags);
- RegExpObject *newRegExpObject(RegExp* re, bool global);
- RegExpObject *newRegExpObject(const QRegExp &re);
+ Returned<RegExpObject> *newRegExpObject(const QString &pattern, int flags);
+ Returned<RegExpObject> *newRegExpObject(RegExp* re, bool global);
+ Returned<RegExpObject> *newRegExpObject(const QRegExp &re);
Object *newErrorObject(const Value &value);
Object *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column);
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 097cfde51d..42b6841959 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -68,6 +68,8 @@ struct Returned : private T
T *getPointer() { return this; }
template<typename X>
static T *getPointer(Returned<X> *x) { return x->getPointer(); }
+ template<typename X>
+ Returned<X> *as() { return Returned<X>::create(Returned<X>::getPointer(this)); }
using T::asReturnedValue;
};
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 355108ad23..38ebf8d9e6 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -241,8 +241,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
if (!f->isUndefined())
ctx->throwTypeError();
- RegExpObject *o = ctx->engine->newRegExpObject(re->value, re->global);
- return Value::fromObject(o).asReturnedValue();
+ return Encode(ctx->engine->newRegExpObject(re->value, re->global));
}
QString pattern;
@@ -272,8 +271,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
if (!re->isValid())
ctx->throwSyntaxError(0);
- RegExpObject *o = ctx->engine->newRegExpObject(re, global);
- return Value::fromObject(o).asReturnedValue();
+ return Encode(ctx->engine->newRegExpObject(re, global));
}
ReturnedValue RegExpCtor::call(Managed *that, CallData *callData)
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index e192cf5477..eed49bfe1f 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -380,7 +380,7 @@ private:
};
template<typename T>
-Scoped<T>::Scoped(const Scope &scope, const ValueRef &v)
+inline Scoped<T>::Scoped(const Scope &scope, const ValueRef &v)
{
ptr = scope.engine->jsStackTop++;
if (T::cast(*v.operator ->()))
@@ -393,7 +393,7 @@ Scoped<T>::Scoped(const Scope &scope, const ValueRef &v)
}
template<typename T>
-Scoped<T> &Scoped<T>::operator=(const ValueRef &v)
+inline Scoped<T> &Scoped<T>::operator=(const ValueRef &v)
{
if (T::cast(*v.operator ->()))
*ptr = *v.operator ->();
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index b1bdec10df..f76f76b6d2 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -345,14 +345,14 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine)
case WorkerNumber:
return QV4::Encode(popDouble(data));
case WorkerDate:
- return QV4::Value::fromObject(v4->newDateObject(QV4::Value::fromDouble(popDouble(data)))).asReturnedValue();
+ return QV4::Encode(v4->newDateObject(QV4::Value::fromDouble(popDouble(data))));
case WorkerRegexp:
{
quint32 flags = headersize(header);
quint32 length = popUint32(data);
QString pattern = QString((QChar *)data, length - 1);
data += ALIGN(length * sizeof(uint16_t));
- return QV4::Value::fromObject(v4->newRegExpObject(pattern, flags)).asReturnedValue();
+ return Encode(v4->newRegExpObject(pattern, flags));
}
case WorkerListModel:
{
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 38ffc5386d..5dcc807ab0 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -270,7 +270,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallCon
QLocale locale;
QString dateString = ctx->arguments[0].stringValue()->toQString();
QDateTime dt = locale.toDateTime(dateString);
- return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(dt));
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -296,7 +296,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallCon
dt = r->locale.toDateTime(dateString, enumFormat);
}
- return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(dt));
}
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCallContext *ctx)
@@ -309,7 +309,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCal
QTime time = locale.toTime(timeString);
QDateTime dt = QDateTime::currentDateTime();
dt.setTime(time);
- return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(dt));
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -338,7 +338,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCal
QDateTime dt = QDateTime::currentDateTime();
dt.setTime(tm);
- return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(dt));
}
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCallContext *ctx)
@@ -349,7 +349,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCal
QLocale locale;
QString dateString = ctx->arguments[0].stringValue()->toQString();
QDate date = locale.toDate(dateString);
- return QV4::Value::fromObject(engine->newDateObject(QDateTime(date))).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(QDateTime(date)));
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -375,7 +375,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCal
dt = r->locale.toDate(dateString, enumFormat);
}
- return QV4::Value::fromObject(engine->newDateObject(QDateTime(dt))).asReturnedValue();
+ return QV4::Encode(engine->newDateObject(QDateTime(dt)));
}
QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::SimpleCallContext *ctx)
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index 63ab33a457..a84de5798c 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -255,13 +255,13 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant)
case QMetaType::QChar:
return QV4::Encode((int)(*reinterpret_cast<const QChar*>(ptr)).unicode());
case QMetaType::QDateTime:
- return QV4::Value::fromObject(m_v4Engine->newDateObject(*reinterpret_cast<const QDateTime *>(ptr))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newDateObject(*reinterpret_cast<const QDateTime *>(ptr)));
case QMetaType::QDate:
- return QV4::Value::fromObject(m_v4Engine->newDateObject(QDateTime(*reinterpret_cast<const QDate *>(ptr)))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newDateObject(QDateTime(*reinterpret_cast<const QDate *>(ptr))));
case QMetaType::QTime:
- return QV4::Value::fromObject(m_v4Engine->newDateObject(QDateTime(QDate(1970,1,1), *reinterpret_cast<const QTime *>(ptr)))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newDateObject(QDateTime(QDate(1970,1,1), *reinterpret_cast<const QTime *>(ptr))));
case QMetaType::QRegExp:
- return QV4::Value::fromObject(m_v4Engine->newRegExpObject(*reinterpret_cast<const QRegExp *>(ptr))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newRegExpObject(*reinterpret_cast<const QRegExp *>(ptr)));
case QMetaType::QObjectStar:
return QV4::QObjectWrapper::wrap(m_v4Engine, *reinterpret_cast<QObject* const *>(ptr));
case QMetaType::QStringList:
@@ -661,11 +661,11 @@ QV4::ReturnedValue QV8Engine::metaTypeToJS(int type, const void *data)
case QMetaType::QVariantMap:
return variantMapToJS(*reinterpret_cast<const QVariantMap *>(data));
case QMetaType::QDateTime:
- return QV4::Value::fromObject(m_v4Engine->newDateObject(*reinterpret_cast<const QDateTime *>(data))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newDateObject(*reinterpret_cast<const QDateTime *>(data)));
case QMetaType::QDate:
- return QV4::Value::fromObject(m_v4Engine->newDateObject(QDateTime(*reinterpret_cast<const QDate *>(data)))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newDateObject(QDateTime(*reinterpret_cast<const QDate *>(data))));
case QMetaType::QRegExp:
- return QV4::Value::fromObject(m_v4Engine->newRegExpObject(*reinterpret_cast<const QRegExp *>(data))).asReturnedValue();
+ return QV4::Encode(m_v4Engine->newRegExpObject(*reinterpret_cast<const QRegExp *>(data)));
case QMetaType::QObjectStar:
return QV4::QObjectWrapper::wrap(m_v4Engine, *reinterpret_cast<QObject* const *>(data));
case QMetaType::QVariant: