using namespace QV4;
#define V4THROW_SQL(error, desc) { \
- QV4::Scoped<String> v(scope, ctx->engine->newString(desc)); \
- QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
+ QV4::Scoped<String> v(scope, scope.engine->newString(desc)); \
+ QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
ctx->throwError(ex); \
return Encode::undefined(); \
}
#define V4THROW_SQL2(error, desc) { \
- QV4::Scoped<String> v(scope, ctx->engine->newString(desc)); \
- QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
+ QV4::Scoped<String> v(scope, scope.engine->newString(desc)); \
+ QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, Primitive::fromInt32(error))); \
args->setReturnValue(ctx->throwError(ex)); \
return; \
}
#define V4THROW_REFERENCE(string) { \
- QV4::Scoped<String> v(scope, ctx->engine->newString(string)); \
+ QV4::Scoped<String> v(scope, scope.engine->newString(string)); \
ctx->throwReferenceError(v); \
return Encode::undefined(); \
}
static ReturnedValue qmlsqldatabase_version(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Database)
V4THROW_REFERENCE("Not a SQLDatabase object");
- return Encode(ctx->engine->newString(r->d()->version));
+ return Encode(scope.engine->newString(r->d()->version));
}
static ReturnedValue qmlsqldatabase_rows_length(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
static ReturnedValue qmlsqldatabase_rows_forwardOnly(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
return Encode(r->d()->sqlQuery.isForwardOnly());
static ReturnedValue qmlsqldatabase_rows_setForwardOnly(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
- if (ctx->callData->argc < 1)
+ if (ctx->d()->callData->argc < 1)
return ctx->throwTypeError();
- r->d()->sqlQuery.setForwardOnly(ctx->callData->args[0].toBoolean());
+ r->d()->sqlQuery.setForwardOnly(ctx->d()->callData->args[0].toBoolean());
return Encode::undefined();
}
static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Rows)
V4THROW_REFERENCE("Not a SQLDatabase::Rows object");
- return qmlsqldatabase_rows_index(r, ctx->engine, ctx->callData->argc ? ctx->callData->args[0].toUInt32() : 0);
+ return qmlsqldatabase_rows_index(r, scope.engine, ctx->d()->callData->argc ? ctx->d()->callData->args[0].toUInt32() : 0);
}
static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Query)
V4THROW_REFERENCE("Not a SQLDatabase::Query object");
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
if (!r->d()->inTransaction)
V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR,QQmlEngine::tr("executeSql called outside transaction()"));
QSqlDatabase db = r->d()->database;
- QString sql = ctx->callData->argc ? ctx->callData->args[0].toQString() : QString();
+ QString sql = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toQString() : QString();
if (r->d()->readonly && !sql.startsWith(QLatin1String("SELECT"),Qt::CaseInsensitive)) {
V4THROW_SQL(SQLEXCEPTION_SYNTAX_ERR, QQmlEngine::tr("Read-only Transaction"));
ScopedValue result(scope, Primitive::undefinedValue());
if (query.prepare(sql)) {
- if (ctx->callData->argc > 1) {
- ScopedValue values(scope, ctx->callData->args[1]);
+ if (ctx->d()->callData->argc > 1) {
+ ScopedValue values(scope, ctx->d()->callData->args[1]);
if (values->asArrayObject()) {
ScopedArrayObject array(scope, values);
quint32 size = array->getLength();
}
}
if (query.exec()) {
- QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, new (ctx->engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
+ QV4::Scoped<QQmlSqlDatabaseWrapper> rows(scope, new (scope.engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
QV4::ScopedObject p(scope, databaseData(engine)->rowsProto.value());
rows->setPrototype(p.getPointer());
rows->d()->type = QQmlSqlDatabaseWrapper::Rows;
rows->d()->database = db;
rows->d()->sqlQuery = query;
- Scoped<Object> resultObject(scope, ctx->engine->newObject());
+ Scoped<Object> resultObject(scope, scope.engine->newObject());
result = resultObject.asReturnedValue();
// XXX optimize
ScopedString s(scope);
ScopedValue v(scope);
- resultObject->put((s = ctx->engine->newIdentifier("rowsAffected")), (v = Primitive::fromInt32(query.numRowsAffected())));
- resultObject->put((s = ctx->engine->newIdentifier("insertId")), (v = engine->toString(query.lastInsertId().toString())));
- resultObject->put((s = ctx->engine->newIdentifier("rows")), rows);
+ resultObject->put((s = scope.engine->newIdentifier("rowsAffected")), (v = Primitive::fromInt32(query.numRowsAffected())));
+ resultObject->put((s = scope.engine->newIdentifier("insertId")), (v = engine->toString(query.lastInsertId().toString())));
+ resultObject->put((s = scope.engine->newIdentifier("rows")), rows);
} else {
err = true;
}
static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx)
{
- if (ctx->callData->argc < 2)
+ if (ctx->d()->callData->argc < 2)
return Encode::undefined();
Scope scope(ctx);
- Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject);
+ Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject);
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Database)
V4THROW_REFERENCE("Not a SQLDatabase object");
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
QSqlDatabase db = r->d()->database;
- QString from_version = ctx->callData->args[0].toQString();
- QString to_version = ctx->callData->args[1].toQString();
+ QString from_version = ctx->d()->callData->args[0].toQString();
+ QString to_version = ctx->d()->callData->args[1].toQString();
Scoped<FunctionObject> callback(scope, ctx->argument(2));
if (from_version != r->d()->version)
V4THROW_SQL(SQLEXCEPTION_VERSION_ERR, QQmlEngine::tr("Version mismatch: expected %1, found %2").arg(from_version).arg(r->d()->version));
- Scoped<QQmlSqlDatabaseWrapper> w(scope, new (ctx->engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
+ Scoped<QQmlSqlDatabaseWrapper> w(scope, new (scope.engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
ScopedObject p(scope, databaseData(engine)->queryProto.value());
w->setPrototype(p.getPointer());
w->d()->type = QQmlSqlDatabaseWrapper::Query;
static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool readOnly)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
+ QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, ctx->d()->callData->thisObject.as<QQmlSqlDatabaseWrapper>());
if (!r || r->d()->type != QQmlSqlDatabaseWrapper::Database)
V4THROW_REFERENCE("Not a SQLDatabase object");
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- FunctionObject *callback = ctx->callData->argc ? ctx->callData->args[0].asFunctionObject() : 0;
+ FunctionObject *callback = ctx->d()->callData->argc ? ctx->d()->callData->args[0].asFunctionObject() : 0;
if (!callback)
V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback"));
QSqlDatabase db = r->d()->database;
- Scoped<QQmlSqlDatabaseWrapper> w(scope, new (ctx->engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
+ Scoped<QQmlSqlDatabaseWrapper> w(scope, new (scope.engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
QV4::ScopedObject p(scope, databaseData(engine)->queryProto.value());
w->setPrototype(p.getPointer());
w->d()->type = QQmlSqlDatabaseWrapper::Query;
database.open();
}
- QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, new (ctx->engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
+ QV4::Scoped<QQmlSqlDatabaseWrapper> db(scope, new (scope.engine->memoryManager) QQmlSqlDatabaseWrapper(engine));
QV4::ScopedObject p(scope, databaseData(engine)->databaseProto.value());
db->setPrototype(p.getPointer());
db->d()->database = database;
static QV4::ReturnedValue particleData_discard(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
static QV4::ReturnedValue particleData_lifeLeft(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
static QV4::ReturnedValue particleData_curSize(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject);
if (!r || !r->d()->datum)
return ctx->throwError(QStringLiteral("Not a valid ParticleData object"));
#define COLOR_GETTER_AND_SETTER(VAR, NAME) static QV4::ReturnedValue particleData_get_ ## NAME (QV4::CallContext *ctx) \
{ \
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
static QV4::ReturnedValue particleData_set_ ## NAME (QV4::CallContext *ctx)\
{\
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
- double d = ctx->callData->argc ? ctx->callData->args[0].toNumber() : 0; \
+ double d = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : 0; \
r->d()->datum->color. VAR = qMin(255, qMax(0, (int)floor(d * 255.0)));\
return QV4::Encode::undefined(); \
}
#define SEMIBOOL_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \
{ \
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
{\
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
- r->d()->datum-> VARIABLE = (ctx->callData->argc && ctx->callData->args[0].toBoolean()) ? 1.0 : 0.0;\
+ r->d()->datum-> VARIABLE = (ctx->d()->callData->argc && ctx->d()->callData->args[0].toBoolean()) ? 1.0 : 0.0;\
return QV4::Encode::undefined(); \
}
#define FLOAT_GETTER_AND_SETTER(VARIABLE) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \
{ \
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
{\
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
- r->d()->datum-> VARIABLE = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();\
+ r->d()->datum-> VARIABLE = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();\
return QV4::Encode::undefined(); \
}
#define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static QV4::ReturnedValue particleData_get_ ## VARIABLE (QV4::CallContext *ctx) \
{ \
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum) \
ctx->throwError(QStringLiteral("Not a valid ParticleData object")); \
\
static QV4::ReturnedValue particleData_set_ ## VARIABLE (QV4::CallContext *ctx)\
{\
QV4::Scope scope(ctx); \
- QV4::Scoped<QV4ParticleData> r(scope, ctx->callData->thisObject); \
+ QV4::Scoped<QV4ParticleData> r(scope, ctx->d()->callData->thisObject); \
if (!r || !r->d()->datum)\
ctx->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
- r->d()->datum-> SETTER (ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN());\
+ r->d()->datum-> SETTER (ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN());\
return QV4::Encode::undefined(); \
}
int scope = al->scope;
RegisterID context = ContextRegister;
if (scope) {
- loadPtr(Address(ContextRegister, qOffsetOf(ExecutionContext, outer)), baseReg);
+ loadPtr(Address(ContextRegister, qOffsetOf(ExecutionContext::Data, outer)), baseReg);
--scope;
context = baseReg;
while (scope) {
- loadPtr(Address(context, qOffsetOf(ExecutionContext, outer)), context);
+ loadPtr(Address(context, qOffsetOf(ExecutionContext::Data, outer)), context);
--scope;
}
}
switch (al->kind) {
case IR::ArgLocal::Formal:
case IR::ArgLocal::ScopedFormal: {
- loadPtr(Address(context, qOffsetOf(ExecutionContext, callData)), baseReg);
+ loadPtr(Address(context, qOffsetOf(ExecutionContext::Data, callData)), baseReg);
offset = sizeof(CallData) + (al->index - 1) * sizeof(Value);
} break;
case IR::ArgLocal::Local:
Assembler::Pointer Assembler::loadStringAddress(RegisterID reg, const QString &string)
{
- loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, compilationUnit)), Assembler::ScratchRegister);
+ loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), Assembler::ScratchRegister);
loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg);
const int id = _isel->registerString(string);
return Pointer(reg, id * sizeof(QV4::StringValue));
void Assembler::loadStringRef(RegisterID reg, const QString &string)
{
- loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, compilationUnit)), reg);
+ loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), reg);
loadPtr(Address(reg, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg);
const int id = _isel->registerString(string);
addPtr(TrustedImmPtr(id * sizeof(QV4::StringValue)), reg);
void leaveStandardStackFrame();
void checkException() {
- loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext, engine)), ScratchRegister);
+ loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, engine)), ScratchRegister);
load32(Address(ScratchRegister, qOffsetOf(QV4::ExecutionEngine, hasException)), ScratchRegister);
Jump exceptionThrown = branch32(NotEqual, ScratchRegister, TrustedImm32(0));
if (catchBlock)
template <typename T> inline void prepareRelativeCall(const T &, Assembler *){}
template <> inline void prepareRelativeCall(const RelativeCall &relativeCall, Assembler *as)
{
- as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lookups)),
+ as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lookups)),
relativeCall.addr.base);
}
#endif
const int locals = _as->stackLayout().calculateJSStackFrameSize();
- _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
+ _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, engine)), Assembler::ScratchRegister);
_as->loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)), Assembler::LocalsRegister);
_as->addPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
foreach (IR::Stmt *s, _block->statements()) {
if (s->location.isValid()) {
if (int(s->location.startLine) != lastLine) {
- Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lineNumber));
+ Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lineNumber));
_as->store32(Assembler::TrustedImm32(s->location.startLine), lineAddr);
lastLine = s->location.startLine;
}
void InstructionSelection::loadThisObject(IR::Expr *temp)
{
- _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, callData)), Assembler::ScratchRegister);
+ _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, callData)), Assembler::ScratchRegister);
#if defined(VALUE_FITS_IN_REGISTER)
_as->load64(Pointer(Assembler::ScratchRegister, qOffsetOf(CallData, thisObject)),
Assembler::ReturnValueRegister);
const int locals = _as->stackLayout().calculateJSStackFrameSize();
_as->subPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
- _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
+ _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, engine)), Assembler::ScratchRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
_as->leaveStandardStackFrame();
QV4::ScopedValue result(scope);
QV4::Script script(ctx, program, fileName, lineNumber);
- script.strictMode = ctx->strictMode;
+ script.strictMode = ctx->d()->strictMode;
script.inheritContext = true;
script.parse();
if (!scope.engine->hasException)
QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
double dbl = d->value.toNumber();
- if (ctx && ctx->engine->hasException) {
+ if (ctx && ctx->d()->engine->hasException) {
ctx->catchException();
return 0;
}
QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
bool b = d->value.toBoolean();
- if (ctx && ctx->engine->hasException) {
+ if (ctx && ctx->d()->engine->hasException) {
ctx->catchException();
return false;
}
QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
qint32 i = d->value.toInt32();
- if (ctx && ctx->engine->hasException) {
+ if (ctx && ctx->d()->engine->hasException) {
ctx->catchException();
return 0;
}
QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
quint32 u = d->value.toUInt32();
- if (ctx && ctx->engine->hasException) {
+ if (ctx && ctx->d()->engine->hasException) {
ctx->catchException();
return 0;
}
DEFINE_OBJECT_VTABLE(ArgumentsObject);
ArgumentsObject::ArgumentsObject(CallContext *context)
- : Object(context->strictMode ? context->engine->strictArgumentsObjectClass : context->engine->argumentsObjectClass)
+ : Object(context->d()->strictMode ? context->d()->engine->strictArgumentsObjectClass : context->d()->engine->argumentsObjectClass)
{
d()->context = context;
d()->fullyCreated = false;
- ExecutionEngine *v4 = context->engine;
+ ExecutionEngine *v4 = context->d()->engine;
Scope scope(v4);
ScopedObject protectThis(scope, this);
setArrayType(ArrayData::Complex);
- if (context->strictMode) {
- Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->engine->id_callee));
- Q_ASSERT(CallerPropertyIndex == internalClass()->find(context->engine->id_caller));
+ if (context->d()->strictMode) {
+ Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->d()->engine->id_callee));
+ Q_ASSERT(CallerPropertyIndex == internalClass()->find(context->d()->engine->id_caller));
propertyAt(CalleePropertyIndex)->value = v4->thrower;
propertyAt(CalleePropertyIndex)->set = v4->thrower;
propertyAt(CallerPropertyIndex)->value = v4->thrower;
propertyAt(CallerPropertyIndex)->set = v4->thrower;
- arrayReserve(context->callData->argc);
- arrayPut(0, context->callData->args, context->callData->argc);
+ arrayReserve(context->d()->callData->argc);
+ arrayPut(0, context->d()->callData->args, context->d()->callData->argc);
d()->fullyCreated = true;
} else {
setHasAccessorProperty();
- Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->engine->id_callee));
+ Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->d()->engine->id_callee));
memberData()[CalleePropertyIndex] = context->function->asReturnedValue();
}
- Q_ASSERT(LengthPropertyIndex == internalClass()->find(context->engine->id_length));
+ Q_ASSERT(LengthPropertyIndex == internalClass()->find(context->d()->engine->id_length));
memberData()[LengthPropertyIndex] = Primitive::fromInt32(context->realArgumentCount);
Q_ASSERT(internalClass()->vtable == staticVTable());
return;
uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->realArgumentCount);
- uint argCount = qMin(context()->realArgumentCount, context()->callData->argc);
+ uint argCount = qMin(context()->realArgumentCount, context()->d()->callData->argc);
ArrayData::realloc(this, ArrayData::Sparse, 0, argCount, true);
- context()->engine->requireArgumentsAccessors(numAccessors);
+ context()->d()->engine->requireArgumentsAccessors(numAccessors);
mappedArguments().ensureIndex(engine(), numAccessors);
for (uint i = 0; i < (uint)numAccessors; ++i) {
- mappedArguments()[i] = context()->callData->args[i];
- arraySet(i, context()->engine->argumentsAccessors[i], Attr_Accessor);
+ mappedArguments()[i] = context()->d()->callData->args[i];
+ arraySet(i, context()->d()->engine->argumentsAccessors[i], Attr_Accessor);
}
- arrayPut(numAccessors, context()->callData->args + numAccessors, argCount - numAccessors);
+ arrayPut(numAccessors, context()->d()->callData->args + numAccessors, argCount - numAccessors);
for (uint i = numAccessors; i < argCount; ++i)
setArrayAttributes(i, Attr_Data);
bool isMapped = false;
uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->realArgumentCount);
if (pd && index < (uint)numAccessors)
- isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->engine->argumentsAccessors[index].getter();
+ isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->d()->engine->argumentsAccessors[index].getter();
if (isMapped) {
mapAttrs = arrayData()->attributes(index);
pd->value = mappedArguments()[index];
}
- bool strict = ctx->strictMode;
- ctx->strictMode = false;
+ bool strict = ctx->d()->strictMode;
+ ctx->d()->strictMode = false;
bool result = Object::defineOwnProperty2(ctx, index, desc, attrs);
- ctx->strictMode = strict;
+ ctx->d()->strictMode = strict;
if (isMapped && attrs.isData()) {
ScopedCallData callData(scope, 1);
}
}
- if (ctx->strictMode && !result)
+ if (ctx->d()->strictMode && !result)
return ctx->throwTypeError();
return result;
}
if (args->fullyCreated())
return Object::getIndexed(m, index, hasProperty);
- if (index < static_cast<uint>(args->context()->callData->argc)) {
+ if (index < static_cast<uint>(args->context()->d()->callData->argc)) {
if (hasProperty)
*hasProperty = true;
- return args->context()->callData->args[index].asReturnedValue();
+ return args->context()->d()->callData->args[index].asReturnedValue();
}
if (hasProperty)
*hasProperty = false;
void ArgumentsObject::putIndexed(Managed *m, uint index, const ValueRef value)
{
ArgumentsObject *args = static_cast<ArgumentsObject *>(m);
- if (!args->fullyCreated() && index >= static_cast<uint>(args->context()->callData->argc))
+ if (!args->fullyCreated() && index >= static_cast<uint>(args->context()->d()->callData->argc))
args->fullyCreate();
if (args->fullyCreated()) {
return;
}
- args->context()->callData->args[index] = value;
+ args->context()->d()->callData->args[index] = value;
}
bool ArgumentsObject::deleteIndexedProperty(Managed *m, uint index)
return Object::queryIndexed(m, index);
uint numAccessors = qMin((int)args->context()->function->formalParameterCount(), args->context()->realArgumentCount);
- uint argCount = qMin(args->context()->realArgumentCount, args->context()->callData->argc);
+ uint argCount = qMin(args->context()->realArgumentCount, args->context()->d()->callData->argc);
if (index >= argCount)
return PropertyAttributes();
if (index >= numAccessors)
if (!o)
return v4->currentContext()->throwTypeError();
- Q_ASSERT(g->index() < static_cast<unsigned>(o->context()->callData->argc));
+ Q_ASSERT(g->index() < static_cast<unsigned>(o->context()->d()->callData->argc));
return o->context()->argument(g->index());
}
if (!o)
return v4->currentContext()->throwTypeError();
- Q_ASSERT(s->index() < static_cast<unsigned>(o->context()->callData->argc));
- o->context()->callData->args[s->index()] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined();
+ Q_ASSERT(s->index() < static_cast<unsigned>(o->context()->d()->callData->argc));
+ o->context()->d()->callData->args[s->index()] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined();
return Encode::undefined();
}
static bool isNonStrictArgumentsObject(Managed *m) {
return m->internalClass()->vtable->type == Type_ArgumentsObject &&
- !static_cast<ArgumentsObject *>(m)->context()->strictMode;
+ !static_cast<ArgumentsObject *>(m)->context()->d()->strictMode;
}
enum {
ReturnedValue ArrayPrototype::method_isArray(CallContext *ctx)
{
- bool isArray = ctx->callData->argc && ctx->callData->args[0].asArrayObject();
+ bool isArray = ctx->d()->callData->argc && ctx->d()->callData->args[0].asArrayObject();
return Encode(isArray);
}
ReturnedValue ArrayPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->callData->thisObject, ScopedObject::Convert);
- if (ctx->engine->hasException)
+ ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert);
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
- ScopedString s(scope, ctx->engine->newString(QStringLiteral("join")));
+ ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("join")));
ScopedFunctionObject f(scope, o->get(s));
if (!!f) {
ScopedCallData d(scope, 0);
- d->thisObject = ctx->callData->thisObject;
+ d->thisObject = ctx->d()->callData->thisObject;
return f->call(d);
}
return ObjectPrototype::method_toString(ctx);
ReturnedValue ArrayPrototype::method_concat(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject result(scope, ctx->engine->newArrayObject());
+ ScopedObject result(scope, ctx->d()->engine->newArrayObject());
- ScopedObject thisObject(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject thisObject(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!thisObject)
return Encode::undefined();
ScopedArrayObject instance(scope, thisObject);
ScopedArrayObject elt(scope);
ScopedObject eltAsObj(scope);
ScopedValue entry(scope);
- for (int i = 0; i < ctx->callData->argc; ++i) {
- eltAsObj = ctx->callData->args[i];
- elt = ctx->callData->args[i];
+ for (int i = 0; i < ctx->d()->callData->argc; ++i) {
+ eltAsObj = ctx->d()->callData->args[i];
+ elt = ctx->d()->callData->args[i];
if (elt) {
uint n = elt->getLength();
uint newLen = ArrayData::append(result.getPointer(), elt.getPointer(), n);
result->putIndexed(startIndex + i, entry);
}
} else {
- result->arraySet(result->getLength(), ValueRef(ctx->callData->args[i]));
+ result->arraySet(result->getLength(), ValueRef(ctx->d()->callData->args[i]));
}
}
else
r4 = arg->toQString();
- ScopedObject self(scope, ctx->callData->thisObject);
- ScopedValue length(scope, self->get(ctx->engine->id_length));
+ ScopedObject self(scope, ctx->d()->callData->thisObject);
+ ScopedValue length(scope, self->get(ctx->d()->engine->id_length));
const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32();
if (!r2)
- return ctx->engine->newString(QString())->asReturnedValue();
+ return ctx->d()->engine->newString(QString())->asReturnedValue();
QString R;
//
// crazy!
//
- ScopedString name(scope, ctx->engine->newString(QStringLiteral("0")));
+ ScopedString name(scope, ctx->d()->engine->newString(QStringLiteral("0")));
ScopedValue r6(scope, self->get(name));
if (!r6->isNullOrUndefined())
R = r6->toString(ctx)->toQString();
}
}
- return ctx->engine->newString(R)->asReturnedValue();
+ return ctx->d()->engine->newString(R)->asReturnedValue();
}
ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
if (!len) {
if (!instance->isArrayObject())
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
return Encode::undefined();
}
if (instance->isArrayObject())
instance->setArrayLength(len - 1);
else
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
return result.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
- if (len + ctx->callData->argc < len) {
+ if (len + ctx->d()->callData->argc < len) {
// ughh...
double l = len;
ScopedString s(scope);
- for (int i = 0; i < ctx->callData->argc; ++i) {
+ for (int i = 0; i < ctx->d()->callData->argc; ++i) {
s = Primitive::fromDouble(l + i).toString(ctx);
- instance->put(s, ctx->callData->args[i]);
+ instance->put(s, ctx->d()->callData->args[i]);
}
- double newLen = l + ctx->callData->argc;
+ double newLen = l + ctx->d()->callData->argc;
if (!instance->isArrayObject())
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
else {
- ScopedString str(scope, ctx->engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
+ ScopedString str(scope, ctx->d()->engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
return ctx->throwRangeError(str);
}
return Encode(newLen);
}
- if (!ctx->callData->argc) {
+ if (!ctx->d()->callData->argc) {
;
} else if (!instance->protoHasArray() && instance->arrayData()->length() <= len && instance->arrayType() == ArrayData::Simple) {
- instance->arrayData()->vtable()->putArray(instance.getPointer(), len, ctx->callData->args, ctx->callData->argc);
+ instance->arrayData()->vtable()->putArray(instance.getPointer(), len, ctx->d()->callData->args, ctx->d()->callData->argc);
len = instance->arrayData()->length();
} else {
- for (int i = 0; i < ctx->callData->argc; ++i)
- instance->putIndexed(len + i, ctx->callData->args[i]);
- len += ctx->callData->argc;
+ for (int i = 0; i < ctx->d()->callData->argc; ++i)
+ instance->putIndexed(len + i, ctx->d()->callData->args[i]);
+ len += ctx->d()->callData->argc;
}
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len);
else
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len)));
return Encode(len);
}
ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint length = instance->getLength();
ReturnedValue ArrayPrototype::method_shift(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
if (!len) {
if (!instance->isArrayObject())
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
return Encode::undefined();
}
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len - 1);
else
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
return result.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_slice(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!o)
return Encode::undefined();
- Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> result(scope, ctx->d()->engine->newArrayObject());
uint len = o->getLength();
double s = ScopedValue(scope, ctx->argument(0))->toInteger();
uint start;
else
start = (uint) s;
uint end = len;
- if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) {
- double e = ctx->callData->args[1].toInteger();
+ if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) {
+ double e = ctx->d()->callData->args[1].toInteger();
if (e < 0)
end = (uint)qMax(len + e, 0.);
else if (e > len)
ReturnedValue ArrayPrototype::method_sort(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
ScopedValue comparefn(scope, ctx->argument(0));
ArrayData::sort(ctx, instance, comparefn, len);
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
- Scoped<ArrayObject> newArray(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> newArray(scope, ctx->d()->engine->newArrayObject());
double rs = ScopedValue(scope, ctx->argument(0))->toInteger();
uint start;
}
newArray->setArrayLengthUnchecked(deleteCount);
- uint itemCount = ctx->callData->argc < 2 ? 0 : ctx->callData->argc - 2;
+ uint itemCount = ctx->d()->callData->argc < 2 ? 0 : ctx->d()->callData->argc - 2;
if (itemCount < deleteCount) {
for (uint k = start; k < len - deleteCount; ++k) {
}
for (uint i = 0; i < itemCount; ++i) {
- instance->putIndexed(start + i, ctx->callData->args[i + 2]);
+ instance->putIndexed(start + i, ctx->d()->callData->args[i + 2]);
if (scope.hasException())
return Encode::undefined();
}
- ctx->strictMode = true;
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount)));
+ ctx->d()->strictMode = true;
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount)));
return newArray.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
if (!instance->protoHasArray() && !instance->arrayData()->hasAttributes() && instance->arrayData()->length() <= len) {
- instance->arrayData()->vtable()->push_front(instance.getPointer(), ctx->callData->args, ctx->callData->argc);
+ instance->arrayData()->vtable()->push_front(instance.getPointer(), ctx->d()->callData->args, ctx->d()->callData->argc);
} else {
ScopedValue v(scope);
for (uint k = len; k > 0; --k) {
bool exists;
v = instance->getIndexed(k - 1, &exists);
if (exists)
- instance->putIndexed(k + ctx->callData->argc - 1, v);
+ instance->putIndexed(k + ctx->d()->callData->argc - 1, v);
else
- instance->deleteIndexedProperty(k + ctx->callData->argc - 1);
+ instance->deleteIndexedProperty(k + ctx->d()->callData->argc - 1);
}
- for (int i = 0; i < ctx->callData->argc; ++i)
- instance->putIndexed(i, ctx->callData->args[i]);
+ for (int i = 0; i < ctx->d()->callData->argc; ++i)
+ instance->putIndexed(i, ctx->d()->callData->args[i]);
}
- uint newLen = len + ctx->callData->argc;
+ uint newLen = len + ctx->d()->callData->argc;
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(newLen);
else
- instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
+ instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
return Encode(newLen);
}
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
if (!len)
return Encode(-1);
- ScopedValue searchValue(scope, ctx->callData->argument(0));
+ ScopedValue searchValue(scope, ctx->d()->callData->argument(0));
uint fromIndex = 0;
- if (ctx->callData->argc >= 2) {
- double f = ctx->callData->args[1].toInteger();
+ if (ctx->d()->callData->argc >= 2) {
+ double f = ctx->d()->callData->args[1].toInteger();
if (scope.hasException())
return Encode::undefined();
if (f >= len)
{
Scope scope(ctx);
- ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
uint len = instance->getLength();
ScopedValue searchValue(scope);
uint fromIndex = len;
- if (ctx->callData->argc >= 1)
+ if (ctx->d()->callData->argc >= 1)
searchValue = ctx->argument(0);
else
searchValue = Primitive::undefinedValue();
- if (ctx->callData->argc >= 2) {
- double f = ctx->callData->args[1].toInteger();
+ if (ctx->d()->callData->argc >= 2) {
+ double f = ctx->d()->callData->args[1].toInteger();
if (scope.hasException())
return Encode::undefined();
if (f > 0)
ReturnedValue ArrayPrototype::method_every(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
ReturnedValue ArrayPrototype::method_some(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
ReturnedValue ArrayPrototype::method_map(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
if (!callback)
return ctx->throwTypeError();
- Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
a->arrayReserve(len);
a->setArrayLengthUnchecked(len);
ReturnedValue ArrayPrototype::method_filter(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
if (!callback)
return ctx->throwTypeError();
- Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
a->arrayReserve(len);
ScopedValue selected(scope);
ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
ScopedValue acc(scope);
ScopedValue v(scope);
- if (ctx->callData->argc > 1) {
+ if (ctx->d()->callData->argc > 1) {
acc = ctx->argument(1);
} else {
bool kPresent = false;
ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> instance(scope, ctx->callData->thisObject.toObject(ctx));
+ Scoped<Object> instance(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!instance)
return Encode::undefined();
return ctx->throwTypeError();
if (len == 0) {
- if (ctx->callData->argc == 1)
+ if (ctx->d()->callData->argc == 1)
return ctx->throwTypeError();
return ctx->argument(1);
}
uint k = len;
ScopedValue acc(scope);
ScopedValue v(scope);
- if (ctx->callData->argc > 1) {
+ if (ctx->d()->callData->argc > 1) {
acc = ctx->argument(1);
} else {
bool kPresent = false;
ReturnedValue BooleanPrototype::method_toString(CallContext *ctx)
{
bool result;
- if (ctx->callData->thisObject.isBoolean()) {
- result = ctx->callData->thisObject.booleanValue();
+ if (ctx->d()->callData->thisObject.isBoolean()) {
+ result = ctx->d()->callData->thisObject.booleanValue();
} else {
Scope scope(ctx);
- Scoped<BooleanObject> thisObject(scope, ctx->callData->thisObject);
+ Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
return ctx->throwTypeError();
result = thisObject->value().booleanValue();
}
- return Encode(ctx->engine->newString(QLatin1String(result ? "true" : "false")));
+ return Encode(ctx->d()->engine->newString(QLatin1String(result ? "true" : "false")));
}
ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx)
{
- if (ctx->callData->thisObject.isBoolean())
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->thisObject.isBoolean())
+ return ctx->d()->callData->thisObject.asReturnedValue();
Scope scope(ctx);
- Scoped<BooleanObject> thisObject(scope, ctx->callData->thisObject);
+ Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject);
if (!thisObject)
return ctx->throwTypeError();
{
Q_ASSERT(function->function());
- CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc)));
- new (c) CallContext(engine, Type_CallContext);
+ CallContext *c = static_cast<CallContext *>(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc)));
+ new (c) CallContext(d()->engine, Type_CallContext);
c->function = function;
c->realArgumentCount = callData->argc;
- c->strictMode = function->strictMode();
- c->outer = function->scope();
+ c->d()->strictMode = function->strictMode();
+ c->d()->outer = function->scope();
c->activation = 0;
- c->compilationUnit = function->function()->compilationUnit;
- c->lookups = c->compilationUnit->runtimeLookups;
+ c->d()->compilationUnit = function->function()->compilationUnit;
+ c->d()->lookups = c->d()->compilationUnit->runtimeLookups;
c->locals = (Value *)((quintptr(c + 1) + 7) & ~7);
const CompiledData::Function *compiledFunction = function->function()->compiledFunction;
if (nLocals)
std::fill(c->locals, c->locals + nLocals, Primitive::undefinedValue());
- c->callData = reinterpret_cast<CallData *>(c->locals + nLocals);
- ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value));
+ c->d()->callData = reinterpret_cast<CallData *>(c->locals + nLocals);
+ ::memcpy(c->d()->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value));
if (callData->argc < static_cast<int>(compiledFunction->nFormals))
- std::fill(c->callData->args + c->callData->argc, c->callData->args + compiledFunction->nFormals, Primitive::undefinedValue());
- c->callData->argc = qMax((uint)callData->argc, compiledFunction->nFormals);
+ std::fill(c->d()->callData->args + c->d()->callData->argc, c->d()->callData->args + compiledFunction->nFormals, Primitive::undefinedValue());
+ c->d()->callData->argc = qMax((uint)callData->argc, compiledFunction->nFormals);
return c;
}
WithContext *ExecutionContext::newWithContext(ObjectRef with)
{
- WithContext *w = new (engine->memoryManager) WithContext(engine, with);
+ WithContext *w = new (d()->engine->memoryManager) WithContext(d()->engine, with);
return w;
}
CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue)
{
- CatchContext *c = new (engine->memoryManager) CatchContext(engine, exceptionVarName, exceptionValue);
+ CatchContext *c = new (d()->engine->memoryManager) CatchContext(d()->engine, exceptionVarName, exceptionValue);
return c;
}
CallContext *ExecutionContext::newQmlContext(FunctionObject *f, ObjectRef qml)
{
- CallContext *c = static_cast<CallContext *>(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0)));
- new (c) CallContext(engine, qml, f);
+ CallContext *c = static_cast<CallContext *>(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0)));
+ new (c) CallContext(d()->engine, qml, f);
return c;
}
Scope scope(this);
// find the right context to create the binding on
- ScopedObject activation(scope, engine->globalObject);
+ ScopedObject activation(scope, d()->engine->globalObject);
ExecutionContext *ctx = this;
while (ctx) {
- if (ctx->type >= Type_CallContext) {
+ if (ctx->d()->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
if (!c->activation)
- c->activation = engine->newObject()->getPointer();
+ c->activation = d()->engine->newObject()->getPointer();
activation = c->activation;
break;
}
- ctx = ctx->outer;
+ ctx = ctx->d()->outer;
}
if (activation->hasProperty(name))
WithContext::WithContext(ExecutionEngine *engine, ObjectRef with)
: ExecutionContext(engine, Type_WithContext)
{
- callData = parent->callData;
- outer = parent;
- lookups = parent->lookups;
- compilationUnit = parent->compilationUnit;
+ d()->callData = d()->parent->d()->callData;
+ d()->outer = d()->parent;
+ d()->lookups = d()->parent->d()->lookups;
+ d()->compilationUnit = d()->parent->d()->compilationUnit;
withObject = with.getPointer();
}
CatchContext::CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue)
: ExecutionContext(engine, Type_CatchContext)
{
- strictMode = parent->strictMode;
- callData = parent->callData;
- outer = parent;
- lookups = parent->lookups;
- compilationUnit = parent->compilationUnit;
+ d()->strictMode = d()->parent->d()->strictMode;
+ d()->callData = d()->parent->d()->callData;
+ d()->outer = d()->parent;
+ d()->lookups = d()->parent->d()->lookups;
+ d()->compilationUnit = d()->parent->d()->compilationUnit;
this->exceptionVarName = exceptionVarName;
this->exceptionValue = exceptionValue;
: ExecutionContext(engine, Type_QmlContext)
{
this->function = function;
- callData = reinterpret_cast<CallData *>(this + 1);
- callData->tag = QV4::Value::_Integer_Type;
- callData->argc = 0;
- callData->thisObject = Primitive::undefinedValue();
+ d()->callData = reinterpret_cast<CallData *>(this + 1);
+ d()->callData->tag = QV4::Value::_Integer_Type;
+ d()->callData->argc = 0;
+ d()->callData->thisObject = Primitive::undefinedValue();
- strictMode = true;
- outer = function->scope();
+ d()->strictMode = true;
+ d()->outer = function->scope();
activation = qml.getPointer();
if (function->function()) {
- compilationUnit = function->function()->compilationUnit;
- lookups = compilationUnit->runtimeLookups;
+ d()->compilationUnit = function->function()->compilationUnit;
+ d()->lookups = d()->compilationUnit->runtimeLookups;
}
locals = (Value *)(this + 1);
{
Scope scope(this);
bool hasWith = false;
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
- if (ctx->type == Type_WithContext) {
+ for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) {
+ if (ctx->d()->type == Type_WithContext) {
hasWith = true;
WithContext *w = static_cast<WithContext *>(ctx);
if (w->withObject->hasProperty(name))
return w->withObject->deleteProperty(name);
- } else if (ctx->type == Type_CatchContext) {
+ } else if (ctx->d()->type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
return false;
- } else if (ctx->type >= Type_CallContext) {
+ } else if (ctx->d()->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
FunctionObject *f = c->function;
if (f->needsActivation() || hasWith) {
}
if (c->activation && c->activation->hasProperty(name))
return c->activation->deleteProperty(name);
- } else if (ctx->type == Type_GlobalContext) {
+ } else if (ctx->d()->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
if (g->global->hasProperty(name))
return g->global->deleteProperty(name);
}
}
- if (strictMode)
+ if (d()->strictMode)
throwSyntaxError(QStringLiteral("Can't delete property %1").arg(name->toQString()));
return true;
}
bool CallContext::needsOwnArguments() const
{
- return function->needsActivation() || callData->argc < static_cast<int>(function->formalParameterCount());
+ return function->needsActivation() || d()->callData->argc < static_cast<int>(function->formalParameterCount());
}
void ExecutionContext::markObjects(Managed *m, ExecutionEngine *engine)
{
ExecutionContext *ctx = static_cast<ExecutionContext *>(m);
- if (ctx->outer)
- ctx->outer->mark(engine);
+ if (ctx->d()->outer)
+ ctx->d()->outer->mark(engine);
// ### shouldn't need these 3 lines
- ctx->callData->thisObject.mark(engine);
- for (int arg = 0; arg < ctx->callData->argc; ++arg)
- ctx->callData->args[arg].mark(engine);
+ ctx->d()->callData->thisObject.mark(engine);
+ for (int arg = 0; arg < ctx->d()->callData->argc; ++arg)
+ ctx->d()->callData->args[arg].mark(engine);
- if (ctx->type >= Type_CallContext) {
+ if (ctx->d()->type >= Type_CallContext) {
QV4::CallContext *c = static_cast<CallContext *>(ctx);
for (unsigned local = 0, lastLocal = c->function->varCount(); local < lastLocal; ++local)
c->locals[local].mark(engine);
if (c->activation)
c->activation->mark(engine);
c->function->mark(engine);
- } else if (ctx->type == Type_WithContext) {
+ } else if (ctx->d()->type == Type_WithContext) {
WithContext *w = static_cast<WithContext *>(ctx);
w->withObject->mark(engine);
- } else if (ctx->type == Type_CatchContext) {
+ } else if (ctx->d()->type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(ctx);
c->exceptionVarName->mark(engine);
c->exceptionValue.mark(engine);
- } else if (ctx->type == Type_GlobalContext) {
+ } else if (ctx->d()->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
g->global->mark(engine);
}
void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
{
Scope scope(this);
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
- if (ctx->type == Type_WithContext) {
+ for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) {
+ if (ctx->d()->type == Type_WithContext) {
ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
if (w->hasProperty(name)) {
w->put(name, value);
return;
}
- } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
+ } else if (ctx->d()->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
static_cast<CatchContext *>(ctx)->exceptionValue = *value;
return;
} else {
ScopedObject activation(scope, (Object *)0);
- if (ctx->type >= Type_CallContext) {
+ if (ctx->d()->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
if (c->function->function()) {
uint index = c->function->function()->internalClass->find(name);
if (index < UINT_MAX) {
if (index < c->function->formalParameterCount()) {
- c->callData->args[c->function->formalParameterCount() - index - 1] = *value;
+ c->d()->callData->args[c->function->formalParameterCount() - index - 1] = *value;
} else {
index -= c->function->formalParameterCount();
c->locals[index] = *value;
}
}
activation = c->activation;
- } else if (ctx->type == Type_GlobalContext) {
+ } else if (ctx->d()->type == Type_GlobalContext) {
activation = static_cast<GlobalContext *>(ctx)->global;
}
if (activation) {
- if (ctx->type == Type_QmlContext) {
+ if (ctx->d()->type == Type_QmlContext) {
activation->put(name, value);
return;
} else {
}
}
}
- if (strictMode || name->equals(engine->id_this)) {
+ if (d()->strictMode || name->equals(d()->engine->id_this)) {
ScopedValue n(scope, name.asReturnedValue());
throwReferenceError(n);
return;
}
- engine->globalObject->put(name, value);
+ d()->engine->globalObject->put(name, value);
}
ReturnedValue ExecutionContext::getProperty(const StringRef name)
ScopedValue v(scope);
name->makeIdentifier();
- if (name->equals(engine->id_this))
- return callData->thisObject.asReturnedValue();
+ if (name->equals(d()->engine->id_this))
+ return d()->callData->thisObject.asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
- if (ctx->type == Type_WithContext) {
+ for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) {
+ if (ctx->d()->type == Type_WithContext) {
ScopedObject w(scope, static_cast<WithContext *>(ctx)->withObject);
hasWith = true;
bool hasProperty = false;
continue;
}
- else if (ctx->type == Type_CatchContext) {
+ else if (ctx->d()->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
- else if (ctx->type >= Type_CallContext) {
+ else if (ctx->d()->type >= Type_CallContext) {
QV4::CallContext *c = static_cast<CallContext *>(ctx);
ScopedFunctionObject f(scope, c->function);
if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) {
uint index = f->function()->internalClass->find(name);
if (index < UINT_MAX) {
if (index < c->function->formalParameterCount())
- return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
+ return c->d()->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
return c->locals[index - c->function->formalParameterCount()].asReturnedValue();
}
}
return f.asReturnedValue();
}
- else if (ctx->type == Type_GlobalContext) {
+ else if (ctx->d()->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
v = g->global->get(name, &hasProperty);
base = (Object *)0;
name->makeIdentifier();
- if (name->equals(engine->id_this))
- return callData->thisObject.asReturnedValue();
+ if (name->equals(d()->engine->id_this))
+ return d()->callData->thisObject.asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
- for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
- if (ctx->type == Type_WithContext) {
+ for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) {
+ if (ctx->d()->type == Type_WithContext) {
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
continue;
}
- else if (ctx->type == Type_CatchContext) {
+ else if (ctx->d()->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
- else if (ctx->type >= Type_CallContext) {
+ else if (ctx->d()->type >= Type_CallContext) {
QV4::CallContext *c = static_cast<CallContext *>(ctx);
FunctionObject *f = c->function;
if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) {
uint index = f->function()->internalClass->find(name);
if (index < UINT_MAX) {
if (index < c->function->formalParameterCount())
- return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
+ return c->d()->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue();
return c->locals[index - c->function->formalParameterCount()].asReturnedValue();
}
}
bool hasProperty = false;
v = c->activation->get(name, &hasProperty);
if (hasProperty) {
- if (ctx->type == Type_QmlContext)
+ if (ctx->d()->type == Type_QmlContext)
base = c->activation;
return v.asReturnedValue();
}
return c->function->asReturnedValue();
}
- else if (ctx->type == Type_GlobalContext) {
+ else if (ctx->d()->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
v = g->global->get(name, &hasProperty);
ReturnedValue ExecutionContext::throwError(const ValueRef value)
{
- return engine->throwException(value);
+ return d()->engine->throwException(value);
}
ReturnedValue ExecutionContext::throwError(const QString &message)
{
Scope scope(this);
- ScopedValue v(scope, engine->newString(message));
- v = engine->newErrorObject(v);
+ ScopedValue v(scope, d()->engine->newString(message));
+ v = d()->engine->newErrorObject(v);
return throwError(v);
}
ReturnedValue ExecutionContext::throwSyntaxError(const QString &message, const QString &fileName, int line, int column)
{
Scope scope(this);
- Scoped<Object> error(scope, engine->newSyntaxErrorObject(message, fileName, line, column));
+ Scoped<Object> error(scope, d()->engine->newSyntaxErrorObject(message, fileName, line, column));
return throwError(error);
}
ReturnedValue ExecutionContext::throwSyntaxError(const QString &message)
{
Scope scope(this);
- Scoped<Object> error(scope, engine->newSyntaxErrorObject(message));
+ Scoped<Object> error(scope, d()->engine->newSyntaxErrorObject(message));
return throwError(error);
}
ReturnedValue ExecutionContext::throwTypeError()
{
Scope scope(this);
- Scoped<Object> error(scope, engine->newTypeErrorObject(QStringLiteral("Type error")));
+ Scoped<Object> error(scope, d()->engine->newTypeErrorObject(QStringLiteral("Type error")));
return throwError(error);
}
ReturnedValue ExecutionContext::throwTypeError(const QString &message)
{
Scope scope(this);
- Scoped<Object> error(scope, engine->newTypeErrorObject(message));
+ Scoped<Object> error(scope, d()->engine->newTypeErrorObject(message));
return throwError(error);
}
ReturnedValue ExecutionContext::throwUnimplemented(const QString &message)
{
Scope scope(this);
- ScopedValue v(scope, engine->newString(QStringLiteral("Unimplemented ") + message));
- v = engine->newErrorObject(v);
+ ScopedValue v(scope, d()->engine->newString(QStringLiteral("Unimplemented ") + message));
+ v = d()->engine->newErrorObject(v);
return throwError(v);
}
ReturnedValue ExecutionContext::catchException(StackTrace *trace)
{
- return engine->catchException(this, trace);
+ return d()->engine->catchException(this, trace);
}
ReturnedValue ExecutionContext::throwReferenceError(const ValueRef value)
Scope scope(this);
Scoped<String> s(scope, value->toString(this));
QString msg = s->toQString() + QStringLiteral(" is not defined");
- Scoped<Object> error(scope, engine->newReferenceErrorObject(msg));
+ Scoped<Object> error(scope, d()->engine->newReferenceErrorObject(msg));
return throwError(error);
}
{
Scope scope(this);
QString msg = message;
- Scoped<Object> error(scope, engine->newReferenceErrorObject(msg, fileName, line, column));
+ Scoped<Object> error(scope, d()->engine->newReferenceErrorObject(msg, fileName, line, column));
return throwError(error);
}
Scope scope(this);
ScopedString s(scope, value->toString(this));
QString msg = s->toQString() + QStringLiteral(" out of range");
- ScopedObject error(scope, engine->newRangeErrorObject(msg));
+ ScopedObject error(scope, d()->engine->newRangeErrorObject(msg));
return throwError(error);
}
ReturnedValue ExecutionContext::throwRangeError(const QString &message)
{
Scope scope(this);
- ScopedObject error(scope, engine->newRangeErrorObject(message));
+ ScopedObject error(scope, d()->engine->newRangeErrorObject(message));
return throwError(error);
}
ReturnedValue ExecutionContext::throwURIError(const ValueRef msg)
{
Scope scope(this);
- ScopedObject error(scope, engine->newURIErrorObject(msg));
+ ScopedObject error(scope, d()->engine->newURIErrorObject(msg));
return throwError(error);
}
struct Q_QML_EXPORT ExecutionContext : public Managed
{
- V4_MANAGED
- Q_MANAGED_TYPE(ExecutionContext)
enum {
IsExecutionContext = true
};
Type_CallContext = 0x5,
Type_QmlContext = 0x6
};
-
- ExecutionContext(ExecutionEngine *engine, ContextType t)
- : Managed(engine->executionContextClass)
+ struct EvalCode
{
- this->type = t;
- strictMode = false;
- this->engine = engine;
- this->parent = engine->currentContext();
- outer = 0;
- lookups = 0;
- compilationUnit = 0;
- currentEvalCode = 0;
- lineNumber = -1;
- engine->current = this;
- }
+ Function *function;
+ EvalCode *next;
+ };
- ContextType type;
- bool strictMode;
+ struct Data : Managed::Data {
+ ContextType type;
+ bool strictMode;
- CallData *callData;
+ CallData *callData;
- ExecutionEngine *engine;
- ExecutionContext *parent;
- ExecutionContext *outer;
- Lookup *lookups;
- CompiledData::CompilationUnit *compilationUnit;
+ ExecutionEngine *engine;
+ ExecutionContext *parent;
+ ExecutionContext *outer;
+ Lookup *lookups;
+ CompiledData::CompilationUnit *compilationUnit;
+ EvalCode *currentEvalCode;
+
+ int lineNumber;
- struct EvalCode
- {
- Function *function;
- EvalCode *next;
};
- EvalCode *currentEvalCode;
+ struct {
+ ContextType type;
+ bool strictMode;
+
+ CallData *callData;
- int lineNumber;
+ ExecutionEngine *engine;
+ ExecutionContext *parent;
+ ExecutionContext *outer;
+ Lookup *lookups;
+ CompiledData::CompilationUnit *compilationUnit;
+ EvalCode *currentEvalCode;
+
+ int lineNumber;
+ } __data;
+
+ V4_MANAGED_NEW
+ Q_MANAGED_TYPE(ExecutionContext)
+
+ ExecutionContext(ExecutionEngine *engine, ContextType t)
+ : Managed(engine->executionContextClass)
+ {
+ d()->type = t;
+ d()->strictMode = false;
+ d()->engine = engine;
+ d()->parent = engine->currentContext();
+ d()->outer = 0;
+ d()->lookups = 0;
+ d()->compilationUnit = 0;
+ d()->currentEvalCode = 0;
+ d()->lineNumber = -1;
+ engine->current = this;
+ }
CallContext *newCallContext(FunctionObject *f, CallData *callData);
WithContext *newWithContext(ObjectRef with);
};
inline ReturnedValue CallContext::argument(int i) {
- return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
+ return i < d()->callData->argc ? d()->callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
}
struct GlobalContext : public ExecutionContext
inline CallContext *ExecutionContext::asCallContext()
{
- return type >= Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0;
+ return d()->type >= Type_SimpleCallContext ? static_cast<CallContext *>(this) : 0;
}
inline const CallContext *ExecutionContext::asCallContext() const
{
- return type >= Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0;
+ return d()->type >= Type_SimpleCallContext ? static_cast<const CallContext *>(this) : 0;
}
inline void ExecutionEngine::pushContext(CallContext *context)
{
- context->parent = current;
+ context->d()->parent = current;
current = context;
- current->currentEvalCode = 0;
+ current->d()->currentEvalCode = 0;
}
inline ExecutionContext *ExecutionEngine::popContext()
{
- Q_ASSERT(current->parent);
- current = current->parent;
+ Q_ASSERT(current->d()->parent);
+ current = current->d()->parent;
return current;
}
ExecutionContext *savedContext;
ExecutionContextSaver(ExecutionContext *context)
- : engine(context->engine)
+ : engine(context->d()->engine)
, savedContext(context)
{
}
};
inline Scope::Scope(ExecutionContext *ctx)
- : engine(ctx->engine)
+ : engine(ctx->d()->engine)
#ifndef QT_NO_DEBUG
, size(0)
#endif
double DatePrototype::getThisDate(ExecutionContext *ctx)
{
- if (DateObject *thisObject = ctx->callData->thisObject.asDateObject())
+ if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject())
return thisObject->date().asDouble();
else {
ctx->throwTypeError();
ReturnedValue DatePrototype::method_parse(CallContext *ctx)
{
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return Encode(qSNaN());
- return Encode(ParseString(ctx->callData->args[0].toString(ctx)->toQString()));
+ return Encode(ParseString(ctx->d()->callData->args[0].toString(ctx)->toQString()));
}
ReturnedValue DatePrototype::method_UTC(CallContext *ctx)
{
- const int numArgs = ctx->callData->argc;
+ const int numArgs = ctx->d()->callData->argc;
if (numArgs >= 2) {
- double year = ctx->callData->args[0].toNumber();
- double month = ctx->callData->args[1].toNumber();
- double day = numArgs >= 3 ? ctx->callData->args[2].toNumber() : 1;
- double hours = numArgs >= 4 ? ctx->callData->args[3].toNumber() : 0;
- double mins = numArgs >= 5 ? ctx->callData->args[4].toNumber() : 0;
- double secs = numArgs >= 6 ? ctx->callData->args[5].toNumber() : 0;
- double ms = numArgs >= 7 ? ctx->callData->args[6].toNumber() : 0;
+ double year = ctx->d()->callData->args[0].toNumber();
+ double month = ctx->d()->callData->args[1].toNumber();
+ double day = numArgs >= 3 ? ctx->d()->callData->args[2].toNumber() : 1;
+ double hours = numArgs >= 4 ? ctx->d()->callData->args[3].toNumber() : 0;
+ double mins = numArgs >= 5 ? ctx->d()->callData->args[4].toNumber() : 0;
+ double secs = numArgs >= 6 ? ctx->d()->callData->args[5].toNumber() : 0;
+ double ms = numArgs >= 7 ? ctx->d()->callData->args[6].toNumber() : 0;
if (year >= 0 && year <= 99)
year += 1900;
double t = MakeDate(MakeDay(year, month, day),
ReturnedValue DatePrototype::method_toString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_toDateString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToDateString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToDateString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_toTimeString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToTimeString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToTimeString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_toLocaleString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToLocaleString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToLocaleString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_toLocaleDateString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToLocaleDateString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToLocaleDateString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_toLocaleTimeString(CallContext *ctx)
{
double t = getThisDate(ctx);
- return ctx->engine->newString(ToLocaleTimeString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToLocaleTimeString(t))->asReturnedValue();
}
ReturnedValue DatePrototype::method_valueOf(CallContext *ctx)
ReturnedValue DatePrototype::method_setTime(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DateObject> self(scope, ctx->callData->thisObject);
+ Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
if (!self)
return ctx->throwTypeError();
- double t = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double t = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(t));
return self->date().asReturnedValue();
}
ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<DateObject> self(scope, ctx->callData->thisObject);
+ Scoped<DateObject> self(scope, ctx->d()->callData->thisObject);
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
return self->date().asReturnedValue();
}
ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
self->date().setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
return self->date().asReturnedValue();
}
ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber();
+ double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber();
+ double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber();
- double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber();
+ double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber();
- double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber();
+ double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setHours(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber();
- double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber();
- double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber();
+ double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber();
- double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber();
- double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber();
+ double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber();
+ double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setDate(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setMonth(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
- double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber();
+ double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber();
+ double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setYear(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
t = 0;
else
t = LocalTime(t);
- double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
double r;
if (std::isnan(year)) {
r = qSNaN();
ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber();
- double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber();
+ double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = LocalTime(self->date().asDouble());
if (std::isnan(t))
t = 0;
- double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
- double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber();
- double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber();
+ double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
+ double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber();
+ double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
self->date().setDouble(t);
return self->date().asReturnedValue();
ReturnedValue DatePrototype::method_toUTCString(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
- return ctx->engine->newString(ToUTCString(t))->asReturnedValue();
+ return ctx->d()->engine->newString(ToUTCString(t))->asReturnedValue();
}
static void addZeroPrefixedInt(QString &str, int num, int nDigits)
ReturnedValue DatePrototype::method_toISOString(CallContext *ctx)
{
- DateObject *self = ctx->callData->thisObject.asDateObject();
+ DateObject *self = ctx->d()->callData->thisObject.asDateObject();
if (!self)
return ctx->throwTypeError();
double t = self->date().asDouble();
if (!std::isfinite(t))
- return ctx->throwRangeError(ctx->callData->thisObject);
+ return ctx->throwRangeError(ctx->d()->callData->thisObject);
QString result;
int year = (int)YearFromTime(t);
if (year < 0 || year > 9999) {
if (qAbs(year) >= 1000000)
- return ctx->engine->newString(QStringLiteral("Invalid Date"))->asReturnedValue();
+ return ctx->d()->engine->newString(QStringLiteral("Invalid Date"))->asReturnedValue();
result += year < 0 ? QLatin1Char('-') : QLatin1Char('+');
year = qAbs(year);
addZeroPrefixedInt(result, year, 6);
addZeroPrefixedInt(result, msFromTime(t), 3);
result += QLatin1Char('Z');
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
ReturnedValue DatePrototype::method_toJSON(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue O(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->callData->thisObject)));
+ ScopedValue O(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->d()->callData->thisObject)));
ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT));
if (tv->isNumber() && !std::isfinite(tv->toNumber()))
return Encode::null();
- ScopedString s(scope, ctx->engine->newString(QStringLiteral("toISOString")));
+ ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString")));
ScopedValue v(scope, O->objectValue()->get(s));
FunctionObject *toIso = v->asFunctionObject();
return ctx->throwTypeError();
ScopedCallData callData(scope, 0);
- callData->thisObject = ctx->callData->thisObject;
+ callData->thisObject = ctx->d()->callData->thisObject;
return toIso->call(callData);
}
{
ExecutionState state;
state.fileName = getFunction()->sourceFile();
- state.lineNumber = engine()->currentContext()->lineNumber;
+ state.lineNumber = engine()->currentContext()->d()->lineNumber;
return state;
}
return cCtxt;
--frame;
}
- ctxt = ctxt->parent;
+ ctxt = ctxt->d()->parent;
}
return 0;
static inline CallContext *findScope(ExecutionContext *ctxt, int scope)
{
for (; scope > 0 && ctxt; --scope)
- ctxt = ctxt->outer;
+ ctxt = ctxt->d()->outer;
return ctxt ? ctxt->asCallContext() : 0;
}
if (CallContext *cCtxt = ctxt->asCallContext())
if (cCtxt->activation)
break;
- ctxt = ctxt->outer;
+ ctxt = ctxt->d()->outer;
}
if (!ctxt)
return types;
CallContext *sctxt = findContext(m_engine->currentContext(), frame);
- if (!sctxt || sctxt->type < ExecutionContext::Type_SimpleCallContext)
+ if (!sctxt || sctxt->d()->type < ExecutionContext::Type_SimpleCallContext)
return types;
CallContext *ctxt = static_cast<CallContext *>(sctxt);
- for (ExecutionContext *it = ctxt; it; it = it->outer)
- types.append(it->type);
+ for (ExecutionContext *it = ctxt; it; it = it->d()->outer)
+ types.append(it->d()->type);
return types;
}
return;
QMutexLocker locker(&m_lock);
- int lineNumber = engine()->currentContext()->lineNumber;
+ int lineNumber = engine()->currentContext()->d()->lineNumber;
if (m_gatherSources) {
m_gatherSources->run();
QMutexLocker locker(&m_lock);
if (m_stepping != NotStepping && m_currentContext == m_engine->currentContext()) {
- m_currentContext = m_engine->currentContext()->parent;
+ m_currentContext = m_engine->currentContext()->d()->parent;
m_stepping = StepOver;
m_returnedValue = retVal;
}
if (CallContext *callCtx = context->asCallContext())
return callCtx->function->function();
else {
- Q_ASSERT(context->type == QV4::ExecutionContext::Type_GlobalContext);
- return context->engine->globalCode;
+ Q_ASSERT(context->d()->type == QV4::ExecutionContext::Type_GlobalContext);
+ return context->d()->engine->globalCode;
}
}
//
globalObject = newObject()->getPointer();
rootContext->global = globalObject;
- rootContext->callData->thisObject = globalObject;
+ rootContext->d()->callData->thisObject = globalObject;
Q_ASSERT(globalObject->internalClass()->vtable);
globalObject->defineDefaultProperty(QStringLiteral("Object"), objectCtor);
{
rootContext = static_cast<GlobalContext *>(memoryManager->allocManaged(sizeof(GlobalContext) + sizeof(CallData)));
new (rootContext) GlobalContext(this);
- rootContext->callData = reinterpret_cast<CallData *>(rootContext + 1);
- rootContext->callData->tag = QV4::Value::_Integer_Type;
- rootContext->callData->argc = 0;
- rootContext->callData->thisObject = globalObject;
- rootContext->callData->args[0] = Encode::undefined();
+ rootContext->d()->callData = reinterpret_cast<CallData *>(rootContext + 1);
+ rootContext->d()->callData->tag = QV4::Value::_Integer_Type;
+ rootContext->d()->callData->argc = 0;
+ rootContext->d()->callData->thisObject = globalObject;
+ rootContext->d()->callData->args[0] = Encode::undefined();
}
InternalClass *ExecutionEngine::newClass(const InternalClass &other)
ExecutionContext *ExecutionEngine::pushGlobalContext()
{
GlobalContext *g = new (memoryManager) GlobalContext(this);
- g->callData = rootContext->callData;
+ g->d()->callData = rootContext->d()->callData;
Q_ASSERT(currentContext() == g);
return g;
{
ExecutionContext *ctx = currentContext();
- if (ctx->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->outer)
- ctx = ctx->parent;
+ if (ctx->d()->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->d()->outer)
+ ctx = ctx->d()->parent;
- if (!ctx->outer)
+ if (!ctx->d()->outer)
return 0;
- while (ctx->outer && ctx->outer->type != ExecutionContext::Type_GlobalContext)
- ctx = ctx->outer;
+ while (ctx->d()->outer && ctx->d()->outer->d()->type != ExecutionContext::Type_GlobalContext)
+ ctx = ctx->d()->outer;
Q_ASSERT(ctx);
- if (ctx->type != ExecutionContext::Type_QmlContext)
+ if (ctx->d()->type != ExecutionContext::Type_QmlContext)
return 0;
return static_cast<CallContext *>(ctx)->activation->asReturned<Object>();
if (callCtx->function->function())
// line numbers can be negative for places where you can't set a real breakpoint
- frame.line = qAbs(callCtx->lineNumber);
+ frame.line = qAbs(callCtx->d()->lineNumber);
stack.append(frame);
--frameLimit;
}
- c = c->parent;
+ c = c->d()->parent;
}
if (frameLimit && globalCode) {
StackFrame frame;
frame.source = globalCode->sourceFile();
frame.function = globalCode->name()->toQString();
- frame.line = rootContext->lineNumber;
+ frame.line = rootContext->d()->lineNumber;
frame.column = -1;
QString result;
QTextStream str(&result);
str << "stack=[";
- if (context && context->engine) {
- const QVector<StackFrame> stackTrace = context->engine->stackTrace(20);
+ if (context && context->d()->engine) {
+ const QVector<StackFrame> stackTrace = context->d()->engine->stackTrace(20);
for (int i = 0; i < stackTrace.size(); ++i) {
if (i)
str << ',';
base.setUrl(callCtx->function->function()->sourceFile());
break;
}
- c = c->parent;
+ c = c->d()->parent;
}
if (base.isEmpty() && globalCode)
ExecutionContext *c = currentContext();
while (c) {
c->mark(this);
- c = c->parent;
+ c = c->d()->parent;
}
id_empty->mark(this);
ReturnedValue ErrorObject::method_get_stack(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<ErrorObject> This(scope, ctx->callData->thisObject);
+ Scoped<ErrorObject> This(scope, ctx->d()->callData->thisObject);
if (!This)
return ctx->throwTypeError();
if (!This->d()->stack) {
trace += QString::number(frame.line);
}
}
- This->d()->stack = ctx->engine->newString(trace)->getPointer();
+ This->d()->stack = ctx->d()->engine->newString(trace)->getPointer();
}
return This->d()->stack->asReturnedValue();
}
{
Scope scope(ctx);
- Object *o = ctx->callData->thisObject.asObject();
+ Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
return ctx->throwTypeError();
- ScopedValue name(scope, o->get(ctx->engine->id_name));
+ ScopedValue name(scope, o->get(ctx->d()->engine->id_name));
QString qname;
if (name->isUndefined())
qname = QString::fromLatin1("Error");
else
qname = name->toQString();
- ScopedString s(scope, ctx->engine->newString(QString::fromLatin1("message")));
+ ScopedString s(scope, ctx->d()->engine->newString(QString::fromLatin1("message")));
ScopedValue message(scope, o->get(s));
QString qmessage;
if (!message->isUndefined())
str = qname + QLatin1String(": ") + qmessage;
}
- return ctx->engine->newString(str)->asReturnedValue();
+ return ctx->d()->engine->newString(str)->asReturnedValue();
}
DEFINE_OBJECT_VTABLE(FunctionObject);
FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto)
- : Object(scope->engine->functionClass)
+ : Object(scope->d()->engine->functionClass)
{
d()->scope = scope;
d()->function = 0;
}
FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
- : Object(scope->engine->functionClass)
+ : Object(scope->d()->engine->functionClass)
{
d()->scope = scope;
d()->function = 0;
}
FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
- : Object(scope->engine->functionClass)
+ : Object(scope->d()->engine->functionClass)
{
d()->scope = scope;
d()->function = 0;
d()->strictMode = false;
if (createProto) {
- Scoped<Object> proto(s, scope()->engine->newObject(scope()->engine->protoClass));
+ Scoped<Object> proto(s, scope()->d()->engine->newObject(scope()->d()->engine->protoClass));
proto->memberData()[Index_ProtoConstructor] = this->asReturnedValue();
memberData()[Index_Prototype] = proto.asReturnedValue();
} else {
}
ScopedValue v(s, n.asReturnedValue());
- defineReadonlyProperty(scope()->engine->id_name, v);
+ defineReadonlyProperty(scope()->d()->engine->id_name, v);
}
ReturnedValue FunctionObject::name()
{
- return get(scope()->engine->id_name);
+ return get(scope()->d()->engine->id_name);
}
function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith ||
function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount ||
function->isNamedExpression())
- return new (scope->engine->memoryManager) ScriptFunction(scope, function);
- return new (scope->engine->memoryManager) SimpleScriptFunction(scope, function, createProto);
+ return new (scope->d()->engine->memoryManager) ScriptFunction(scope, function);
+ return new (scope->d()->engine->memoryManager) SimpleScriptFunction(scope, function, createProto);
}
DEFINE_OBJECT_VTABLE(FunctionCtor);
}
body = callData->args[callData->argc - 1].toString(ctx)->toQString();
}
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
QString function = QLatin1String("function(") + arguments + QLatin1String("){") + body + QLatin1String("}");
ReturnedValue FunctionPrototype::method_toString(CallContext *ctx)
{
- FunctionObject *fun = ctx->callData->thisObject.asFunctionObject();
+ FunctionObject *fun = ctx->d()->callData->thisObject.asFunctionObject();
if (!fun)
return ctx->throwTypeError();
- return ctx->engine->newString(QStringLiteral("function() { [code] }"))->asReturnedValue();
+ return ctx->d()->engine->newString(QStringLiteral("function() { [code] }"))->asReturnedValue();
}
ReturnedValue FunctionPrototype::method_apply(CallContext *ctx)
{
Scope scope(ctx);
- FunctionObject *o = ctx->callData->thisObject.asFunctionObject();
+ FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject();
if (!o)
return ctx->throwTypeError();
{
Scope scope(ctx);
- FunctionObject *o = ctx->callData->thisObject.asFunctionObject();
+ FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject();
if (!o)
return ctx->throwTypeError();
- ScopedCallData callData(scope, ctx->callData->argc ? ctx->callData->argc - 1 : 0);
- if (ctx->callData->argc) {
- for (int i = 1; i < ctx->callData->argc; ++i)
- callData->args[i - 1] = ctx->callData->args[i];
+ ScopedCallData callData(scope, ctx->d()->callData->argc ? ctx->d()->callData->argc - 1 : 0);
+ if (ctx->d()->callData->argc) {
+ for (int i = 1; i < ctx->d()->callData->argc; ++i)
+ callData->args[i - 1] = ctx->d()->callData->args[i];
}
callData->thisObject = ctx->argument(0);
return o->call(callData);
ReturnedValue FunctionPrototype::method_bind(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<FunctionObject> target(scope, ctx->callData->thisObject);
+ Scoped<FunctionObject> target(scope, ctx->d()->callData->thisObject);
if (!target)
return ctx->throwTypeError();
ScopedValue boundThis(scope, ctx->argument(0));
Members boundArgs;
boundArgs.reset();
- if (ctx->callData->argc > 1) {
- boundArgs.ensureIndex(scope.engine, ctx->callData->argc - 1);
- boundArgs.d()->d()->size = ctx->callData->argc - 1;
- memcpy(boundArgs.data(), ctx->callData->args + 1, (ctx->callData->argc - 1)*sizeof(Value));
+ if (ctx->d()->callData->argc > 1) {
+ boundArgs.ensureIndex(scope.engine, ctx->d()->callData->argc - 1);
+ boundArgs.d()->d()->size = ctx->d()->callData->argc - 1;
+ memcpy(boundArgs.data(), ctx->d()->callData->args + 1, (ctx->d()->callData->argc - 1)*sizeof(Value));
}
ScopedValue protectBoundArgs(scope, boundArgs.d());
- return ctx->engine->newBoundFunction(ctx->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue();
+ return ctx->d()->engine->newBoundFunction(ctx->d()->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue();
}
DEFINE_OBJECT_VTABLE(ScriptFunction);
d()->needsActivation = function->needsActivation();
d()->strictMode = function->isStrict();
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount()));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(formalParameterCount()));
- if (scope->strictMode) {
+ if (scope->d()->strictMode) {
ExecutionEngine *v4 = scope->engine;
Property pd(v4->thrower, v4->thrower);
- insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
}
ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function()));
if (f->function()->compiledFunction->hasQmlDependencies())
- QmlContextWrapper::registerQmlDependencies(ctx->engine, f->function()->compiledFunction);
+ QmlContextWrapper::registerQmlDependencies(ctx->d()->engine, f->function()->compiledFunction);
return result.asReturnedValue();
}
if (!scope)
return;
- ExecutionEngine *v4 = scope->engine;
+ ExecutionEngine *v4 = scope->d()->engine;
d()->needsActivation = function->needsActivation();
d()->strictMode = function->isStrict();
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount()));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(formalParameterCount()));
- if (scope->strictMode) {
+ if (scope->d()->strictMode) {
Property pd(v4->thrower, v4->thrower);
- insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
}
ExecutionContextSaver ctxSaver(context);
CallContext ctx(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
+ ctx.d()->strictMode = f->strictMode();
+ ctx.d()->callData = callData;
ctx.function = f.getPointer();
- ctx.compilationUnit = f->function()->compilationUnit;
- ctx.lookups = ctx.compilationUnit->runtimeLookups;
- ctx.outer = f->scope();
+ ctx.d()->compilationUnit = f->function()->compilationUnit;
+ ctx.d()->lookups = ctx.d()->compilationUnit->runtimeLookups;
+ ctx.d()->outer = f->scope();
ctx.locals = v4->stackPush(f->varCount());
while (callData->argc < (int)f->formalParameterCount()) {
callData->args[callData->argc] = Encode::undefined();
ExecutionContextSaver ctxSaver(context);
CallContext ctx(v4);
- ctx.strictMode = f->strictMode();
- ctx.callData = callData;
+ ctx.d()->strictMode = f->strictMode();
+ ctx.d()->callData = callData;
ctx.function = f;
- ctx.compilationUnit = f->function()->compilationUnit;
- ctx.lookups = ctx.compilationUnit->runtimeLookups;
- ctx.outer = f->scope();
+ ctx.d()->compilationUnit = f->function()->compilationUnit;
+ ctx.d()->lookups = ctx.d()->compilationUnit->runtimeLookups;
+ ctx.d()->outer = f->scope();
ctx.locals = v4->stackPush(f->varCount());
while (callData->argc < (int)f->formalParameterCount()) {
callData->args[callData->argc] = Encode::undefined();
ExecutionContextSaver ctxSaver(context);
CallContext ctx(v4);
- ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
- ctx.callData = callData;
+ ctx.d()->strictMode = f->scope()->d()->strictMode; // ### needed? scope or parent context?
+ ctx.d()->callData = callData;
Q_ASSERT(v4->currentContext() == &ctx);
return f->d()->code(&ctx);
ExecutionContextSaver ctxSaver(context);
CallContext ctx(v4);
- ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
- ctx.callData = callData;
+ ctx.d()->strictMode = f->scope()->d()->strictMode; // ### needed? scope or parent context?
+ ctx.d()->callData = callData;
Q_ASSERT(v4->currentContext() == &ctx);
return f->d()->code(&ctx, f->d()->index);
Scope s(scope);
ScopedValue protectThis(s, this);
- ScopedValue l(s, target->get(scope->engine->id_length));
+ ScopedValue l(s, target->get(scope->d()->engine->id_length));
int len = l->toUInt32();
len -= boundArgs.size();
if (len < 0)
len = 0;
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(len));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(len));
- ExecutionEngine *v4 = scope->engine;
+ ExecutionEngine *v4 = scope->d()->engine;
Property pd(v4->thrower, v4->thrower);
- insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
- insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
+ insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
void BoundFunction::destroy(Managed *that)
ReturnedValue BoundFunction::call(Managed *that, CallData *dd)
{
BoundFunction *f = static_cast<BoundFunction *>(that);
- Scope scope(f->scope()->engine);
+ Scope scope(f->scope()->d()->engine);
if (scope.hasException())
return Encode::undefined();
ReturnedValue BoundFunction::construct(Managed *that, CallData *dd)
{
BoundFunction *f = static_cast<BoundFunction *>(that);
- Scope scope(f->scope()->engine);
+ Scope scope(f->scope()->d()->engine);
if (scope.hasException())
return Encode::undefined();
DEFINE_OBJECT_VTABLE(EvalFunction);
EvalFunction::EvalFunction(ExecutionContext *scope)
- : FunctionObject(scope, scope->engine->id_eval)
+ : FunctionObject(scope, scope->d()->engine->id_eval)
{
setVTable(staticVTable());
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
}
ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
ContextStateSaver(ExecutionContext *context)
: savedContext(context)
- , strictMode(context->strictMode)
- , evalCode(context->currentEvalCode)
- , compilationUnit(context->compilationUnit)
+ , strictMode(context->d()->strictMode)
+ , evalCode(context->d()->currentEvalCode)
+ , compilationUnit(context->d()->compilationUnit)
{}
~ContextStateSaver()
{
- savedContext->strictMode = strictMode;
- savedContext->currentEvalCode = evalCode;
- savedContext->compilationUnit = compilationUnit;
+ savedContext->d()->strictMode = strictMode;
+ savedContext->d()->currentEvalCode = evalCode;
+ savedContext->d()->compilationUnit = compilationUnit;
}
};
return callData->args[0].asReturnedValue();
const QString code = callData->args[0].stringValue()->toQString();
- bool inheritContext = !ctx->strictMode;
+ bool inheritContext = !ctx->d()->strictMode;
Script script(ctx, code, QStringLiteral("eval code"));
- script.strictMode = (directCall && parentContext->strictMode);
+ script.strictMode = (directCall && parentContext->d()->strictMode);
script.inheritContext = inheritContext;
script.parse();
if (scope.engine->hasException)
if (!function)
return Encode::undefined();
- d()->strictMode = function->isStrict() || (ctx->strictMode);
+ d()->strictMode = function->isStrict() || (ctx->d()->strictMode);
d()->needsActivation = function->needsActivation();
if (strictMode()) {
ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function));
ScopedCallData callData(scope, 0);
- callData->thisObject = ctx->callData->thisObject;
+ callData->thisObject = ctx->d()->callData->thisObject;
return e->call(callData);
}
ExecutionContext::EvalCode evalCode;
evalCode.function = function;
- evalCode.next = ctx->currentEvalCode;
- ctx->currentEvalCode = &evalCode;
+ evalCode.next = ctx->d()->currentEvalCode;
+ ctx->d()->currentEvalCode = &evalCode;
// set the correct strict mode flag on the context
- ctx->strictMode = strictMode();
- ctx->compilationUnit = function->compilationUnit;
+ ctx->d()->strictMode = strictMode();
+ ctx->d()->compilationUnit = function->compilationUnit;
return function->code(ctx, function->codeData);
}
String *inputString = string->toString(ctx); // 1
QString trimmed = inputString->toQString().trimmed(); // 2
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
const QChar *pos = trimmed.constData();
/// isNaN [15.1.2.4]
ReturnedValue GlobalFunctions::method_isNaN(CallContext *ctx)
{
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
// undefined gets converted to NaN
return Encode(true);
- if (ctx->callData->args[0].integerCompatible())
+ if (ctx->d()->callData->args[0].integerCompatible())
return Encode(false);
- double d = ctx->callData->args[0].toNumber();
+ double d = ctx->d()->callData->args[0].toNumber();
return Encode((bool)std::isnan(d));
}
/// isFinite [15.1.2.5]
ReturnedValue GlobalFunctions::method_isFinite(CallContext *ctx)
{
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
// undefined gets converted to NaN
return Encode(false);
- if (ctx->callData->args[0].integerCompatible())
+ if (ctx->d()->callData->args[0].integerCompatible())
return Encode(true);
- double d = ctx->callData->args[0].toNumber();
+ double d = ctx->d()->callData->args[0].toNumber();
return Encode((bool)std::isfinite(d));
}
/// decodeURI [15.1.3.1]
ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context)
{
- if (context->callData->argc == 0)
+ if (context->d()->callData->argc == 0)
return Encode::undefined();
- QString uriString = context->callData->args[0].toString(context)->toQString();
+ QString uriString = context->d()->callData->args[0].toString(context)->toQString();
bool ok;
QString out = decode(uriString, DecodeNonReserved, &ok);
if (!ok) {
Scope scope(context);
- ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence")));
+ ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
return context->throwURIError(s);
}
- return context->engine->newString(out)->asReturnedValue();
+ return context->d()->engine->newString(out)->asReturnedValue();
}
/// decodeURIComponent [15.1.3.2]
ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context)
{
- if (context->callData->argc == 0)
+ if (context->d()->callData->argc == 0)
return Encode::undefined();
- QString uriString = context->callData->args[0].toString(context)->toQString();
+ QString uriString = context->d()->callData->args[0].toString(context)->toQString();
bool ok;
QString out = decode(uriString, DecodeAll, &ok);
if (!ok) {
Scope scope(context);
- ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence")));
+ ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
return context->throwURIError(s);
}
- return context->engine->newString(out)->asReturnedValue();
+ return context->d()->engine->newString(out)->asReturnedValue();
}
/// encodeURI [15.1.3.3]
ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context)
{
- if (context->callData->argc == 0)
+ if (context->d()->callData->argc == 0)
return Encode::undefined();
- QString uriString = context->callData->args[0].toString(context)->toQString();
+ QString uriString = context->d()->callData->args[0].toString(context)->toQString();
bool ok;
QString out = encode(uriString, uriUnescapedReserved, &ok);
if (!ok) {
Scope scope(context);
- ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence")));
+ ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
return context->throwURIError(s);
}
- return context->engine->newString(out)->asReturnedValue();
+ return context->d()->engine->newString(out)->asReturnedValue();
}
/// encodeURIComponent [15.1.3.4]
ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context)
{
- if (context->callData->argc == 0)
+ if (context->d()->callData->argc == 0)
return Encode::undefined();
- QString uriString = context->callData->args[0].toString(context)->toQString();
+ QString uriString = context->d()->callData->args[0].toString(context)->toQString();
bool ok;
QString out = encode(uriString, uriUnescaped, &ok);
if (!ok) {
Scope scope(context);
- ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence")));
+ ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence")));
return context->throwURIError(s);
}
- return context->engine->newString(out)->asReturnedValue();
+ return context->d()->engine->newString(out)->asReturnedValue();
}
ReturnedValue GlobalFunctions::method_escape(CallContext *context)
{
- if (!context->callData->argc)
- return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
+ if (!context->d()->callData->argc)
+ return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
- QString str = context->callData->args[0].toString(context)->toQString();
- return context->engine->newString(escape(str))->asReturnedValue();
+ QString str = context->d()->callData->args[0].toString(context)->toQString();
+ return context->d()->engine->newString(escape(str))->asReturnedValue();
}
ReturnedValue GlobalFunctions::method_unescape(CallContext *context)
{
- if (!context->callData->argc)
- return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
+ if (!context->d()->callData->argc)
+ return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue();
- QString str = context->callData->args[0].toString(context)->toQString();
- return context->engine->newString(unescape(str))->asReturnedValue();
+ QString str = context->d()->callData->args[0].toString(context)->toQString();
+ return context->d()->engine->newString(unescape(str))->asReturnedValue();
}
*/
QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
{
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return QV4::Encode::undefined();
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV8Engine *engine = v4->v8Engine;
- QQmlContextData *context = QV4::QmlContextWrapper::callingContext(v4);
+ QV4::Scope scope(ctx->engine());
+ QV8Engine *engine = scope.engine->v8Engine;
+ QQmlContextData *context = QV4::QmlContextWrapper::callingContext(scope.engine);
if (!context || !context->isJSContext)
V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files");
- QUrl url(ctx->engine->resolvedUrl(ctx->callData->args[0].toQStringNoThrow()));
+ QUrl url(scope.engine->resolvedUrl(ctx->d()->callData->args[0].toQStringNoThrow()));
QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue());
- if (ctx->callData->argc >= 2 && ctx->callData->args[1].asFunctionObject())
- callbackFunction = ctx->callData->args[1];
+ if (ctx->d()->callData->argc >= 2 && ctx->d()->callData->args[1].asFunctionObject())
+ callbackFunction = ctx->d()->callData->args[1];
QString localFile = QQmlFile::urlToLocalFileOrQrc(url);
QV4::ScopedValue result(scope);
- QV4::ScopedObject qmlcontextobject(scope, v4->qmlContextObject());
+ QV4::ScopedObject qmlcontextobject(scope, scope.engine->qmlContextObject());
if (localFile.isEmpty()) {
QV4Include *i = new QV4Include(url, engine, context,
QString code = QString::fromUtf8(data);
QmlIR::Document::removeScriptPragmas(code);
- QV4::Script script(v4, qmlcontextobject, code, url.toString());
+ QV4::Script script(scope.engine, qmlcontextobject, code, url.toString());
- QV4::ExecutionContext *ctx = v4->currentContext();
+ QV4::ExecutionContext *ctx = scope.engine->currentContext();
script.parse();
- if (!v4->hasException)
+ if (!scope.engine->hasException)
script.run();
- if (v4->hasException) {
+ if (scope.engine->hasException) {
QV4::ScopedValue ex(scope, ctx->catchException());
- result = resultValue(v4, Exception);
- result->asObject()->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("exception"))), ex);
+ result = resultValue(scope.engine, Exception);
+ result->asObject()->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("exception"))), ex);
} else {
- result = resultValue(v4, Ok);
+ result = resultValue(scope.engine, Ok);
}
} else {
- result = resultValue(v4, NetworkError);
+ result = resultValue(scope.engine, NetworkError);
}
callback(callbackFunction, result);
BEGIN << "parseObject pos=" << json;
Scope scope(context);
- ScopedObject o(scope, context->engine->newObject());
+ ScopedObject o(scope, context->d()->engine->newObject());
QChar token = nextToken();
while (token == Quote) {
if (!parseValue(val))
return false;
- ScopedString s(scope, context->engine->newIdentifier(key));
+ ScopedString s(scope, context->d()->engine->newIdentifier(key));
uint idx = s->asArrayIndex();
if (idx < UINT_MAX) {
o->putIndexed(idx, val);
{
Scope scope(context);
BEGIN << "parseArray";
- Scoped<ArrayObject> array(scope, context->engine->newArrayObject());
+ Scoped<ArrayObject> array(scope, context->d()->engine->newArrayObject());
if (++nestingLevel > nestingLimit) {
lastError = QJsonParseError::DeepNesting;
return false;
DEBUG << "value: string";
END;
- val = context->engine->newString(value);
+ val = context->d()->engine->newString(value);
return true;
}
case BeginArray: {
ScopedValue value(scope, *v);
ScopedObject o(scope, value);
if (o) {
- ScopedString s(scope, ctx->engine->newString(QStringLiteral("toJSON")));
+ ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toJSON")));
Scoped<FunctionObject> toJSON(scope, o->get(s));
if (!!toJSON) {
ScopedCallData callData(scope, 1);
callData->thisObject = value;
- callData->args[0] = ctx->engine->newString(key);
+ callData->args[0] = ctx->d()->engine->newString(key);
value = toJSON->call(callData);
}
}
if (replacerFunction) {
- ScopedObject holder(scope, ctx->engine->newObject());
+ ScopedObject holder(scope, ctx->d()->engine->newObject());
holder->put(ctx, QString(), value);
ScopedCallData callData(scope, 2);
- callData->args[0] = ctx->engine->newString(key);
+ callData->args[0] = ctx->d()->engine->newString(key);
callData->args[1] = value;
callData->thisObject = holder;
value = replacerFunction->call(callData);
QString result = stringify.Str(QString(), arg0);
if (result.isEmpty() || scope.engine->hasException)
return Encode::undefined();
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValue &value)
{
if (value.isString())
- return engine->currentContext()->engine->newString(value.toString())->asReturnedValue();
+ return engine->currentContext()->d()->engine->newString(value.toString())->asReturnedValue();
else if (value.isDouble())
return Encode(value.toDouble());
else if (value.isBool())
ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
PropertyAttributes attrs;
ReturnedValue v = l->lookup(o, &attrs);
if (v != Primitive::emptyValue().asReturnedValue()) {
ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass())
return o->memberData()[l->index].asReturnedValue();
ReturnedValue Lookup::globalGetter1(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass() &&
l->classList[1] == o->prototype()->internalClass())
return o->prototype()->memberData()[l->index].asReturnedValue();
ReturnedValue Lookup::globalGetter2(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass()) {
o = o->prototype();
if (l->classList[1] == o->internalClass()) {
ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass()) {
Scope scope(o->engine());
FunctionObject *getter = o->propertyAt(l->index)->getter();
ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass() &&
l->classList[1] == o->prototype()->internalClass()) {
Scope scope(o->engine());
ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionContext *ctx)
{
- Object *o = ctx->engine->globalObject;
+ Object *o = ctx->d()->engine->globalObject;
if (l->classList[0] == o->internalClass()) {
o = o->prototype();
if (l->classList[1] == o->internalClass()) {
ReturnedValue MathObject::method_abs(CallContext *context)
{
- if (!context->callData->argc)
+ if (!context->d()->callData->argc)
return Encode(qSNaN());
- if (context->callData->args[0].isInteger()) {
- int i = context->callData->args[0].integerValue();
+ if (context->d()->callData->args[0].isInteger()) {
+ int i = context->d()->callData->args[0].integerValue();
return Encode(i < 0 ? - i : i);
}
- double v = context->callData->args[0].toNumber();
+ double v = context->d()->callData->args[0].toNumber();
if (v == 0) // 0 | -0
return Encode(0);
ReturnedValue MathObject::method_acos(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : 2;
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
ReturnedValue MathObject::method_asin(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : 2;
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2;
if (v > 1)
return Encode(qSNaN());
else
ReturnedValue MathObject::method_atan(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else
ReturnedValue MathObject::method_atan2(CallContext *context)
{
- double v1 = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
- double v2 = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN();
+ double v1 = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double v2 = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0))
return Encode(copySign(0, -1.0));
ReturnedValue MathObject::method_ceil(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
if (v < 0.0 && v > -1.0)
return Encode(copySign(0, -1.0));
else
ReturnedValue MathObject::method_cos(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
return Encode(::cos(v));
}
ReturnedValue MathObject::method_exp(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
if (qIsInf(v)) {
if (copySign(1.0, v) == -1.0)
return Encode(0);
ReturnedValue MathObject::method_floor(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
return Encode(::floor(v));
}
ReturnedValue MathObject::method_log(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
if (v < 0)
return Encode(qSNaN());
else
ReturnedValue MathObject::method_max(CallContext *context)
{
double mx = -qInf();
- for (int i = 0; i < context->callData->argc; ++i) {
- double x = context->callData->args[i].toNumber();
+ for (int i = 0; i < context->d()->callData->argc; ++i) {
+ double x = context->d()->callData->args[i].toNumber();
if (x > mx || std::isnan(x))
mx = x;
}
ReturnedValue MathObject::method_min(CallContext *context)
{
double mx = qInf();
- for (int i = 0; i < context->callData->argc; ++i) {
- double x = context->callData->args[i].toNumber();
+ for (int i = 0; i < context->d()->callData->argc; ++i) {
+ double x = context->d()->callData->args[i].toNumber();
if ((x == 0 && mx == x && copySign(1.0, x) == -1.0)
|| (x < mx) || std::isnan(x)) {
mx = x;
ReturnedValue MathObject::method_pow(CallContext *context)
{
- double x = context->callData->argc > 0 ? context->callData->args[0].toNumber() : qSNaN();
- double y = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN();
+ double x = context->d()->callData->argc > 0 ? context->d()->callData->args[0].toNumber() : qSNaN();
+ double y = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN();
if (std::isnan(y))
return Encode(qSNaN());
ReturnedValue MathObject::method_round(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
v = copySign(::floor(v + 0.5), v);
return Encode(v);
}
ReturnedValue MathObject::method_sin(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
return Encode(::sin(v));
}
ReturnedValue MathObject::method_sqrt(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
return Encode(::sqrt(v));
}
ReturnedValue MathObject::method_tan(CallContext *context)
{
- double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN();
+ double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN();
if (v == 0.0)
return Encode(v);
else
inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
{
- if (ctx->callData->thisObject.isNumber())
- return ctx->callData->thisObject.asReturnedValue();
- NumberObject *n = ctx->callData->thisObject.asNumberObject();
+ if (ctx->d()->callData->thisObject.isNumber())
+ return ctx->d()->callData->thisObject.asReturnedValue();
+ NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
if (!n)
return ctx->throwTypeError();
return n->value().asReturnedValue();
inline double thisNumber(ExecutionContext *ctx)
{
- if (ctx->callData->thisObject.isNumber())
- return ctx->callData->thisObject.asDouble();
- NumberObject *n = ctx->callData->thisObject.asNumberObject();
+ if (ctx->d()->callData->thisObject.isNumber())
+ return ctx->d()->callData->thisObject.asDouble();
+ NumberObject *n = ctx->d()->callData->thisObject.asNumberObject();
if (!n)
return ctx->throwTypeError();
return n->value().asDouble();
ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
{
double num = thisNumber(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
- if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) {
- int radix = ctx->callData->args[0].toInt32();
+ if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
+ int radix = ctx->d()->callData->args[0].toInt32();
if (radix < 2 || radix > 36)
return ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
if (std::isnan(num)) {
- return ctx->engine->newString(QStringLiteral("NaN"))->asReturnedValue();
+ return ctx->d()->engine->newString(QStringLiteral("NaN"))->asReturnedValue();
} else if (qIsInf(num)) {
- return ctx->engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue();
+ return ctx->d()->engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue();
}
if (radix != 10) {
}
if (negative)
str.prepend(QLatin1Char('-'));
- return ctx->engine->newString(str)->asReturnedValue();
+ return ctx->d()->engine->newString(str)->asReturnedValue();
}
}
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
ScopedString str(scope, v->toString(ctx));
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
return str.asReturnedValue();
}
ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx)
{
double v = thisNumber(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
double fdigits = 0;
- if (ctx->callData->argc > 0)
- fdigits = ctx->callData->args[0].toInteger();
+ if (ctx->d()->callData->argc > 0)
+ fdigits = ctx->d()->callData->args[0].toInteger();
if (std::isnan(fdigits))
fdigits = 0;
if (fdigits < 0 || fdigits > 20)
- return ctx->throwRangeError(ctx->callData->thisObject);
+ return ctx->throwRangeError(ctx->d()->callData->thisObject);
QString str;
if (std::isnan(v))
str = QString::number(v, 'f', int (fdigits));
else
return RuntimeHelpers::stringFromNumber(ctx, v)->asReturnedValue();
- return ctx->engine->newString(str)->asReturnedValue();
+ return ctx->d()->engine->newString(str)->asReturnedValue();
}
ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
{
Scope scope(ctx);
double d = thisNumber(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
int fdigits = -1;
- if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) {
- fdigits = ctx->callData->args[0].toInt32();
+ if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
+ fdigits = ctx->d()->callData->args[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
- ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
+ ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
return ctx->throwRangeError(error);
}
}
double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToExponential(d, fdigits, &builder);
QString result = QString::fromLatin1(builder.Finalize());
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
{
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
- if (!ctx->callData->argc || ctx->callData->args[0].isUndefined())
+ if (!ctx->d()->callData->argc || ctx->d()->callData->args[0].isUndefined())
return RuntimeHelpers::toString(ctx, v);
- double precision = ctx->callData->args[0].toInt32();
+ double precision = ctx->d()->callData->args[0].toInt32();
if (precision < 1 || precision > 21) {
- ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
+ ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
return ctx->throwRangeError(error);
}
double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToPrecision(v->asDouble(), precision, &builder);
QString result = QString::fromLatin1(builder.Finalize());
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef value)
{
Scope scope(ctx);
- ScopedString n(scope, ctx->engine->newString(name));
+ ScopedString n(scope, ctx->d()->engine->newString(name));
put(n, value);
}
return;
reject:
- if (engine()->currentContext()->strictMode)
+ if (engine()->currentContext()->d()->strictMode)
engine()->currentContext()->throwTypeError();
}
return;
reject:
- if (engine()->currentContext()->strictMode) {
+ if (engine()->currentContext()->d()->strictMode) {
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
return;
reject:
- if (engine()->currentContext()->strictMode)
+ if (engine()->currentContext()->d()->strictMode)
engine()->currentContext()->throwTypeError();
}
InternalClass::removeMember(this, name->identifier());
return true;
}
- if (engine()->currentContext()->strictMode)
+ if (engine()->currentContext()->d()->strictMode)
engine()->currentContext()->throwTypeError();
return false;
}
if (!arrayData() || arrayData()->vtable()->del(this, index))
return true;
- if (engine()->currentContext()->strictMode)
+ if (engine()->currentContext()->d()->strictMode)
engine()->currentContext()->throwTypeError();
return false;
}
PropertyAttributes *cattrs;
uint memberIndex;
- if (isArrayObject() && name->equals(ctx->engine->id_length)) {
- assert(ArrayObject::LengthPropertyIndex == internalClass()->find(ctx->engine->id_length));
+ if (isArrayObject() && name->equals(ctx->d()->engine->id_length)) {
+ assert(ArrayObject::LengthPropertyIndex == internalClass()->find(ctx->d()->engine->id_length));
Property *lp = propertyAt(ArrayObject::LengthPropertyIndex);
cattrs = internalClass()->propertyData.constData() + ArrayObject::LengthPropertyIndex;
if (attrs.isEmpty() || p.isSubset(attrs, *lp, *cattrs))
return __defineOwnProperty__(ctx, memberIndex, name, p, attrs);
reject:
- if (ctx->strictMode)
+ if (ctx->d()->strictMode)
ctx->throwTypeError();
return false;
}
return defineOwnProperty2(ctx, index, p, attrs);
reject:
- if (ctx->strictMode)
+ if (ctx->d()->strictMode)
ctx->throwTypeError();
return false;
}
return __defineOwnProperty__(ctx, index, StringRef::null(), p, attrs);
reject:
- if (ctx->strictMode)
+ if (ctx->d()->strictMode)
ctx->throwTypeError();
return false;
}
setHasAccessorProperty();
return true;
reject:
- if (ctx->strictMode)
+ if (ctx->d()->strictMode)
ctx->throwTypeError();
return false;
}
bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, const Property &p, PropertyAttributes attrs)
{
Scope scope(ctx);
- ScopedString s(scope, ctx->engine->newString(name));
+ ScopedString s(scope, ctx->d()->engine->newString(name));
return __defineOwnProperty__(ctx, s, p, attrs);
}
Q_MANAGED_TYPE(ForeachIteratorObject)
ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o)
- : Object(ctx->engine)
+ : Object(ctx->d()->engine)
, __data(o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) {
setVTable(staticVTable());
}
if (!O)
return context->throwTypeError();
- ScopedArrayObject array(scope, getOwnPropertyNames(context->engine, context->callData->args[0]));
+ ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->d()->callData->args[0]));
return array.asReturnedValue();
}
if (!O->isObject() && !O->isNull())
return ctx->throwTypeError();
- Scoped<Object> newObject(scope, ctx->engine->newObject());
+ Scoped<Object> newObject(scope, ctx->d()->engine->newObject());
newObject->setPrototype(O->asObject());
- if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) {
- ctx->callData->args[0] = newObject.asReturnedValue();
+ if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) {
+ ctx->d()->callData->args[0] = newObject.asReturnedValue();
return method_defineProperties(ctx);
}
if (!o)
return ctx->throwTypeError();
- Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> a(scope, ctx->d()->engine->newArrayObject());
ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly);
ScopedValue name(scope);
ReturnedValue ObjectPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- if (ctx->callData->thisObject.isUndefined()) {
- return ctx->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue();
- } else if (ctx->callData->thisObject.isNull()) {
- return ctx->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue();
+ if (ctx->d()->callData->thisObject.isUndefined()) {
+ return ctx->d()->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue();
+ } else if (ctx->d()->callData->thisObject.isNull()) {
+ return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue();
} else {
- ScopedObject obj(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->callData->thisObject)));
+ ScopedObject obj(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->d()->callData->thisObject)));
QString className = obj->className();
- return ctx->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue();
+ return ctx->d()->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue();
}
}
ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx));
+ ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(ctx));
if (!o)
return Encode::undefined();
- Scoped<FunctionObject> f(scope, o->get(ctx->engine->id_toString));
+ Scoped<FunctionObject> f(scope, o->get(ctx->d()->engine->id_toString));
if (!f)
return ctx->throwTypeError();
ScopedCallData callData(scope, 0);
ReturnedValue ObjectPrototype::method_valueOf(CallContext *ctx)
{
Scope scope(ctx);
- ScopedValue v(scope, ctx->callData->thisObject.toObject(ctx));
- if (ctx->engine->hasException)
+ ScopedValue v(scope, ctx->d()->callData->thisObject.toObject(ctx));
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
return v.asReturnedValue();
}
Scoped<String> P(scope, ctx->argument(0), Scoped<String>::Convert);
if (scope.engine->hasException)
return Encode::undefined();
- Scoped<Object> O(scope, ctx->callData->thisObject, Scoped<Object>::Convert);
+ Scoped<Object> O(scope, ctx->d()->callData->thisObject, Scoped<Object>::Convert);
if (scope.engine->hasException)
return Encode::undefined();
bool r = O->hasOwnProperty(P);
if (!V)
return Encode(false);
- Scoped<Object> O(scope, ctx->callData->thisObject, Scoped<Object>::Convert);
+ Scoped<Object> O(scope, ctx->d()->callData->thisObject, Scoped<Object>::Convert);
if (scope.engine->hasException)
return Encode::undefined();
Scoped<Object> proto(scope, V->prototype());
if (scope.engine->hasException)
return Encode::undefined();
- Scoped<Object> o(scope, ctx->callData->thisObject, Scoped<Object>::Convert);
+ Scoped<Object> o(scope, ctx->d()->callData->thisObject, Scoped<Object>::Convert);
if (scope.engine->hasException)
return Encode::undefined();
PropertyAttributes attrs;
ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx)
{
- if (ctx->callData->argc < 2)
+ if (ctx->d()->callData->argc < 2)
return ctx->throwTypeError();
Scope scope(ctx);
if (scope.engine->hasException)
return Encode::undefined();
- Scoped<Object> o(scope, ctx->callData->thisObject);
+ Scoped<Object> o(scope, ctx->d()->callData->thisObject);
if (!o) {
- if (!ctx->callData->thisObject.isUndefined())
+ if (!ctx->d()->callData->thisObject.isUndefined())
return Encode::undefined();
- o = ctx->engine->globalObject;
+ o = ctx->d()->engine->globalObject;
}
Property pd;
ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx)
{
- if (ctx->callData->argc < 2)
+ if (ctx->d()->callData->argc < 2)
return ctx->throwTypeError();
Scope scope(ctx);
if (scope.engine->hasException)
return Encode::undefined();
- Scoped<Object> o(scope, ctx->callData->thisObject);
+ Scoped<Object> o(scope, ctx->d()->callData->thisObject);
if (!o) {
- if (!ctx->callData->thisObject.isUndefined())
+ if (!ctx->d()->callData->thisObject.isUndefined())
return Encode::undefined();
- o = ctx->engine->globalObject;
+ o = ctx->d()->engine->globalObject;
}
Property pd;
ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx)
{
Scope scope(ctx);
- ScopedObject o(scope, ctx->callData->thisObject.asObject());
+ ScopedObject o(scope, ctx->d()->callData->thisObject.asObject());
if (!o)
return ctx->throwTypeError();
ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Object> o(scope, ctx->callData->thisObject);
- if (!o || !ctx->callData->argc)
+ Scoped<Object> o(scope, ctx->d()->callData->thisObject);
+ if (!o || !ctx->d()->callData->argc)
return ctx->throwTypeError();
- if (ctx->callData->args[0].isNull()) {
+ if (ctx->d()->callData->args[0].isNull()) {
o->setPrototype(0);
return Encode::undefined();
}
- Scoped<Object> p(scope, ctx->callData->args[0]);
+ Scoped<Object> p(scope, ctx->d()->callData->args[0]);
bool ok = false;
if (!!p) {
if (o->prototype() == p.getPointer()) {
desc->set = Primitive::emptyValue();
ScopedValue tmp(scope);
- if (o->hasProperty(ctx->engine->id_enumerable))
- attrs->setEnumerable((tmp = o->get(ctx->engine->id_enumerable))->toBoolean());
+ if (o->hasProperty(ctx->d()->engine->id_enumerable))
+ attrs->setEnumerable((tmp = o->get(ctx->d()->engine->id_enumerable))->toBoolean());
- if (o->hasProperty(ctx->engine->id_configurable))
- attrs->setConfigurable((tmp = o->get(ctx->engine->id_configurable))->toBoolean());
+ if (o->hasProperty(ctx->d()->engine->id_configurable))
+ attrs->setConfigurable((tmp = o->get(ctx->d()->engine->id_configurable))->toBoolean());
- if (o->hasProperty(ctx->engine->id_get)) {
- ScopedValue get(scope, o->get(ctx->engine->id_get));
+ if (o->hasProperty(ctx->d()->engine->id_get)) {
+ ScopedValue get(scope, o->get(ctx->d()->engine->id_get));
FunctionObject *f = get->asFunctionObject();
if (f || get->isUndefined()) {
desc->value = get;
attrs->setType(PropertyAttributes::Accessor);
}
- if (o->hasProperty(ctx->engine->id_set)) {
- ScopedValue set(scope, o->get(ctx->engine->id_set));
+ if (o->hasProperty(ctx->d()->engine->id_set)) {
+ ScopedValue set(scope, o->get(ctx->d()->engine->id_set));
FunctionObject *f = set->asFunctionObject();
if (f || set->isUndefined()) {
desc->set = set;
attrs->setType(PropertyAttributes::Accessor);
}
- if (o->hasProperty(ctx->engine->id_writable)) {
+ if (o->hasProperty(ctx->d()->engine->id_writable)) {
if (attrs->isAccessor()) {
ctx->throwTypeError();
return;
}
- attrs->setWritable((tmp = o->get(ctx->engine->id_writable))->toBoolean());
+ attrs->setWritable((tmp = o->get(ctx->d()->engine->id_writable))->toBoolean());
// writable forces it to be a data descriptor
desc->value = Primitive::undefinedValue();
}
- if (o->hasProperty(ctx->engine->id_value)) {
+ if (o->hasProperty(ctx->d()->engine->id_value)) {
if (attrs->isAccessor()) {
ctx->throwTypeError();
return;
}
- desc->value = o->get(ctx->engine->id_value);
+ desc->value = o->get(ctx->d()->engine->id_value);
attrs->setType(PropertyAttributes::Data);
}
if (!desc)
return Encode::undefined();
- ExecutionEngine *engine = ctx->engine;
+ ExecutionEngine *engine = ctx->d()->engine;
Scope scope(engine);
// Let obj be the result of creating a new object as if by the expression new Object() where Object
// is the standard built-in constructor with that name.
if (name->equals(scope.engine->id_destroy) || name->equals(scope.engine->id_toString)) {
int index = name->equals(scope.engine->id_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
- QV4::ScopedValue method(scope, QV4::QObjectMethod::create(ctx->engine->rootContext, d()->object, index));
+ QV4::ScopedValue method(scope, QV4::QObjectMethod::create(ctx->d()->engine->rootContext, d()->object, index));
if (hasProperty)
*hasProperty = true;
return method.asReturnedValue();
}
QQmlPropertyData local;
- QQmlPropertyData *result = findProperty(ctx->engine, qmlContext, name.getPointer(), revisionMode, &local);
+ QQmlPropertyData *result = findProperty(ctx->d()->engine, qmlContext, name.getPointer(), revisionMode, &local);
if (!result) {
if (includeImports && name->startsWithUpper()) {
if (r.scriptIndex != -1) {
return QV4::Encode::undefined();
} else if (r.type) {
- return QmlTypeWrapper::create(ctx->engine->v8Engine, d()->object, r.type, QmlTypeWrapper::ExcludeEnums);
+ return QmlTypeWrapper::create(ctx->d()->engine->v8Engine, d()->object, r.type, QmlTypeWrapper::ExcludeEnums);
} else if (r.importNamespace) {
- return QmlTypeWrapper::create(ctx->engine->v8Engine, d()->object, qmlContext->imports, r.importNamespace, QmlTypeWrapper::ExcludeEnums);
+ return QmlTypeWrapper::create(ctx->d()->engine->v8Engine, d()->object, qmlContext->imports, r.importNamespace, QmlTypeWrapper::ExcludeEnums);
}
Q_ASSERT(!"Unreachable");
}
Q_ASSERT(vmemo);
return vmemo->vmeMethod(property->coreIndex);
} else if (property->isV4Function()) {
- QV4::Scoped<QV4::Object> qmlcontextobject(scope, ctx->engine->qmlContextObject());
- return QV4::QObjectMethod::create(ctx->engine->rootContext, object, property->coreIndex, qmlcontextobject);
+ QV4::Scoped<QV4::Object> qmlcontextobject(scope, ctx->d()->engine->qmlContextObject());
+ return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex, qmlcontextobject);
} else if (property->isSignalHandler()) {
- QV4::Scoped<QV4::QmlSignalHandler> handler(scope, new (ctx->engine->memoryManager) QV4::QmlSignalHandler(ctx->engine, object, property->coreIndex));
+ QV4::Scoped<QV4::QmlSignalHandler> handler(scope, new (ctx->d()->engine->memoryManager) QV4::QmlSignalHandler(ctx->d()->engine, object, property->coreIndex));
- QV4::ScopedString connect(scope, ctx->engine->newIdentifier(QStringLiteral("connect")));
- QV4::ScopedString disconnect(scope, ctx->engine->newIdentifier(QStringLiteral("disconnect")));
- handler->put(connect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(connect)));
- handler->put(disconnect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(disconnect)));
+ QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect")));
+ QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect")));
+ handler->put(connect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect)));
+ handler->put(disconnect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect)));
return handler.asReturnedValue();
} else {
- return QV4::QObjectMethod::create(ctx->engine->rootContext, object, property->coreIndex);
+ return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex);
}
}
- QQmlEnginePrivate *ep = ctx->engine->v8Engine->engine() ? QQmlEnginePrivate::get(ctx->engine->v8Engine->engine()) : 0;
+ QQmlEnginePrivate *ep = ctx->d()->engine->v8Engine->engine() ? QQmlEnginePrivate::get(ctx->d()->engine->v8Engine->engine()) : 0;
if (property->hasAccessors()) {
QQmlNotifier *n = 0;
if (ep && ep->propertyCapture && property->accessors->notifier)
nptr = &n;
- QV4::ScopedValue rv(scope, LoadProperty<ReadAccessor::Accessor>(ctx->engine->v8Engine, object, *property, nptr));
+ QV4::ScopedValue rv(scope, LoadProperty<ReadAccessor::Accessor>(ctx->d()->engine->v8Engine, object, *property, nptr));
if (captureRequired) {
if (property->accessors->notifier) {
Q_ASSERT(vmemo);
return vmemo->vmeProperty(property->coreIndex);
} else if (property->isDirect()) {
- return LoadProperty<ReadAccessor::Direct>(ctx->engine->v8Engine, object, *property, 0);
+ return LoadProperty<ReadAccessor::Direct>(ctx->d()->engine->v8Engine, object, *property, 0);
} else {
- return LoadProperty<ReadAccessor::Indirect>(ctx->engine->v8Engine, object, *property, 0);
+ return LoadProperty<ReadAccessor::Indirect>(ctx->d()->engine->v8Engine, object, *property, 0);
}
}
return QV4::Encode::null();
}
- QV4::Scoped<QObjectWrapper> wrapper(scope, wrap(ctx->engine, object));
+ QV4::Scoped<QObjectWrapper> wrapper(scope, wrap(ctx->d()->engine, object));
if (!wrapper) {
if (hasProperty)
*hasProperty = false;
QQmlPropertyData local;
QQmlPropertyData *result = 0;
{
- result = QQmlPropertyCache::property(ctx->engine->v8Engine->engine(), object, name, qmlContext, local);
+ result = QQmlPropertyCache::property(ctx->d()->engine->v8Engine->engine(), object, name, qmlContext, local);
}
if (!result)
}
} else {
// binding assignment.
- QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine);
+ QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->d()->engine);
QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, f);
bindingFunction->initBindingLocation();
} else if (value->isUndefined() && property->propType == QMetaType::QJsonValue) {
PROPERTY_STORE(QJsonValue, QJsonValue(QJsonValue::Undefined));
} else if (!newBinding && property->propType == qMetaTypeId<QJSValue>()) {
- PROPERTY_STORE(QJSValue, new QJSValuePrivate(ctx->engine, value));
+ PROPERTY_STORE(QJSValue, new QJSValuePrivate(ctx->d()->engine, value));
} else if (value->isUndefined()) {
QString error = QLatin1String("Cannot assign [undefined] to ");
if (!QMetaType::typeName(property->propType))
} else {
QVariant v;
if (property->isQList())
- v = ctx->engine->v8Engine->toVariant(value, qMetaTypeId<QList<QObject *> >());
+ v = ctx->d()->engine->v8Engine->toVariant(value, qMetaTypeId<QList<QObject *> >());
else
- v = ctx->engine->v8Engine->toVariant(value, property->propType);
+ v = ctx->d()->engine->v8Engine->toVariant(value, property->propType);
- QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine);
+ QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->d()->engine);
if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) {
const char *valueType = 0;
if (v.userType() == QVariant::Invalid) valueType = "null";
ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
{
- if (ctx->callData->argc == 0)
+ if (ctx->d()->callData->argc == 0)
V4THROW_ERROR("Function.prototype.connect: no arguments given");
- QPair<QObject *, int> signalInfo = extractQtSignal(ctx->callData->thisObject);
+ QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject);
QObject *signalObject = signalInfo.first;
int signalIndex = signalInfo.second; // in method range, not signal range!
QV4::ScopedFunctionObject f(scope);
QV4::ScopedValue thisObject (scope, QV4::Encode::undefined());
- if (ctx->callData->argc == 1) {
- f = ctx->callData->args[0];
- } else if (ctx->callData->argc >= 2) {
- thisObject = ctx->callData->args[0];
- f = ctx->callData->args[1];
+ if (ctx->d()->callData->argc == 1) {
+ f = ctx->d()->callData->args[0];
+ } else if (ctx->d()->callData->argc >= 2) {
+ thisObject = ctx->d()->callData->args[0];
+ f = ctx->d()->callData->args[1];
}
if (!f)
ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx)
{
- if (ctx->callData->argc == 0)
+ if (ctx->d()->callData->argc == 0)
V4THROW_ERROR("Function.prototype.disconnect: no arguments given");
QV4::Scope scope(ctx);
- QPair<QObject *, int> signalInfo = extractQtSignal(ctx->callData->thisObject);
+ QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject);
QObject *signalObject = signalInfo.first;
int signalIndex = signalInfo.second;
QV4::ScopedFunctionObject functionValue(scope);
QV4::ScopedValue functionThisValue(scope, QV4::Encode::undefined());
- if (ctx->callData->argc == 1) {
- functionValue = ctx->callData->args[0];
- } else if (ctx->callData->argc >= 2) {
- functionThisValue = ctx->callData->args[0];
- functionValue = ctx->callData->args[1];
+ if (ctx->d()->callData->argc == 1) {
+ functionValue = ctx->d()->callData->args[0];
+ } else if (ctx->d()->callData->argc >= 2) {
+ functionThisValue = ctx->d()->callData->args[0];
+ functionValue = ctx->d()->callData->args[1];
}
if (!functionValue)
QPair<QObject *, int> functionData = extractQtMethod(functionValue);
void *a[] = {
- ctx->engine,
+ ctx->d()->engine,
functionValue.ptr,
functionThisValue.ptr,
functionData.first,
ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal)
{
- return (new (scope->engine->memoryManager) QObjectMethod(scope, object, index, qmlGlobal))->asReturnedValue();
+ return (new (scope->d()->engine->memoryManager) QObjectMethod(scope, object, index, qmlGlobal))->asReturnedValue();
}
QObjectMethod::QObjectMethod(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal)
result = QLatin1String("null");
}
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const ValueRef args, int argc)
if (!ddata)
return Encode::undefined();
- QV8Engine *v8Engine = context->engine->v8Engine;
+ QV8Engine *v8Engine = context->d()->engine->v8Engine;
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
QV4::Scope scope(v4);
Property *RegExpObject::lastIndexProperty(ExecutionContext *ctx)
{
Q_UNUSED(ctx);
- Q_ASSERT(0 == internalClass()->find(ctx->engine->newIdentifier(QStringLiteral("lastIndex"))));
+ Q_ASSERT(0 == internalClass()->find(ctx->d()->engine->newIdentifier(QStringLiteral("lastIndex"))));
return propertyAt(0);
}
return ctx->throwTypeError();
Scoped<RegExp> newRe(scope, re->value());
- return Encode(ctx->engine->newRegExpObject(newRe, re->global()));
+ return Encode(ctx->d()->engine->newRegExpObject(newRe, re->global()));
}
QString pattern;
}
}
- Scoped<RegExp> regexp(scope, RegExp::create(ctx->engine, pattern, ignoreCase, multiLine));
+ Scoped<RegExp> regexp(scope, RegExp::create(ctx->d()->engine, pattern, ignoreCase, multiLine));
if (!regexp->isValid())
return ctx->throwSyntaxError(QStringLiteral("Invalid regular expression"));
- return Encode(ctx->engine->newRegExpObject(regexp, global));
+ return Encode(ctx->d()->engine->newRegExpObject(regexp, global));
}
ReturnedValue RegExpCtor::call(Managed *that, CallData *callData)
ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
return ctx->throwTypeError();
uint* matchOffsets = (uint*)alloca(r->value()->captureCount() * 2 * sizeof(uint));
const int result = r->value()->match(s, offset, matchOffsets);
- Scoped<RegExpCtor> regExpCtor(scope, ctx->engine->regExpCtor);
+ Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
regExpCtor->clearLastMatch();
if (result == -1) {
}
// fill in result data
- Scoped<ArrayObject> array(scope, ctx->engine->newArrayObject(ctx->engine->regExpExecArrayClass));
+ Scoped<ArrayObject> array(scope, ctx->d()->engine->newArrayObject(ctx->d()->engine->regExpExecArrayClass));
int len = r->value()->captureCount();
array->arrayReserve(len);
ScopedValue v(scope);
for (int i = 0; i < len; ++i) {
int start = matchOffsets[i * 2];
int end = matchOffsets[i * 2 + 1];
- v = (start != -1 && end != -1) ? ctx->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined();
+ v = (start != -1 && end != -1) ? ctx->d()->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined();
array->arrayPut(i, v);
}
array->setArrayLengthUnchecked(len);
ReturnedValue RegExpPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
return ctx->throwTypeError();
- return ctx->engine->newString(r->toString())->asReturnedValue();
+ return ctx->d()->engine->newString(r->toString())->asReturnedValue();
}
ReturnedValue RegExpPrototype::method_compile(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpObject> r(scope, ctx->callData->thisObject.as<RegExpObject>());
+ Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>());
if (!r)
return ctx->throwTypeError();
- ScopedCallData callData(scope, ctx->callData->argc);
- memcpy(callData->args, ctx->callData->args, ctx->callData->argc*sizeof(Value));
+ ScopedCallData callData(scope, ctx->d()->callData->argc);
+ memcpy(callData->args, ctx->d()->callData->args, ctx->d()->callData->argc*sizeof(Value));
- Scoped<RegExpObject> re(scope, ctx->engine->regExpCtor.asFunctionObject()->construct(callData));
+ Scoped<RegExpObject> re(scope, ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData));
r->d()->value = re->value();
r->d()->global = re->global();
ReturnedValue RegExpPrototype::method_get_lastMatch_n(CallContext *ctx)
{
Scope scope(ctx);
- ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(ctx->engine->regExpCtor.objectValue())->lastMatch());
+ ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(ctx->d()->engine->regExpCtor.objectValue())->lastMatch());
ScopedValue result(scope, lastMatch ? lastMatch->getIndexed(index) : Encode::undefined());
if (result->isUndefined())
- return ctx->engine->newString(QString())->asReturnedValue();
+ return ctx->d()->engine->newString(QString())->asReturnedValue();
return result.asReturnedValue();
}
ReturnedValue RegExpPrototype::method_get_lastParen(CallContext *ctx)
{
Scope scope(ctx);
- ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(ctx->engine->regExpCtor.objectValue())->lastMatch());
+ ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(ctx->d()->engine->regExpCtor.objectValue())->lastMatch());
ScopedValue result(scope, lastMatch ? lastMatch->getIndexed(lastMatch->getLength() - 1) : Encode::undefined());
if (result->isUndefined())
- return ctx->engine->newString(QString())->asReturnedValue();
+ return ctx->d()->engine->newString(QString())->asReturnedValue();
return result.asReturnedValue();
}
ReturnedValue RegExpPrototype::method_get_input(CallContext *ctx)
{
- return static_cast<RegExpCtor*>(ctx->engine->regExpCtor.objectValue())->lastInput().asReturnedValue();
+ return static_cast<RegExpCtor*>(ctx->d()->engine->regExpCtor.objectValue())->lastInput().asReturnedValue();
}
ReturnedValue RegExpPrototype::method_get_leftContext(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpCtor> regExpCtor(scope, ctx->engine->regExpCtor);
+ Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
QString lastInput = regExpCtor->lastInput()->toQString();
- return ctx->engine->newString(lastInput.left(regExpCtor->lastMatchStart()))->asReturnedValue();
+ return ctx->d()->engine->newString(lastInput.left(regExpCtor->lastMatchStart()))->asReturnedValue();
}
ReturnedValue RegExpPrototype::method_get_rightContext(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<RegExpCtor> regExpCtor(scope, ctx->engine->regExpCtor);
+ Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
QString lastInput = regExpCtor->lastInput()->toQString();
- return ctx->engine->newString(lastInput.mid(regExpCtor->lastMatchEnd()))->asReturnedValue();
+ return ctx->d()->engine->newString(lastInput.mid(regExpCtor->lastMatchEnd()))->asReturnedValue();
}
QT_END_NAMESPACE
ReturnedValue Runtime::closure(ExecutionContext *ctx, int functionId)
{
- QV4::Function *clos = ctx->compilationUnit->runtimeFunctions[functionId];
+ QV4::Function *clos = ctx->d()->compilationUnit->runtimeFunctions[functionId];
Q_ASSERT(clos);
FunctionObject *f = FunctionObject::createScriptFunction(ctx, clos);
return f->asReturnedValue();
{
QString qstr;
RuntimeHelpers::numberToString(&qstr, number, 10);
- return ctx->engine->newString(qstr);
+ return ctx->engine()->newString(qstr);
}
ReturnedValue RuntimeHelpers::objectDefaultValue(Object *object, int typeHint)
ctx->throwTypeError();
return 0;
case Value::Boolean_Type:
- return ctx->engine->newBooleanObject(value);
+ return ctx->engine()->newBooleanObject(value);
case Value::Managed_Type:
Q_ASSERT(value->isString());
- return ctx->engine->newStringObject(value);
+ return ctx->engine()->newStringObject(value);
case Value::Integer_Type:
default: // double
- return ctx->engine->newNumberObject(value);
+ return ctx->engine()->newNumberObject(value);
}
}
case Value::Empty_Type:
Q_ASSERT(!"empty Value encountered");
case Value::Undefined_Type:
- return ctx->engine->id_undefined.ret();
+ return ctx->engine()->id_undefined.ret();
case Value::Null_Type:
- return ctx->engine->id_null.ret();
+ return ctx->engine()->id_null.ret();
case Value::Boolean_Type:
if (value->booleanValue())
- return ctx->engine->id_true.ret();
+ return ctx->engine()->id_true.ret();
else
- return ctx->engine->id_false.ret();
+ return ctx->engine()->id_false.ret();
case Value::Managed_Type:
if (value->isString())
return value->stringValue()->asReturned<String>();
case Value::Empty_Type:
Q_ASSERT(!"empty Value encountered");
case Value::Undefined_Type:
- return ctx->engine->id_undefined.ret();
+ return ctx->engine()->id_undefined.ret();
case Value::Null_Type:
- return ctx->engine->id_null.ret();
+ return ctx->engine()->id_null.ret();
case Value::Boolean_Type:
if (value->booleanValue())
- return ctx->engine->id_true.ret();
+ return ctx->engine()->id_true.ret();
else
- return ctx->engine->id_false.ret();
+ return ctx->engine()->id_false.ret();
case Value::Managed_Type:
if (value->isString())
return value->stringValue()->asReturned<String>();
return pright->asReturnedValue();
if (!pright->stringValue()->length())
return pleft->asReturnedValue();
- return (new (ctx->engine->memoryManager) String(ctx->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue();
+ return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue();
}
double x = RuntimeHelpers::toNumber(pleft);
double y = RuntimeHelpers::toNumber(pright);
return right->asReturnedValue();
if (!right->stringValue()->length())
return left->asReturnedValue();
- return (new (ctx->engine->memoryManager) String(ctx->engine, left->stringValue(), right->stringValue()))->asReturnedValue();
+ return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, left->stringValue(), right->stringValue()))->asReturnedValue();
}
Scope scope(ctx);
return pright->asReturnedValue();
if (!pright->stringValue()->length())
return pleft->asReturnedValue();
- return (new (ctx->engine->memoryManager) String(ctx->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue();
+ return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue();
}
void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value)
Scoped<Object> o(scope, (Object *)0);
if (!in->isNullOrUndefined())
o = in->toObject(ctx);
- Scoped<Object> it(scope, ctx->engine->newForEachIteratorObject(ctx, o));
+ Scoped<Object> it(scope, ctx->engine()->newForEachIteratorObject(ctx, o));
return it.asReturnedValue();
}
Scope scope(context);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = context->lookups + index;
+ Lookup *l = context->d()->lookups + index;
Scoped<FunctionObject> o(scope, l->globalGetter(l, context));
if (!o)
return context->throwTypeError();
- if (o.getPointer() == context->engine->evalFunction && l->name->equals(context->engine->id_eval))
+ if (o.getPointer() == scope.engine->evalFunction && l->name->equals(scope.engine->id_eval))
return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true);
return o->call(callData);
ScopedObject base(scope);
ScopedValue func(scope, context->getPropertyAndBase(name, base));
- if (context->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
if (base)
return context->throwTypeError(msg);
}
- if (o == context->engine->evalFunction && name->equals(context->engine->id_eval)) {
+ if (o == scope.engine->evalFunction && name->equals(scope.engine->id_eval)) {
return static_cast<EvalFunction *>(o)->evalCall(callData, true);
}
ReturnedValue Runtime::callPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData)
{
- Lookup *l = context->lookups + index;
+ Lookup *l = context->d()->lookups + index;
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
Scope scope(context);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = context->lookups + index;
+ Lookup *l = context->d()->lookups + index;
Scoped<Object> f(scope, l->globalGetter(l, context));
if (!f)
return context->throwTypeError();
{
Scope scope(context);
ScopedValue func(scope, context->getProperty(name));
- if (context->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
Object *f = func->asObject();
ReturnedValue Runtime::constructPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData)
{
- Lookup *l = context->lookups + index;
+ Lookup *l = context->d()->lookups + index;
Value v;
v = l->getter(l, callData->thisObject);
if (!v.isObject())
ScopedString res(scope);
switch (value->type()) {
case Value::Undefined_Type:
- res = ctx->engine->id_undefined;
+ res = ctx->engine()->id_undefined;
break;
case Value::Null_Type:
- res = ctx->engine->id_object;
+ res = ctx->engine()->id_object;
break;
case Value::Boolean_Type:
- res = ctx->engine->id_boolean;
+ res = ctx->engine()->id_boolean;
break;
case Value::Managed_Type:
if (value->isString())
- res = ctx->engine->id_string;
+ res = ctx->engine()->id_string;
else if (value->objectValue()->asFunctionObject())
- res = ctx->engine->id_function;
+ res = ctx->engine()->id_function;
else
- res = ctx->engine->id_object; // ### implementation-defined
+ res = ctx->engine()->id_object; // ### implementation-defined
break;
default:
- res = ctx->engine->id_number;
+ res = ctx->engine()->id_number;
break;
}
return res.asReturnedValue();
Scope scope(context);
ScopedValue prop(scope, context->getProperty(name));
// typeof doesn't throw. clear any possible exception
- context->engine->hasException = false;
+ scope.engine->hasException = false;
return Runtime::typeofValue(context, prop);
}
ReturnedValue Runtime::unwindException(ExecutionContext *ctx)
{
- if (!ctx->engine->hasException)
+ if (!ctx->engine()->hasException)
return Primitive::emptyValue().asReturnedValue();
- return ctx->engine->catchException(ctx, 0);
+ return ctx->engine()->catchException(ctx, 0);
}
ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, const StringRef exceptionVarName)
{
Scope scope(ctx);
- ScopedValue v(scope, ctx->engine->catchException(ctx, 0));
+ ScopedValue v(scope, ctx->engine()->catchException(ctx, 0));
return ctx->newCatchContext(exceptionVarName, v);
}
ExecutionContext *Runtime::popScope(ExecutionContext *ctx)
{
- return ctx->engine->popContext();
+ return ctx->engine()->popContext();
}
void Runtime::declareVar(ExecutionContext *ctx, bool deletable, const StringRef name)
ReturnedValue Runtime::arrayLiteral(ExecutionContext *ctx, Value *values, uint length)
{
Scope scope(ctx);
- Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
+ Scoped<ArrayObject> a(scope, ctx->engine()->newArrayObject());
if (length) {
a->arrayReserve(length);
ReturnedValue Runtime::objectLiteral(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)
{
Scope scope(ctx);
- QV4::InternalClass *klass = ctx->compilationUnit->runtimeClasses[classId];
- Scoped<Object> o(scope, ctx->engine->newObject(klass));
+ QV4::InternalClass *klass = ctx->d()->compilationUnit->runtimeClasses[classId];
+ Scoped<Object> o(scope, ctx->engine()->newObject(klass));
{
bool needSparseArray = arrayGetterSetterCountAndFlags >> 30;
QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionContext *ctx)
{
- assert(ctx->type >= ExecutionContext::Type_CallContext);
+ Q_ASSERT(ctx->d()->type >= ExecutionContext::Type_CallContext);
CallContext *c = static_cast<CallContext *>(ctx);
- return (new (c->engine->memoryManager) ArgumentsObject(c))->asReturnedValue();
+ return (new (c->engine()->memoryManager) ArgumentsObject(c))->asReturnedValue();
}
#endif // V4_BOOTSTRAP
ReturnedValue Runtime::regexpLiteral(ExecutionContext *ctx, int id)
{
- return ctx->compilationUnit->runtimeRegularExpressions[id].asReturnedValue();
+ return ctx->d()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue();
}
ReturnedValue Runtime::getQmlIdArray(NoThrowContext *ctx)
{
- return ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->idObjectsArray();
+ return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->idObjectsArray();
}
ReturnedValue Runtime::getQmlContextObject(NoThrowContext *ctx)
{
- QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine);
+ QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine());
if (!context)
return Encode::undefined();
- return QObjectWrapper::wrap(ctx->engine, context->contextObject);
+ return QObjectWrapper::wrap(ctx->d()->engine, context->contextObject);
}
ReturnedValue Runtime::getQmlScopeObject(NoThrowContext *ctx)
{
Scope scope(ctx);
- QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
- return QObjectWrapper::wrap(ctx->engine, c->getScopeObject());
+ QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ return QObjectWrapper::wrap(ctx->d()->engine, c->getScopeObject());
}
ReturnedValue Runtime::getQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object, int propertyIndex, bool captureRequired)
QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionContext *ctx, int attachedPropertiesId, int propertyIndex)
{
Scope scope(ctx);
- QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
+ QV4::Scoped<QmlContextWrapper> c(scope, ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>());
QObject *scopeObject = c->getScopeObject();
QObject *attachedObject = qmlAttachedPropertiesObjectById(attachedPropertiesId, scopeObject);
- QQmlEngine *qmlEngine = ctx->engine->v8Engine->engine();
+ QQmlEngine *qmlEngine = ctx->engine()->v8Engine->engine();
QQmlData::ensurePropertyCache(qmlEngine, attachedObject);
return QV4::QObjectWrapper::getProperty(attachedObject, ctx, propertyIndex, /*captureRequired*/true);
}
ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx)
{
- QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine);
+ QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine());
if (!context)
return Encode::undefined();
return context->importedScripts.value();
QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, const QV4::StringRef name)
{
- return ctx->engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine->v8Engine, name);
+ return ctx->engine()->qmlContextObject()->getPointer()->as<QmlContextWrapper>()->qmlSingletonWrapper(ctx->engine()->v8Engine, name);
}
void Runtime::convertThisToObject(ExecutionContext *ctx)
{
- Value *t = &ctx->callData->thisObject;
+ Value *t = &ctx->d()->callData->thisObject;
if (t->isObject())
return;
if (t->isNullOrUndefined()) {
- *t = ctx->engine->globalObject->asReturnedValue();
+ *t = ctx->engine()->globalObject->asReturnedValue();
} else {
*t = t->toObject(ctx)->asReturnedValue();
}
using namespace QV4;
QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml)
- : FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false)
+ : FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
{
d()->qml = qml;
Scope s(scope);
ScopedValue protectThis(s, this);
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
- scope->engine->popContext();
+ d()->qmlContext = scope->d()->engine->currentContext()->newQmlContext(this, qml);
+ scope->d()->engine->popContext();
}
QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml)
- : FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false)
+ : FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
{
d()->qml = qml;
Scope s(scope);
ScopedValue protectThis(s, this);
- defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1));
+ defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml);
- scope->engine->popContext();
+ d()->qmlContext = scope->d()->engine->currentContext()->newQmlContext(this, qml);
+ scope->d()->engine->popContext();
}
ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *)
static ReturnedValue signalParameterGetter(QV4::CallContext *ctx, uint parameterIndex)
{
- QV4::CallContext *signalEmittingContext = ctx->parent->asCallContext();
+ QV4::CallContext *signalEmittingContext = ctx->d()->parent->asCallContext();
Q_ASSERT(signalEmittingContext);
return signalEmittingContext->argument(parameterIndex);
}
parsed = true;
- ExecutionEngine *v4 = scope->engine;
+ ExecutionEngine *v4 = scope->d()->engine;
Scope valueScope(v4);
MemoryManager::GCBlocker gcBlocker(v4->memoryManager);
ContextStateSaver(ExecutionContext *context)
: savedContext(context)
- , strictMode(context->strictMode)
- , lookups(context->lookups)
- , compilationUnit(context->compilationUnit)
+ , strictMode(context->d()->strictMode)
+ , lookups(context->d()->lookups)
+ , compilationUnit(context->d()->compilationUnit)
{}
~ContextStateSaver()
{
- savedContext->strictMode = strictMode;
- savedContext->lookups = lookups;
- savedContext->compilationUnit = compilationUnit;
+ savedContext->d()->strictMode = strictMode;
+ savedContext->d()->lookups = lookups;
+ savedContext->d()->compilationUnit = compilationUnit;
}
};
if (!vmFunction)
return Encode::undefined();
- QV4::ExecutionEngine *engine = scope->engine;
+ QV4::ExecutionEngine *engine = scope->d()->engine;
QV4::Scope valueScope(engine);
if (qml.isUndefined()) {
ExecutionContextSaver ctxSaver(scope);
ContextStateSaver stateSaver(scope);
- scope->strictMode = vmFunction->isStrict();
- scope->lookups = vmFunction->compilationUnit->runtimeLookups;
- scope->compilationUnit = vmFunction->compilationUnit;
+ scope->d()->strictMode = vmFunction->isStrict();
+ scope->d()->lookups = vmFunction->compilationUnit->runtimeLookups;
+ scope->d()->compilationUnit = vmFunction->compilationUnit;
return vmFunction->code(scope, vmFunction->codeData);
} else {
{
if (!parsed)
parse();
- ExecutionEngine *v4 = scope->engine;
+ ExecutionEngine *v4 = scope->d()->engine;
Scope valueScope(v4);
ScopedObject qmlObj(valueScope, qml.value());
ScopedObject v(valueScope, new (v4->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj));
// helper function to generate valid warnings if errors occur during sequence operations.
static void generateWarning(QV4::ExecutionContext *ctx, const QString& description)
{
- QQmlEngine *engine = ctx->engine->v8Engine->engine();
+ QQmlEngine *engine = ctx->d()->engine->v8Engine->engine();
if (!engine)
return;
QQmlError retn;
retn.setDescription(description);
- QV4::StackFrame frame = ctx->engine->currentStackFrame();
+ QV4::StackFrame frame = ctx->d()->engine->currentStackFrame();
retn.setLine(frame.line);
retn.setUrl(QUrl(frame.source));
QV4::Scope scope(m_ctx);
ScopedObject compare(scope, m_compareFn);
ScopedCallData callData(scope, 2);
- callData->args[0] = convertElementToValue(this->m_ctx->engine, lhs);
- callData->args[1] = convertElementToValue(this->m_ctx->engine, rhs);
- callData->thisObject = this->m_ctx->engine->globalObject;
+ callData->args[0] = convertElementToValue(this->m_ctx->d()->engine, lhs);
+ callData->args[1] = convertElementToValue(this->m_ctx->d()->engine, rhs);
+ callData->thisObject = this->m_ctx->d()->engine->globalObject;
QV4::ScopedValue result(scope, compare->call(callData));
return result->toNumber() < 0;
}
}
QV4::Scope scope(ctx);
- if (ctx->callData->argc == 1 && ctx->callData->args[0].asFunctionObject()) {
- CompareFunctor cf(ctx, ctx->callData->args[0]);
+ if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].asFunctionObject()) {
+ CompareFunctor cf(ctx, ctx->d()->callData->args[0]);
std::sort(d()->container.begin(), d()->container.end(), cf);
} else {
DefaultCompareFunctor cf;
static QV4::ReturnedValue method_get_length(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->callData->thisObject.as<QQmlSequence<Container> >());
+ QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
if (!This)
return ctx->throwTypeError();
static QV4::ReturnedValue method_set_length(QV4::CallContext* ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->callData->thisObject.as<QQmlSequence<Container> >());
+ QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >());
if (!This)
return ctx->throwTypeError();
- quint32 newLength = ctx->callData->args[0].toUInt32();
+ quint32 newLength = ctx->d()->callData->args[0].toUInt32();
/* Qt containers have int (rather than uint) allowable indexes. */
if (newLength > INT_MAX) {
generateWarning(ctx, QLatin1String("Index out of range during length set"));
QV4::ReturnedValue SequencePrototype::method_sort(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::ScopedObject o(scope, ctx->callData->thisObject);
+ QV4::ScopedObject o(scope, ctx->d()->callData->thisObject);
if (!o || !o->isListType())
return ctx->throwTypeError();
- if (ctx->callData->argc >= 2)
+ if (ctx->d()->callData->argc >= 2)
return o.asReturnedValue();
#define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \
static ReturnedValue method_valueOf(QV4::CallContext *ctx)
{
- return ctx->callData->thisObject.toString(ctx)->asReturnedValue();
+ return ctx->d()->callData->thisObject.toString(ctx)->asReturnedValue();
}
static ReturnedValue method_sort(QV4::CallContext *ctx);
}
if (index < static_cast<uint>(o->d()->value.stringValue()->toQString().length())) {
- if (v4->currentContext()->strictMode)
+ if (v4->currentContext()->d()->strictMode)
v4->currentContext()->throwTypeError();
return false;
}
static QString getThisString(ExecutionContext *ctx)
{
Scope scope(ctx);
- ScopedValue t(scope, ctx->callData->thisObject);
+ ScopedValue t(scope, ctx->d()->callData->thisObject);
if (t->isString())
return t->stringValue()->toQString();
if (StringObject *thisString = t->asStringObject())
ReturnedValue StringPrototype::method_toString(CallContext *context)
{
- if (context->callData->thisObject.isString())
- return context->callData->thisObject.asReturnedValue();
+ if (context->d()->callData->thisObject.isString())
+ return context->d()->callData->thisObject.asReturnedValue();
- StringObject *o = context->callData->thisObject.asStringObject();
+ StringObject *o = context->d()->callData->thisObject.asStringObject();
if (!o)
return context->throwTypeError();
return o->d()->value.asReturnedValue();
ReturnedValue StringPrototype::method_charAt(CallContext *context)
{
const QString str = getThisString(context);
- if (context->engine->hasException)
+ if (context->d()->engine->hasException)
return Encode::undefined();
int pos = 0;
- if (context->callData->argc > 0)
- pos = (int) context->callData->args[0].toInteger();
+ if (context->d()->callData->argc > 0)
+ pos = (int) context->d()->callData->args[0].toInteger();
QString result;
if (pos >= 0 && pos < str.length())
result += str.at(pos);
- return context->engine->newString(result)->asReturnedValue();
+ return context->d()->engine->newString(result)->asReturnedValue();
}
ReturnedValue StringPrototype::method_charCodeAt(CallContext *context)
{
const QString str = getThisString(context);
- if (context->engine->hasException)
+ if (context->d()->engine->hasException)
return Encode::undefined();
int pos = 0;
- if (context->callData->argc > 0)
- pos = (int) context->callData->args[0].toInteger();
+ if (context->d()->callData->argc > 0)
+ pos = (int) context->d()->callData->args[0].toInteger();
if (pos >= 0 && pos < str.length())
return Encode::undefined();
ScopedValue v(scope);
- for (int i = 0; i < context->callData->argc; ++i) {
- v = RuntimeHelpers::toString(context, ValueRef(&context->callData->args[i]));
+ for (int i = 0; i < context->d()->callData->argc; ++i) {
+ v = RuntimeHelpers::toString(context, ValueRef(&context->d()->callData->args[i]));
if (scope.hasException())
return Encode::undefined();
Q_ASSERT(v->isString());
value += v->stringValue()->toQString();
}
- return context->engine->newString(value)->asReturnedValue();
+ return context->d()->engine->newString(value)->asReturnedValue();
}
ReturnedValue StringPrototype::method_indexOf(CallContext *context)
{
QString value = getThisString(context);
- if (context->engine->hasException)
+ if (context->d()->engine->hasException)
return Encode::undefined();
QString searchString;
- if (context->callData->argc)
- searchString = context->callData->args[0].toString(context)->toQString();
+ if (context->d()->callData->argc)
+ searchString = context->d()->callData->args[0].toString(context)->toQString();
int pos = 0;
- if (context->callData->argc > 1)
- pos = (int) context->callData->args[1].toInteger();
+ if (context->d()->callData->argc > 1)
+ pos = (int) context->d()->callData->args[1].toInteger();
int index = -1;
if (! value.isEmpty())
return Encode::undefined();
QString searchString;
- if (context->callData->argc)
- searchString = context->callData->args[0].toQString();
+ if (context->d()->callData->argc)
+ searchString = context->d()->callData->args[0].toQString();
ScopedValue posArg(scope, context->argument(1));
double position = RuntimeHelpers::toNumber(posArg);
if (scope.engine->hasException)
return Encode::undefined();
- ScopedValue v(scope, context->callData->argument(0));
+ ScopedValue v(scope, context->d()->callData->argument(0));
const QString that = v->toQString();
return Encode(QString::localeAwareCompare(value, that));
}
ReturnedValue StringPrototype::method_match(CallContext *context)
{
- if (context->callData->thisObject.isUndefined() || context->callData->thisObject.isNull())
+ if (context->d()->callData->thisObject.isUndefined() || context->d()->callData->thisObject.isNull())
return context->throwTypeError();
Scope scope(context);
- ScopedString s(scope, context->callData->thisObject.toString(context));
+ ScopedString s(scope, context->d()->callData->thisObject.toString(context));
- ScopedValue regexp(scope, context->callData->argument(0));
+ ScopedValue regexp(scope, context->d()->callData->argument(0));
Scoped<RegExpObject> rx(scope, regexp);
if (!rx) {
ScopedCallData callData(scope, 1);
callData->args[0] = regexp;
- rx = context->engine->regExpCtor.asFunctionObject()->construct(callData);
+ rx = context->d()->engine->regExpCtor.asFunctionObject()->construct(callData);
}
if (!rx)
bool global = rx->global();
// ### use the standard builtin function, not the one that might be redefined in the proto
- ScopedString execString(scope, context->engine->newString(QStringLiteral("exec")));
- Scoped<FunctionObject> exec(scope, context->engine->regExpClass->prototype->get(execString));
+ ScopedString execString(scope, context->d()->engine->newString(QStringLiteral("exec")));
+ Scoped<FunctionObject> exec(scope, context->d()->engine->regExpClass->prototype->get(execString));
ScopedCallData callData(scope, 1);
callData->thisObject = rx;
if (!global)
return exec->call(callData);
- ScopedString lastIndex(scope, context->engine->newString(QStringLiteral("lastIndex")));
+ ScopedString lastIndex(scope, context->d()->engine->newString(QStringLiteral("lastIndex")));
rx->put(lastIndex, ScopedValue(scope, Primitive::fromInt32(0)));
- Scoped<ArrayObject> a(scope, context->engine->newArrayObject());
+ Scoped<ArrayObject> a(scope, context->d()->engine->newArrayObject());
double previousLastIndex = 0;
uint n = 0;
{
Scope scope(ctx);
QString string;
- if (StringObject *thisString = ctx->callData->thisObject.asStringObject())
+ if (StringObject *thisString = ctx->d()->callData->thisObject.asStringObject())
string = thisString->d()->value.stringValue()->toQString();
else
- string = ctx->callData->thisObject.toString(ctx)->toQString();
+ string = ctx->d()->callData->thisObject.toString(ctx)->toQString();
int numCaptures = 0;
int numStringMatches = 0;
uint end = matchOffsets[idx + 1];
entry = Primitive::undefinedValue();
if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch)
- entry = ctx->engine->newString(string.mid(start, end - start));
+ entry = ctx->d()->engine->newString(string.mid(start, end - start));
callData->args[k] = entry;
}
uint matchStart = matchOffsets[i * numCaptures * 2];
Q_ASSERT(matchStart >= static_cast<uint>(lastEnd));
uint matchEnd = matchOffsets[i * numCaptures * 2 + 1];
callData->args[numCaptures] = Primitive::fromUInt32(matchStart);
- callData->args[numCaptures + 1] = ctx->engine->newString(string);
+ callData->args[numCaptures + 1] = ctx->d()->engine->newString(string);
replacement = searchCallback->call(callData);
result += string.midRef(lastEnd, matchStart - lastEnd);
if (matchOffsets != _matchOffsets)
free(matchOffsets);
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
ReturnedValue StringPrototype::method_search(CallContext *ctx)
if (!regExp) {
ScopedCallData callData(scope, 1);
callData->args[0] = regExpValue;
- regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(callData);
+ regExpValue = ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData);
if (scope.engine->hasException)
return Encode::undefined();
regExp = regExpValue->as<RegExpObject>();
ReturnedValue StringPrototype::method_slice(CallContext *ctx)
{
const QString text = getThisString(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
const double length = text.length();
- double start = ctx->callData->argc ? ctx->callData->args[0].toInteger() : 0;
- double end = (ctx->callData->argc < 2 || ctx->callData->args[1].isUndefined())
- ? length : ctx->callData->args[1].toInteger();
+ double start = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toInteger() : 0;
+ double end = (ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined())
+ ? length : ctx->d()->callData->args[1].toInteger();
if (start < 0)
start = qMax(length + start, 0.);
const int intEnd = int(end);
int count = qMax(0, intEnd - intStart);
- return ctx->engine->newString(text.mid(intStart, count))->asReturnedValue();
+ return ctx->d()->engine->newString(text.mid(intStart, count))->asReturnedValue();
}
ReturnedValue StringPrototype::method_split(CallContext *ctx)
ScopedValue separatorValue(scope, ctx->argument(0));
ScopedValue limitValue(scope, ctx->argument(1));
- ScopedArrayObject array(scope, ctx->engine->newArrayObject());
+ ScopedArrayObject array(scope, ctx->d()->engine->newArrayObject());
if (separatorValue->isUndefined()) {
if (limitValue->isUndefined()) {
- ScopedString s(scope, ctx->engine->newString(text));
+ ScopedString s(scope, ctx->d()->engine->newString(text));
array->push_back(s);
return array.asReturnedValue();
}
- return ctx->engine->newString(text.left(limitValue->toInteger()))->asReturnedValue();
+ return ctx->d()->engine->newString(text.left(limitValue->toInteger()))->asReturnedValue();
}
uint limit = limitValue->isUndefined() ? UINT_MAX : limitValue->toUInt32();
if (re) {
if (re->value()->pattern().isEmpty()) {
re = (RegExpObject *)0;
- separatorValue = ctx->engine->newString(QString());
+ separatorValue = ctx->d()->engine->newString(QString());
}
}
if (result == JSC::Yarr::offsetNoMatch)
break;
- array->push_back((s = ctx->engine->newString(text.mid(offset, matchOffsets[0] - offset))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(offset, matchOffsets[0] - offset))));
offset = qMax(offset + 1, matchOffsets[1]);
if (array->getLength() >= limit)
for (int i = 1; i < re->value()->captureCount(); ++i) {
uint start = matchOffsets[i * 2];
uint end = matchOffsets[i * 2 + 1];
- array->push_back((s = ctx->engine->newString(text.mid(start, end - start))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(start, end - start))));
if (array->getLength() >= limit)
break;
}
}
if (array->getLength() < limit)
- array->push_back((s = ctx->engine->newString(text.mid(offset))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(offset))));
} else {
QString separator = separatorValue->toString(ctx)->toQString();
if (separator.isEmpty()) {
for (uint i = 0; i < qMin(limit, uint(text.length())); ++i)
- array->push_back((s = ctx->engine->newString(text.mid(i, 1))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(i, 1))));
return array.asReturnedValue();
}
int start = 0;
int end;
while ((end = text.indexOf(separator, start)) != -1) {
- array->push_back((s = ctx->engine->newString(text.mid(start, end - start))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(start, end - start))));
start = end + separator.size();
if (array->getLength() >= limit)
break;
}
if (array->getLength() < limit && start != -1)
- array->push_back((s = ctx->engine->newString(text.mid(start))));
+ array->push_back((s = ctx->d()->engine->newString(text.mid(start))));
}
return array.asReturnedValue();
}
ReturnedValue StringPrototype::method_substr(CallContext *context)
{
const QString value = getThisString(context);
- if (context->engine->hasException)
+ if (context->d()->engine->hasException)
return Encode::undefined();
double start = 0;
- if (context->callData->argc > 0)
- start = context->callData->args[0].toInteger();
+ if (context->d()->callData->argc > 0)
+ start = context->d()->callData->args[0].toInteger();
double length = +qInf();
- if (context->callData->argc > 1)
- length = context->callData->args[1].toInteger();
+ if (context->d()->callData->argc > 1)
+ length = context->d()->callData->args[1].toInteger();
double count = value.length();
if (start < 0)
qint32 x = Primitive::toInt32(start);
qint32 y = Primitive::toInt32(length);
- return context->engine->newString(value.mid(x, y))->asReturnedValue();
+ return context->d()->engine->newString(value.mid(x, y))->asReturnedValue();
}
ReturnedValue StringPrototype::method_substring(CallContext *context)
{
QString value = getThisString(context);
- if (context->engine->hasException)
+ if (context->d()->engine->hasException)
return Encode::undefined();
int length = value.length();
double start = 0;
double end = length;
- if (context->callData->argc > 0)
- start = context->callData->args[0].toInteger();
+ if (context->d()->callData->argc > 0)
+ start = context->d()->callData->args[0].toInteger();
Scope scope(context);
ScopedValue endValue(scope, context->argument(1));
qint32 x = (int)start;
qint32 y = (int)(end - start);
- return context->engine->newString(value.mid(x, y))->asReturnedValue();
+ return context->d()->engine->newString(value.mid(x, y))->asReturnedValue();
}
ReturnedValue StringPrototype::method_toLowerCase(CallContext *ctx)
{
QString value = getThisString(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
- return ctx->engine->newString(value.toLower())->asReturnedValue();
+ return ctx->d()->engine->newString(value.toLower())->asReturnedValue();
}
ReturnedValue StringPrototype::method_toLocaleLowerCase(CallContext *ctx)
ReturnedValue StringPrototype::method_toUpperCase(CallContext *ctx)
{
QString value = getThisString(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
- return ctx->engine->newString(value.toUpper())->asReturnedValue();
+ return ctx->d()->engine->newString(value.toUpper())->asReturnedValue();
}
ReturnedValue StringPrototype::method_toLocaleUpperCase(CallContext *ctx)
ReturnedValue StringPrototype::method_fromCharCode(CallContext *context)
{
- QString str(context->callData->argc, Qt::Uninitialized);
+ QString str(context->d()->callData->argc, Qt::Uninitialized);
QChar *ch = str.data();
- for (int i = 0; i < context->callData->argc; ++i) {
- *ch = QChar(context->callData->args[i].toUInt16());
+ for (int i = 0; i < context->d()->callData->argc; ++i) {
+ *ch = QChar(context->d()->callData->args[i].toUInt16());
++ch;
}
- return context->engine->newString(str)->asReturnedValue();
+ return context->d()->engine->newString(str)->asReturnedValue();
}
ReturnedValue StringPrototype::method_trim(CallContext *ctx)
{
QString s = getThisString(ctx);
- if (ctx->engine->hasException)
+ if (ctx->d()->engine->hasException)
return Encode::undefined();
const QChar *chars = s.constData();
break;
}
- return ctx->engine->newString(QString(chars + start, end - start + 1))->asReturnedValue();
+ return ctx->d()->engine->newString(QString(chars + start, end - start + 1))->asReturnedValue();
}
QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
if (o && o->isScarce())
o->d()->node.remove();
return Encode::undefined();
QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
if (o) {
if (o->isScarce())
o->d()->node.remove();
QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
if (!o)
return Encode::undefined();
QString result = o->d()->data.toString();
if (result.isEmpty() && !o->d()->data.canConvert(QVariant::String))
result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(o->d()->data.typeName()));
- return Encode(ctx->engine->newString(result));
+ return Encode(ctx->d()->engine->newString(result));
}
QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<VariantObject> o(scope, ctx->callData->thisObject.as<QV4::VariantObject>());
+ Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>());
if (o) {
QVariant v = o->d()->data;
switch (v.type()) {
case QVariant::Invalid:
return Encode::undefined();
case QVariant::String:
- return Encode(ctx->engine->newString(v.toString()));
+ return Encode(ctx->d()->engine->newString(v.toString()));
case QVariant::Int:
return Encode(v.toInt());
case QVariant::Double:
break;
}
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
QT_END_NAMESPACE
const uchar *exceptionHandler = 0;
- context->lineNumber = -1;
- QV4::ExecutionEngine *engine = context->engine;
+ context->d()->lineNumber = -1;
+ QV4::ExecutionEngine *engine = context->d()->engine;
#ifdef DO_TRACE_INSTR
qDebug("Starting VME with context=%p and code=%p", context, code);
#endif // DO_TRACE_INSTR
- QV4::StringValue * const runtimeStrings = context->compilationUnit->runtimeStrings;
+ QV4::StringValue * const runtimeStrings = context->d()->compilationUnit->runtimeStrings;
// setup lookup scopes
int scopeDepth = 0;
QV4::ExecutionContext *scope = context;
while (scope) {
++scopeDepth;
- scope = scope->outer;
+ scope = scope->d()->outer;
}
}
QV4::Value **scopes = static_cast<QV4::Value **>(alloca(sizeof(QV4::Value *)*(2 + 2*scopeDepth)));
{
- scopes[0] = const_cast<QV4::Value *>(context->compilationUnit->data->constants());
+ scopes[0] = const_cast<QV4::Value *>(context->d()->compilationUnit->data->constants());
// stack gets setup in push instruction
scopes[1] = 0;
QV4::ExecutionContext *scope = context;
int i = 0;
while (scope) {
- if (scope->type >= QV4::ExecutionContext::Type_SimpleCallContext) {
+ if (scope->d()->type >= QV4::ExecutionContext::Type_SimpleCallContext) {
QV4::CallContext *cc = static_cast<QV4::CallContext *>(scope);
- scopes[2*i + 2] = cc->callData->args;
+ scopes[2*i + 2] = cc->d()->callData->args;
scopes[2*i + 3] = cc->locals;
} else {
scopes[2*i + 2] = 0;
scopes[2*i + 3] = 0;
}
++i;
- scope = scope->outer;
+ scope = scope->d()->outer;
}
}
MOTH_BEGIN_INSTR(LoadRegExp)
// TRACE(value, "%s", instr.value.toString(context)->toQString().toUtf8().constData());
- VALUE(instr.result) = context->compilationUnit->runtimeRegularExpressions[instr.regExpId];
+ VALUE(instr.result) = context->d()->compilationUnit->runtimeRegularExpressions[instr.regExpId];
MOTH_END_INSTR(LoadRegExp)
MOTH_BEGIN_INSTR(LoadClosure)
MOTH_BEGIN_INSTR(GetGlobalLookup)
TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData());
- QV4::Lookup *l = context->lookups + instr.index;
+ QV4::Lookup *l = context->d()->lookups + instr.index;
STOREVALUE(instr.result, l->globalGetter(l, context));
MOTH_END_INSTR(GetGlobalLookup)
MOTH_END_INSTR(LoadElement)
MOTH_BEGIN_INSTR(LoadElementLookup)
- QV4::Lookup *l = context->lookups + instr.lookup;
+ QV4::Lookup *l = context->d()->lookups + instr.lookup;
STOREVALUE(instr.result, l->indexedGetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index)));
MOTH_END_INSTR(LoadElementLookup)
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(StoreElementLookup)
- QV4::Lookup *l = context->lookups + instr.lookup;
+ QV4::Lookup *l = context->d()->lookups + instr.lookup;
l->indexedSetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source));
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreElementLookup)
MOTH_END_INSTR(LoadProperty)
MOTH_BEGIN_INSTR(GetLookup)
- QV4::Lookup *l = context->lookups + instr.index;
+ QV4::Lookup *l = context->d()->lookups + instr.index;
STOREVALUE(instr.result, l->getter(l, VALUEPTR(instr.base)));
MOTH_END_INSTR(GetLookup)
MOTH_END_INSTR(StoreProperty)
MOTH_BEGIN_INSTR(SetLookup)
- QV4::Lookup *l = context->lookups + instr.index;
+ QV4::Lookup *l = context->d()->lookups + instr.index;
l->setter(l, VALUEPTR(instr.base), VALUEPTR(instr.source));
CHECK_EXCEPTION;
MOTH_END_INSTR(SetLookup)
MOTH_BEGIN_INSTR(Push)
TRACE(inline, "stack size: %u", instr.value);
stackSize = instr.value;
- stack = context->engine->stackPush(stackSize);
+ stack = context->engine()->stackPush(stackSize);
#ifndef QT_NO_DEBUG
memset(stack, 0, stackSize * sizeof(QV4::Value));
#endif
MOTH_BEGIN_INSTR(CallValue)
#if 0 //def DO_TRACE_INSTR
- if (Debugging::Debugger *debugger = context->engine->debugger) {
+ if (Debugging::Debugger *debugger = context->engine()->debugger) {
if (QV4::FunctionObject *o = (VALUE(instr.dest)).asFunctionObject()) {
if (Debugging::FunctionDebugInfo *info = debugger->debugInfo(o)) {
QString n = debugger->name(o);
MOTH_END_INSTR(BinopContext)
MOTH_BEGIN_INSTR(Ret)
- context->engine->stackPop(stackSize);
+ context->engine()->stackPop(stackSize);
// TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData());
return VALUE(instr.result).asReturnedValue();
MOTH_END_INSTR(Ret)
MOTH_BEGIN_INSTR(Debug)
- context->lineNumber = instr.lineNumber;
- QV4::Debugging::Debugger *debugger = context->engine->debugger;
+ context->d()->lineNumber = instr.lineNumber;
+ QV4::Debugging::Debugger *debugger = context->engine()->debugger;
if (debugger && debugger->pauseAtNextOpportunity())
debugger->maybeBreakAtInstruction();
MOTH_END_INSTR(Debug)
MOTH_BEGIN_INSTR(Line)
- context->lineNumber = instr.lineNumber;
+ context->d()->lineNumber = instr.lineNumber;
MOTH_END_INSTR(Debug)
MOTH_BEGIN_INSTR(LoadThis)
- VALUE(instr.result) = context->callData->thisObject;
+ VALUE(instr.result) = context->d()->callData->thisObject;
MOTH_END_INSTR(LoadThis)
MOTH_BEGIN_INSTR(LoadQmlIdArray)
Q_ASSERT(false);
catchException:
- Q_ASSERT(context->engine->hasException);
+ Q_ASSERT(context->engine()->hasException);
if (!exceptionHandler) {
- context->engine->stackPop(stackSize);
+ context->engine()->stackPop(stackSize);
return QV4::Encode::undefined();
}
code = exceptionHandler;
QV4::ReturnedValue VME::exec(QV4::ExecutionContext *ctxt, const uchar *code)
{
VME vme;
- QV4::Debugging::Debugger *debugger = ctxt->engine->debugger;
+ QV4::Debugging::Debugger *debugger = ctxt->engine()->debugger;
if (debugger)
debugger->enteringFunction();
QV4::ReturnedValue retVal = vme.run(ctxt, code);
QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
+ QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
return ctx->throwTypeError();
- return QV4::QObjectWrapper::wrap(ctx->engine, o->d()->incubator->object());
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, o->d()->incubator->object());
}
QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
+ QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
return ctx->throwTypeError();
QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
+ QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
return ctx->throwTypeError();
QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
+ QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
if (!o)
return ctx->throwTypeError();
QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QmlIncubatorObject> o(scope, ctx->callData->thisObject.as<QmlIncubatorObject>());
- if (!o || ctx->callData->argc < 1)
+ QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>());
+ if (!o || ctx->d()->callData->argc < 1)
return ctx->throwTypeError();
- o->d()->statusChanged = ctx->callData->args[0];
+ o->d()->statusChanged = ctx->d()->callData->args[0];
return QV4::Encode::undefined();
}
if (wrapper && wrapper->d()->readOnly) {
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
- Scoped<String> e(scope, v4->currentContext()->engine->newString(error));
+ Scoped<String> e(scope, v4->currentContext()->d()->engine->newString(error));
v4->currentContext()->throwError(e);
return;
}
QV4::ExecutionContext *ctx = v4->currentContext();
callData->thisObject = v4->globalObject;
if (scopeObject()) {
- QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject()));
+ QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->d()->engine, scopeObject()));
if (value->isObject())
callData->thisObject = value;
}
QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleString(ctx);
QV4::Scope scope(ctx);
- QV4::DateObject *date = ctx->callData->thisObject.asDateObject();
+ QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject();
if (!date)
return QV4::DatePrototype::method_toLocaleString(ctx);
QDateTime dt = date->toQDateTime();
- if (ctx->callData->argc == 0) {
+ if (ctx->d()->callData->argc == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return ctx->engine->newString(locale.toString(dt))->asReturnedValue();
+ return ctx->d()->engine->newString(locale.toString(dt))->asReturnedValue();
}
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
return QV4::DatePrototype::method_toLocaleString(ctx); // Use the default Date toLocaleString()
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDt;
- if (ctx->callData->argc == 2) {
- if (ctx->callData->args[1].isString()) {
- QString format = ctx->callData->args[1].stringValue()->toQString();
+ if (ctx->d()->callData->argc == 2) {
+ if (ctx->d()->callData->args[1].isString()) {
+ QString format = ctx->d()->callData->args[1].stringValue()->toQString();
formattedDt = r->d()->locale.toString(dt, format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].toNumber();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
formattedDt = r->d()->locale.toString(dt, format);
} else {
formattedDt = r->d()->locale.toString(dt, enumFormat);
}
- return ctx->engine->newString(formattedDt)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedDt)->asReturnedValue();
}
QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleTimeString(ctx);
QV4::Scope scope(ctx);
- QV4::DateObject *date = ctx->callData->thisObject.asDateObject();
+ QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject();
if (!date)
return QV4::DatePrototype::method_toLocaleTimeString(ctx);
QDateTime dt = date->toQDateTime();
QTime time = dt.time();
- if (ctx->callData->argc == 0) {
+ if (ctx->d()->callData->argc == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return ctx->engine->newString(locale.toString(time))->asReturnedValue();
+ return ctx->d()->engine->newString(locale.toString(time))->asReturnedValue();
}
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
return QV4::DatePrototype::method_toLocaleTimeString(ctx); // Use the default Date toLocaleTimeString()
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedTime;
- if (ctx->callData->argc == 2) {
- if (ctx->callData->args[1].isString()) {
- QString format = ctx->callData->args[1].stringValue()->toQString();
+ if (ctx->d()->callData->argc == 2) {
+ if (ctx->d()->callData->args[1].isString()) {
+ QString format = ctx->d()->callData->args[1].stringValue()->toQString();
formattedTime = r->d()->locale.toString(time, format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].toNumber();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
formattedTime = r->d()->locale.toString(time, format);
} else {
formattedTime = r->d()->locale.toString(time, enumFormat);
}
- return ctx->engine->newString(formattedTime)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedTime)->asReturnedValue();
}
QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc > 2)
return QV4::DatePrototype::method_toLocaleDateString(ctx);
QV4::Scope scope(ctx);
- QV4::DateObject *dateObj = ctx->callData->thisObject.asDateObject();
+ QV4::DateObject *dateObj = ctx->d()->callData->thisObject.asDateObject();
if (!dateObj)
return QV4::DatePrototype::method_toLocaleDateString(ctx);
QDateTime dt = dateObj->toQDateTime();
QDate date = dt.date();
- if (ctx->callData->argc == 0) {
+ if (ctx->d()->callData->argc == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return ctx->engine->newString(locale.toString(date))->asReturnedValue();
+ return ctx->d()->engine->newString(locale.toString(date))->asReturnedValue();
}
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
return QV4::DatePrototype::method_toLocaleDateString(ctx); // Use the default Date toLocaleDateString()
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QString formattedDate;
- if (ctx->callData->argc == 2) {
- if (ctx->callData->args[1].isString()) {
- QString format = ctx->callData->args[1].stringValue()->toQString();
+ if (ctx->d()->callData->argc == 2) {
+ if (ctx->d()->callData->args[1].isString()) {
+ QString format = ctx->d()->callData->args[1].stringValue()->toQString();
formattedDate = r->d()->locale.toString(date, format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].toNumber();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
formattedDate = r->d()->locale.toString(date, format);
} else {
formattedDate = r->d()->locale.toString(date, enumFormat);
}
- return ctx->engine->newString(formattedDate)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedDate)->asReturnedValue();
}
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine * const engine = ctx->engine;
- if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) {
+ QV4::ExecutionEngine * const engine = ctx->d()->engine;
+ if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) {
QLocale locale;
- QString dateString = ctx->callData->args[0].stringValue()->toQString();
+ QString dateString = ctx->d()->callData->args[0].stringValue()->toQString();
QDateTime dt = locale.toDateTime(dateString);
return QV4::Encode(engine->newDateObject(dt));
}
QV4::Scope scope(ctx);
- if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0]))
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0]))
V4THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments");
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QDateTime dt;
- QString dateString = ctx->callData->args[1].toQStringNoThrow();
- if (ctx->callData->argc == 3) {
- if (ctx->callData->args[2].isString()) {
- QString format = ctx->callData->args[2].stringValue()->toQString();
+ QString dateString = ctx->d()->callData->args[1].toQStringNoThrow();
+ if (ctx->d()->callData->argc == 3) {
+ if (ctx->d()->callData->args[2].isString()) {
+ QString format = ctx->d()->callData->args[2].stringValue()->toQString();
dt = r->d()->locale.toDateTime(dateString, format);
- } else if (ctx->callData->args[2].isNumber()) {
- quint32 intFormat = ctx->callData->args[2].toNumber();
+ } else if (ctx->d()->callData->args[2].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[2].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
dt = r->d()->locale.toDateTime(dateString, format);
} else {
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine * const engine = ctx->engine;
+ QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) {
+ if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) {
QLocale locale;
- QString timeString = ctx->callData->args[0].stringValue()->toQString();
+ QString timeString = ctx->d()->callData->args[0].stringValue()->toQString();
QTime time = locale.toTime(timeString);
QDateTime dt = QDateTime::currentDateTime();
dt.setTime(time);
return QV4::Encode(engine->newDateObject(dt));
}
- if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0]))
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0]))
V4THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments");
QV4::Scope scope(ctx);
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QTime tm;
- QString dateString = ctx->callData->args[1].toQStringNoThrow();
- if (ctx->callData->argc == 3) {
- if (ctx->callData->args[2].isString()) {
- QString format = ctx->callData->args[2].stringValue()->toQString();
+ QString dateString = ctx->d()->callData->args[1].toQStringNoThrow();
+ if (ctx->d()->callData->argc == 3) {
+ if (ctx->d()->callData->args[2].isString()) {
+ QString format = ctx->d()->callData->args[2].stringValue()->toQString();
tm = r->d()->locale.toTime(dateString, format);
- } else if (ctx->callData->args[2].isNumber()) {
- quint32 intFormat = ctx->callData->args[2].toNumber();
+ } else if (ctx->d()->callData->args[2].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[2].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
tm = r->d()->locale.toTime(dateString, format);
} else {
QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine * const engine = ctx->engine;
+ QV4::ExecutionEngine * const engine = ctx->d()->engine;
- if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) {
+ if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) {
QLocale locale;
- QString dateString = ctx->callData->args[0].stringValue()->toQString();
+ QString dateString = ctx->d()->callData->args[0].stringValue()->toQString();
QDate date = locale.toDate(dateString);
return QV4::Encode(engine->newDateObject(QDateTime(date)));
}
- if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0]))
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0]))
V4THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments");
QV4::Scope scope(ctx);
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QLocale::FormatType enumFormat = QLocale::LongFormat;
QDate dt;
- QString dateString = ctx->callData->args[1].toQStringNoThrow();
- if (ctx->callData->argc == 3) {
- if (ctx->callData->args[2].isString()) {
- QString format = ctx->callData->args[2].stringValue()->toQString();
+ QString dateString = ctx->d()->callData->args[1].toQStringNoThrow();
+ if (ctx->d()->callData->argc == 3) {
+ if (ctx->d()->callData->args[2].isString()) {
+ QString format = ctx->d()->callData->args[2].stringValue()->toQString();
dt = r->d()->locale.toDate(dateString, format);
- } else if (ctx->callData->args[2].isNumber()) {
- quint32 intFormat = ctx->callData->args[2].toNumber();
+ } else if (ctx->d()->callData->args[2].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[2].toNumber();
QLocale::FormatType format = QLocale::FormatType(intFormat);
dt = r->d()->locale.toDate(dateString, format);
} else {
QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 0)
+ if (ctx->d()->callData->argc != 0)
V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments");
QV4::DatePrototype::timezoneUpdated();
QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc > 3)
+ if (ctx->d()->callData->argc > 3)
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- double number = ctx->callData->thisObject.toNumber();
+ double number = ctx->d()->callData->thisObject.toNumber();
- if (ctx->callData->argc == 0) {
+ if (ctx->d()->callData->argc == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return ctx->engine->newString(locale.toString(number))->asReturnedValue();
+ return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue();
}
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
return QV4::NumberPrototype::method_toLocaleString(ctx); // Use the default Number toLocaleString()
QV4::Scope scope(ctx);
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
quint16 format = 'f';
- if (ctx->callData->argc > 1) {
- if (!ctx->callData->args[1].isString())
+ if (ctx->d()->callData->argc > 1) {
+ if (!ctx->d()->callData->args[1].isString())
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- QV4::String *fs = ctx->callData->args[1].toString(ctx);
+ QV4::String *fs = ctx->d()->callData->args[1].toString(ctx);
if (fs->length())
format = fs->toQString().at(0).unicode();
}
int prec = 2;
- if (ctx->callData->argc > 2) {
- if (!ctx->callData->args[2].isNumber())
+ if (ctx->d()->callData->argc > 2) {
+ if (!ctx->d()->callData->args[2].isNumber())
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- prec = ctx->callData->args[2].toInt32();
+ prec = ctx->d()->callData->args[2].toInt32();
}
- return ctx->engine->newString(r->d()->locale.toString(number, (char)format, prec))->asReturnedValue();
+ return ctx->d()->engine->newString(r->d()->locale.toString(number, (char)format, prec))->asReturnedValue();
}
QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc > 2)
V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
- double number = ctx->callData->thisObject.toNumber();
+ double number = ctx->d()->callData->thisObject.toNumber();
- if (ctx->callData->argc == 0) {
+ if (ctx->d()->callData->argc == 0) {
// Use QLocale for standard toLocaleString() function
QLocale locale;
- return ctx->engine->newString(locale.toString(number))->asReturnedValue();
+ return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue();
}
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");
QV4::Scope scope(ctx);
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
QString symbol;
- if (ctx->callData->argc > 1) {
- if (!ctx->callData->args[1].isString())
+ if (ctx->d()->callData->argc > 1) {
+ if (!ctx->d()->callData->args[1].isString())
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
- symbol = ctx->callData->args[1].toQStringNoThrow();
+ symbol = ctx->d()->callData->args[1].toQStringNoThrow();
}
- return ctx->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue();
+ return ctx->d()->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue();
}
QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext *ctx)
{
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2)
V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
int numberIdx = 0;
QV4::Scope scope(ctx);
- if (ctx->callData->argc == 2) {
- if (!isLocaleObject(ctx->callData->args[0]))
+ if (ctx->d()->callData->argc == 2) {
+ if (!isLocaleObject(ctx->d()->callData->args[0]))
V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments");
- GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]);
+ GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]);
locale = r->d()->locale;
numberIdx = 1;
}
- QV4::String *ns = ctx->callData->args[numberIdx].toString(ctx);
+ QV4::String *ns = ctx->d()->callData->args[numberIdx].toString(ctx);
if (!ns->length())
return QV4::Encode(Q_QNAN);
QList<Qt::DayOfWeek> days = locale->weekdays();
- QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject());
+ QV4::Scoped<QV4::ArrayObject> result(scope, ctx->d()->engine->newArrayObject());
result->arrayReserve(days.size());
for (int i = 0; i < days.size(); ++i) {
int day = days.at(i);
return QV4::Encode::undefined();
QStringList langs = locale->uiLanguages();
- QV4::Scoped<QV4::ArrayObject> result(scope, ctx->engine->newArrayObject());
+ QV4::Scoped<QV4::ArrayObject> result(scope, ctx->d()->engine->newArrayObject());
result->arrayReserve(langs.size());
QV4::ScopedValue v(scope);
for (int i = 0; i < langs.size(); ++i)
- result->arrayPut(i, (v = ctx->engine->newString(langs.at(i))));
+ result->arrayPut(i, (v = ctx->d()->engine->newString(langs.at(i))));
result->setArrayLengthUnchecked(langs.size());
if (!locale)
return QV4::Encode::undefined();
- if (ctx->callData->argc > 1)
+ if (ctx->d()->callData->argc > 1)
V4THROW_ERROR("Locale: currencySymbol(): Invalid arguments");
QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
- if (ctx->callData->argc == 1) {
- quint32 intFormat = ctx->callData->args[0].toNumber();
+ if (ctx->d()->callData->argc == 1) {
+ quint32 intFormat = ctx->d()->callData->args[0].toNumber();
format = QLocale::CurrencySymbolFormat(intFormat);
}
- return ctx->engine->newString(locale->currencySymbol(format))->asReturnedValue();
+ return ctx->d()->engine->newString(locale->currencySymbol(format))->asReturnedValue();
}
#define LOCALE_FORMAT(FUNC) \
QLocale *locale = getThisLocale(ctx); \
if (!locale) \
return QV4::Encode::undefined(); \
- if (ctx->callData->argc > 1) \
+ if (ctx->d()->callData->argc > 1) \
V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \
QLocale::FormatType format = QLocale::LongFormat;\
- if (ctx->callData->argc == 1) { \
- quint32 intFormat = ctx->callData->args[0].toUInt32(); \
+ if (ctx->d()->callData->argc == 1) { \
+ quint32 intFormat = ctx->d()->callData->args[0].toUInt32(); \
format = QLocale::FormatType(intFormat); \
} \
- return ctx->engine->newString(locale-> FUNC (format))->asReturnedValue(); \
+ return ctx->engine()->newString(locale-> FUNC (format))->asReturnedValue(); \
}
LOCALE_FORMAT(dateTimeFormat)
QLocale *locale = getThisLocale(ctx); \
if (!locale) \
return QV4::Encode::undefined(); \
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
QLocale::FormatType enumFormat = QLocale::LongFormat; \
- int idx = ctx->callData->args[0].toInt32() + 1; \
+ int idx = ctx->d()->callData->args[0].toInt32() + 1; \
if (idx < 1 || idx > 12) \
V4THROW_ERROR("Locale: Invalid month"); \
QString name; \
- if (ctx->callData->argc == 2) { \
- if (ctx->callData->args[1].isNumber()) { \
- quint32 intFormat = ctx->callData->args[1].toUInt32(); \
+ if (ctx->d()->callData->argc == 2) { \
+ if (ctx->d()->callData->args[1].isNumber()) { \
+ quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \
QLocale::FormatType format = QLocale::FormatType(intFormat); \
name = locale-> VARIABLE(idx, format); \
} else { \
} else { \
name = locale-> VARIABLE(idx, enumFormat); \
} \
- return ctx->engine->newString(name)->asReturnedValue(); \
+ return ctx->engine()->newString(name)->asReturnedValue(); \
}
// 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date
QLocale *locale = getThisLocale(ctx); \
if (!locale) \
return QV4::Encode::undefined(); \
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \
V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \
QLocale::FormatType enumFormat = QLocale::LongFormat; \
- int idx = ctx->callData->args[0].toInt32(); \
+ int idx = ctx->d()->callData->args[0].toInt32(); \
if (idx < 0 || idx > 7) \
V4THROW_ERROR("Locale: Invalid day"); \
if (idx == 0) idx = 7; \
QString name; \
- if (ctx->callData->argc == 2) { \
- if (ctx->callData->args[1].isNumber()) { \
- quint32 intFormat = ctx->callData->args[1].toUInt32(); \
+ if (ctx->d()->callData->argc == 2) { \
+ if (ctx->d()->callData->args[1].isNumber()) { \
+ quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \
QLocale::FormatType format = QLocale::FormatType(intFormat); \
name = locale-> VARIABLE(idx, format); \
} else { \
} else { \
name = locale-> VARIABLE(idx, enumFormat); \
} \
- return ctx->engine->newString(name)->asReturnedValue(); \
+ return ctx->engine()->newString(name)->asReturnedValue(); \
}
LOCALE_FORMATTED_MONTHNAME(monthName)
QLocale *locale = getThisLocale(ctx); \
if (!locale) \
return QV4::Encode::undefined(); \
- return ctx->engine->newString(locale-> VARIABLE())->asReturnedValue();\
+ return ctx->engine()->newString(locale-> VARIABLE())->asReturnedValue();\
}
LOCALE_STRING_PROPERTY(name)
QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 1 || (!ctx->callData->args[0].isString() && !ctx->callData->args[0].asStringObject()))
+ if (ctx->d()->callData->argc != 1 || (!ctx->d()->callData->args[0].isString() && !ctx->d()->callData->args[0].asStringObject()))
return QV4::StringPrototype::method_localeCompare(ctx);
- if (!ctx->callData->thisObject.isString() && !ctx->callData->thisObject.asStringObject())
+ if (!ctx->d()->callData->thisObject.isString() && !ctx->d()->callData->thisObject.asStringObject())
return QV4::StringPrototype::method_localeCompare(ctx);
- QString thisString = ctx->callData->thisObject.toQStringNoThrow();
- QString thatString = ctx->callData->args[0].toQStringNoThrow();
+ QString thisString = ctx->d()->callData->thisObject.toQStringNoThrow();
+ QString thatString = ctx->d()->callData->args[0].toQStringNoThrow();
return QV4::Encode(QString::localeAwareCompare(thisString, thatString));
}
static QLocale *getThisLocale(QV4::CallContext *ctx) {
- QQmlLocaleData *thisObject = ctx->callData->thisObject.asObject()->as<QQmlLocaleData>();
+ QQmlLocaleData *thisObject = ctx->d()->callData->thisObject.asObject()->as<QQmlLocaleData>();
if (!thisObject) {
ctx->throwTypeError();
return 0;
ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx)
{
- Object *o = ctx->callData->thisObject.asObject();
+ Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
return ctx->throwTypeError();
QmlValueTypeWrapper *w = o->as<QmlValueTypeWrapper>();
#ifndef QT_NO_XMLSTREAMREADER
#define V4THROW_REFERENCE(string) { \
- Scoped<Object> error(scope, ctx->engine->newReferenceErrorObject(QStringLiteral(string))); \
+ Scoped<Object> error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \
return ctx->throwError(error); \
}
ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
name = r->d()->d->name;
break;
}
- return Encode(ctx->engine->newString(name));
+ return Encode(ctx->d()->engine->newString(name));
}
ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
r->d()->d->type == NodeImpl::Notation)
return Encode::null();
- return Encode(ctx->engine->newString(r->d()->d->data));
+ return Encode(ctx->d()->engine->newString(r->d()->d->data));
}
ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->d()->d->parent)
return Node::create(engine, r->d()->d->parent);
ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return NodeList::create(engine, r->d()->d);
}
ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->d()->d->children.isEmpty())
return Encode::null();
ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->d()->d->children.isEmpty())
return Encode::null();
ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (!r->d()->d->parent)
return Encode::null();
ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (!r->d()->d->parent)
return Encode::null();
ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return ctx->throwTypeError();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->d()->d->type != NodeImpl::Element)
return Encode::null();
ReturnedValue Attr::method_name(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return engine->toString(r->d()->d->name);
}
ReturnedValue Attr::method_value(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return engine->toString(r->d()->d->data);
}
ReturnedValue Attr::method_ownerElement(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return Node::create(engine, r->d()->d->parent);
}
ReturnedValue CharacterData::method_length(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
Q_UNUSED(engine)
return Encode(r->d()->d->data.length());
}
ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r) return Encode::undefined();
return Encode(r->d()->d->data.trimmed().isEmpty());
ReturnedValue Text::method_wholeText(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return engine->toString(r->d()->d->data);
}
ReturnedValue Document::method_documentElement(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r || r->d()->d->type != NodeImpl::Document)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return Node::create(engine, static_cast<DocumentImpl *>(r->d()->d)->root);
}
ReturnedValue Document::method_xmlStandalone(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r || r->d()->d->type != NodeImpl::Document)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
Q_UNUSED(engine)
return Encode(static_cast<DocumentImpl *>(r->d()->d)->isStandalone);
}
ReturnedValue Document::method_xmlVersion(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r || r->d()->d->type != NodeImpl::Document)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return engine->toString(static_cast<DocumentImpl *>(r->d()->d)->version);
}
ReturnedValue Document::method_xmlEncoding(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<Node> r(scope, ctx->callData->thisObject.as<Node>());
+ Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>());
if (!r || r->d()->d->type != NodeImpl::Document)
return Encode::undefined();
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
return engine->toString(static_cast<DocumentImpl *>(r->d()->d)->encoding);
}
ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- if (ctx->callData->argc < 2 || ctx->callData->argc > 5)
+ if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 5)
V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
// Argument 0 - Method
- QString method = ctx->callData->args[0].toQStringNoThrow().toUpper();
+ QString method = ctx->d()->callData->args[0].toQStringNoThrow().toUpper();
if (method != QLatin1String("GET") &&
method != QLatin1String("PUT") &&
method != QLatin1String("HEAD") &&
V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type");
// Argument 1 - URL
- QUrl url = QUrl(ctx->callData->args[1].toQStringNoThrow());
+ QUrl url = QUrl(ctx->d()->callData->args[1].toQStringNoThrow());
if (url.isRelative())
url = engine->callingContext()->resolvedUrl(url);
// Argument 2 - async (optional)
- if (ctx->callData->argc > 2 && !ctx->callData->args[2].booleanValue())
+ if (ctx->d()->callData->argc > 2 && !ctx->d()->callData->args[2].booleanValue())
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported");
// Argument 3/4 - user/pass (optional)
QString username, password;
- if (ctx->callData->argc > 3)
- username = ctx->callData->args[3].toQStringNoThrow();
- if (ctx->callData->argc > 4)
- password = ctx->callData->args[4].toQStringNoThrow();
+ if (ctx->d()->callData->argc > 3)
+ username = ctx->d()->callData->args[3].toQStringNoThrow();
+ if (ctx->d()->callData->argc > 4)
+ password = ctx->d()->callData->args[4].toQStringNoThrow();
// Clear the fragment (if any)
url.setFragment(QString());
if (!username.isNull()) url.setUserName(username);
if (!password.isNull()) url.setPassword(password);
- ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine));
+ ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine));
return r->open(meObject, method, url);
}
ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag())
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
- QString name = ctx->callData->args[0].toQStringNoThrow();
- QString value = ctx->callData->args[1].toQStringNoThrow();
+ QString name = ctx->d()->callData->args[0].toQStringNoThrow();
+ QString value = ctx->d()->callData->args[1].toQStringNoThrow();
// ### Check that name and value are well formed
ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->readyState() != QQmlXMLHttpRequest::Opened ||
r->sendFlag())
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
QByteArray data;
- if (ctx->callData->argc > 0)
- data = ctx->callData->args[0].toQStringNoThrow().toUtf8();
+ if (ctx->d()->callData->argc > 0)
+ data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8();
- ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine));
+ ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine));
return r->send(meObject, data);
}
ReturnedValue QQmlXMLHttpRequestCtor::method_abort(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, ctx->engine->v8Engine));
+ ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, ctx->d()->engine->v8Engine));
return r->abort(meObject);
}
ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QQmlXMLHttpRequest::Loading &&
r->readyState() != QQmlXMLHttpRequest::HeadersReceived)
V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state");
- return engine->toString(r->header(ctx->callData->args[0].toQStringNoThrow()));
+ return engine->toString(r->header(ctx->d()->callData->args[0].toQStringNoThrow()));
}
ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
- if (ctx->callData->argc != 0)
+ if (ctx->d()->callData->argc != 0)
V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count");
if (r->readyState() != QQmlXMLHttpRequest::Loading &&
ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->readyState() == QQmlXMLHttpRequest::Unsent ||
r->readyState() == QQmlXMLHttpRequest::Opened)
ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = ctx->d()->engine->v8Engine;
if (r->readyState() != QQmlXMLHttpRequest::Loading &&
r->readyState() != QQmlXMLHttpRequest::Done)
ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx)
{
Scope scope(ctx);
- Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
+ Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>());
if (!w)
V4THROW_REFERENCE("Not an XMLHttpRequest object");
QQmlXMLHttpRequest *r = w->d()->request;
r->readyState() != QQmlXMLHttpRequest::Done)) {
return Encode::null();
} else {
- return Document::load(ctx->engine->v8Engine, r->rawResponseBody());
+ return Document::load(ctx->d()->engine->v8Engine, r->rawResponseBody());
}
}
*/
ReturnedValue QtObject::method_isQtObject(QV4::CallContext *ctx)
{
- if (ctx->callData->argc == 0)
+ if (ctx->d()->callData->argc == 0)
return QV4::Encode(false);
- return QV4::Encode(ctx->callData->args[0].as<QV4::QObjectWrapper>() != 0);
+ return QV4::Encode(ctx->d()->callData->args[0].as<QV4::QObjectWrapper>() != 0);
}
/*!
*/
ReturnedValue QtObject::method_rgba(QV4::CallContext *ctx)
{
- int argCount = ctx->callData->argc;
+ int argCount = ctx->d()->callData->argc;
if (argCount < 3 || argCount > 4)
V4THROW_ERROR("Qt.rgba(): Invalid arguments");
- double r = ctx->callData->args[0].toNumber();
- double g = ctx->callData->args[1].toNumber();
- double b = ctx->callData->args[2].toNumber();
- double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1;
+ double r = ctx->d()->callData->args[0].toNumber();
+ double g = ctx->d()->callData->args[1].toNumber();
+ double b = ctx->d()->callData->args[2].toNumber();
+ double a = (argCount == 4) ? ctx->d()->callData->args[3].toNumber() : 1;
if (r < 0.0) r=0.0;
if (r > 1.0) r=1.0;
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->d()->engine->v8Engine->fromVariant(QQml_colorProvider()->fromRgbF(r, g, b, a));
}
/*!
*/
ReturnedValue QtObject::method_hsla(QV4::CallContext *ctx)
{
- int argCount = ctx->callData->argc;
+ int argCount = ctx->d()->callData->argc;
if (argCount < 3 || argCount > 4)
V4THROW_ERROR("Qt.hsla(): Invalid arguments");
- double h = ctx->callData->args[0].toNumber();
- double s = ctx->callData->args[1].toNumber();
- double l = ctx->callData->args[2].toNumber();
- double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1;
+ double h = ctx->d()->callData->args[0].toNumber();
+ double s = ctx->d()->callData->args[1].toNumber();
+ double l = ctx->d()->callData->args[2].toNumber();
+ double a = (argCount == 4) ? ctx->d()->callData->args[3].toNumber() : 1;
if (h < 0.0) h=0.0;
if (h > 1.0) h=1.0;
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->d()->engine->v8Engine->fromVariant(QQml_colorProvider()->fromHslF(h, s, l, a));
}
/*!
*/
ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.colorEqual(): Invalid arguments");
bool ok = false;
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- QVariant lhs = v8engine->toVariant(ctx->callData->args[0], -1);
+ QVariant lhs = v8engine->toVariant(ctx->d()->callData->args[0], -1);
if (lhs.userType() == QVariant::String) {
lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok);
if (!ok) {
V4THROW_ERROR("Qt.colorEqual(): Invalid arguments");
}
- QVariant rhs = v8engine->toVariant(ctx->callData->args[1], -1);
+ QVariant rhs = v8engine->toVariant(ctx->d()->callData->args[1], -1);
if (rhs.userType() == QVariant::String) {
rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok);
if (!ok) {
*/
ReturnedValue QtObject::method_rect(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 4)
+ if (ctx->d()->callData->argc != 4)
V4THROW_ERROR("Qt.rect(): Invalid arguments");
- double x = ctx->callData->args[0].toNumber();
- double y = ctx->callData->args[1].toNumber();
- double w = ctx->callData->args[2].toNumber();
- double h = ctx->callData->args[3].toNumber();
+ double x = ctx->d()->callData->args[0].toNumber();
+ double y = ctx->d()->callData->args[1].toNumber();
+ double w = ctx->d()->callData->args[2].toNumber();
+ double h = ctx->d()->callData->args[3].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
+ return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
}
/*!
*/
ReturnedValue QtObject::method_point(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.point(): Invalid arguments");
- double x = ctx->callData->args[0].toNumber();
- double y = ctx->callData->args[1].toNumber();
+ double x = ctx->d()->callData->args[0].toNumber();
+ double y = ctx->d()->callData->args[1].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y)));
+ return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y)));
}
/*!
*/
ReturnedValue QtObject::method_size(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.size(): Invalid arguments");
- double w = ctx->callData->args[0].toNumber();
- double h = ctx->callData->args[1].toNumber();
+ double w = ctx->d()->callData->args[0].toNumber();
+ double h = ctx->d()->callData->args[1].toNumber();
- return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h)));
+ return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h)));
}
/*!
*/
ReturnedValue QtObject::method_font(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 1 || !ctx->callData->args[0].isObject())
+ if (ctx->d()->callData->argc != 1 || !ctx->d()->callData->args[0].isObject())
V4THROW_ERROR("Qt.font(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
bool ok = false;
- QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok);
+ QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->d()->callData->args[0]), v8engine, &ok);
if (!ok)
V4THROW_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified");
return v8engine->fromVariant(v);
*/
ReturnedValue QtObject::method_vector2d(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.vector2d(): Invalid arguments");
float xy[3]; // qvector2d uses float internally
- xy[0] = ctx->callData->args[0].toNumber();
- xy[1] = ctx->callData->args[1].toNumber();
+ xy[0] = ctx->d()->callData->args[0].toNumber();
+ xy[1] = ctx->d()->callData->args[1].toNumber();
const void *params[] = { xy };
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params));
}
*/
ReturnedValue QtObject::method_vector3d(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 3)
+ if (ctx->d()->callData->argc != 3)
V4THROW_ERROR("Qt.vector3d(): Invalid arguments");
float xyz[3]; // qvector3d uses float internally
- xyz[0] = ctx->callData->args[0].toNumber();
- xyz[1] = ctx->callData->args[1].toNumber();
- xyz[2] = ctx->callData->args[2].toNumber();
+ xyz[0] = ctx->d()->callData->args[0].toNumber();
+ xyz[1] = ctx->d()->callData->args[1].toNumber();
+ xyz[2] = ctx->d()->callData->args[2].toNumber();
const void *params[] = { xyz };
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params));
}
*/
ReturnedValue QtObject::method_vector4d(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 4)
+ if (ctx->d()->callData->argc != 4)
V4THROW_ERROR("Qt.vector4d(): Invalid arguments");
float xyzw[4]; // qvector4d uses float internally
- xyzw[0] = ctx->callData->args[0].toNumber();
- xyzw[1] = ctx->callData->args[1].toNumber();
- xyzw[2] = ctx->callData->args[2].toNumber();
- xyzw[3] = ctx->callData->args[3].toNumber();
+ xyzw[0] = ctx->d()->callData->args[0].toNumber();
+ xyzw[1] = ctx->d()->callData->args[1].toNumber();
+ xyzw[2] = ctx->d()->callData->args[2].toNumber();
+ xyzw[3] = ctx->d()->callData->args[3].toNumber();
const void *params[] = { xyzw };
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params));
}
*/
ReturnedValue QtObject::method_quaternion(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 4)
+ if (ctx->d()->callData->argc != 4)
V4THROW_ERROR("Qt.quaternion(): Invalid arguments");
qreal sxyz[4]; // qquaternion uses qreal internally
- sxyz[0] = ctx->callData->args[0].toNumber();
- sxyz[1] = ctx->callData->args[1].toNumber();
- sxyz[2] = ctx->callData->args[2].toNumber();
- sxyz[3] = ctx->callData->args[3].toNumber();
+ sxyz[0] = ctx->d()->callData->args[0].toNumber();
+ sxyz[1] = ctx->d()->callData->args[1].toNumber();
+ sxyz[2] = ctx->d()->callData->args[2].toNumber();
+ sxyz[3] = ctx->d()->callData->args[3].toNumber();
const void *params[] = { sxyz };
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params));
}
*/
ReturnedValue QtObject::method_matrix4x4(QV4::CallContext *ctx)
{
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- if (ctx->callData->argc == 1 && ctx->callData->args[0].isObject()) {
+ if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isObject()) {
bool ok = false;
- QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok);
+ QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->d()->callData->args[0]), v8engine, &ok);
if (!ok)
V4THROW_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array");
return v8engine->fromVariant(v);
}
- if (ctx->callData->argc != 16)
+ if (ctx->d()->callData->argc != 16)
V4THROW_ERROR("Qt.matrix4x4(): Invalid arguments");
qreal vals[16]; // qmatrix4x4 uses qreal internally
- vals[0] = ctx->callData->args[0].toNumber();
- vals[1] = ctx->callData->args[1].toNumber();
- vals[2] = ctx->callData->args[2].toNumber();
- vals[3] = ctx->callData->args[3].toNumber();
- vals[4] = ctx->callData->args[4].toNumber();
- vals[5] = ctx->callData->args[5].toNumber();
- vals[6] = ctx->callData->args[6].toNumber();
- vals[7] = ctx->callData->args[7].toNumber();
- vals[8] = ctx->callData->args[8].toNumber();
- vals[9] = ctx->callData->args[9].toNumber();
- vals[10] = ctx->callData->args[10].toNumber();
- vals[11] = ctx->callData->args[11].toNumber();
- vals[12] = ctx->callData->args[12].toNumber();
- vals[13] = ctx->callData->args[13].toNumber();
- vals[14] = ctx->callData->args[14].toNumber();
- vals[15] = ctx->callData->args[15].toNumber();
+ vals[0] = ctx->d()->callData->args[0].toNumber();
+ vals[1] = ctx->d()->callData->args[1].toNumber();
+ vals[2] = ctx->d()->callData->args[2].toNumber();
+ vals[3] = ctx->d()->callData->args[3].toNumber();
+ vals[4] = ctx->d()->callData->args[4].toNumber();
+ vals[5] = ctx->d()->callData->args[5].toNumber();
+ vals[6] = ctx->d()->callData->args[6].toNumber();
+ vals[7] = ctx->d()->callData->args[7].toNumber();
+ vals[8] = ctx->d()->callData->args[8].toNumber();
+ vals[9] = ctx->d()->callData->args[9].toNumber();
+ vals[10] = ctx->d()->callData->args[10].toNumber();
+ vals[11] = ctx->d()->callData->args[11].toNumber();
+ vals[12] = ctx->d()->callData->args[12].toNumber();
+ vals[13] = ctx->d()->callData->args[13].toNumber();
+ vals[14] = ctx->d()->callData->args[14].toNumber();
+ vals[15] = ctx->d()->callData->args[15].toNumber();
const void *params[] = { vals };
return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params));
*/
ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 1 && ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.lighter(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
- QVariant v = v8engine->toVariant(ctx->callData->args[0], -1);
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
+ QVariant v = v8engine->toVariant(ctx->d()->callData->args[0], -1);
if (v.userType() == QVariant::String) {
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
}
qreal factor = 1.5;
- if (ctx->callData->argc == 2)
- factor = ctx->callData->args[1].toNumber();
+ if (ctx->d()->callData->argc == 2)
+ factor = ctx->d()->callData->args[1].toNumber();
return v8engine->fromVariant(QQml_colorProvider()->lighter(v, factor));
}
*/
ReturnedValue QtObject::method_darker(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 1 && ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.darker(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
- QVariant v = v8engine->toVariant(ctx->callData->args[0], -1);
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
+ QVariant v = v8engine->toVariant(ctx->d()->callData->args[0], -1);
if (v.userType() == QVariant::String) {
bool ok = false;
v = QQmlStringConverters::colorFromString(v.toString(), &ok);
}
qreal factor = 2.0;
- if (ctx->callData->argc == 2)
- factor = ctx->callData->args[1].toNumber();
+ if (ctx->d()->callData->argc == 2)
+ factor = ctx->d()->callData->args[1].toNumber();
return v8engine->fromVariant(QQml_colorProvider()->darker(v, factor));
}
*/
ReturnedValue QtObject::method_tint(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 2)
+ if (ctx->d()->callData->argc != 2)
V4THROW_ERROR("Qt.tint(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
// base color
- QVariant v1 = v8engine->toVariant(ctx->callData->args[0], -1);
+ QVariant v1 = v8engine->toVariant(ctx->d()->callData->args[0], -1);
if (v1.userType() == QVariant::String) {
bool ok = false;
v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok);
}
// tint color
- QVariant v2 = v8engine->toVariant(ctx->callData->args[1], -1);
+ QVariant v2 = v8engine->toVariant(ctx->d()->callData->args[1], -1);
if (v2.userType() == QVariant::String) {
bool ok = false;
v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok);
*/
ReturnedValue QtObject::method_formatDate(QV4::CallContext *ctx)
{
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2)
V4THROW_ERROR("Qt.formatDate(): Invalid arguments");
QV4::Scope scope(ctx);
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QDate date = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime().date();
+ QDate date = v8engine->toVariant(ctx->d()->callData->args[0], -1).toDateTime().date();
QString formattedDate;
- if (ctx->callData->argc == 2) {
- QV4::ScopedString s(scope, ctx->callData->args[1]);
+ if (ctx->d()->callData->argc == 2) {
+ QV4::ScopedString s(scope, ctx->d()->callData->args[1]);
if (s) {
QString format = s->toQString();
formattedDate = date.toString(format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].asDouble();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].asDouble();
Qt::DateFormat format = Qt::DateFormat(intFormat);
formattedDate = date.toString(format);
} else {
formattedDate = date.toString(enumFormat);
}
- return ctx->engine->newString(formattedDate)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedDate)->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_formatTime(QV4::CallContext *ctx)
{
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2)
V4THROW_ERROR("Qt.formatTime(): Invalid arguments");
QV4::Scope scope(ctx);
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- QVariant argVariant = v8engine->toVariant(ctx->callData->args[0], -1);
+ QVariant argVariant = v8engine->toVariant(ctx->d()->callData->args[0], -1);
QTime time;
- if (ctx->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String))
+ if (ctx->d()->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String))
time = argVariant.toDateTime().time();
else // if (argVariant.type() == QVariant::Time), or invalid.
time = argVariant.toTime();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
QString formattedTime;
- if (ctx->callData->argc == 2) {
- QV4::ScopedString s(scope, ctx->callData->args[1]);
+ if (ctx->d()->callData->argc == 2) {
+ QV4::ScopedString s(scope, ctx->d()->callData->args[1]);
if (s) {
QString format = s->toQString();
formattedTime = time.toString(format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].asDouble();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].asDouble();
Qt::DateFormat format = Qt::DateFormat(intFormat);
formattedTime = time.toString(format);
} else {
formattedTime = time.toString(enumFormat);
}
- return ctx->engine->newString(formattedTime)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedTime)->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_formatDateTime(QV4::CallContext *ctx)
{
- if (ctx->callData->argc < 1 || ctx->callData->argc > 2)
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2)
V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments");
QV4::Scope scope(ctx);
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
- QDateTime dt = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime();
+ QDateTime dt = v8engine->toVariant(ctx->d()->callData->args[0], -1).toDateTime();
QString formattedDt;
- if (ctx->callData->argc == 2) {
- QV4::ScopedString s(scope, ctx->callData->args[1]);
+ if (ctx->d()->callData->argc == 2) {
+ QV4::ScopedString s(scope, ctx->d()->callData->args[1]);
if (s) {
QString format = s->toQString();
formattedDt = dt.toString(format);
- } else if (ctx->callData->args[1].isNumber()) {
- quint32 intFormat = ctx->callData->args[1].asDouble();
+ } else if (ctx->d()->callData->args[1].isNumber()) {
+ quint32 intFormat = ctx->d()->callData->args[1].asDouble();
Qt::DateFormat format = Qt::DateFormat(intFormat);
formattedDt = dt.toString(format);
} else {
formattedDt = dt.toString(enumFormat);
}
- return ctx->engine->newString(formattedDt)->asReturnedValue();
+ return ctx->d()->engine->newString(formattedDt)->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_openUrlExternally(QV4::CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
return QV4::Encode(false);
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QUrl url(Value::fromReturnedValue(method_resolvedUrl(ctx)).toQStringNoThrow());
return v8engine->fromVariant(QQml_guiProvider()->openUrlExternally(url));
*/
ReturnedValue QtObject::method_resolvedUrl(QV4::CallContext *ctx)
{
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- QUrl url = v8engine->toVariant(ctx->callData->args[0], -1).toUrl();
+ QUrl url = v8engine->toVariant(ctx->d()->callData->args[0], -1).toUrl();
QQmlEngine *e = v8engine->engine();
QQmlEnginePrivate *p = 0;
if (e) p = QQmlEnginePrivate::get(e);
if (p) {
QQmlContextData *ctxt = v8engine->callingContext();
if (ctxt)
- return ctx->engine->newString(ctxt->resolvedUrl(url).toString())->asReturnedValue();
+ return ctx->d()->engine->newString(ctxt->resolvedUrl(url).toString())->asReturnedValue();
else
- return ctx->engine->newString(url.toString())->asReturnedValue();
+ return ctx->d()->engine->newString(url.toString())->asReturnedValue();
}
- return ctx->engine->newString(e->baseUrl().resolved(url).toString())->asReturnedValue();
+ return ctx->d()->engine->newString(e->baseUrl().resolved(url).toString())->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_fontFamilies(CallContext *ctx)
{
- if (ctx->callData->argc != 0)
+ if (ctx->d()->callData->argc != 0)
V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
return v8engine->fromVariant(QVariant(QQml_guiProvider()->fontFamilies()));
}
*/
ReturnedValue QtObject::method_md5(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("Qt.md5(): Invalid arguments");
- QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8();
+ QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8();
QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5);
- return ctx->engine->newString(QLatin1String(result.toHex()))->asReturnedValue();
+ return ctx->d()->engine->newString(QLatin1String(result.toHex()))->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_btoa(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("Qt.btoa(): Invalid arguments");
- QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8();
+ QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8();
- return ctx->engine->newString(QLatin1String(data.toBase64()))->asReturnedValue();
+ return ctx->d()->engine->newString(QLatin1String(data.toBase64()))->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_atob(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("Qt.atob(): Invalid arguments");
- QByteArray data = ctx->callData->args[0].toQStringNoThrow().toLatin1();
+ QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toLatin1();
- return ctx->engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))->asReturnedValue();
+ return ctx->d()->engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))->asReturnedValue();
}
/*!
*/
ReturnedValue QtObject::method_quit(CallContext *ctx)
{
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QQmlEnginePrivate::get(v8engine->engine())->sendQuit();
return QV4::Encode::undefined();
ReturnedValue QtObject::method_createQmlObject(CallContext *ctx)
{
Scope scope(ctx);
- if (ctx->callData->argc < 2 || ctx->callData->argc > 3)
+ if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 3)
V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments");
struct Error {
}
};
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QQmlEngine *engine = v8engine->engine();
QQmlContextData *context = v8engine->callingContext();
effectiveContext = context->asQQmlContext();
Q_ASSERT(effectiveContext);
- QString qml = ctx->callData->args[0].toQStringNoThrow();
+ QString qml = ctx->d()->callData->args[0].toQStringNoThrow();
if (qml.isEmpty())
return QV4::Encode::null();
QUrl url;
- if (ctx->callData->argc > 2)
- url = QUrl(ctx->callData->args[2].toQStringNoThrow());
+ if (ctx->d()->callData->argc > 2)
+ url = QUrl(ctx->d()->callData->args[2].toQStringNoThrow());
else
url = QUrl(QLatin1String("inline"));
url = context->resolvedUrl(url);
QObject *parentArg = 0;
- QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->callData->args[1]);
+ QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->d()->callData->args[1]);
if (!!qobjectWrapper)
parentArg = qobjectWrapper->object();
if (!parentArg)
component.setData(qml.toUtf8(), url);
if (component.isError()) {
- ScopedValue v(scope, Error::create(ctx->engine, component.errors()));
+ ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors()));
return ctx->throwError(v);
}
component.completeCreate();
if (component.isError()) {
- ScopedValue v(scope, Error::create(ctx->engine, component.errors()));
+ ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors()));
return ctx->throwError(v);
}
Q_ASSERT(obj);
- return QV4::QObjectWrapper::wrap(ctx->engine, obj);
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, obj);
}
/*!
*/
ReturnedValue QtObject::method_createComponent(CallContext *ctx)
{
- if (ctx->callData->argc < 1 || ctx->callData->argc > 3)
+ if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3)
return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
Scope scope(ctx);
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QQmlEngine *engine = v8engine->engine();
QQmlContextData *context = v8engine->callingContext();
if (context->isPragmaLibraryContext)
effectiveContext = 0;
- QString arg = ctx->callData->args[0].toQStringNoThrow();
+ QString arg = ctx->d()->callData->args[0].toQStringNoThrow();
if (arg.isEmpty())
return QV4::Encode::null();
QObject *parentArg = 0;
int consumedCount = 1;
- if (ctx->callData->argc > 1) {
- ScopedValue lastArg(scope, ctx->callData->args[ctx->callData->argc-1]);
+ if (ctx->d()->callData->argc > 1) {
+ ScopedValue lastArg(scope, ctx->d()->callData->args[ctx->d()->callData->argc-1]);
// The second argument could be the mode enum
- if (ctx->callData->args[1].isInteger()) {
- int mode = ctx->callData->args[1].integerValue();
+ if (ctx->d()->callData->args[1].isInteger()) {
+ int mode = ctx->d()->callData->args[1].integerValue();
if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous))
return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
compileMode = QQmlComponent::CompilationMode(mode);
consumedCount += 1;
} else {
// The second argument could be the parent only if there are exactly two args
- if ((ctx->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull()))
+ if ((ctx->d()->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull()))
return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments"));
}
- if (consumedCount < ctx->callData->argc) {
+ if (consumedCount < ctx->d()->callData->argc) {
if (lastArg->isObject()) {
Scoped<QObjectWrapper> qobjectWrapper(scope, lastArg);
if (qobjectWrapper)
QQmlData::get(c, true)->explicitIndestructibleSet = false;
QQmlData::get(c)->indestructible = false;
- return QV4::QObjectWrapper::wrap(ctx->engine, c);
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, c);
}
/*!
ReturnedValue QtObject::method_locale(CallContext *ctx)
{
QString code;
- if (ctx->callData->argc > 1)
+ if (ctx->d()->callData->argc > 1)
V4THROW_ERROR("locale() requires 0 or 1 argument");
- if (ctx->callData->argc == 1 && !ctx->callData->args[0].isString())
+ if (ctx->d()->callData->argc == 1 && !ctx->d()->callData->args[0].isString())
V4THROW_TYPE("locale(): argument (locale code) must be a string");
- QV8Engine *v8engine = ctx->engine->v8Engine;
- if (ctx->callData->argc == 1)
- code = ctx->callData->args[0].toQStringNoThrow();
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
+ if (ctx->d()->callData->argc == 1)
+ code = ctx->d()->callData->args[0].toQStringNoThrow();
return QQmlLocale::locale(v8engine, code);
}
*/
ReturnedValue QtObject::method_binding(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("binding() requires 1 argument");
- QV4::FunctionObject *f = ctx->callData->args[0].asFunctionObject();
+ QV4::FunctionObject *f = ctx->d()->callData->args[0].asFunctionObject();
if (!f)
V4THROW_TYPE("binding(): argument (binding expression) must be a function");
- return (new (ctx->engine->memoryManager) QQmlBindingFunction(f))->asReturnedValue();
+ return (new (ctx->d()->engine->memoryManager) QQmlBindingFunction(f))->asReturnedValue();
}
ReturnedValue QtObject::method_get_platform(CallContext *ctx)
{
// ### inefficient. Should be just a value based getter
- Object *o = ctx->callData->thisObject.asObject();
+ Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
return ctx->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt->d()->platform)
// Only allocate a platform object once
- qt->d()->platform = new QQmlPlatform(ctx->engine->v8Engine->publicEngine());
+ qt->d()->platform = new QQmlPlatform(ctx->d()->engine->v8Engine->publicEngine());
- return QV4::QObjectWrapper::wrap(ctx->engine, qt->d()->platform);
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->platform);
}
ReturnedValue QtObject::method_get_application(CallContext *ctx)
{
// ### inefficient. Should be just a value based getter
- Object *o = ctx->callData->thisObject.asObject();
+ Object *o = ctx->d()->callData->thisObject.asObject();
if (!o)
return ctx->throwTypeError();
QtObject *qt = o->as<QtObject>();
if (!qt->d()->application)
// Only allocate an application object once
- qt->d()->application = QQml_guiProvider()->application(ctx->engine->v8Engine->publicEngine());
+ qt->d()->application = QQml_guiProvider()->application(ctx->d()->engine->v8Engine->publicEngine());
- return QV4::QObjectWrapper::wrap(ctx->engine, qt->d()->application);
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->application);
}
#ifndef QT_NO_IM
{
QObject *o = QQml_guiProvider()->inputMethod();
QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership);
- return QV4::QObjectWrapper::wrap(ctx->engine, o);
+ return QV4::QObjectWrapper::wrap(ctx->d()->engine, o);
}
#endif
bool printStack = false)
{
QString result;
- QV4::ExecutionEngine *v4 = ctx->engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
- for (int i = 0; i < ctx->callData->argc; ++i) {
+ for (int i = 0; i < ctx->d()->callData->argc; ++i) {
if (i != 0)
result.append(QLatin1Char(' '));
- if (ctx->callData->args[i].asArrayObject())
- result.append(QStringLiteral("[") + ctx->callData->args[i].toQStringNoThrow() + QStringLiteral("]"));
+ if (ctx->d()->callData->args[i].asArrayObject())
+ result.append(QStringLiteral("[") + ctx->d()->callData->args[i].toQStringNoThrow() + QStringLiteral("]"));
else
- result.append(ctx->callData->args[i].toQStringNoThrow());
+ result.append(ctx->d()->callData->args[i].toQStringNoThrow());
}
if (printStack) {
QV4::ReturnedValue ConsoleObject::method_profile(CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
QV4::StackFrame frame = v4->currentStackFrame();
const QByteArray baSource = frame.source.toUtf8();
QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
QV4::StackFrame frame = v4->currentStackFrame();
const QByteArray baSource = frame.source.toUtf8();
QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- QString name = ctx->callData->args[0].toQStringNoThrow();
+ QString name = ctx->d()->callData->args[0].toQStringNoThrow();
v8engine->startTimer(name);
return QV4::Encode::undefined();
}
QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("console.time(): Invalid arguments");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
- QString name = ctx->callData->args[0].toQStringNoThrow();
+ QString name = ctx->d()->callData->args[0].toQStringNoThrow();
bool wasRunning;
qint64 elapsed = v8engine->stopTimer(name, &wasRunning);
if (wasRunning) {
{
// first argument: name to print. Ignore any additional arguments
QString name;
- if (ctx->callData->argc > 0)
- name = ctx->callData->args[0].toQStringNoThrow();
+ if (ctx->d()->callData->argc > 0)
+ name = ctx->d()->callData->args[0].toQStringNoThrow();
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QV4::StackFrame frame = v4->currentStackFrame();
QV4::ReturnedValue ConsoleObject::method_trace(CallContext *ctx)
{
- if (ctx->callData->argc != 0)
+ if (ctx->d()->callData->argc != 0)
V4THROW_ERROR("console.trace(): Invalid arguments");
- QV4::ExecutionEngine *v4 = ctx->engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
QString stack = jsStack(v4);
QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx)
{
- if (ctx->callData->argc == 0)
+ if (ctx->d()->callData->argc == 0)
V4THROW_ERROR("console.assert(): Missing argument");
- QV4::ExecutionEngine *v4 = ctx->engine;
+ QV4::ExecutionEngine *v4 = ctx->d()->engine;
- if (!ctx->callData->args[0].toBoolean()) {
+ if (!ctx->d()->callData->args[0].toBoolean()) {
QString message;
- for (int i = 1; i < ctx->callData->argc; ++i) {
+ for (int i = 1; i < ctx->d()->callData->argc; ++i) {
if (i != 1)
message.append(QLatin1Char(' '));
- message.append(ctx->callData->args[i].toQStringNoThrow());
+ message.append(ctx->d()->callData->args[i].toQStringNoThrow());
}
QString stack = jsStack(v4);
QV4::ReturnedValue ConsoleObject::method_exception(CallContext *ctx)
{
- if (ctx->callData->argc == 0)
+ if (ctx->d()->callData->argc == 0)
V4THROW_ERROR("console.exception(): Missing argument");
writeToConsole(Error, ctx, true);
*/
ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx)
{
- if (ctx->callData->argc < 2)
+ if (ctx->d()->callData->argc < 2)
V4THROW_ERROR("qsTranslate() requires at least two arguments");
- if (!ctx->callData->args[0].isString())
+ if (!ctx->d()->callData->args[0].isString())
V4THROW_ERROR("qsTranslate(): first argument (context) must be a string");
- if (!ctx->callData->args[1].isString())
+ if (!ctx->d()->callData->args[1].isString())
V4THROW_ERROR("qsTranslate(): second argument (sourceText) must be a string");
- if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isString())
+ if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isString())
V4THROW_ERROR("qsTranslate(): third argument (disambiguation) must be a string");
- QString context = ctx->callData->args[0].toQStringNoThrow();
- QString text = ctx->callData->args[1].toQStringNoThrow();
+ QString context = ctx->d()->callData->args[0].toQStringNoThrow();
+ QString text = ctx->d()->callData->args[1].toQStringNoThrow();
QString comment;
- if (ctx->callData->argc > 2) comment = ctx->callData->args[2].toQStringNoThrow();
+ if (ctx->d()->callData->argc > 2) comment = ctx->d()->callData->args[2].toQStringNoThrow();
int i = 3;
- if (ctx->callData->argc > i && ctx->callData->args[i].isString()) {
+ if (ctx->d()->callData->argc > i && ctx->d()->callData->args[i].isString()) {
qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated");
++i;
}
int n = -1;
- if (ctx->callData->argc > i)
- n = ctx->callData->args[i].toInt32();
+ if (ctx->d()->callData->argc > i)
+ n = ctx->d()->callData->args[i].toInt32();
QString result = QCoreApplication::translate(context.toUtf8().constData(),
text.toUtf8().constData(),
comment.toUtf8().constData(),
n);
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
/*!
*/
ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx)
{
- if (ctx->callData->argc < 2)
+ if (ctx->d()->callData->argc < 2)
return QV4::Encode::undefined();
- return ctx->callData->args[1].asReturnedValue();
+ return ctx->d()->callData->args[1].asReturnedValue();
}
/*!
*/
ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx)
{
- if (ctx->callData->argc < 1)
+ if (ctx->d()->callData->argc < 1)
V4THROW_ERROR("qsTr() requires at least one argument");
- if (!ctx->callData->args[0].isString())
+ if (!ctx->d()->callData->args[0].isString())
V4THROW_ERROR("qsTr(): first argument (sourceText) must be a string");
- if ((ctx->callData->argc > 1) && !ctx->callData->args[1].isString())
+ if ((ctx->d()->callData->argc > 1) && !ctx->d()->callData->args[1].isString())
V4THROW_ERROR("qsTr(): second argument (disambiguation) must be a string");
- if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isNumber())
+ if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isNumber())
V4THROW_ERROR("qsTr(): third argument (n) must be a number");
- QV8Engine *v8engine = ctx->engine->v8Engine;
+ QV8Engine *v8engine = ctx->d()->engine->v8Engine;
QString context;
if (QQmlContextData *ctxt = v8engine->callingContext()) {
QString path = ctxt->url.toString();
int lastDot = path.lastIndexOf(QLatin1Char('.'));
int length = lastDot - (lastSlash + 1);
context = (lastSlash > -1) ? path.mid(lastSlash + 1, (length > -1) ? length : -1) : QString();
- } else if (QV4::ExecutionContext *parentCtx = ctx->parent) {
+ } else if (QV4::ExecutionContext *parentCtx = ctx->d()->parent) {
// The first non-empty source URL in the call stack determines the translation context.
while (parentCtx && context.isEmpty()) {
- if (QV4::CompiledData::CompilationUnit *unit = parentCtx->compilationUnit) {
+ if (QV4::CompiledData::CompilationUnit *unit = parentCtx->d()->compilationUnit) {
QString fileName = unit->fileName();
QUrl url(unit->fileName());
if (url.isValid() && url.isRelative()) {
}
context = QFileInfo(context).baseName();
}
- parentCtx = parentCtx->parent;
+ parentCtx = parentCtx->d()->parent;
}
}
- QString text = ctx->callData->args[0].toQStringNoThrow();
+ QString text = ctx->d()->callData->args[0].toQStringNoThrow();
QString comment;
- if (ctx->callData->argc > 1)
- comment = ctx->callData->args[1].toQStringNoThrow();
+ if (ctx->d()->callData->argc > 1)
+ comment = ctx->d()->callData->args[1].toQStringNoThrow();
int n = -1;
- if (ctx->callData->argc > 2)
- n = ctx->callData->args[2].toInt32();
+ if (ctx->d()->callData->argc > 2)
+ n = ctx->d()->callData->args[2].toInt32();
QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(),
comment.toUtf8().constData(), n);
- return ctx->engine->newString(result)->asReturnedValue();
+ return ctx->d()->engine->newString(result)->asReturnedValue();
}
/*!
*/
ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx)
{
- if (ctx->callData->argc < 1)
+ if (ctx->d()->callData->argc < 1)
return QV4::Encode::undefined();
- return ctx->callData->args[0].asReturnedValue();
+ return ctx->d()->callData->args[0].asReturnedValue();
}
/*!
*/
ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx)
{
- if (ctx->callData->argc < 1)
+ if (ctx->d()->callData->argc < 1)
V4THROW_ERROR("qsTrId() requires at least one argument");
- if (!ctx->callData->args[0].isString())
+ if (!ctx->d()->callData->args[0].isString())
V4THROW_TYPE("qsTrId(): first argument (id) must be a string");
- if (ctx->callData->argc > 1 && !ctx->callData->args[1].isNumber())
+ if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isNumber())
V4THROW_TYPE("qsTrId(): second argument (n) must be a number");
int n = -1;
- if (ctx->callData->argc > 1)
- n = ctx->callData->args[1].toInt32();
+ if (ctx->d()->callData->argc > 1)
+ n = ctx->d()->callData->args[1].toInt32();
- return ctx->engine->newString(qtTrId(ctx->callData->args[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue();
+ return ctx->d()->engine->newString(qtTrId(ctx->d()->callData->args[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue();
}
/*!
*/
ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx)
{
- if (ctx->callData->argc < 1)
+ if (ctx->d()->callData->argc < 1)
return QV4::Encode::undefined();
- return ctx->callData->args[0].asReturnedValue();
+ return ctx->d()->callData->args[0].asReturnedValue();
}
#endif // QT_NO_TRANSLATION
QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx)
{
- ctx->engine->memoryManager->runGC();
+ ctx->d()->engine->memoryManager->runGC();
return QV4::Encode::undefined();
}
ReturnedValue GlobalExtensions::method_string_arg(CallContext *ctx)
{
- if (ctx->callData->argc != 1)
+ if (ctx->d()->callData->argc != 1)
V4THROW_ERROR("String.arg(): Invalid arguments");
- QString value = ctx->callData->thisObject.toQString();
+ QString value = ctx->d()->callData->thisObject.toQString();
QV4::Scope scope(ctx);
- QV4::ScopedValue arg(scope, ctx->callData->args[0]);
+ QV4::ScopedValue arg(scope, ctx->d()->callData->args[0]);
if (arg->isInteger())
- return ctx->engine->newString(value.arg(arg->integerValue()))->asReturnedValue();
+ return ctx->d()->engine->newString(value.arg(arg->integerValue()))->asReturnedValue();
else if (arg->isDouble())
- return ctx->engine->newString(value.arg(arg->doubleValue()))->asReturnedValue();
+ return ctx->d()->engine->newString(value.arg(arg->doubleValue()))->asReturnedValue();
else if (arg->isBoolean())
- return ctx->engine->newString(value.arg(arg->booleanValue()))->asReturnedValue();
+ return ctx->d()->engine->newString(value.arg(arg->booleanValue()))->asReturnedValue();
- return ctx->engine->newString(value.arg(arg->toQString()))->asReturnedValue();
+ return ctx->d()->engine->newString(value.arg(arg->toQString()))->asReturnedValue();
}
#define DOMEXCEPTION_TYPE_MISMATCH_ERR 17
#define V4THROW_DOM(error, string) { \
- QV4::ScopedValue v(scope, ctx->engine->newString(QStringLiteral(string))); \
- QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v)); \
- ex->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \
+ QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \
+ QV4::Scoped<Object> ex(scope, scope.engine->newErrorObject(v)); \
+ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \
return ctx->throwError(ex); \
}
case QMetaType::Double:
return QV4::Encode(*reinterpret_cast<const double*>(ptr));
case QMetaType::QString:
- return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
+ return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
case QMetaType::Float:
return QV4::Encode(*reinterpret_cast<const float*>(ptr));
case QMetaType::Short:
case QMetaType::Double:
return QV4::Encode(*reinterpret_cast<const double*>(data));
case QMetaType::QString:
- return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
+ return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
case QMetaType::Float:
return QV4::Encode(*reinterpret_cast<const float*>(data));
case QMetaType::Short:
QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
if (!o->d()->item->metaType->model)
QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
groups.append(o->d()->item->metaType->groupNames.at(i - 1));
}
- return ctx->engine->v8Engine->fromVariant(groups);
+ return scope.engine->v8Engine->fromVariant(groups);
}
QV4::ReturnedValue QQmlDelegateModelItem::set_groups(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return ctx->throwTypeError();
if (!o->d()->item->metaType->model)
return QV4::Encode::undefined();
QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(o->d()->item->metaType->model);
- const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->callData->args[0]);
+ const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->d()->callData->args[0]);
const int cacheIndex = model->m_cache.indexOf(o->d()->item);
Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex);
model->setGroups(it, 1, Compositor::Cache, groupFlags);
static QV4::ReturnedValue method_get_index(QV4::CallContext *ctx) {
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>());
+ QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
return ctx->throwTypeError();
return QV4::Encode(that->d()->change.index);
}
static QV4::ReturnedValue method_get_count(QV4::CallContext *ctx) {
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>());
+ QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
return ctx->throwTypeError();
return QV4::Encode(that->d()->change.count);
}
static QV4::ReturnedValue method_get_moveId(QV4::CallContext *ctx) {
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->callData->thisObject.as<QQmlDelegateModelGroupChange>());
+ QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>());
if (!that)
return ctx->throwTypeError();
if (that->d()->change.moveId < 0)
QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(QV4::CallContext *ctx)
{
- WorkerEngine *engine = (WorkerEngine*)ctx->engine->v8Engine;
+ WorkerEngine *engine = (WorkerEngine*)ctx->engine()->v8Engine;
- int id = ctx->callData->argc > 1 ? ctx->callData->args[1].toInt32() : 0;
+ int id = ctx->d()->callData->argc > 1 ? ctx->d()->callData->args[1].toInt32() : 0;
QV4::Scope scope(ctx);
- QV4::ScopedValue v(scope, ctx->callData->argument(2));
+ QV4::ScopedValue v(scope, ctx->d()->callData->argument(2));
QByteArray data = QV4::Serialize::serialize(v, engine);
QMutexLocker locker(&engine->p->m_lock);
static QV4::ReturnedValue get_index(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
static QV4::ReturnedValue get_hasModelChildren(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::CallContext *ctx, uint propertyId)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item);
if (o->d()->item->index == -1) {
if (!modelData->cachedData.isEmpty()) {
- return ctx->engine->v8Engine->fromVariant(
+ return ctx->d()->engine->v8Engine->fromVariant(
modelData->cachedData.at(modelData->type->hasModelData ? 0 : propertyId));
}
} else if (*modelData->type->model) {
- return ctx->engine->v8Engine->fromVariant(
+ return ctx->d()->engine->v8Engine->fromVariant(
modelData->value(modelData->type->propertyRoles.at(propertyId)));
}
return QV4::Encode::undefined();
QV4::ReturnedValue QQmlDMCachedModelData::set_property(QV4::CallContext *ctx, uint propertyId)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return ctx->throwTypeError();
if (o->d()->item->index == -1) {
QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item);
if (!modelData->cachedData.isEmpty()) {
if (modelData->cachedData.count() > 1) {
- modelData->cachedData[propertyId] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid);
+ modelData->cachedData[propertyId] = scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid);
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, 0);
} else if (modelData->cachedData.count() == 1) {
- modelData->cachedData[0] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid);
+ modelData->cachedData[0] = scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid);
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, 0);
QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, 0);
}
static QV4::ReturnedValue get_modelData(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
- return ctx->engine->v8Engine->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData);
+ return scope.engine->v8Engine->fromVariant(static_cast<QQmlDMListAccessorData *>(o->d()->item)->cachedData);
}
static QV4::ReturnedValue set_modelData(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->callData->thisObject.as<QQmlDelegateModelItemObject>());
+ QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>());
if (!o)
return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object"));
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return ctx->throwTypeError();
- static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid));
+ static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid));
return QV4::Encode::undefined();
}
QQuickContext2DEngineData *ed = engineData(engine);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, new (v4->memoryManager) QQuickJSContext2DPixelData(v4));
+ QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, new (scope.engine->memoryManager) QQuickJSContext2DPixelData(v4));
QV4::ScopedObject p(scope, ed->pixelArrayProto.value());
pixelData->setPrototype(p.getPointer());
pixelData->d()->image = image.format() == QImage::Format_ARGB32 ? image : image.convertToFormat(QImage::Format_ARGB32);
}
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, new (v4->memoryManager) QQuickJSContext2DImageData(v4));
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, new (scope.engine->memoryManager) QQuickJSContext2DImageData(v4));
imageData->d()->pixelData = pixelData.asReturnedValue();
return imageData.asReturnedValue();
}
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_get_canvas(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return QV4::QObjectWrapper::wrap(ctx->engine, r->d()->context->canvas());
+ return QV4::QObjectWrapper::wrap(scope.engine, r->d()->context->canvas());
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_restore(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->popState();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_reset(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->reset();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_save(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->pushState();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
// transformations
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_rotate(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 1)
- r->d()->context->rotate(ctx->callData->args[0].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 1)
+ r->d()->context->rotate(ctx->d()->callData->args[0].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 2)
- r->d()->context->scale(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 2)
+ r->d()->context->scale(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 6)
- r->d()->context->setTransform( ctx->callData->args[0].toNumber()
- , ctx->callData->args[1].toNumber()
- , ctx->callData->args[2].toNumber()
- , ctx->callData->args[3].toNumber()
- , ctx->callData->args[4].toNumber()
- , ctx->callData->args[5].toNumber());
+ if (ctx->d()->callData->argc == 6)
+ r->d()->context->setTransform( ctx->d()->callData->args[0].toNumber()
+ , ctx->d()->callData->args[1].toNumber()
+ , ctx->d()->callData->args[2].toNumber()
+ , ctx->d()->callData->args[3].toNumber()
+ , ctx->d()->callData->args[4].toNumber()
+ , ctx->d()->callData->args[5].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 6)
- r->d()->context->transform( ctx->callData->args[0].toNumber()
- , ctx->callData->args[1].toNumber()
- , ctx->callData->args[2].toNumber()
- , ctx->callData->args[3].toNumber()
- , ctx->callData->args[4].toNumber()
- , ctx->callData->args[5].toNumber());
+ if (ctx->d()->callData->argc == 6)
+ r->d()->context->transform( ctx->d()->callData->args[0].toNumber()
+ , ctx->d()->callData->args[1].toNumber()
+ , ctx->d()->callData->args[2].toNumber()
+ , ctx->d()->callData->args[3].toNumber()
+ , ctx->d()->callData->args[4].toNumber()
+ , ctx->d()->callData->args[5].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_translate(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 2)
- r->d()->context->translate(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 2)
+ r->d()->context->translate(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_resetTransform(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->setTransform(1, 0, 0, 1, 0, 0);
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 2)
- r->d()->context->shear(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber());
+ if (ctx->d()->callData->argc == 2)
+ r->d()->context->shear(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
// compositing
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_globalAlpha(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.globalAlpha);
QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- double globalAlpha = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ double globalAlpha = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
if (!qIsFinite(globalAlpha))
return QV4::Encode::undefined();
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_globalCompositeOperation(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return QV4::Encode(ctx->engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation)));
+ return QV4::Encode(scope.engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation)));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return ctx->throwTypeError();
- QString mode = ctx->callData->args[0].toQString();
+ QString mode = ctx->d()->callData->args[0].toQString();
QPainter::CompositionMode cm = qt_composite_mode_from_string(mode);
if (cm == QPainter::CompositionMode_SourceOver && mode != QStringLiteral("source-over"))
return QV4::Encode::undefined();
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_fillStyle(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
QColor color = r->d()->context->state.fillStyle.color();
if (color.isValid()) {
if (color.alpha() == 255)
- return QV4::Encode(ctx->engine->newString(color.name()));
+ return QV4::Encode(scope.engine->newString(color.name()));
QString alphaString = QString::number(color.alphaF(), 'f');
while (alphaString.endsWith(QLatin1Char('0')))
alphaString.chop(1);
if (alphaString.endsWith(QLatin1Char('.')))
alphaString += QLatin1Char('0');
QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);
- return QV4::Encode(ctx->engine->newString(str));
+ return QV4::Encode(scope.engine->newString(str));
}
return r->d()->context->m_fillStyle.value();
}
QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
QV4::ScopedValue value(scope, ctx->argument(0));
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
if (value->asObject()) {
QColor color = engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_fillRule(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
return engine->fromVariant(r->d()->context->state.fillRule);
}
QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
QV4::ScopedValue value(scope, ctx->argument(0));
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_strokeStyle(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
QColor color = r->d()->context->state.strokeStyle.color();
if (color.isValid()) {
if (color.alpha() == 255)
- return QV4::Encode(ctx->engine->newString(color.name()));
+ return QV4::Encode(scope.engine->newString(color.name()));
QString alphaString = QString::number(color.alphaF(), 'f');
while (alphaString.endsWith(QLatin1Char('0')))
alphaString.chop(1);
if (alphaString.endsWith(QLatin1Char('.')))
alphaString += QLatin1Char('0');
QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);
- return QV4::Encode(ctx->engine->newString(str));
+ return QV4::Encode(scope.engine->newString(str));
}
return r->d()->context->m_strokeStyle.value();
}
QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
QV4::ScopedValue value(scope, ctx->argument(0));
if (value->asObject()) {
QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 4) {
- qreal x0 = ctx->callData->args[0].toNumber();
- qreal y0 = ctx->callData->args[1].toNumber();
- qreal x1 = ctx->callData->args[2].toNumber();
- qreal y1 = ctx->callData->args[3].toNumber();
+ if (ctx->d()->callData->argc == 4) {
+ qreal x0 = ctx->d()->callData->args[0].toNumber();
+ qreal y0 = ctx->d()->callData->args[1].toNumber();
+ qreal x1 = ctx->d()->callData->args[2].toNumber();
+ qreal y1 = ctx->d()->callData->args[3].toNumber();
if (!qIsFinite(x0)
|| !qIsFinite(y0)
}
QQuickContext2DEngineData *ed = engineData(engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (v4->memoryManager) QQuickContext2DStyle(v4));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (scope.engine->memoryManager) QQuickContext2DStyle(scope.engine));
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p.getPointer());
gradient->d()->brush = QLinearGradient(x0, y0, x1, y1);
return gradient.asReturnedValue();
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 6) {
- qreal x0 = ctx->callData->args[0].toNumber();
- qreal y0 = ctx->callData->args[1].toNumber();
- qreal r0 = ctx->callData->args[2].toNumber();
- qreal x1 = ctx->callData->args[3].toNumber();
- qreal y1 = ctx->callData->args[4].toNumber();
- qreal r1 = ctx->callData->args[5].toNumber();
+ if (ctx->d()->callData->argc == 6) {
+ qreal x0 = ctx->d()->callData->args[0].toNumber();
+ qreal y0 = ctx->d()->callData->args[1].toNumber();
+ qreal r0 = ctx->d()->callData->args[2].toNumber();
+ qreal x1 = ctx->d()->callData->args[3].toNumber();
+ qreal y1 = ctx->d()->callData->args[4].toNumber();
+ qreal r1 = ctx->d()->callData->args[5].toNumber();
if (!qIsFinite(x0)
|| !qIsFinite(y0)
QQuickContext2DEngineData *ed = engineData(engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (v4->memoryManager) QQuickContext2DStyle(v4));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (scope.engine->memoryManager) QQuickContext2DStyle(scope.engine));
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p.getPointer());
gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
return gradient.asReturnedValue();
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 3) {
- qreal x = ctx->callData->args[0].toNumber();
- qreal y = ctx->callData->args[1].toNumber();
- qreal angle = DEGREES(ctx->callData->args[2].toNumber());
+ if (ctx->d()->callData->argc == 3) {
+ qreal x = ctx->d()->callData->args[0].toNumber();
+ qreal y = ctx->d()->callData->args[1].toNumber();
+ qreal angle = DEGREES(ctx->d()->callData->args[2].toNumber());
if (!qIsFinite(x) || !qIsFinite(y)) {
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments");
}
QQuickContext2DEngineData *ed = engineData(engine);
- QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (v4->memoryManager) QQuickContext2DStyle(v4));
+ QV4::Scoped<QQuickContext2DStyle> gradient(scope, new (scope.engine->memoryManager) QQuickContext2DStyle(scope.engine));
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p.getPointer());
gradient->d()->brush = QConicalGradient(x, y, angle);
return gradient.asReturnedValue();
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
\qmlmethod variant QtQuick::Context2D::createPattern(color color, enumeration patternMode)
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 2) {
- QV4::Scoped<QQuickContext2DStyle> pattern(scope, new (v4->memoryManager) QQuickContext2DStyle(v4));
+ if (ctx->d()->callData->argc == 2) {
+ QV4::Scoped<QQuickContext2DStyle> pattern(scope, new (scope.engine->memoryManager) QQuickContext2DStyle(scope.engine));
- QColor color = engine->toVariant(ctx->callData->args[0], qMetaTypeId<QColor>()).value<QColor>();
+ QColor color = engine->toVariant(ctx->d()->callData->args[0], qMetaTypeId<QColor>()).value<QColor>();
if (color.isValid()) {
- int patternMode = ctx->callData->args[1].toInt32();
+ int patternMode = ctx->d()->callData->args[1].toInt32();
Qt::BrushStyle style = Qt::SolidPattern;
if (patternMode >= 0 && patternMode < Qt::LinearGradientPattern) {
style = static_cast<Qt::BrushStyle>(patternMode);
} else {
QImage patternTexture;
- if (QV4::Object *o = ctx->callData->args[0].asObject()) {
- QV4::ScopedString s(scope, ctx->engine->newString(QStringLiteral("data")));
+ if (QV4::Object *o = ctx->d()->callData->args[0].asObject()) {
+ QV4::ScopedString s(scope, scope.engine->newString(QStringLiteral("data")));
QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(s));
if (!!pixelData) {
patternTexture = pixelData->d()->image;
}
} else {
- patternTexture = r->d()->context->createPixmap(QUrl(ctx->callData->args[0].toQStringNoThrow()))->image();
+ patternTexture = r->d()->context->createPixmap(QUrl(ctx->d()->callData->args[0].toQStringNoThrow()))->image();
}
if (!patternTexture.isNull()) {
pattern->d()->brush.setTextureImage(patternTexture);
- QString repetition = ctx->callData->args[1].toQStringNoThrow();
+ QString repetition = ctx->d()->callData->args[1].toQStringNoThrow();
if (repetition == QStringLiteral("repeat") || repetition.isEmpty()) {
pattern->d()->patternRepeatX = true;
pattern->d()->patternRepeatY = true;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_lineCap(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.lineCap) {
case Qt::RoundCap:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("round")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("round")));
case Qt::SquareCap:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("square")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("square")));
case Qt::FlatCap:
default:
break;
}
- return QV4::Encode(ctx->engine->newString(QStringLiteral("butt")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("butt")));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QString lineCap = ctx->callData->args[0].toQString();
+ QString lineCap = ctx->d()->callData->args[0].toQString();
Qt::PenCapStyle cap;
if (lineCap == QStringLiteral("round"))
cap = Qt::RoundCap;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_lineJoin(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.lineJoin) {
case Qt::RoundJoin:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("round")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("round")));
case Qt::BevelJoin:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("bevel")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("bevel")));
case Qt::MiterJoin:
default:
break;
}
- return QV4::Encode(ctx->engine->newString(QStringLiteral("miter")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("miter")));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- if (!ctx->callData->argc)
+ if (!ctx->d()->callData->argc)
return ctx->throwTypeError();
- QString lineJoin = ctx->callData->args[0].toQString();
+ QString lineJoin = ctx->d()->callData->args[0].toQString();
Qt::PenJoinStyle join;
if (lineJoin == QStringLiteral("round"))
join = Qt::RoundJoin;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_lineWidth(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.lineWidth);
QV4::ReturnedValue QQuickJSContext2D::method_set_lineWidth(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal w = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1;
+ qreal w = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : -1;
if (w > 0 && qIsFinite(w) && w != r->d()->context->state.lineWidth) {
r->d()->context->state.lineWidth = w;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_miterLimit(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.miterLimit);
QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal ml = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1;
+ qreal ml = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : -1;
if (ml > 0 && qIsFinite(ml) && ml != r->d()->context->state.miterLimit) {
r->d()->context->state.miterLimit = ml;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_shadowBlur(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.shadowBlur);
QV4::ReturnedValue QQuickJSContext2D::method_set_shadowBlur(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal blur = ctx->callData->argc ? ctx->callData->args[0].toNumber() : -1;
+ qreal blur = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : -1;
if (blur > 0 && qIsFinite(blur) && blur != r->d()->context->state.shadowBlur) {
r->d()->context->state.shadowBlur = blur;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_shadowColor(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(ctx->engine->newString(r->d()->context->state.shadowColor.name()));
+ return QV4::Encode(scope.engine->newString(r->d()->context->state.shadowColor.name()));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_shadowColor(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QColor color;
- if (ctx->callData->argc)
- color = qt_color_from_string(ctx->callData->args[0]);
+ if (ctx->d()->callData->argc)
+ color = qt_color_from_string(ctx->d()->callData->args[0]);
if (color.isValid() && color != r->d()->context->state.shadowColor) {
r->d()->context->state.shadowColor = color;
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetX(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.shadowOffsetX);
QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal offsetX = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ qreal offsetX = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
if (qIsFinite(offsetX) && offsetX != r->d()->context->state.shadowOffsetX) {
r->d()->context->state.shadowOffsetX = offsetX;
r->d()->context->buffer()->setShadowOffsetX(offsetX);
*/
QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetY(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return QV4::Encode(r->d()->context->state.shadowOffsetY);
QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetY(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal offsetY = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN();
+ qreal offsetY = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN();
if (qIsFinite(offsetY) && offsetY != r->d()->context->state.shadowOffsetY) {
r->d()->context->state.shadowOffsetY = offsetY;
r->d()->context->buffer()->setShadowOffsetY(offsetY);
QV4::ReturnedValue QQuickJSContext2D::method_get_path(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
return r->d()->context->m_v4path.value();
QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QV4::ScopedValue value(scope, ctx->argument(0));
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4)
- r->d()->context->clearRect(ctx->callData->args[0].toNumber(),
- ctx->callData->args[1].toNumber(),
- ctx->callData->args[2].toNumber(),
- ctx->callData->args[3].toNumber());
+ if (ctx->d()->callData->argc == 4)
+ r->d()->context->clearRect(ctx->d()->callData->args[0].toNumber(),
+ ctx->d()->callData->args[1].toNumber(),
+ ctx->d()->callData->args[2].toNumber(),
+ ctx->d()->callData->args[3].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
\qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h)
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4)
- r->d()->context->fillRect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 4)
+ r->d()->context->fillRect(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber(), ctx->d()->callData->args[2].toNumber(), ctx->d()->callData->args[3].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4)
- r->d()->context->strokeRect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber());
+ if (ctx->d()->callData->argc == 4)
+ r->d()->context->strokeRect(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber(), ctx->d()->callData->args[2].toNumber(), ctx->d()->callData->args[3].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
// Complex shapes (paths) API
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc >= 5) {
+ if (ctx->d()->callData->argc >= 5) {
bool antiClockwise = false;
- if (ctx->callData->argc == 6)
- antiClockwise = ctx->callData->args[5].toBoolean();
+ if (ctx->d()->callData->argc == 6)
+ antiClockwise = ctx->d()->callData->args[5].toBoolean();
- qreal radius = ctx->callData->args[2].toNumber();
+ qreal radius = ctx->d()->callData->args[2].toNumber();
if (qIsFinite(radius) && radius < 0)
V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
- r->d()->context->arc(ctx->callData->args[0].toNumber(),
- ctx->callData->args[1].toNumber(),
+ r->d()->context->arc(ctx->d()->callData->args[0].toNumber(),
+ ctx->d()->callData->args[1].toNumber(),
radius,
- ctx->callData->args[3].toNumber(),
- ctx->callData->args[4].toNumber(),
+ ctx->d()->callData->args[3].toNumber(),
+ ctx->d()->callData->args[4].toNumber(),
antiClockwise);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 5) {
- qreal radius = ctx->callData->args[4].toNumber();
+ if (ctx->d()->callData->argc == 5) {
+ qreal radius = ctx->d()->callData->args[4].toNumber();
if (qIsFinite(radius) && radius < 0)
V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
- r->d()->context->arcTo(ctx->callData->args[0].toNumber(),
- ctx->callData->args[1].toNumber(),
- ctx->callData->args[2].toNumber(),
- ctx->callData->args[3].toNumber(),
+ r->d()->context->arcTo(ctx->d()->callData->args[0].toNumber(),
+ ctx->d()->callData->args[1].toNumber(),
+ ctx->d()->callData->args[2].toNumber(),
+ ctx->d()->callData->args[3].toNumber(),
radius);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->beginPath();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 6) {
- qreal cp1x = ctx->callData->args[0].toNumber();
- qreal cp1y = ctx->callData->args[1].toNumber();
- qreal cp2x = ctx->callData->args[2].toNumber();
- qreal cp2y = ctx->callData->args[3].toNumber();
- qreal x = ctx->callData->args[4].toNumber();
- qreal y = ctx->callData->args[5].toNumber();
+ if (ctx->d()->callData->argc == 6) {
+ qreal cp1x = ctx->d()->callData->args[0].toNumber();
+ qreal cp1y = ctx->d()->callData->args[1].toNumber();
+ qreal cp2x = ctx->d()->callData->args[2].toNumber();
+ qreal cp2y = ctx->d()->callData->args[3].toNumber();
+ qreal x = ctx->d()->callData->args[4].toNumber();
+ qreal y = ctx->d()->callData->args[5].toNumber();
if (!qIsFinite(cp1x) || !qIsFinite(cp1y) || !qIsFinite(cp2x) || !qIsFinite(cp2y) || !qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
r->d()->context->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->clip();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->closePath();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r);
r->d()->context->fill();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 2) {
- qreal x = ctx->callData->args[0].toNumber();
- qreal y = ctx->callData->args[1].toNumber();
+ if (ctx->d()->callData->argc == 2) {
+ qreal x = ctx->d()->callData->args[0].toNumber();
+ qreal y = ctx->d()->callData->args[1].toNumber();
if (!qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
r->d()->context->lineTo(x, y);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 2) {
- qreal x = ctx->callData->args[0].toNumber();
- qreal y = ctx->callData->args[1].toNumber();
+ if (ctx->d()->callData->argc == 2) {
+ qreal x = ctx->d()->callData->args[0].toNumber();
+ qreal y = ctx->d()->callData->args[1].toNumber();
if (!qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
r->d()->context->moveTo(x, y);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4) {
- qreal cpx = ctx->callData->args[0].toNumber();
- qreal cpy = ctx->callData->args[1].toNumber();
- qreal x = ctx->callData->args[2].toNumber();
- qreal y = ctx->callData->args[3].toNumber();
+ if (ctx->d()->callData->argc == 4) {
+ qreal cpx = ctx->d()->callData->args[0].toNumber();
+ qreal cpy = ctx->d()->callData->args[1].toNumber();
+ qreal x = ctx->d()->callData->args[2].toNumber();
+ qreal y = ctx->d()->callData->args[3].toNumber();
if (!qIsFinite(cpx) || !qIsFinite(cpy) || !qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
r->d()->context->quadraticCurveTo(cpx, cpy, x, y);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4)
- r->d()->context->rect(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 4)
+ r->d()->context->rect(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber(), ctx->d()->callData->args[2].toNumber(), ctx->d()->callData->args[3].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 6)
- r->d()->context->roundedRect(ctx->callData->args[0].toNumber()
- , ctx->callData->args[1].toNumber()
- , ctx->callData->args[2].toNumber()
- , ctx->callData->args[3].toNumber()
- , ctx->callData->args[4].toNumber()
- , ctx->callData->args[5].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 6)
+ r->d()->context->roundedRect(ctx->d()->callData->args[0].toNumber()
+ , ctx->d()->callData->args[1].toNumber()
+ , ctx->d()->callData->args[2].toNumber()
+ , ctx->d()->callData->args[3].toNumber()
+ , ctx->d()->callData->args[4].toNumber()
+ , ctx->d()->callData->args[5].toNumber());
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 4)
- r->d()->context->ellipse(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), ctx->callData->args[3].toNumber());
+ if (ctx->d()->callData->argc == 4)
+ r->d()->context->ellipse(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber(), ctx->d()->callData->args[2].toNumber(), ctx->d()->callData->args[3].toNumber());
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 3) {
- qreal x = ctx->callData->args[1].toNumber();
- qreal y = ctx->callData->args[2].toNumber();
+ if (ctx->d()->callData->argc == 3) {
+ qreal x = ctx->d()->callData->args[1].toNumber();
+ qreal y = ctx->d()->callData->args[2].toNumber();
if (!qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
- r->d()->context->text(ctx->callData->args[0].toQStringNoThrow(), x, y);
+ return ctx->d()->callData->thisObject.asReturnedValue();
+ r->d()->context->text(ctx->d()->callData->args[0].toQStringNoThrow(), x, y);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->stroke();
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
*/
QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(QV4::CallContext *ctx)
{
- QV4::ExecutionEngine *v4 = ctx->engine;
- QV4::Scope scope(v4);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scope scope(ctx);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
bool pointInPath = false;
- if (ctx->callData->argc == 2)
- pointInPath = r->d()->context->isPointInPath(ctx->callData->args[0].toNumber(), ctx->callData->args[1].toNumber());
+ if (ctx->d()->callData->argc == 2)
+ pointInPath = r->d()->context->isPointInPath(ctx->d()->callData->args[0].toNumber(), ctx->d()->callData->args[1].toNumber());
return QV4::Primitive::fromBoolean(pointInPath).asReturnedValue();
}
QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(ctx->engine->newString(r->d()->context->state.font.toString()));
+ return QV4::Encode(scope.engine->newString(r->d()->context->state.font.toString()));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert);
QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.textAlign) {
case QQuickContext2D::End:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("end")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("end")));
case QQuickContext2D::Left:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("left")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("left")));
case QQuickContext2D::Right:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("right")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("right")));
case QQuickContext2D::Center:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("center")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("center")));
case QQuickContext2D::Start:
default:
break;
}
- return QV4::Encode(ctx->engine->newString(QStringLiteral("start")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("start")));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert);
QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.textBaseline) {
case QQuickContext2D::Hanging:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("hanging")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("hanging")));
case QQuickContext2D::Top:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("top")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("top")));
case QQuickContext2D::Bottom:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("bottom")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("bottom")));
case QQuickContext2D::Middle:
- return QV4::Encode(ctx->engine->newString(QStringLiteral("middle")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("middle")));
case QQuickContext2D::Alphabetic:
default:
break;
}
- return QV4::Encode(ctx->engine->newString(QStringLiteral("alphabetic")));
+ return QV4::Encode(scope.engine->newString(QStringLiteral("alphabetic")));
}
QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QV4::Scoped<QV4::String> s(scope, ctx->argument(0), QV4::Scoped<QV4::String>::Convert);
if (scope.engine->hasException)
QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 3) {
- qreal x = ctx->callData->args[1].toNumber();
- qreal y = ctx->callData->args[2].toNumber();
+ if (ctx->d()->callData->argc == 3) {
+ qreal x = ctx->d()->callData->args[1].toNumber();
+ qreal y = ctx->d()->callData->args[2].toNumber();
if (!qIsFinite(x) || !qIsFinite(y))
- return ctx->callData->thisObject.asReturnedValue();
- QPainterPath textPath = r->d()->context->createTextGlyphs(x, y, ctx->callData->args[0].toQStringNoThrow());
+ return ctx->d()->callData->thisObject.asReturnedValue();
+ QPainterPath textPath = r->d()->context->createTextGlyphs(x, y, ctx->d()->callData->args[0].toQStringNoThrow());
r->d()->context->buffer()->fill(textPath);
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
\qmlmethod object QtQuick::Context2D::strokeText(text, x, y)
QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 3)
- r->d()->context->drawText(ctx->callData->args[0].toQStringNoThrow(), ctx->callData->args[1].toNumber(), ctx->callData->args[2].toNumber(), false);
- return ctx->callData->thisObject.asReturnedValue();
+ if (ctx->d()->callData->argc == 3)
+ r->d()->context->drawText(ctx->d()->callData->args[0].toQStringNoThrow(), ctx->d()->callData->args[1].toNumber(), ctx->d()->callData->args[2].toNumber(), false);
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->callData->argc == 1) {
+ if (ctx->d()->callData->argc == 1) {
QFontMetrics fm(r->d()->context->state.font);
- uint width = fm.width(ctx->callData->args[0].toQStringNoThrow());
- QV4::Scoped<QV4::Object> tm(scope, ctx->engine->newObject());
- tm->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("width"))),
+ uint width = fm.width(ctx->d()->callData->args[0].toQStringNoThrow());
+ QV4::Scoped<QV4::Object> tm(scope, scope.engine->newObject());
+ tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))),
QV4::ScopedValue(scope, QV4::Primitive::fromDouble(width)));
return tm.asReturnedValue();
}
QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject);
CHECK_CONTEXT(r)
qreal sx, sy, sw, sh, dx, dy, dw, dh;
- if (!ctx->callData->argc)
- return ctx->callData->thisObject.asReturnedValue();
+ if (!ctx->d()->callData->argc)
+ return ctx->d()->callData->thisObject.asReturnedValue();
//FIXME:This function should be moved to QQuickContext2D::drawImage(...)
if (!r->d()->context->state.invertibleCTM)
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
QQmlRefPointer<QQuickCanvasPixmap> pixmap;
- QV4::ScopedValue arg(scope, ctx->callData->args[0]);
+ QV4::ScopedValue arg(scope, ctx->d()->callData->args[0]);
if (arg->isString()) {
QUrl url(arg->toQString());
if (!url.isValid())
}
if (pixmap.isNull() || !pixmap->isValid())
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
- if (ctx->callData->argc == 3) {
- dx = ctx->callData->args[1].toNumber();
- dy = ctx->callData->args[2].toNumber();
+ if (ctx->d()->callData->argc == 3) {
+ dx = ctx->d()->callData->args[1].toNumber();
+ dy = ctx->d()->callData->args[2].toNumber();
sx = 0;
sy = 0;
sw = pixmap->width();
sh = pixmap->height();
dw = sw;
dh = sh;
- } else if (ctx->callData->argc == 5) {
+ } else if (ctx->d()->callData->argc == 5) {
sx = 0;
sy = 0;
sw = pixmap->width();
sh = pixmap->height();
- dx = ctx->callData->args[1].toNumber();
- dy = ctx->callData->args[2].toNumber();
- dw = ctx->callData->args[3].toNumber();
- dh = ctx->callData->args[4].toNumber();
- } else if (ctx->callData->argc == 9) {
- sx = ctx->callData->args[1].toNumber();
- sy = ctx->callData->args[2].toNumber();
- sw = ctx->callData->args[3].toNumber();
- sh = ctx->callData->args[4].toNumber();
- dx = ctx->callData->args[5].toNumber();
- dy = ctx->callData->args[6].toNumber();
- dw = ctx->callData->args[7].toNumber();
- dh = ctx->callData->args[8].toNumber();
+ dx = ctx->d()->callData->args[1].toNumber();
+ dy = ctx->d()->callData->args[2].toNumber();
+ dw = ctx->d()->callData->args[3].toNumber();
+ dh = ctx->d()->callData->args[4].toNumber();
+ } else if (ctx->d()->callData->argc == 9) {
+ sx = ctx->d()->callData->args[1].toNumber();
+ sy = ctx->d()->callData->args[2].toNumber();
+ sw = ctx->d()->callData->args[3].toNumber();
+ sh = ctx->d()->callData->args[4].toNumber();
+ dx = ctx->d()->callData->args[5].toNumber();
+ dy = ctx->d()->callData->args[6].toNumber();
+ dw = ctx->d()->callData->args[7].toNumber();
+ dh = ctx->d()->callData->args[8].toNumber();
} else {
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
if (!qIsFinite(sx)
|| !qIsFinite(dy)
|| !qIsFinite(dw)
|| !qIsFinite(dh))
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
if (sx < 0
|| sy < 0
r->d()->context->buffer()->drawPixmap(pixmap, QRectF(sx, sy, sw, sh), QRectF(dx, dy, dw, dh));
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
// pixel manipulation
QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
return ctx->throwTypeError();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
return ctx->throwTypeError();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->callData->thisObject);
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->d()->callData->thisObject);
if (!imageData)
return ctx->throwTypeError();
return imageData->d()->pixelData.asReturnedValue();
QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DPixelData> r(scope, ctx->callData->thisObject.as<QQuickJSContext2DPixelData>());
+ QV4::Scoped<QQuickJSContext2DPixelData> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2DPixelData>());
if (!r || r->d()->image.isNull())
return QV4::Encode::undefined();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>());
if (!r) {
- v4->currentContext()->throwTypeError();
+ scope.engine->currentContext()->throwTypeError();
return;
}
QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 1) {
- QV4::ScopedValue arg0(scope, ctx->callData->args[0]);
+ if (ctx->d()->callData->argc == 1) {
+ QV4::ScopedValue arg0(scope, ctx->d()->callData->args[0]);
QQuickJSContext2DImageDataRef imgData = arg0;
if (!!imgData) {
QV4::Scoped<QQuickJSContext2DPixelData> pa(scope, imgData->d()->pixelData.as<QQuickJSContext2DPixelData>());
QImage image = r->d()->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image();
return qt_create_image_data(image.width(), image.height(), engine, image);
}
- } else if (ctx->callData->argc == 2) {
- qreal w = ctx->callData->args[0].toNumber();
- qreal h = ctx->callData->args[1].toNumber();
+ } else if (ctx->d()->callData->argc == 2) {
+ qreal w = ctx->d()->callData->args[0].toNumber();
+ qreal h = ctx->d()->callData->args[1].toNumber();
if (!qIsFinite(w) || !qIsFinite(h))
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- QV8Engine *engine = ctx->engine->v8Engine;
- if (ctx->callData->argc == 4) {
- qreal x = ctx->callData->args[0].toNumber();
- qreal y = ctx->callData->args[1].toNumber();
- qreal w = ctx->callData->args[2].toNumber();
- qreal h = ctx->callData->args[3].toNumber();
+ QV8Engine *engine = scope.engine->v8Engine;
+ if (ctx->d()->callData->argc == 4) {
+ qreal x = ctx->d()->callData->args[0].toNumber();
+ qreal y = ctx->d()->callData->args[1].toNumber();
+ qreal w = ctx->d()->callData->args[2].toNumber();
+ qreal h = ctx->d()->callData->args[3].toNumber();
if (!qIsFinite(x) || !qIsFinite(y) || !qIsFinite(w) || !qIsFinite(h))
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments");
QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->callData->thisObject.as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, ctx->d()->callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->callData->argc != 3 && ctx->callData->argc != 7)
+ if (ctx->d()->callData->argc != 3 && ctx->d()->callData->argc != 7)
return QV4::Encode::undefined();
- QV4::ScopedValue arg0(scope, ctx->callData->args[0]);
+ QV4::ScopedValue arg0(scope, ctx->d()->callData->args[0]);
if (!arg0->isObject())
V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch");
- qreal dx = ctx->callData->args[1].toNumber();
- qreal dy = ctx->callData->args[2].toNumber();
+ qreal dx = ctx->d()->callData->args[1].toNumber();
+ qreal dy = ctx->d()->callData->args[2].toNumber();
qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight;
if (!qIsFinite(dx) || !qIsFinite(dy))
QQuickJSContext2DImageDataRef imageData = arg0;
if (!imageData)
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
QV4::Scoped<QQuickJSContext2DPixelData> pixelArray(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
if (pixelArray) {
w = pixelArray->d()->image.width();
h = pixelArray->d()->image.height();
- if (ctx->callData->argc == 7) {
- dirtyX = ctx->callData->args[3].toNumber();
- dirtyY = ctx->callData->args[4].toNumber();
- dirtyWidth = ctx->callData->args[5].toNumber();
- dirtyHeight = ctx->callData->args[6].toNumber();
+ if (ctx->d()->callData->argc == 7) {
+ dirtyX = ctx->d()->callData->args[3].toNumber();
+ dirtyY = ctx->d()->callData->args[4].toNumber();
+ dirtyWidth = ctx->d()->callData->args[5].toNumber();
+ dirtyHeight = ctx->d()->callData->args[6].toNumber();
if (!qIsFinite(dirtyX) || !qIsFinite(dirtyY) || !qIsFinite(dirtyWidth) || !qIsFinite(dirtyHeight))
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
}
if (dirtyWidth <=0 || dirtyHeight <= 0)
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
} else {
dirtyX = 0;
dirtyY = 0;
QImage image = pixelArray->d()->image.copy(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
r->d()->context->buffer()->drawImage(image, QRectF(dirtyX, dirtyY, dirtyWidth, dirtyHeight), QRectF(dx, dy, dirtyWidth, dirtyHeight));
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
/*!
QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(QV4::CallContext *ctx)
{
QV4::Scope scope(ctx);
- QV4::Scoped<QQuickContext2DStyle> style(scope, ctx->callData->thisObject.as<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> style(scope, ctx->d()->callData->thisObject.as<QQuickContext2DStyle>());
if (!style)
V4THROW_ERROR("Not a CanvasGradient object");
- QV8Engine *engine = ctx->engine->v8Engine;
+ QV8Engine *engine = scope.engine->v8Engine;
- if (ctx->callData->argc == 2) {
+ if (ctx->d()->callData->argc == 2) {
if (!style->d()->brush.gradient())
V4THROW_ERROR("Not a valid CanvasGradient object, can't get the gradient information");
QGradient gradient = *(style->d()->brush.gradient());
- qreal pos = ctx->callData->args[0].toNumber();
+ qreal pos = ctx->d()->callData->args[0].toNumber();
QColor color;
- if (ctx->callData->args[1].asObject()) {
- color = engine->toVariant(ctx->callData->args[1], qMetaTypeId<QColor>()).value<QColor>();
+ if (ctx->d()->callData->args[1].asObject()) {
+ color = engine->toVariant(ctx->d()->callData->args[1], qMetaTypeId<QColor>()).value<QColor>();
} else {
- color = qt_color_from_string(ctx->callData->args[1]);
+ color = qt_color_from_string(ctx->d()->callData->args[1]);
}
if (pos < 0.0 || pos > 1.0 || !qIsFinite(pos)) {
V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range");
style->d()->brush = gradient;
}
- return ctx->callData->thisObject.asReturnedValue();
+ return ctx->d()->callData->thisObject.asReturnedValue();
}
void QQuickContext2D::scale(qreal x, qreal y)
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope scope(v4);
- QV4::Scoped<QV4::Object> proto(scope, new (v4->memoryManager) QQuickJSContext2DPrototype(v4));
+ QV4::Scoped<QV4::Object> proto(scope, new (scope.engine->memoryManager) QQuickJSContext2DPrototype(v4));
proto->defineAccessorProperty(QStringLiteral("strokeStyle"), QQuickJSContext2D::method_get_strokeStyle, QQuickJSContext2D::method_set_strokeStyle);
proto->defineAccessorProperty(QStringLiteral("font"), QQuickJSContext2D::method_get_font, QQuickJSContext2D::method_set_font);
proto->defineAccessorProperty(QStringLiteral("fillRule"), QQuickJSContext2D::method_get_fillRule, QQuickJSContext2D::method_set_fillRule);
proto->defineAccessorProperty(QStringLiteral("shadowBlur"), QQuickJSContext2D::method_get_shadowBlur, QQuickJSContext2D::method_set_shadowBlur);
contextPrototype = proto;
- proto = v4->newObject();
+ proto = scope.engine->newObject();
proto->defineDefaultProperty(QStringLiteral("addColorStop"), QQuickContext2DStyle::gradient_proto_addColorStop, 0);
gradientProto = proto;
- proto = v4->newObject();
- QV4::ScopedString s(scope, v4->id_length);
+ proto = scope.engine->newObject();
+ QV4::ScopedString s(scope, scope.engine->id_length);
proto->defineAccessorProperty(s, QQuickJSContext2DPixelData::proto_get_length, 0);
pixelArrayProto = proto;
}
if (!e) {
std::cerr << "Uncaught exception: " << qPrintable(ex->toString(ctx)->toQString()) << std::endl;
} else {
- QV4::ScopedString m(scope, ctx->engine->newString(QStringLiteral("message")));
+ QV4::ScopedString m(scope, scope.engine->newString(QStringLiteral("message")));
QV4::ScopedValue message(scope, e->get(m));
std::cerr << "Uncaught exception: " << qPrintable(message->toQStringNoThrow()) << std::endl;
}
QV4::Scope scope(ctx);
QV4::ScopedObject globalObject(scope, vm.globalObject);
- QV4::ScopedObject print(scope, new (ctx->engine->memoryManager) builtins::Print(ctx));
+ QV4::ScopedObject print(scope, new (scope.engine->memoryManager) builtins::Print(ctx));
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))), print);
- QV4::ScopedObject gc(scope, new (ctx->engine->memoryManager) builtins::GC(ctx));
+ QV4::ScopedObject gc(scope, new (scope.engine->memoryManager) builtins::GC(ctx));
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))), gc);
foreach (const QString &fn, args) {