aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-12 11:13:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 13:13:47 +0200
commit16f92ad85cf665d863ded5eeaaa7fc3f90820b3f (patch)
tree74b3477b9d6c023730835f1c478ceb6eaec68a2b /src/qml/qml
parent7d4e61dd824706984030c58684fa844ff9cde251 (diff)
Convert builtin methods to return a ReturnedValue
Change-Id: I6b75adbf53a5be0deab023d2eed98ce2a7915551 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp30
-rw-r--r--src/qml/qml/qqmllocale.cpp178
-rw-r--r--src/qml/qml/qqmllocale_p.h22
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp293
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp260
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h106
8 files changed, 460 insertions, 439 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 8cea3b6a69..9fbfa33a16 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1093,11 +1093,11 @@ class QmlIncubatorObject : public QV4::Object, public QQmlIncubator
public:
QmlIncubatorObject(QV8Engine *engine, IncubationMode = Asynchronous);
- static QV4::Value method_get_statusChanged(QV4::SimpleCallContext *ctx);
- static QV4::Value method_set_statusChanged(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_status(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_object(QV4::SimpleCallContext *ctx);
- static QV4::Value method_forceCompletion(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_statusChanged(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_set_statusChanged(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_status(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_object(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_forceCompletion(QV4::SimpleCallContext *ctx);
static void destroy(Managed *that);
static void markObjects(Managed *that);
@@ -1405,16 +1405,16 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
incubationProto = QV4::Value::fromObject(proto);
}
-QV4::Value QmlIncubatorObject::method_get_object(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::SimpleCallContext *ctx)
{
QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>();
if (!o)
ctx->throwTypeError();
- return QV4::QObjectWrapper::wrap(ctx->engine, o->object());
+ return QV4::QObjectWrapper::wrap(ctx->engine, o->object()).asReturnedValue();
}
-QV4::Value QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallContext *ctx)
{
QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>();
if (!o)
@@ -1422,35 +1422,35 @@ QV4::Value QmlIncubatorObject::method_forceCompletion(QV4::SimpleCallContext *ct
o->forceCompletion();
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value QmlIncubatorObject::method_get_status(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::SimpleCallContext *ctx)
{
QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>();
if (!o)
ctx->throwTypeError();
- return QV4::Value::fromUInt32(o->status());
+ return QV4::Encode(o->status());
}
-QV4::Value QmlIncubatorObject::method_get_statusChanged(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::SimpleCallContext *ctx)
{
QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>();
if (!o)
ctx->throwTypeError();
- return o->m_statusChanged;
+ return o->m_statusChanged.asReturnedValue();
}
-QV4::Value QmlIncubatorObject::method_set_statusChanged(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::SimpleCallContext *ctx)
{
QmlIncubatorObject *o = ctx->thisObject.as<QmlIncubatorObject>();
if (!o || ctx->argumentCount < 1)
ctx->throwTypeError();
o->m_statusChanged = ctx->arguments[0];
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
QQmlComponentExtension::~QQmlComponentExtension()
diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp
index 4cdcb96857..27c8dff598 100644
--- a/src/qml/qml/qqmllocale.cpp
+++ b/src/qml/qml/qqmllocale.cpp
@@ -74,33 +74,33 @@ public:
return thisObject->locale;
}
- static QV4::Value method_currencySymbol(QV4::SimpleCallContext *ctx);
- static QV4::Value method_dateTimeFormat(QV4::SimpleCallContext *ctx);
- static QV4::Value method_timeFormat(QV4::SimpleCallContext *ctx);
- static QV4::Value method_dateFormat(QV4::SimpleCallContext *ctx);
- static QV4::Value method_monthName(QV4::SimpleCallContext *ctx);
- static QV4::Value method_standaloneMonthName(QV4::SimpleCallContext *ctx);
- static QV4::Value method_dayName(QV4::SimpleCallContext *ctx);
- static QV4::Value method_standaloneDayName(QV4::SimpleCallContext *ctx);
-
- static QV4::Value method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_measurementSystem(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_textDirection(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_weekDays(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_uiLanguages(QV4::SimpleCallContext *ctx);
-
- static QV4::Value method_get_name(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_nativeLanguageName(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_nativeCountryName(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_decimalPoint(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_groupSeparator(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_percent(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_zeroDigit(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_negativeSign(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_positiveSign(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_exponential(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_amText(QV4::SimpleCallContext *ctx);
- static QV4::Value method_get_pmText(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_currencySymbol(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_dateTimeFormat(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_timeFormat(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_dateFormat(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_monthName(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_standaloneMonthName(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_dayName(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_standaloneDayName(QV4::SimpleCallContext *ctx);
+
+ static QV4::ReturnedValue method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_measurementSystem(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_textDirection(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_weekDays(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_uiLanguages(QV4::SimpleCallContext *ctx);
+
+ static QV4::ReturnedValue method_get_name(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_nativeLanguageName(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_nativeCountryName(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_decimalPoint(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_groupSeparator(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_percent(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_zeroDigit(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_negativeSign(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_positiveSign(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_exponential(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_amText(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_get_pmText(QV4::SimpleCallContext *ctx);
private:
static void destroy(Managed *that)
@@ -126,16 +126,16 @@ static bool isLocaleObject(const QV4::Value &val)
void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine)
{
- engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString);
- engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleTimeString"), toLocaleTimeString);
- engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleDateString"), toLocaleDateString);
- engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), fromLocaleString);
- engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleTimeString"), fromLocaleTimeString);
- engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleDateString"), fromLocaleDateString);
- engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("timeZoneUpdated"), timeZoneUpdated);
+ engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), method_toLocaleString);
+ engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString);
+ engine->dateClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleDateString"), method_toLocaleDateString);
+ engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), method_fromLocaleString);
+ engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleTimeString"), method_fromLocaleTimeString);
+ engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleDateString"), method_fromLocaleDateString);
+ engine->dateCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("timeZoneUpdated"), method_timeZoneUpdated);
}
-QV4::Value QQmlDateExtension::toLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount > 2)
return QV4::DatePrototype::method_toLocaleString(ctx);
@@ -149,7 +149,7 @@ QV4::Value QQmlDateExtension::toLocaleString(QV4::SimpleCallContext *ctx)
if (ctx->argumentCount == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return QV4::Value::fromString(ctx, locale.toString(dt));
+ return QV4::Value::fromString(ctx, locale.toString(dt)).asReturnedValue();
}
if (!isLocaleObject(ctx->arguments[0]))
@@ -174,10 +174,10 @@ QV4::Value QQmlDateExtension::toLocaleString(QV4::SimpleCallContext *ctx)
formattedDt = r->locale.toString(dt, enumFormat);
}
- return QV4::Value::fromString(ctx, formattedDt);
+ return QV4::Value::fromString(ctx, formattedDt).asReturnedValue();
}
-QV4::Value QQmlDateExtension::toLocaleTimeString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount > 2)
return QV4::DatePrototype::method_toLocaleTimeString(ctx);
@@ -192,7 +192,7 @@ QV4::Value QQmlDateExtension::toLocaleTimeString(QV4::SimpleCallContext *ctx)
if (ctx->argumentCount == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return QV4::Value::fromString(ctx, locale.toString(time));
+ return QV4::Value::fromString(ctx, locale.toString(time)).asReturnedValue();
}
if (!isLocaleObject(ctx->arguments[0]))
@@ -217,10 +217,10 @@ QV4::Value QQmlDateExtension::toLocaleTimeString(QV4::SimpleCallContext *ctx)
formattedTime = r->locale.toString(time, enumFormat);
}
- return QV4::Value::fromString(ctx, formattedTime);
+ return QV4::Value::fromString(ctx, formattedTime).asReturnedValue();
}
-QV4::Value QQmlDateExtension::toLocaleDateString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount > 2)
return QV4::DatePrototype::method_toLocaleDateString(ctx);
@@ -235,7 +235,7 @@ QV4::Value QQmlDateExtension::toLocaleDateString(QV4::SimpleCallContext *ctx)
if (ctx->argumentCount == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return QV4::Value::fromString(ctx, locale.toString(date));
+ return QV4::Value::fromString(ctx, locale.toString(date)).asReturnedValue();
}
if (!isLocaleObject(ctx->arguments[0]))
@@ -260,17 +260,17 @@ QV4::Value QQmlDateExtension::toLocaleDateString(QV4::SimpleCallContext *ctx)
formattedDate = r->locale.toString(date, enumFormat);
}
- return QV4::Value::fromString(ctx, formattedDate);
+ return QV4::Value::fromString(ctx, formattedDate).asReturnedValue();
}
-QV4::Value QQmlDateExtension::fromLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
if (ctx->argumentCount == 1 && ctx->arguments[0].isString()) {
QLocale locale;
QString dateString = ctx->arguments[0].stringValue()->toQString();
QDateTime dt = locale.toDateTime(dateString);
- return QV4::Value::fromObject(engine->newDateObject(dt));
+ return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -296,10 +296,10 @@ QV4::Value QQmlDateExtension::fromLocaleString(QV4::SimpleCallContext *ctx)
dt = r->locale.toDateTime(dateString, enumFormat);
}
- return QV4::Value::fromObject(engine->newDateObject(dt));
+ return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
}
-QV4::Value QQmlDateExtension::fromLocaleTimeString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::SimpleCallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
@@ -309,7 +309,7 @@ QV4::Value QQmlDateExtension::fromLocaleTimeString(QV4::SimpleCallContext *ctx)
QTime time = locale.toTime(timeString);
QDateTime dt = QDateTime::currentDateTime();
dt.setTime(time);
- return QV4::Value::fromObject(engine->newDateObject(dt));
+ return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -338,10 +338,10 @@ QV4::Value QQmlDateExtension::fromLocaleTimeString(QV4::SimpleCallContext *ctx)
QDateTime dt = QDateTime::currentDateTime();
dt.setTime(tm);
- return QV4::Value::fromObject(engine->newDateObject(dt));
+ return QV4::Value::fromObject(engine->newDateObject(dt)).asReturnedValue();
}
-QV4::Value QQmlDateExtension::fromLocaleDateString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::SimpleCallContext *ctx)
{
QV4::ExecutionEngine * const engine = ctx->engine;
@@ -349,7 +349,7 @@ QV4::Value QQmlDateExtension::fromLocaleDateString(QV4::SimpleCallContext *ctx)
QLocale locale;
QString dateString = ctx->arguments[0].stringValue()->toQString();
QDate date = locale.toDate(dateString);
- return QV4::Value::fromObject(engine->newDateObject(QDateTime(date)));
+ return QV4::Value::fromObject(engine->newDateObject(QDateTime(date))).asReturnedValue();
}
if (ctx->argumentCount < 1 || ctx->argumentCount > 3 || !isLocaleObject(ctx->arguments[0]))
@@ -375,17 +375,17 @@ QV4::Value QQmlDateExtension::fromLocaleDateString(QV4::SimpleCallContext *ctx)
dt = r->locale.toDate(dateString, enumFormat);
}
- return QV4::Value::fromObject(engine->newDateObject(QDateTime(dt)));
+ return QV4::Value::fromObject(engine->newDateObject(QDateTime(dt))).asReturnedValue();
}
-QV4::Value QQmlDateExtension::timeZoneUpdated(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 0)
V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments");
QV4::DatePrototype::timezoneUpdated();
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
//-----------------
@@ -393,12 +393,12 @@ QV4::Value QQmlDateExtension::timeZoneUpdated(QV4::SimpleCallContext *ctx)
void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine)
{
- engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), toLocaleString);
- engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleCurrencyString"), toLocaleCurrencyString);
- engine->numberCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), fromLocaleString);
+ engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleString"), method_toLocaleString);
+ engine->numberClass->prototype->defineDefaultProperty(engine, QStringLiteral("toLocaleCurrencyString"), method_toLocaleCurrencyString);
+ engine->numberCtor.objectValue()->defineDefaultProperty(engine, QStringLiteral("fromLocaleString"), method_fromLocaleString);
}
-QV4::Value QQmlNumberExtension::toLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount > 3)
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
@@ -408,7 +408,7 @@ QV4::Value QQmlNumberExtension::toLocaleString(QV4::SimpleCallContext *ctx)
if (ctx->argumentCount == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return QV4::Value::fromString(ctx, locale.toString(number));
+ return QV4::Value::fromString(ctx, locale.toString(number)).asReturnedValue();
}
if (!isLocaleObject(ctx->arguments[0]))
@@ -431,10 +431,10 @@ QV4::Value QQmlNumberExtension::toLocaleString(QV4::SimpleCallContext *ctx)
prec = ctx->arguments[2].toInt32();
}
- return QV4::Value::fromString(ctx, r->locale.toString(number, (char)format, prec));
+ return QV4::Value::fromString(ctx, r->locale.toString(number, (char)format, prec)).asReturnedValue();
}
-QV4::Value QQmlNumberExtension::toLocaleCurrencyString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount > 2)
V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
@@ -444,7 +444,7 @@ QV4::Value QQmlNumberExtension::toLocaleCurrencyString(QV4::SimpleCallContext *c
if (ctx->argumentCount == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return QV4::Value::fromString(ctx, locale.toString(number));
+ return QV4::Value::fromString(ctx, locale.toString(number)).asReturnedValue();
}
if (!isLocaleObject(ctx->arguments[0]))
@@ -459,10 +459,10 @@ QV4::Value QQmlNumberExtension::toLocaleCurrencyString(QV4::SimpleCallContext *c
symbol = ctx->arguments[1].toQStringNoThrow();
}
- return QV4::Value::fromString(ctx, r->locale.toCurrencyString(number, symbol));
+ return QV4::Value::fromString(ctx, r->locale.toCurrencyString(number, symbol)).asReturnedValue();
}
-QV4::Value QQmlNumberExtension::fromLocaleString(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1 || ctx->argumentCount > 2)
V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
@@ -482,7 +482,7 @@ QV4::Value QQmlNumberExtension::fromLocaleString(QV4::SimpleCallContext *ctx)
QV4::String *ns = ctx->arguments[numberIdx].toString(ctx);
if (ns->isEmpty())
- return QV4::Value::fromDouble(Q_QNAN);
+ return QV4::Encode(Q_QNAN);
bool ok = false;
double val = locale.toDouble(ns->toQString(), &ok);
@@ -490,34 +490,34 @@ QV4::Value QQmlNumberExtension::fromLocaleString(QV4::SimpleCallContext *ctx)
if (!ok)
V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid format")
- return QV4::Value::fromDouble(val);
+ return QV4::Encode(val);
}
//--------------
// Locale object
-QV4::Value QQmlLocaleData::method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_firstDayOfWeek(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
int fdow = int(locale.firstDayOfWeek());
if (fdow == 7)
fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date
- return QV4::Value::fromInt32(fdow);
+ return QV4::Encode(fdow);
}
-QV4::Value QQmlLocaleData::method_get_measurementSystem(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_measurementSystem(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
- return QV4::Value::fromInt32(locale.measurementSystem());
+ return QV4::Encode(locale.measurementSystem());
}
-QV4::Value QQmlLocaleData::method_get_textDirection(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_textDirection(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
- return QV4::Value::fromInt32(locale.textDirection());
+ return QV4::Encode(locale.textDirection());
}
-QV4::Value QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
QList<Qt::DayOfWeek> days = locale.weekdays();
@@ -533,10 +533,10 @@ QV4::Value QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *ctx)
}
result->setArrayLengthUnchecked(days.size());
- return QV4::Value::fromObject(result);
+ return QV4::Value::fromObject(result).asReturnedValue();
}
-QV4::Value QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
QStringList langs = locale.uiLanguages();
@@ -547,10 +547,10 @@ QV4::Value QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext *ctx)
result->arrayData[i].value = QV4::Value::fromString(ctx, langs.at(i));
result->setArrayLengthUnchecked(langs.size());
- return QV4::Value::fromObject(result);
+ return QV4::Value::fromObject(result).asReturnedValue();
}
-QV4::Value QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext *ctx)
{
QLocale locale = getThisLocale(ctx);
if (ctx->argumentCount > 1)
@@ -562,11 +562,11 @@ QV4::Value QQmlLocaleData::method_currencySymbol(QV4::SimpleCallContext *ctx)
format = QLocale::CurrencySymbolFormat(intFormat);
}
- return QV4::Value::fromString(ctx, locale.currencySymbol(format));
+ return QV4::Value::fromString(ctx, locale.currencySymbol(format)).asReturnedValue();
}
#define LOCALE_FORMAT(FUNC) \
-QV4::Value QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx) { \
+QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx) { \
QLocale locale = getThisLocale(ctx); \
if (ctx->argumentCount > 1) \
V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
@@ -575,7 +575,7 @@ QV4::Value QQmlLocaleData::method_ ##FUNC (QV4::SimpleCallContext *ctx) { \
quint32 intFormat = ctx->arguments[0].toUInt32(); \
format = QLocale::FormatType(intFormat); \
} \
- return QV4::Value::fromString(ctx, locale. FUNC (format)); \
+ return QV4::Value::fromString(ctx, locale. FUNC (format)).asReturnedValue(); \
}
LOCALE_FORMAT(dateTimeFormat)
@@ -584,7 +584,7 @@ LOCALE_FORMAT(dateFormat)
// +1 added to idx because JS is 0-based, whereas QLocale months begin at 1.
#define LOCALE_FORMATTED_MONTHNAME(VARIABLE) \
-QV4::Value QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
+QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
QLocale locale = getThisLocale(ctx); \
if (ctx->argumentCount < 1 || ctx->argumentCount > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
@@ -604,12 +604,12 @@ QV4::Value QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
} else { \
name = locale. VARIABLE(idx, enumFormat); \
} \
- return QV4::Value::fromString(ctx, name); \
+ return QV4::Value::fromString(ctx, name).asReturnedValue(); \
}
// 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date
#define LOCALE_FORMATTED_DAYNAME(VARIABLE) \
-QV4::Value QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
+QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
QLocale locale = getThisLocale(ctx); \
if (ctx->argumentCount < 1 || ctx->argumentCount > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
@@ -630,7 +630,7 @@ QV4::Value QQmlLocaleData::method_ ## VARIABLE (QV4::SimpleCallContext *ctx) {\
} else { \
name = locale. VARIABLE(idx, enumFormat); \
} \
- return QV4::Value::fromString(ctx, name); \
+ return QV4::Value::fromString(ctx, name).asReturnedValue(); \
}
LOCALE_FORMATTED_MONTHNAME(monthName)
@@ -638,10 +638,10 @@ LOCALE_FORMATTED_MONTHNAME(standaloneMonthName)
LOCALE_FORMATTED_DAYNAME(dayName)
LOCALE_FORMATTED_DAYNAME(standaloneDayName)
-#define LOCALE_STRING_PROPERTY(VARIABLE) QV4::Value QQmlLocaleData::method_get_ ## VARIABLE (QV4::SimpleCallContext* ctx) \
+#define LOCALE_STRING_PROPERTY(VARIABLE) QV4::ReturnedValue QQmlLocaleData::method_get_ ## VARIABLE (QV4::SimpleCallContext* ctx) \
{ \
QLocale locale = getThisLocale(ctx); \
- return QV4::Value::fromString(ctx, locale. VARIABLE());\
+ return QV4::Value::fromString(ctx, locale. VARIABLE()).asReturnedValue();\
}
LOCALE_STRING_PROPERTY(name)
@@ -820,10 +820,10 @@ QV4::Value QQmlLocale::locale(QV8Engine *v8engine, const QString &locale)
void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine)
{
- engine->stringClass->prototype->defineDefaultProperty(engine, QStringLiteral("localeCompare"), localeCompare);
+ engine->stringClass->prototype->defineDefaultProperty(engine, QStringLiteral("localeCompare"), method_localeCompare);
}
-QV4::Value QQmlLocale::localeCompare(QV4::SimpleCallContext *ctx)
+QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1 || (!ctx->arguments[0].isString() && !ctx->arguments[0].asStringObject()))
return QV4::StringPrototype::method_localeCompare(ctx);
@@ -834,7 +834,7 @@ QV4::Value QQmlLocale::localeCompare(QV4::SimpleCallContext *ctx)
QString thisString = ctx->thisObject.toQStringNoThrow();
QString thatString = ctx->arguments[0].toQStringNoThrow();
- return QV4::Value::fromInt32(QString::localeAwareCompare(thisString, thatString));
+ return QV4::Encode(QString::localeAwareCompare(thisString, thatString));
}
/*!
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 3bc8b6096e..5088693269 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -58,13 +58,13 @@ public:
static void registerExtension(QV4::ExecutionEngine *engine);
private:
- static QV4::Value toLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::Value toLocaleTimeString(QV4::SimpleCallContext *ctx);
- static QV4::Value toLocaleDateString(QV4::SimpleCallContext *ctx);
- static QV4::Value fromLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::Value fromLocaleTimeString(QV4::SimpleCallContext *ctx);
- static QV4::Value fromLocaleDateString(QV4::SimpleCallContext *ctx);
- static QV4::Value timeZoneUpdated(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleTimeString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleDateString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleTimeString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleDateString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_timeZoneUpdated(QV4::SimpleCallContext *ctx);
};
@@ -74,9 +74,9 @@ public:
static void registerExtension(QV4::ExecutionEngine *engine);
private:
- static QV4::Value toLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::Value fromLocaleString(QV4::SimpleCallContext *ctx);
- static QV4::Value toLocaleCurrencyString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_fromLocaleString(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toLocaleCurrencyString(QV4::SimpleCallContext *ctx);
};
@@ -125,7 +125,7 @@ public:
private:
QQmlLocale();
- static QV4::Value localeCompare(QV4::SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_localeCompare(QV4::SimpleCallContext *ctx);
};
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 98b2497b0d..d9ee928858 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -239,7 +239,7 @@ bool QmlValueTypeWrapper::isEqual(const QVariant& value)
}
}
-Value QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
+ReturnedValue QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
{
Object *o = ctx->thisObject.asObject();
if (!o)
@@ -251,15 +251,15 @@ Value QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
if (w->objectType == QmlValueTypeWrapper::Reference) {
QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(w);
if (reference->object && readReferenceValue(reference)) {
- return w->v8->toString(w->type->toString());
+ return w->v8->toString(w->type->toString()).asReturnedValue();
} else {
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
} else {
Q_ASSERT(w->objectType == QmlValueTypeWrapper::Copy);
QmlValueTypeCopy *copy = static_cast<QmlValueTypeCopy *>(w);
w->type->setValue(copy->value);
- return w->v8->toString(w->type->toString());
+ return w->v8->toString(w->type->toString()).asReturnedValue();
}
}
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index aa9de3330e..2483b8e26b 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -89,7 +89,7 @@ public:
static bool isEqualTo(Managed *m, Managed *other);
static PropertyAttributes query(const Managed *, String *name);
- static QV4::Value method_toString(SimpleCallContext *ctx);
+ static QV4::ReturnedValue method_toString(SimpleCallContext *ctx);
QV8Engine *v8;
ObjectType objectType;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 85ae7fbe6c..651a2703f3 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -270,17 +270,17 @@ public:
static void initClass(ExecutionEngine *engine);
// JS API
- static Value method_get_nodeName(SimpleCallContext *ctx);
- static Value method_get_nodeValue(SimpleCallContext *ctx);
- static Value method_get_nodeType(SimpleCallContext *ctx);
-
- static Value method_get_parentNode(SimpleCallContext *ctx);
- static Value method_get_childNodes(SimpleCallContext *ctx);
- static Value method_get_firstChild(SimpleCallContext *ctx);
- static Value method_get_lastChild(SimpleCallContext *ctx);
- static Value method_get_previousSibling(SimpleCallContext *ctx);
- static Value method_get_nextSibling(SimpleCallContext *ctx);
- static Value method_get_attributes(SimpleCallContext *ctx);
+ static ReturnedValue method_get_nodeName(SimpleCallContext *ctx);
+ static ReturnedValue method_get_nodeValue(SimpleCallContext *ctx);
+ static ReturnedValue method_get_nodeType(SimpleCallContext *ctx);
+
+ static ReturnedValue method_get_parentNode(SimpleCallContext *ctx);
+ static ReturnedValue method_get_childNodes(SimpleCallContext *ctx);
+ static ReturnedValue method_get_firstChild(SimpleCallContext *ctx);
+ static ReturnedValue method_get_lastChild(SimpleCallContext *ctx);
+ static ReturnedValue method_get_previousSibling(SimpleCallContext *ctx);
+ static ReturnedValue method_get_nextSibling(SimpleCallContext *ctx);
+ static ReturnedValue method_get_attributes(SimpleCallContext *ctx);
//static Value ownerDocument(SimpleCallContext *ctx);
//static Value namespaceURI(SimpleCallContext *ctx);
@@ -343,10 +343,10 @@ class Attr : public Node
{
public:
// JS API
- static Value name(SimpleCallContext *ctx);
+ static ReturnedValue method_name(SimpleCallContext *ctx);
// static Value specified(SimpleCallContext *);
- static Value value(SimpleCallContext *ctx);
- static Value ownerElement(SimpleCallContext *ctx);
+ static ReturnedValue method_value(SimpleCallContext *ctx);
+ static ReturnedValue method_ownerElement(SimpleCallContext *ctx);
// static Value schemaTypeInfo(SimpleCallContext *);
// static Value isId(SimpleCallContext *c);
@@ -358,7 +358,7 @@ class CharacterData : public Node
{
public:
// JS API
- static Value length(SimpleCallContext *ctx);
+ static ReturnedValue method_length(SimpleCallContext *ctx);
// C++ API
static Value prototype(ExecutionEngine *v4);
@@ -368,8 +368,8 @@ class Text : public CharacterData
{
public:
// JS API
- static Value isElementContentWhitespace(SimpleCallContext *ctx);
- static Value wholeText(SimpleCallContext *ctx);
+ static ReturnedValue method_isElementContentWhitespace(SimpleCallContext *ctx);
+ static ReturnedValue method_wholeText(SimpleCallContext *ctx);
// C++ API
static Value prototype(ExecutionEngine *);
@@ -386,14 +386,14 @@ class Document : public Node
{
public:
// JS API
- static Value xmlVersion(SimpleCallContext *ctx);
- static Value xmlEncoding(SimpleCallContext *ctx);
- static Value xmlStandalone(SimpleCallContext *ctx);
- static Value documentElement(SimpleCallContext *ctx);
+ static ReturnedValue method_xmlVersion(SimpleCallContext *ctx);
+ static ReturnedValue method_xmlEncoding(SimpleCallContext *ctx);
+ static ReturnedValue method_xmlStandalone(SimpleCallContext *ctx);
+ static ReturnedValue method_documentElement(SimpleCallContext *ctx);
// C++ API
static Value prototype(ExecutionEngine *);
- static Value load(QV8Engine *engine, const QByteArray &data);
+ static ReturnedValue load(QV8Engine *engine, const QByteArray &data);
};
}
@@ -408,7 +408,7 @@ void NodeImpl::release()
document->release();
}
-Value NodePrototype::method_get_nodeName(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeName(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -429,10 +429,10 @@ Value NodePrototype::method_get_nodeName(SimpleCallContext *ctx)
name = r->d->name;
break;
}
- return Value::fromString(ctx->engine->newString(name));
+ return Value::fromString(ctx->engine->newString(name)).asReturnedValue();
}
-Value NodePrototype::method_get_nodeValue(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeValue(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -445,21 +445,21 @@ Value NodePrototype::method_get_nodeValue(SimpleCallContext *ctx)
r->d->type == NodeImpl::Entity ||
r->d->type == NodeImpl::EntityReference ||
r->d->type == NodeImpl::Notation)
- return Value::nullValue();
+ return Encode::null();
- return Value::fromString(ctx->engine->newString(r->d->data));
+ return Value::fromString(ctx->engine->newString(r->d->data)).asReturnedValue();
}
-Value NodePrototype::method_get_nodeType(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nodeType(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
ctx->throwTypeError();
- return Value::fromInt32(r->d->type);
+ return Encode(r->d->type);
}
-Value NodePrototype::method_get_parentNode(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -467,11 +467,13 @@ Value NodePrototype::method_get_parentNode(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- if (r->d->parent) return Node::create(engine, r->d->parent);
- else return Value::nullValue();
+ if (r->d->parent)
+ return Node::create(engine, r->d->parent).asReturnedValue();
+ else
+ return Encode::null();
}
-Value NodePrototype::method_get_childNodes(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_childNodes(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -479,10 +481,10 @@ Value NodePrototype::method_get_childNodes(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- return NodeList::create(engine, r->d);
+ return NodeList::create(engine, r->d).asReturnedValue();
}
-Value NodePrototype::method_get_firstChild(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -490,11 +492,13 @@ Value NodePrototype::method_get_firstChild(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- if (r->d->children.isEmpty()) return Value::nullValue();
- else return Node::create(engine, r->d->children.first());
+ if (r->d->children.isEmpty())
+ return Encode::null();
+ else
+ return Node::create(engine, r->d->children.first()).asReturnedValue();
}
-Value NodePrototype::method_get_lastChild(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -502,11 +506,13 @@ Value NodePrototype::method_get_lastChild(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- if (r->d->children.isEmpty()) return Value::nullValue();
- else return Node::create(engine, r->d->children.last());
+ if (r->d->children.isEmpty())
+ return Encode::null();
+ else
+ return Node::create(engine, r->d->children.last()).asReturnedValue();
}
-Value NodePrototype::method_get_previousSibling(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -514,19 +520,22 @@ Value NodePrototype::method_get_previousSibling(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- if (!r->d->parent) return Value::nullValue();
+ if (!r->d->parent)
+ return Encode::null();
for (int ii = 0; ii < r->d->parent->children.count(); ++ii) {
if (r->d->parent->children.at(ii) == r->d) {
- if (ii == 0) return Value::nullValue();
- else return Node::create(engine, r->d->parent->children.at(ii - 1));
+ if (ii == 0)
+ return Encode::null();
+ else
+ return Node::create(engine, r->d->parent->children.at(ii - 1)).asReturnedValue();
}
}
- return Value::nullValue();
+ return Encode::null();
}
-Value NodePrototype::method_get_nextSibling(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -534,19 +543,22 @@ Value NodePrototype::method_get_nextSibling(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
- if (!r->d->parent) return Value::nullValue();
+ if (!r->d->parent)
+ return Encode::null();
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 Value::nullValue();
- else return Node::create(engine, r->d->parent->children.at(ii + 1));
+ if ((ii + 1) == r->d->parent->children.count())
+ return Encode::null();
+ else
+ return Node::create(engine, r->d->parent->children.at(ii + 1)).asReturnedValue();
}
}
- return Value::nullValue();
+ return Encode::null();
}
-Value NodePrototype::method_get_attributes(SimpleCallContext *ctx)
+ReturnedValue NodePrototype::method_get_attributes(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
if (!r)
@@ -555,9 +567,9 @@ Value NodePrototype::method_get_attributes(SimpleCallContext *ctx)
QV8Engine *engine = ctx->engine->v8Engine;
if (r->d->type != NodeImpl::Element)
- return Value::nullValue();
+ return Encode::null();
else
- return NamedNodeMap::create(engine, r->d, r->d->attributes);
+ return NamedNodeMap::create(engine, r->d, r->d->attributes).asReturnedValue();
}
Value NodePrototype::getProto(ExecutionEngine *v4)
@@ -624,49 +636,53 @@ Value Attr::prototype(ExecutionEngine *engine)
if (d->attrPrototype.isEmpty()) {
Object *p = engine->newObject();
p->setPrototype(NodePrototype::getProto(engine).asObject());
- p->defineAccessorProperty(engine, QStringLiteral("name"), name, 0);
- p->defineAccessorProperty(engine, QStringLiteral("value"), value, 0);
- p->defineAccessorProperty(engine, QStringLiteral("ownerElement"), ownerElement, 0);
+ p->defineAccessorProperty(engine, QStringLiteral("name"), method_name, 0);
+ p->defineAccessorProperty(engine, QStringLiteral("value"), method_value, 0);
+ p->defineAccessorProperty(engine, QStringLiteral("ownerElement"), method_ownerElement, 0);
d->attrPrototype = Value::fromObject(p);
engine->v8Engine->freezeObject(d->attrPrototype.value());
}
return d->attrPrototype.value();
}
-Value Attr::name(SimpleCallContext *ctx)
+ReturnedValue Attr::method_name(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return engine->toString(r->d->name);
+ return engine->toString(r->d->name).asReturnedValue();
}
-Value Attr::value(SimpleCallContext *ctx)
+ReturnedValue Attr::method_value(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return engine->toString(r->d->data);
+ return engine->toString(r->d->data).asReturnedValue();
}
-Value Attr::ownerElement(SimpleCallContext *ctx)
+ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return Node::create(engine, r->d->parent);
+ return Node::create(engine, r->d->parent).asReturnedValue();
}
-Value CharacterData::length(SimpleCallContext *ctx)
+ReturnedValue CharacterData::method_length(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
Q_UNUSED(engine)
- return Value::fromInt32(r->d->data.length());
+ return Encode(r->d->data.length());
}
Value CharacterData::prototype(ExecutionEngine *v4)
@@ -676,28 +692,29 @@ Value CharacterData::prototype(ExecutionEngine *v4)
Object *p = v4->newObject();
p->setPrototype(NodePrototype::getProto(v4).asObject());
p->defineAccessorProperty(v4, QStringLiteral("data"), NodePrototype::method_get_nodeValue, 0);
- p->defineAccessorProperty(v4, QStringLiteral("length"), length, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("length"), method_length, 0);
d->characterDataPrototype = Value::fromObject(p);
v4->v8Engine->freezeObject(d->characterDataPrototype);
}
return d->characterDataPrototype.value();
}
-Value Text::isElementContentWhitespace(SimpleCallContext *ctx)
+ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r) return Encode::undefined();
- return Value::fromBoolean(r->d->data.trimmed().isEmpty());
+ return Encode(r->d->data.trimmed().isEmpty());
}
-Value Text::wholeText(SimpleCallContext *ctx)
+ReturnedValue Text::method_wholeText(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r) return Value::undefinedValue();
+ if (!r)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return engine->toString(r->d->data);
+ return engine->toString(r->d->data).asReturnedValue();
}
Value Text::prototype(ExecutionEngine *v4)
@@ -706,8 +723,8 @@ Value Text::prototype(ExecutionEngine *v4)
if (d->textPrototype.isEmpty()) {
Object *p = v4->newObject();
p->setPrototype(CharacterData::prototype(v4).asObject());
- p->defineAccessorProperty(v4, QStringLiteral("isElementContentWhitespace"), isElementContentWhitespace, 0);
- p->defineAccessorProperty(v4, QStringLiteral("wholeText"), wholeText, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("wholeText"), method_wholeText, 0);
d->textPrototype = Value::fromObject(p);
v4->v8Engine->freezeObject(d->textPrototype);
}
@@ -733,17 +750,17 @@ Value Document::prototype(ExecutionEngine *v4)
if (d->documentPrototype.isEmpty()) {
Object *p = v4->newObject();
p->setPrototype(NodePrototype::getProto(v4).asObject());
- p->defineAccessorProperty(v4, QStringLiteral("xmlVersion"), xmlVersion, 0);
- p->defineAccessorProperty(v4, QStringLiteral("xmlEncoding"), xmlEncoding, 0);
- p->defineAccessorProperty(v4, QStringLiteral("xmlStandalone"), xmlStandalone, 0);
- p->defineAccessorProperty(v4, QStringLiteral("documentElement"), documentElement, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("xmlVersion"), method_xmlVersion, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("xmlEncoding"), method_xmlEncoding, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("xmlStandalone"), method_xmlStandalone, 0);
+ p->defineAccessorProperty(v4, QStringLiteral("documentElement"), method_documentElement, 0);
d->documentPrototype = Value::fromObject(p);
v4->v8Engine->freezeObject(d->documentPrototype);
}
return d->documentPrototype.value();
}
-Value Document::load(QV8Engine *engine, const QByteArray &data)
+ReturnedValue Document::load(QV8Engine *engine, const QByteArray &data)
{
Q_ASSERT(engine);
ExecutionEngine *v4 = QV8Engine::getV4(engine);
@@ -823,12 +840,12 @@ Value Document::load(QV8Engine *engine, const QByteArray &data)
if (!document || reader.hasError()) {
if (document)
document->release();
- return Value::nullValue();
+ return Encode::null();
}
Object *instance = new (v4->memoryManager) Node(v4, document);
instance->setPrototype(Document::prototype(v4).asObject());
- return Value::fromObject(instance);
+ return Value::fromObject(instance).asReturnedValue();
}
Node::Node(const Node &o)
@@ -859,7 +876,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
}
if (hasProperty)
*hasProperty = false;
- return Value::undefinedValue().asReturnedValue();
+ return Encode::undefined();
}
ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
@@ -886,7 +903,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
if (hasProperty)
*hasProperty = false;
- return Value::undefinedValue().asReturnedValue();
+ return Encode::undefined();
}
Value NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QList<NodeImpl *> &list)
@@ -913,7 +930,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
}
if (hasProperty)
*hasProperty = false;
- return Value::undefinedValue().asReturnedValue();
+ return Encode::undefined();
}
ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
@@ -938,40 +955,44 @@ Value NodeList::create(QV8Engine *engine, NodeImpl *data)
return Value::fromObject(instance);
}
-Value Document::documentElement(SimpleCallContext *ctx)
+ReturnedValue Document::method_documentElement(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r || r->d->type != NodeImpl::Document) return Value::undefinedValue();
+ if (!r || r->d->type != NodeImpl::Document)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return Node::create(engine, static_cast<DocumentImpl *>(r->d)->root);
+ return Node::create(engine, static_cast<DocumentImpl *>(r->d)->root).asReturnedValue();
}
-Value Document::xmlStandalone(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r || r->d->type != NodeImpl::Document) return Value::undefinedValue();
+ if (!r || r->d->type != NodeImpl::Document)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
Q_UNUSED(engine)
- return Value::fromBoolean(static_cast<DocumentImpl *>(r->d)->isStandalone);
+ return Encode(static_cast<DocumentImpl *>(r->d)->isStandalone);
}
-Value Document::xmlVersion(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlVersion(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r || r->d->type != NodeImpl::Document) return Value::undefinedValue();
+ if (!r || r->d->type != NodeImpl::Document)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return engine->toString(static_cast<DocumentImpl *>(r->d)->version);
+ return engine->toString(static_cast<DocumentImpl *>(r->d)->version).asReturnedValue();
}
-Value Document::xmlEncoding(SimpleCallContext *ctx)
+ReturnedValue Document::method_xmlEncoding(SimpleCallContext *ctx)
{
Node *r = ctx->thisObject.as<Node>();
- if (!r || r->d->type != NodeImpl::Document) return Value::undefinedValue();
+ if (!r || r->d->type != NodeImpl::Document)
+ return Encode::undefined();
QV8Engine *engine = ctx->engine->v8Engine;
- return engine->toString(static_cast<DocumentImpl *>(r->d)->encoding);
+ return engine->toString(static_cast<DocumentImpl *>(r->d)->encoding).asReturnedValue();
}
class QQmlXMLHttpRequest : public QObject
@@ -1584,18 +1605,18 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
void setupProto();
- static Value method_open(SimpleCallContext *ctx);
- static Value method_setRequestHeader(SimpleCallContext *ctx);
- static Value method_send(SimpleCallContext *ctx);
- static Value method_abort(SimpleCallContext *ctx);
- static Value method_getResponseHeader(SimpleCallContext *ctx);
- static Value method_getAllResponseHeaders(SimpleCallContext *ctx);
+ static ReturnedValue method_open(SimpleCallContext *ctx);
+ static ReturnedValue method_setRequestHeader(SimpleCallContext *ctx);
+ static ReturnedValue method_send(SimpleCallContext *ctx);
+ static ReturnedValue method_abort(SimpleCallContext *ctx);
+ static ReturnedValue method_getResponseHeader(SimpleCallContext *ctx);
+ static ReturnedValue method_getAllResponseHeaders(SimpleCallContext *ctx);
- static Value method_get_readyState(SimpleCallContext *ctx);
- static Value method_get_status(SimpleCallContext *ctx);
- static Value method_get_statusText(SimpleCallContext *ctx);
- static Value method_get_responseText(SimpleCallContext *ctx);
- static Value method_get_responseXML(SimpleCallContext *ctx);
+ static ReturnedValue method_get_readyState(SimpleCallContext *ctx);
+ static ReturnedValue method_get_status(SimpleCallContext *ctx);
+ static ReturnedValue method_get_statusText(SimpleCallContext *ctx);
+ static ReturnedValue method_get_responseText(SimpleCallContext *ctx);
+ static ReturnedValue method_get_responseXML(SimpleCallContext *ctx);
Object *proto;
@@ -1633,7 +1654,7 @@ void QQmlXMLHttpRequestCtor::setupProto()
// XMLHttpRequest methods
-Value QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1678,10 +1699,10 @@ Value QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx)
if (!username.isNull()) url.setUserName(username);
if (!password.isNull()) url.setPassword(password);
- return r->open(constructMeObject(ctx->thisObject, engine), method, url);
+ return r->open(constructMeObject(ctx->thisObject, engine), method, url).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1720,14 +1741,14 @@ Value QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx)
nameUpper == QLatin1String("VIA") ||
nameUpper.startsWith(QLatin1String("PROXY-")) ||
nameUpper.startsWith(QLatin1String("SEC-")))
- return Value::undefinedValue();
+ return Encode::undefined();
r->addHeader(name, value);
- return Value::undefinedValue();
+ return Encode::undefined();
}
-Value QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1744,20 +1765,20 @@ Value QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx)
if (ctx->argumentCount > 0)
data = ctx->arguments[0].toQStringNoThrow().toUtf8();
- return r->send(constructMeObject(ctx->thisObject, engine), data);
+ return r->send(constructMeObject(ctx->thisObject, engine), data).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->request;
- return r->abort(constructMeObject(ctx->thisObject, ctx->engine->v8Engine));
+ return r->abort(constructMeObject(ctx->thisObject, ctx->engine->v8Engine)).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1774,10 +1795,10 @@ Value QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx)
r->readyState() != QQmlXMLHttpRequest::HeadersReceived)
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
- return engine->toString(r->header(ctx->arguments[0].toQStringNoThrow()));
+ return engine->toString(r->header(ctx->arguments[0].toQStringNoThrow())).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1794,21 +1815,21 @@ Value QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ct
r->readyState() != QQmlXMLHttpRequest::HeadersReceived)
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
- return engine->toString(r->headers());
+ return engine->toString(r->headers()).asReturnedValue();
}
// XMLHttpRequest properties
-Value QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->request;
- return Value::fromUInt32(r->readyState());
+ return Encode(r->readyState());
}
-Value QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1820,12 +1841,12 @@ Value QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx)
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
if (r->errorFlag())
- return Value::fromInt32(0);
+ return Encode(0);
else
- return Value::fromInt32(r->replyStatus());
+ return Encode(r->replyStatus());
}
-Value QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1839,12 +1860,12 @@ Value QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx)
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
if (r->errorFlag())
- return engine->toString(QString());
+ return engine->toString(QString()).asReturnedValue();
else
- return engine->toString(r->replyStatusText());
+ return engine->toString(r->replyStatusText()).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1855,12 +1876,12 @@ Value QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx)
if (r->readyState() != QQmlXMLHttpRequest::Loading &&
r->readyState() != QQmlXMLHttpRequest::Done)
- return engine->toString(QString());
+ return engine->toString(QString()).asReturnedValue();
else
- return engine->toString(r->responseBody());
+ return engine->toString(r->responseBody()).asReturnedValue();
}
-Value QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx)
+ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx)
{
QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>();
if (!w)
@@ -1870,7 +1891,7 @@ Value QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx)
if (!r->receivedXml() ||
(r->readyState() != QQmlXMLHttpRequest::Loading &&
r->readyState() != QQmlXMLHttpRequest::Done)) {
- return Value::nullValue();
+ return Encode::null();
} else {
return Document::load(ctx->engine->v8Engine, r->rawResponseBody());
}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 867d63e551..59457df30c 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -103,7 +103,7 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
put(v4->newString("Asynchronous"), QV4::Value::fromInt32(0));
put(v4->newString("Synchronous"), QV4::Value::fromInt32(1));
- defineDefaultProperty(v4, QStringLiteral("include"), QV4Include::include);
+ defineDefaultProperty(v4, QStringLiteral("include"), QV4Include::method_include);
defineDefaultProperty(v4, QStringLiteral("isQtObject"), method_isQtObject);
defineDefaultProperty(v4, QStringLiteral("rgba"), method_rgba);
defineDefaultProperty(v4, QStringLiteral("hsla"), method_hsla);
@@ -168,12 +168,12 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
\qmlmethod bool Qt::isQtObject(object)
Returns true if \c object is a valid reference to a Qt or QML object, otherwise false.
*/
-Value QtObject::method_isQtObject(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_isQtObject(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount == 0)
- return QV4::Value::fromBoolean(false);
+ return QV4::Encode(false);
- return QV4::Value::fromBoolean(ctx->arguments[0].as<QV4::QObjectWrapper>() != 0);
+ return QV4::Encode(ctx->arguments[0].as<QV4::QObjectWrapper>() != 0);
}
/*!
@@ -182,7 +182,7 @@ Value QtObject::method_isQtObject(QV4::SimpleCallContext *ctx)
Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
-Value QtObject::method_rgba(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_rgba(QV4::SimpleCallContext *ctx)
{
int argCount = ctx->argumentCount;
if (argCount < 3 || argCount > 4)
@@ -202,7 +202,7 @@ Value QtObject::method_rgba(QV4::SimpleCallContext *ctx)
if (a < 0.0) a=0.0;
if (a > 1.0) a=1.0;
- return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromRgbF(r, g, b, a));
+ return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromRgbF(r, g, b, a)).asReturnedValue();
}
/*!
@@ -211,7 +211,7 @@ Value QtObject::method_rgba(QV4::SimpleCallContext *ctx)
Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
-Value QtObject::method_hsla(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_hsla(QV4::SimpleCallContext *ctx)
{
int argCount = ctx->argumentCount;
if (argCount < 3 || argCount > 4)
@@ -231,7 +231,7 @@ Value QtObject::method_hsla(QV4::SimpleCallContext *ctx)
if (a < 0.0) a=0.0;
if (a > 1.0) a=1.0;
- return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromHslF(h, s, l, a));
+ return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromHslF(h, s, l, a)).asReturnedValue();
}
/*!
@@ -242,7 +242,7 @@ may be either color values or string values. If a string value is supplied it
must be convertible to a color, as described for the \l{colorbasictypedocs}{color}
basic type.
*/
-Value QtObject::method_colorEqual(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_colorEqual(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 2)
V4THROW_ERROR("Qt.colorEqual(): Invalid arguments");
@@ -272,7 +272,7 @@ Value QtObject::method_colorEqual(QV4::SimpleCallContext *ctx)
}
bool equal = (lhs == rhs);
- return QV4::Value::fromBoolean(equal);
+ return QV4::Encode(equal);
}
/*!
@@ -282,7 +282,7 @@ Returns a \c rect with the top-left corner at \c x, \c y and the specified \c wi
The returned object has \c x, \c y, \c width and \c height attributes with the given values.
*/
-Value QtObject::method_rect(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_rect(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 4)
V4THROW_ERROR("Qt.rect(): Invalid arguments");
@@ -292,14 +292,14 @@ Value QtObject::method_rect(QV4::SimpleCallContext *ctx)
double w = ctx->arguments[2].toNumber();
double h = ctx->arguments[3].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
+ return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))).asReturnedValue();
}
/*!
\qmlmethod point Qt::point(int x, int y)
Returns a Point with the specified \c x and \c y coordinates.
*/
-Value QtObject::method_point(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_point(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 2)
V4THROW_ERROR("Qt.point(): Invalid arguments");
@@ -307,14 +307,14 @@ Value QtObject::method_point(QV4::SimpleCallContext *ctx)
double x = ctx->arguments[0].toNumber();
double y = ctx->arguments[1].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y)));
+ return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y))).asReturnedValue();
}
/*!
\qmlmethod Qt::size(int width, int height)
Returns a Size with the specified \c width and \c height.
*/
-Value QtObject::method_size(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_size(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 2)
V4THROW_ERROR("Qt.size(): Invalid arguments");
@@ -322,7 +322,7 @@ Value QtObject::method_size(QV4::SimpleCallContext *ctx)
double w = ctx->arguments[0].toNumber();
double h = ctx->arguments[1].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h)));
+ return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h))).asReturnedValue();
}
/*!
@@ -333,7 +333,7 @@ key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's
subproperty names, and the values are valid values for each subproperty.
Invalid keys will be ignored.
*/
-Value QtObject::method_font(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_font(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1 || !ctx->arguments[0].isObject())
V4THROW_ERROR("Qt.font(): Invalid arguments");
@@ -343,7 +343,7 @@ Value QtObject::method_font(QV4::SimpleCallContext *ctx)
QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->arguments[0]), v8engine, &ok);
if (!ok)
V4THROW_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified");
- return v8engine->fromVariant(v);
+ return v8engine->fromVariant(v).asReturnedValue();
}
@@ -352,7 +352,7 @@ Value QtObject::method_font(QV4::SimpleCallContext *ctx)
\qmlmethod Qt::vector2d(real x, real y)
Returns a Vector2D with the specified \c x and \c y.
*/
-Value QtObject::method_vector2d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector2d(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 2)
V4THROW_ERROR("Qt.vector2d(): Invalid arguments");
@@ -363,14 +363,14 @@ Value QtObject::method_vector2d(QV4::SimpleCallContext *ctx)
const void *params[] = { xy };
QV8Engine *v8engine = ctx->engine->v8Engine;
- return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params));
+ return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params)).asReturnedValue();
}
/*!
\qmlmethod Qt::vector3d(real x, real y, real z)
Returns a Vector3D with the specified \c x, \c y and \c z.
*/
-Value QtObject::method_vector3d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector3d(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 3)
V4THROW_ERROR("Qt.vector3d(): Invalid arguments");
@@ -382,14 +382,14 @@ Value QtObject::method_vector3d(QV4::SimpleCallContext *ctx)
const void *params[] = { xyz };
QV8Engine *v8engine = ctx->engine->v8Engine;
- return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params));
+ return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params)).asReturnedValue();
}
/*!
\qmlmethod Qt::vector4d(real x, real y, real z, real w)
Returns a Vector4D with the specified \c x, \c y, \c z and \c w.
*/
-Value QtObject::method_vector4d(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_vector4d(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 4)
V4THROW_ERROR("Qt.vector4d(): Invalid arguments");
@@ -402,14 +402,14 @@ Value QtObject::method_vector4d(QV4::SimpleCallContext *ctx)
const void *params[] = { xyzw };
QV8Engine *v8engine = ctx->engine->v8Engine;
- return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params));
+ return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params)).asReturnedValue();
}
/*!
\qmlmethod Qt::quaternion(real scalar, real x, real y, real z)
Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z.
*/
-Value QtObject::method_quaternion(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_quaternion(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 4)
V4THROW_ERROR("Qt.quaternion(): Invalid arguments");
@@ -422,7 +422,7 @@ Value QtObject::method_quaternion(QV4::SimpleCallContext *ctx)
const void *params[] = { sxyz };
QV8Engine *v8engine = ctx->engine->v8Engine;
- return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params));
+ return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params)).asReturnedValue();
}
/*!
@@ -432,7 +432,7 @@ Alternatively, the function may be called with a single argument
where that argument is a JavaScript array which contains the sixteen
matrix values.
*/
-Value QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
@@ -441,7 +441,7 @@ Value QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx)
QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->arguments[0]), v8engine, &ok);
if (!ok)
V4THROW_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array");
- return v8engine->fromVariant(v);
+ return v8engine->fromVariant(v).asReturnedValue();
}
if (ctx->argumentCount != 16)
@@ -466,7 +466,7 @@ Value QtObject::method_matrix4x4(QV4::SimpleCallContext *ctx)
vals[15] = ctx->arguments[15].toNumber();
const void *params[] = { vals };
- return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params));
+ return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params)).asReturnedValue();
}
/*!
@@ -483,7 +483,7 @@ by factor and converts the color back to RGB.
If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5).
*/
-Value QtObject::method_lighter(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_lighter(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1 && ctx->argumentCount != 2)
V4THROW_ERROR("Qt.lighter(): Invalid arguments");
@@ -494,17 +494,17 @@ Value QtObject::method_lighter(QV4::SimpleCallContext *ctx)
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
if (!ok) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
} else if (v.userType() != QVariant::Color) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
qreal factor = 1.5;
if (ctx->argumentCount == 2)
factor = ctx->arguments[1].toNumber();
- return v8engine->fromVariant(QQml_colorProvider()->lighter(v, factor));
+ return v8engine->fromVariant(QQml_colorProvider()->lighter(v, factor)).asReturnedValue();
}
/*!
@@ -522,7 +522,7 @@ by factor and converts the color back to RGB.
If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0).
*/
-Value QtObject::method_darker(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_darker(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1 && ctx->argumentCount != 2)
V4THROW_ERROR("Qt.darker(): Invalid arguments");
@@ -533,17 +533,17 @@ Value QtObject::method_darker(QV4::SimpleCallContext *ctx)
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
if (!ok) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
} else if (v.userType() != QVariant::Color) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
qreal factor = 2.0;
if (ctx->argumentCount == 2)
factor = ctx->arguments[1].toNumber();
- return v8engine->fromVariant(QQml_colorProvider()->darker(v, factor));
+ return v8engine->fromVariant(QQml_colorProvider()->darker(v, factor)).asReturnedValue();
}
/*!
@@ -570,7 +570,7 @@ Value QtObject::method_darker(QV4::SimpleCallContext *ctx)
Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color.
*/
-Value QtObject::method_tint(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_tint(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 2)
V4THROW_ERROR("Qt.tint(): Invalid arguments");
@@ -583,10 +583,10 @@ Value QtObject::method_tint(QV4::SimpleCallContext *ctx)
bool ok = false;
v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok);
if (!ok) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
} else if (v1.userType() != QVariant::Color) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
// tint color
@@ -595,13 +595,13 @@ Value QtObject::method_tint(QV4::SimpleCallContext *ctx)
bool ok = false;
v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok);
if (!ok) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
} else if (v2.userType() != QVariant::Color) {
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
}
- return v8engine->fromVariant(QQml_colorProvider()->tint(v1, v2));
+ return v8engine->fromVariant(QQml_colorProvider()->tint(v1, v2)).asReturnedValue();
}
/*!
@@ -620,7 +620,7 @@ If \a format is not specified, \a date is formatted using
\sa Locale
*/
-Value QtObject::method_formatDate(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatDate(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1 || ctx->argumentCount > 2)
V4THROW_ERROR("Qt.formatDate(): Invalid arguments");
@@ -645,7 +645,7 @@ Value QtObject::method_formatDate(QV4::SimpleCallContext *ctx)
formattedDate = date.toString(enumFormat);
}
- return v8engine->fromVariant(QVariant::fromValue(formattedDate));
+ return v8engine->fromVariant(QVariant::fromValue(formattedDate)).asReturnedValue();
}
/*!
@@ -663,7 +663,7 @@ If \a format is not specified, \a time is formatted using
\sa Locale
*/
-Value QtObject::method_formatTime(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatTime(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1 || ctx->argumentCount > 2)
V4THROW_ERROR("Qt.formatTime(): Invalid arguments");
@@ -694,7 +694,7 @@ Value QtObject::method_formatTime(QV4::SimpleCallContext *ctx)
formattedTime = time.toString(enumFormat);
}
- return v8engine->fromVariant(QVariant::fromValue(formattedTime));
+ return v8engine->fromVariant(QVariant::fromValue(formattedTime)).asReturnedValue();
}
/*!
@@ -787,7 +787,7 @@ with the \a format values below to produce the following results:
\sa Locale
*/
-Value QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1 || ctx->argumentCount > 2)
V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments");
@@ -812,29 +812,29 @@ Value QtObject::method_formatDateTime(QV4::SimpleCallContext *ctx)
formattedDt = dt.toString(enumFormat);
}
- return v8engine->fromVariant(QVariant::fromValue(formattedDt));
+ return v8engine->fromVariant(QVariant::fromValue(formattedDt)).asReturnedValue();
}
/*!
\qmlmethod bool Qt::openUrlExternally(url target)
Attempts to open the specified \c target url in an external application, based on the user's desktop preferences. Returns true if it succeeds, and false otherwise.
*/
-Value QtObject::method_openUrlExternally(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_openUrlExternally(QV4::SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
- return QV4::Value::fromBoolean(false);
+ return QV4::Encode(false);
QV8Engine *v8engine = ctx->engine->v8Engine;
- QUrl url(method_resolvedUrl(ctx).toQStringNoThrow());
- return v8engine->fromVariant(QQml_guiProvider()->openUrlExternally(url));
+ QUrl url(Value::fromReturnedValue(method_resolvedUrl(ctx)).toQStringNoThrow());
+ return v8engine->fromVariant(QQml_guiProvider()->openUrlExternally(url)).asReturnedValue();
}
/*!
\qmlmethod url Qt::resolvedUrl(url url)
Returns \a url resolved relative to the URL of the caller.
*/
-Value QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx)
+ReturnedValue QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
@@ -845,67 +845,67 @@ Value QtObject::method_resolvedUrl(QV4::SimpleCallContext *ctx)
if (p) {
QQmlContextData *ctxt = v8engine->callingContext();
if (ctxt)
- return Value::fromString(ctx, ctxt->resolvedUrl(url).toString());
+ return Value::fromString(ctx, ctxt->resolvedUrl(url).toString()).asReturnedValue();
else
- return Value::fromString(ctx, url.toString());
+ return Value::fromString(ctx, url.toString()).asReturnedValue();
}
- return Value::fromString(ctx, e->baseUrl().resolved(url).toString());
+ return Value::fromString(ctx, e->baseUrl().resolved(url).toString()).asReturnedValue();
}
/*!
\qmlmethod list<string> Qt::fontFamilies()
Returns a list of the font families available to the application.
*/
-Value QtObject::method_fontFamilies(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_fontFamilies(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 0)
V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments");
QV8Engine *v8engine = ctx->engine->v8Engine;
- return v8engine->fromVariant(QVariant(QQml_guiProvider()->fontFamilies()));
+ return v8engine->fromVariant(QVariant(QQml_guiProvider()->fontFamilies())).asReturnedValue();
}
/*!
\qmlmethod string Qt::md5(data)
Returns a hex string of the md5 hash of \c data.
*/
-Value QtObject::method_md5(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_md5(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("Qt.md5(): Invalid arguments");
QByteArray data = ctx->arguments[0].toQStringNoThrow().toUtf8();
QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
- return Value::fromString(ctx, QLatin1String(result.toHex()));
+ return Value::fromString(ctx, QLatin1String(result.toHex())).asReturnedValue();
}
/*!
\qmlmethod string Qt::btoa(data)
Binary to ASCII - this function returns a base64 encoding of \c data.
*/
-Value QtObject::method_btoa(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_btoa(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("Qt.btoa(): Invalid arguments");
QByteArray data = ctx->arguments[0].toQStringNoThrow().toUtf8();
- return Value::fromString(ctx, QLatin1String(data.toBase64()));
+ return Value::fromString(ctx, QLatin1String(data.toBase64())).asReturnedValue();
}
/*!
\qmlmethod string Qt::atob(data)
ASCII to binary - this function returns a base64 decoding of \c data.
*/
-Value QtObject::method_atob(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_atob(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("Qt.atob(): Invalid arguments");
QByteArray data = ctx->arguments[0].toQStringNoThrow().toLatin1();
- return Value::fromString(ctx, QString::fromUtf8(QByteArray::fromBase64(data)));
+ return Value::fromString(ctx, QString::fromUtf8(QByteArray::fromBase64(data))).asReturnedValue();
}
/*!
@@ -915,12 +915,12 @@ Within the \l {Prototyping with qmlscene}, this causes the launcher application
to quit a C++ application when this method is called, connect the
QQmlEngine::quit() signal to the QCoreApplication::quit() slot.
*/
-Value QtObject::method_quit(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_quit(SimpleCallContext *ctx)
{
QV8Engine *v8engine = ctx->engine->v8Engine;
QQmlEnginePrivate::get(v8engine->engine())->sendQuit();
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
/*!
@@ -947,7 +947,7 @@ If this is the case, consider using \l{QtQml2::Qt::createComponent()}{Qt.createC
See \l {Dynamic QML Object Creation from JavaScript} for more information on using this function.
*/
-Value QtObject::method_createQmlObject(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 2 || ctx->argumentCount > 3)
V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments");
@@ -988,7 +988,7 @@ Value QtObject::method_createQmlObject(SimpleCallContext *ctx)
QString qml = ctx->arguments[0].toQStringNoThrow();
if (qml.isEmpty())
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
QUrl url;
if (ctx->argumentCount > 2)
@@ -1010,7 +1010,7 @@ Value QtObject::method_createQmlObject(SimpleCallContext *ctx)
if (component.isError()) {
ctx->throwError(Error::create(v8engine, component.errors()));
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
if (!component.isReady())
@@ -1034,12 +1034,12 @@ Value QtObject::method_createQmlObject(SimpleCallContext *ctx)
if (component.isError()) {
ctx->throwError(Error::create(v8engine, component.errors()));
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
Q_ASSERT(obj);
- return QV4::QObjectWrapper::wrap(ctx->engine, obj);
+ return QV4::QObjectWrapper::wrap(ctx->engine, obj).asReturnedValue();
}
/*!
@@ -1073,7 +1073,7 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi
To create a QML object from an arbitrary string of QML (instead of a file),
use \l{QtQml2::Qt::createQmlObject()}{Qt.createQmlObject()}.
*/
-Value QtObject::method_createComponent(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_createComponent(SimpleCallContext *ctx)
{
const QString invalidArgs = QStringLiteral("Qt.createComponent(): Invalid arguments");
const QString invalidParent = QStringLiteral("Qt.createComponent(): Invalid parent object");
@@ -1091,7 +1091,7 @@ Value QtObject::method_createComponent(SimpleCallContext *ctx)
QString arg = ctx->arguments[0].toQStringNoThrow();
if (arg.isEmpty())
- return QV4::Value::nullValue();
+ return QV4::Encode::null();
QQmlComponent::CompilationMode compileMode = QQmlComponent::PreferSynchronous;
QObject *parentArg = 0;
@@ -1133,7 +1133,7 @@ Value QtObject::method_createComponent(SimpleCallContext *ctx)
QQmlData::get(c, true)->explicitIndestructibleSet = false;
QQmlData::get(c)->indestructible = false;
- return QV4::QObjectWrapper::wrap(ctx->engine, c);
+ return QV4::QObjectWrapper::wrap(ctx->engine, c).asReturnedValue();
}
/*!
@@ -1156,7 +1156,7 @@ Value QtObject::method_createComponent(SimpleCallContext *ctx)
\sa QtQuick2::Locale
*/
-Value QtObject::method_locale(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_locale(SimpleCallContext *ctx)
{
QString code;
if (ctx->argumentCount > 1)
@@ -1168,7 +1168,7 @@ Value QtObject::method_locale(SimpleCallContext *ctx)
if (ctx->argumentCount == 1)
code = ctx->arguments[0].toQStringNoThrow();
- return QQmlLocale::locale(v8engine, code);
+ return QQmlLocale::locale(v8engine, code).asReturnedValue();
}
namespace {
@@ -1250,7 +1250,7 @@ DEFINE_MANAGED_VTABLE(BindingFunction);
\since QtQuick 2.0
*/
-Value QtObject::method_binding(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_binding(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("binding() requires 1 argument");
@@ -1258,11 +1258,11 @@ Value QtObject::method_binding(SimpleCallContext *ctx)
if (!f)
V4THROW_TYPE("binding(): argument (binding expression) must be a function");
- return QV4::Value::fromObject(new (ctx->engine->memoryManager) BindingFunction(f));
+ return QV4::Value::fromObject(new (ctx->engine->memoryManager) BindingFunction(f)).asReturnedValue();
}
-Value QtObject::method_get_platform(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_platform(SimpleCallContext *ctx)
{
// ### inefficient. Should be just a value based getter
Object *o = ctx->thisObject.asObject();
@@ -1276,10 +1276,10 @@ Value QtObject::method_get_platform(SimpleCallContext *ctx)
// Only allocate a platform object once
qt->m_platform = new QQmlPlatform(ctx->engine->v8Engine->publicEngine());
- return QV4::QObjectWrapper::wrap(ctx->engine, qt->m_platform);
+ return QV4::QObjectWrapper::wrap(ctx->engine, qt->m_platform).asReturnedValue();
}
-Value QtObject::method_get_application(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_application(SimpleCallContext *ctx)
{
// ### inefficient. Should be just a value based getter
Object *o = ctx->thisObject.asObject();
@@ -1293,15 +1293,15 @@ Value QtObject::method_get_application(SimpleCallContext *ctx)
// Only allocate an application object once
qt->m_application = QQml_guiProvider()->application(ctx->engine->v8Engine->publicEngine());
- return QV4::QObjectWrapper::wrap(ctx->engine, qt->m_application);
+ return QV4::QObjectWrapper::wrap(ctx->engine, qt->m_application).asReturnedValue();
}
#ifndef QT_NO_IM
-Value QtObject::method_get_inputMethod(SimpleCallContext *ctx)
+ReturnedValue QtObject::method_get_inputMethod(SimpleCallContext *ctx)
{
QObject *o = QQml_guiProvider()->inputMethod();
QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership);
- return QV4::QObjectWrapper::wrap(ctx->engine, o);
+ return QV4::QObjectWrapper::wrap(ctx->engine, o).asReturnedValue();
}
#endif
@@ -1358,8 +1358,8 @@ static QString jsStack(QV4::ExecutionEngine *engine) {
return stack;
}
-static QV4::Value writeToConsole(ConsoleLogTypes logType, SimpleCallContext *ctx,
- bool printStack = false)
+static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, SimpleCallContext *ctx,
+ bool printStack = false)
{
QString result;
QV4::ExecutionEngine *v4 = ctx->engine;
@@ -1396,15 +1396,15 @@ static QV4::Value writeToConsole(ConsoleLogTypes logType, SimpleCallContext *ctx
break;
}
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_error(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_error(SimpleCallContext *ctx)
{
return writeToConsole(Error, ctx);
}
-QV4::Value ConsoleObject::method_log(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_log(SimpleCallContext *ctx)
{
//console.log
//console.debug
@@ -1413,7 +1413,7 @@ QV4::Value ConsoleObject::method_log(SimpleCallContext *ctx)
return writeToConsole(Log, ctx);
}
-QV4::Value ConsoleObject::method_profile(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_profile(SimpleCallContext *ctx)
{
//DeclarativeDebugTrace cannot handle nested profiling
//although v8 can handle several profiling at once,
@@ -1431,10 +1431,10 @@ QV4::Value ConsoleObject::method_profile(SimpleCallContext *ctx)
logger.warning("Profiling is already in progress. First, end current profiling session.");
}
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_profileEnd(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_profileEnd(SimpleCallContext *ctx)
{
//DeclarativeDebugTrace cannot handle nested profiling
//although v8 can handle several profiling at once,
@@ -1457,10 +1457,10 @@ QV4::Value ConsoleObject::method_profileEnd(SimpleCallContext *ctx)
logger.warning("Profiling was not started.");
}
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_time(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_time(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
@@ -1469,10 +1469,10 @@ QV4::Value ConsoleObject::method_time(SimpleCallContext *ctx)
QString name = ctx->arguments[0].toQStringNoThrow();
v8engine->startTimer(name);
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_timeEnd(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_timeEnd(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
@@ -1485,10 +1485,10 @@ QV4::Value ConsoleObject::method_timeEnd(SimpleCallContext *ctx)
if (wasRunning) {
qDebug("%s: %llims", qPrintable(name), elapsed);
}
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_count(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_count(SimpleCallContext *ctx)
{
// first argument: name to print. Ignore any additional arguments
QString name;
@@ -1508,10 +1508,10 @@ QV4::Value ConsoleObject::method_count(SimpleCallContext *ctx)
QMessageLogger(qPrintable(scriptName), frame.line,
qPrintable(frame.function)).debug("%s", qPrintable(message));
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_trace(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_trace(SimpleCallContext *ctx)
{
if (ctx->argumentCount != 0)
V4THROW_ERROR("console.trace(): Invalid arguments");
@@ -1524,15 +1524,15 @@ QV4::Value ConsoleObject::method_trace(SimpleCallContext *ctx)
QMessageLogger logger(frame.source.toUtf8().constData(), frame.line, frame.function.toUtf8().constData());
logger.debug("%s", qPrintable(stack));
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_warn(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_warn(SimpleCallContext *ctx)
{
return writeToConsole(Warn, ctx);
}
-QV4::Value ConsoleObject::method_assert(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_assert(SimpleCallContext *ctx)
{
if (ctx->argumentCount == 0)
V4THROW_ERROR("console.assert(): Missing argument");
@@ -1555,17 +1555,17 @@ QV4::Value ConsoleObject::method_assert(SimpleCallContext *ctx)
logger.critical("%s\n%s", qPrintable(message), qPrintable(stack));
}
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-QV4::Value ConsoleObject::method_exception(SimpleCallContext *ctx)
+QV4::ReturnedValue ConsoleObject::method_exception(SimpleCallContext *ctx)
{
if (ctx->argumentCount == 0)
V4THROW_ERROR("console.exception(): Missing argument");
writeToConsole(Error, ctx, true);
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
@@ -1594,7 +1594,7 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject)
// string prototype extension
QV4::Object *stringProto = v4->stringClass->prototype;
- stringProto->defineDefaultProperty(v4, QStringLiteral("arg"), string_arg);
+ stringProto->defineDefaultProperty(v4, QStringLiteral("arg"), method_string_arg);
}
@@ -1616,7 +1616,7 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject)
\sa {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 2)
V4THROW_ERROR("qsTranslate() requires at least two arguments");
@@ -1647,7 +1647,7 @@ Value GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
comment.toUtf8().constData(),
n);
- return Value::fromString(ctx, result);
+ return Value::fromString(ctx, result).asReturnedValue();
}
/*!
@@ -1672,11 +1672,11 @@ Value GlobalExtensions::method_qsTranslate(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 2)
- return QV4::Value::undefinedValue();
- return ctx->arguments[1];
+ return QV4::Encode::undefined();
+ return ctx->arguments[1].asReturnedValue();
}
/*!
@@ -1696,7 +1696,7 @@ Value GlobalExtensions::method_qsTranslateNoOp(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1)
V4THROW_ERROR("qsTr() requires at least one argument");
@@ -1725,7 +1725,7 @@ Value GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(),
comment.toUtf8().constData(), n);
- return Value::fromString(ctx, result);
+ return Value::fromString(ctx, result).asReturnedValue();
}
/*!
@@ -1750,11 +1750,11 @@ Value GlobalExtensions::method_qsTr(SimpleCallContext *ctx)
\sa {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1)
- return QV4::Value::undefinedValue();
- return ctx->arguments[0];
+ return QV4::Encode::undefined();
+ return ctx->arguments[0].asReturnedValue();
}
/*!
@@ -1787,7 +1787,7 @@ Value GlobalExtensions::method_qsTrNoOp(SimpleCallContext *ctx)
\sa QT_TRID_NOOP, {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1)
V4THROW_ERROR("qsTrId() requires at least one argument");
@@ -1800,7 +1800,7 @@ Value GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
if (ctx->argumentCount > 1)
n = ctx->arguments[1].toInt32();
- return Value::fromString(ctx, qtTrId(ctx->arguments[0].toQStringNoThrow().toUtf8().constData(), n));
+ return Value::fromString(ctx, qtTrId(ctx->arguments[0].toQStringNoThrow().toUtf8().constData(), n)).asReturnedValue();
}
/*!
@@ -1819,25 +1819,25 @@ Value GlobalExtensions::method_qsTrId(SimpleCallContext *ctx)
\sa qsTrId(), {Internationalization and Localization with Qt Quick}
*/
-Value GlobalExtensions::method_qsTrIdNoOp(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_qsTrIdNoOp(SimpleCallContext *ctx)
{
if (ctx->argumentCount < 1)
- return QV4::Value::undefinedValue();
- return ctx->arguments[0];
+ return QV4::Encode::undefined();
+ return ctx->arguments[0].asReturnedValue();
}
#endif // QT_NO_TRANSLATION
-QV4::Value GlobalExtensions::method_gc(SimpleCallContext *ctx)
+QV4::ReturnedValue GlobalExtensions::method_gc(SimpleCallContext *ctx)
{
ctx->engine->memoryManager->runGC();
- return QV4::Value::undefinedValue();
+ return QV4::Encode::undefined();
}
-Value GlobalExtensions::string_arg(SimpleCallContext *ctx)
+ReturnedValue GlobalExtensions::method_string_arg(SimpleCallContext *ctx)
{
QString value = ctx->thisObject.toQStringNoThrow();
if (ctx->argumentCount != 1)
@@ -1845,13 +1845,13 @@ Value GlobalExtensions::string_arg(SimpleCallContext *ctx)
QV4::Value arg = ctx->arguments[0];
if (arg.isInteger())
- return Value::fromString(ctx, value.arg(arg.integerValue()));
+ return Value::fromString(ctx, value.arg(arg.integerValue())).asReturnedValue();
else if (arg.isDouble())
- return Value::fromString(ctx, value.arg(arg.doubleValue()));
+ return Value::fromString(ctx, value.arg(arg.doubleValue())).asReturnedValue();
else if (arg.isBoolean())
- return Value::fromString(ctx, value.arg(arg.booleanValue()));
+ return Value::fromString(ctx, value.arg(arg.booleanValue())).asReturnedValue();
- return Value::fromString(ctx, value.arg(arg.toQStringNoThrow()));
+ return Value::fromString(ctx, value.arg(arg.toQStringNoThrow())).asReturnedValue();
}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index d03605f48a..070796f03c 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -68,41 +68,41 @@ struct QtObject : Object
Q_MANAGED
QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine);
- static Value method_isQtObject(SimpleCallContext *ctx);
- static Value method_rgba(SimpleCallContext *ctx);
- static Value method_hsla(SimpleCallContext *ctx);
- static Value method_colorEqual(SimpleCallContext *ctx);
- static Value method_font(SimpleCallContext *ctx);
- static Value method_rect(SimpleCallContext *ctx);
- static Value method_point(SimpleCallContext *ctx);
- static Value method_size(SimpleCallContext *ctx);
- static Value method_vector2d(SimpleCallContext *ctx);
- static Value method_vector3d(SimpleCallContext *ctx);
- static Value method_vector4d(SimpleCallContext *ctx);
- static Value method_quaternion(SimpleCallContext *ctx);
- static Value method_matrix4x4(SimpleCallContext *ctx);
- static Value method_lighter(SimpleCallContext *ctx);
- static Value method_darker(SimpleCallContext *ctx);
- static Value method_tint(SimpleCallContext *ctx);
- static Value method_formatDate(SimpleCallContext *ctx);
- static Value method_formatTime(SimpleCallContext *ctx);
- static Value method_formatDateTime(SimpleCallContext *ctx);
- static Value method_openUrlExternally(SimpleCallContext *ctx);
- static Value method_fontFamilies(SimpleCallContext *ctx);
- static Value method_md5(SimpleCallContext *ctx);
- static Value method_btoa(SimpleCallContext *ctx);
- static Value method_atob(SimpleCallContext *ctx);
- static Value method_quit(SimpleCallContext *ctx);
- static Value method_resolvedUrl(SimpleCallContext *ctx);
- static Value method_createQmlObject(SimpleCallContext *ctx);
- static Value method_createComponent(SimpleCallContext *ctx);
- static Value method_locale(SimpleCallContext *ctx);
- static Value method_binding(SimpleCallContext *ctx);
-
- static Value method_get_platform(SimpleCallContext *ctx);
- static Value method_get_application(SimpleCallContext *ctx);
+ static ReturnedValue method_isQtObject(SimpleCallContext *ctx);
+ static ReturnedValue method_rgba(SimpleCallContext *ctx);
+ static ReturnedValue method_hsla(SimpleCallContext *ctx);
+ static ReturnedValue method_colorEqual(SimpleCallContext *ctx);
+ static ReturnedValue method_font(SimpleCallContext *ctx);
+ static ReturnedValue method_rect(SimpleCallContext *ctx);
+ static ReturnedValue method_point(SimpleCallContext *ctx);
+ static ReturnedValue method_size(SimpleCallContext *ctx);
+ static ReturnedValue method_vector2d(SimpleCallContext *ctx);
+ static ReturnedValue method_vector3d(SimpleCallContext *ctx);
+ static ReturnedValue method_vector4d(SimpleCallContext *ctx);
+ static ReturnedValue method_quaternion(SimpleCallContext *ctx);
+ static ReturnedValue method_matrix4x4(SimpleCallContext *ctx);
+ static ReturnedValue method_lighter(SimpleCallContext *ctx);
+ static ReturnedValue method_darker(SimpleCallContext *ctx);
+ static ReturnedValue method_tint(SimpleCallContext *ctx);
+ static ReturnedValue method_formatDate(SimpleCallContext *ctx);
+ static ReturnedValue method_formatTime(SimpleCallContext *ctx);
+ static ReturnedValue method_formatDateTime(SimpleCallContext *ctx);
+ static ReturnedValue method_openUrlExternally(SimpleCallContext *ctx);
+ static ReturnedValue method_fontFamilies(SimpleCallContext *ctx);
+ static ReturnedValue method_md5(SimpleCallContext *ctx);
+ static ReturnedValue method_btoa(SimpleCallContext *ctx);
+ static ReturnedValue method_atob(SimpleCallContext *ctx);
+ static ReturnedValue method_quit(SimpleCallContext *ctx);
+ static ReturnedValue method_resolvedUrl(SimpleCallContext *ctx);
+ static ReturnedValue method_createQmlObject(SimpleCallContext *ctx);
+ static ReturnedValue method_createComponent(SimpleCallContext *ctx);
+ static ReturnedValue method_locale(SimpleCallContext *ctx);
+ static ReturnedValue method_binding(SimpleCallContext *ctx);
+
+ static ReturnedValue method_get_platform(SimpleCallContext *ctx);
+ static ReturnedValue method_get_application(SimpleCallContext *ctx);
#ifndef QT_NO_IM
- static Value method_get_inputMethod(SimpleCallContext *ctx);
+ static ReturnedValue method_get_inputMethod(SimpleCallContext *ctx);
#endif
QObject *m_platform;
@@ -113,17 +113,17 @@ struct ConsoleObject : Object
{
ConsoleObject(ExecutionEngine *v4);
- static Value method_error(SimpleCallContext *ctx);
- static Value method_log(SimpleCallContext *ctx);
- static Value method_profile(SimpleCallContext *ctx);
- static Value method_profileEnd(SimpleCallContext *ctx);
- static Value method_time(SimpleCallContext *ctx);
- static Value method_timeEnd(SimpleCallContext *ctx);
- static Value method_count(SimpleCallContext *ctx);
- static Value method_trace(SimpleCallContext *ctx);
- static Value method_warn(SimpleCallContext *ctx);
- static Value method_assert(SimpleCallContext *ctx);
- static Value method_exception(SimpleCallContext *ctx);
+ static ReturnedValue method_error(SimpleCallContext *ctx);
+ static ReturnedValue method_log(SimpleCallContext *ctx);
+ static ReturnedValue method_profile(SimpleCallContext *ctx);
+ static ReturnedValue method_profileEnd(SimpleCallContext *ctx);
+ static ReturnedValue method_time(SimpleCallContext *ctx);
+ static ReturnedValue method_timeEnd(SimpleCallContext *ctx);
+ static ReturnedValue method_count(SimpleCallContext *ctx);
+ static ReturnedValue method_trace(SimpleCallContext *ctx);
+ static ReturnedValue method_warn(SimpleCallContext *ctx);
+ static ReturnedValue method_assert(SimpleCallContext *ctx);
+ static ReturnedValue method_exception(SimpleCallContext *ctx);
};
@@ -131,17 +131,17 @@ struct GlobalExtensions {
static void init(QQmlEngine *qmlEngine, Object *globalObject);
#ifndef QT_NO_TRANSLATION
- static Value method_qsTranslate(SimpleCallContext *ctx);
- static Value method_qsTranslateNoOp(SimpleCallContext *ctx);
- static Value method_qsTr(SimpleCallContext *ctx);
- static Value method_qsTrNoOp(SimpleCallContext *ctx);
- static Value method_qsTrId(SimpleCallContext *ctx);
- static Value method_qsTrIdNoOp(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTranslate(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTranslateNoOp(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTr(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTrNoOp(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTrId(SimpleCallContext *ctx);
+ static ReturnedValue method_qsTrIdNoOp(SimpleCallContext *ctx);
#endif
- static Value method_gc(SimpleCallContext *ctx);
+ static ReturnedValue method_gc(SimpleCallContext *ctx);
// on String:prototype
- static Value string_arg(SimpleCallContext *ctx);
+ static ReturnedValue method_string_arg(SimpleCallContext *ctx);
};