v8function = evalFunction(ctxt, obj, code, QString(), 0);
}
-QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
+QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
QQmlContextData *ctxt,
const QString &url, quint16 lineNumber, quint16 columnNumber)
: QQmlJavaScriptExpression(&QQmlBinding_jsvtable), QQmlAbstractBinding(Binding),
v8function = evalFunction(ctxt, obj, code, url, m_lineNumber);
}
-/*!
- \internal
+/*!
+ \internal
- To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
+ To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>.
For example:
v8::Handle<v8::Function> function;
new QQmlBinding(&function, scope, ctxt);
} else {
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
- ep->referenceScarceResources();
+ ep->referenceScarceResources();
bool isUndefined = false;
this, result, isUndefined, flags);
if (!watcher.wasDeleted()) {
-
+
if (needsErrorLocationData)
delayedError()->setErrorLocation(QUrl(m_url), m_lineNumber, m_columnNumber);
}
- ep->dereferenceScarceResources();
+ ep->dereferenceScarceResources();
}
if (!watcher.wasDeleted())
setEnabledFlag(e);
setNotifyOnValueChanged(e);
- if (e)
+ if (e)
update(flags);
}
private:
QBiPointer<QQmlPropertyCache, const QMetaObject> _m;
};
-
+
QQmlPropertyData::QQmlPropertyData()
{
propType = 0;
overrideIndexIsProperty = false;
overrideIndex = -1;
revision = 0;
- metaObjectOffset = -1;
+ metaObjectOffset = -1;
flags = 0;
}
coreIndex == other.coreIndex &&
notifyIndex == other.notifyIndex &&
revision == other.revision &&
- (!isValueTypeVirtual() ||
- (valueTypeCoreIndex == other.valueTypeCoreIndex &&
+ (!isValueTypeVirtual() ||
+ (valueTypeCoreIndex == other.valueTypeCoreIndex &&
valueTypePropType == other.valueTypePropType));
}
{
*this = other;
if (other.dataType >= FirstCleanupType) {
- if (other.dataType == QStringType)
+ if (other.dataType == QStringType)
copyConstructPointee(getstringptr(), other.getstringptr());
else if (other.dataType == QUrlType)
copyConstructPointee(geturlptr(), other.geturlptr());
copyConstructPointee(gethandleptr(), other.gethandleptr());
else if (other.dataType == qMetaTypeId<QJSValue>())
copyConstructPointee(getjsvalueptr(), other.getjsvalueptr());
- }
+ }
}
void Register::init(Type type)
{
dataType = type;
if (dataType >= FirstCleanupType) {
- if (dataType == QStringType)
+ if (dataType == QStringType)
defaultConstructPointee(getstringptr());
else if (dataType == QUrlType)
defaultConstructPointee(geturlptr());
return;
QQmlContextData *context = QQmlAbstractExpression::context();
- if (!context || !context->isValid())
+ if (!context || !context->isValid())
return;
// Check that the target has not been deleted
sub->connect(&p->idValues[idIndex].bindings);
}
}
-
+
void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex, QQmlEngine *e)
{
Subscription *sub = (subscriptions + subIndex);
if (sub->isConnected(o, notifyIndex))
return;
sub->bindings = this;
- sub->method = subIndex;
+ sub->method = subIndex;
if (o)
sub->connect(o, notifyIndex, e);
else
return;
} else if(isUndefined != result.isUndefined()) {
iserror = true;
- }
-
+ }
+
QVariant v4value;
if (!result.isUndefined()) {
switch (resultType) {
if (v4Result.isEmpty())
v4Result = testResultToString(v4value, result.isUndefined());
- if (!testCompareVariants(value, v4value))
+ if (!testCompareVariants(value, v4value))
iserror = true;
if (iserror) {
}
}
-static void throwException(int id, QQmlDelayedError *error,
+static void throwException(int id, QQmlDelayedError *error,
QV4Program *program, QQmlContextData *context,
const QString &description = QString())
{
if (testBinding) testBindingException(*testBindingSource, bindingLine, bindingColumn, context, scope); \
throwException((id), error, program, context, (str)); \
goto exceptionExit; \
-}
+}
#define THROW_VALUE_EXCEPTION_STR(id, str) { \
throwException((id), error, program, context, (str)); \
{
Register ® = registers[instr->fetchAndSubscribe.reg];
- if (reg.isUndefined())
+ if (reg.isUndefined())
THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
QObject *object = reg.getQObject();
{
const Register &input = registers[instr->attached.reg];
Register &output = registers[instr->attached.output];
- if (input.isUndefined())
+ if (input.isUndefined())
THROW_EXCEPTION(instr->attached.exceptionId);
QObject *object = registers[instr->attached.reg].getQObject();
Register &output = registers[instr->unaryop.output];
if (src.isUndefined()) {
output.setUndefined();
- } else {
+ } else {
new (output.getstringptr()) QString(QLatin1String(src.getbool() ? "true" : "false"));
STRING_REGISTER(instr->unaryop.output);
}
QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
{
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(BitAndInt, binaryop)
QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
{
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(BitAndInt, binaryop)
QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
{
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(BitXorInt, binaryop)
if (instr->binaryop.output == instr->binaryop.left) {
string += registers[instr->binaryop.right].getstringptr();
} else {
- string = *registers[instr->binaryop.left].getstringptr() +
+ string = *registers[instr->binaryop.left].getstringptr() +
*registers[instr->binaryop.right].getstringptr();
}
}
QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
{
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(LShiftInt, binaryop)
QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
{
- registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
+ registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(RShiftInt, binaryop)
QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
{
- registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
+ registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
registers[instr->binaryop.right].getint());
}
QML_V4_END_INSTR(URShiftInt, binaryop)
{
Register ® = registers[instr->fetch.reg];
- if (reg.isUndefined())
+ if (reg.isUndefined())
THROW_EXCEPTION(instr->fetch.exceptionId);
QObject *object = reg.getQObject();
QML_V4_BEGIN_INSTR(TestV4Store, storetest)
{
Register &data = registers[instr->storetest.reg];
- testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
+ testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
scope, data, instr->storetest.regType);
}
QML_V4_END_INSTR(TestV4Store, storetest)
{
Register &data = registers[instr->store.reg];
- if (data.isUndefined())
+ if (data.isUndefined())
THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign undefined value"));
if (data.gettype() == QObjectStarType) {
int reg = 0;
while (cleanupRegisterMask) {
- if (cleanupRegisterMask & 0x1)
+ if (cleanupRegisterMask & 0x1)
registers[reg].cleanup();
reg++;
out << '}' << endl;
}
-Temp *BasicBlock::TEMP(Type type, int index)
-{
+Temp *BasicBlock::TEMP(Type type, int index)
+{
Temp *e = function->pool->New<Temp>();
e->init(type, index);
return e;
}
-Temp *BasicBlock::TEMP(Type type)
-{
- return TEMP(type, function->tempCount++);
+Temp *BasicBlock::TEMP(Type type)
+{
+ return TEMP(type, function->tempCount++);
}
-Expr *BasicBlock::CONST(Type type, double value)
-{
+Expr *BasicBlock::CONST(Type type, double value)
+{
Const *e = function->pool->New<Const>();
e->init(type, value);
return e;
return name;
}
-Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
-{
+Expr *BasicBlock::UNOP(AluOp op, Expr *expr)
+{
Unop *e = function->pool->New<Unop>();
e->init(op, expr);
return e;
}
Expr *BasicBlock::CALL(Expr *base, ExprList *args)
-{
+{
Call *e = function->pool->New<Call>();
e->init(base, args);
return e;
}
-Stmt *BasicBlock::EXP(Expr *expr)
-{
+Stmt *BasicBlock::EXP(Expr *expr)
+{
Exp *s = function->pool->New<Exp>();
s->init(expr);
statements.append(s);
return s;
}
-Stmt *BasicBlock::MOVE(Expr *target, Expr *source, bool isMoveForReturn)
-{
+Stmt *BasicBlock::MOVE(Expr *target, Expr *source, bool isMoveForReturn)
+{
Move *s = function->pool->New<Move>();
s->init(target, source, isMoveForReturn);
statements.append(s);
return s;
}
-Stmt *BasicBlock::JUMP(BasicBlock *target)
+Stmt *BasicBlock::JUMP(BasicBlock *target)
{
if (isTerminated())
return 0;
return s;
}
-Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
+Stmt *BasicBlock::CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse)
{
if (isTerminated())
return 0;
#ifdef DEBUG_IR_STRUCTURE
-static const char *symbolname(Name::Symbol s)
+static const char *symbolname(Name::Symbol s)
{
switch (s) {
case Name::Unbound:
return "Slot";
default:
Q_ASSERT(!"Unreachable");
- return "Unknown";
+ return "Unknown";
}
}
qWarning().nospace() << indent() << "String:Expr { type: " << typeName(e->type) << ", value: " << e->value << '}';
}
-static void namedumprecur(QQmlJS::IR::Name *e, const char *indent)
+static void namedumprecur(QQmlJS::IR::Name *e, const char *indent)
{
if (e->base) namedumprecur(e->base, indent);
qWarning().nospace() << indent << " { type: " << typeName(e->type) << ", symbol: " << symbolname(e->symbol) << ", storage: " << storagename(e->storage) << ", id: " << e->id << '}';
bool isUndefined = false;
DeleteWatcher watcher(this);
- ep->referenceScarceResources();
+ ep->referenceScarceResources();
v8::HandleScope handle_scope;
v8::Context::Scope scope(ep->v8engine()->context());
setUpdatingFlag(false);
}
- ep->dereferenceScarceResources();
+ ep->dereferenceScarceResources();
} else {
QQmlProperty p = QQmlPropertyPrivate::restore(*target, instruction->property, context);
Q_DECLARE_METATYPE(QList<int>)
-// XXX TODO: Need to check all the global functions will also work in a worker script where the
+// XXX TODO: Need to check all the global functions will also work in a worker script where the
// QQmlEngine is not available
QT_BEGIN_NAMESPACE
case QV8ObjectResource::VariantType:
// a variant might be equal to a value type or other variant.
if (rhst == QV8ObjectResource::VariantType) {
- return lhsr->engine->variantWrapper()->toVariant(lhsr) ==
+ return lhsr->engine->variantWrapper()->toVariant(lhsr) ==
lhsr->engine->variantWrapper()->toVariant(rhsr);
} else if (rhst == QV8ObjectResource::ValueTypeType) {
return rhsr->engine->valueTypeWrapper()->isEqual(rhsr, rhsr->engine->variantWrapper()->toVariant(lhsr));
QV8Engine::~QV8Engine()
{
Q_ASSERT_X(v8::Isolate::GetCurrent(), "QV8Engine::~QV8Engine()", "called after v8::Isolate has exited");
- for (int ii = 0; ii < m_extensionData.count(); ++ii)
+ for (int ii = 0; ii < m_extensionData.count(); ++ii)
delete m_extensionData[ii];
m_extensionData.clear();
QVariant QV8Engine::toVariant(v8::Handle<v8::Value> value, int typeHint)
{
- if (value.IsEmpty())
+ if (value.IsEmpty())
return QVariant();
if (typeHint == QVariant::Bool)
{
v8::Context::Scope scope(engine->context());
v8::Local<v8::Object> object = v8::Object::New();
- for (QVariantMap::ConstIterator iter = map.begin(); iter != map.end(); ++iter)
+ for (QVariantMap::ConstIterator iter = map.begin(); iter != map.end(); ++iter)
object->Set(engine->toString(iter.key()), engine->fromVariant(iter.value()));
return object;
}
// directly against QList<QObject*>?
const QList<QObject *> &list = *(QList<QObject *>*)ptr;
v8::Local<v8::Array> array = v8::Array::New(list.count());
- for (int ii = 0; ii < list.count(); ++ii)
+ for (int ii = 0; ii < list.count(); ++ii)
array->Set(ii, newQObject(list.at(ii)));
return array;
- }
+ }
bool objOk;
QObject *obj = QQmlMetaType::toQObject(variant, &objOk);
- if (objOk)
+ if (objOk)
return newQObject(obj);
bool succeeded = false;
v8::ScriptOrigin origin(v8fileName, v8::Integer::New(lineNumber - 1));
- v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
+ v8::Local<v8::Script> script = v8::Script::Compile(v8source, &origin, 0, v8::Handle<v8::String>(),
v8::Script::QmlMode);
return script;
return script;
}
-QNetworkAccessManager *QV8Engine::networkAccessManager()
+QNetworkAccessManager *QV8Engine::networkAccessManager()
{
return QQmlEnginePrivate::get(m_engine)->getNetworkAccessManager();
}
v8::Handle<v8::Value> args[] = { global };
v8::Local<v8::Value> names = m_getOwnPropertyNames->Call(global, 1, args);
v8::Local<v8::Array> namesArray = v8::Local<v8::Array>::Cast(names);
- for (quint32 ii = 0; ii < namesArray->Length(); ++ii)
+ for (quint32 ii = 0; ii < namesArray->Length(); ++ii)
m_illegalNames.insert(toString(namesArray->Get(ii)), true);
}
return;
}
- if (!QV8Engine_activeHandles.hasLocalData())
+ if (!QV8Engine_activeHandles.hasLocalData())
QV8Engine_activeHandles.setLocalData(new QSet<void *>);
if (QV8Engine_activeHandles.localData()->contains(handle)) {
if (!handle)
return;
- if (!QV8Engine_activeHandles.hasLocalData())
+ if (!QV8Engine_activeHandles.hasLocalData())
QV8Engine_activeHandles.setLocalData(new QSet<void *>);
if (QV8Engine_activeHandles.localData()->contains(handle)) {
void QV8Engine::setExtensionData(int index, Deletable *data)
{
- if (m_extensionData.count() <= index)
+ if (m_extensionData.count() <= index)
m_extensionData.resize(index + 1);
- if (m_extensionData.at(index))
+ if (m_extensionData.at(index))
delete m_extensionData.at(index);
m_extensionData[index] = data;
QCOMPARE(obj->property("test"), value); \
\
delete obj; \
-}
+}
void tst_qqmlcontext::setContextProperty()
{
// Changes in context properties
{
- QQmlComponent component(&engine);
+ QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
- QObject *obj = component.create(&ctxt2);
+ QObject *obj = component.create(&ctxt2);
- QCOMPARE(obj->property("test"), QVariant(13));
+ QCOMPARE(obj->property("test"), QVariant(13));
ctxt.setContextProperty("a", QVariant(19));
- QCOMPARE(obj->property("test"), QVariant(19));
+ QCOMPARE(obj->property("test"), QVariant(19));
- delete obj;
+ delete obj;
}
{
- QQmlComponent component(&engine);
+ QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl());
- QObject *obj = component.create(&ctxt2);
+ QObject *obj = component.create(&ctxt2);
- QCOMPARE(obj->property("test"), QVariant(8));
+ QCOMPARE(obj->property("test"), QVariant(8));
ctxt.setContextProperty("b", QVariant(5));
- QCOMPARE(obj->property("test"), QVariant(8));
+ QCOMPARE(obj->property("test"), QVariant(8));
ctxt2.setContextProperty("b", QVariant(1912));
- QCOMPARE(obj->property("test"), QVariant(1912));
+ QCOMPARE(obj->property("test"), QVariant(1912));
- delete obj;
+ delete obj;
}
{
- QQmlComponent component(&engine);
+ QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl());
- QObject *obj = component.create(&ctxt2);
+ QObject *obj = component.create(&ctxt2);
- QCOMPARE(obj->property("test"), QVariant(12));
+ QCOMPARE(obj->property("test"), QVariant(12));
obj1.setA(13);
- QCOMPARE(obj->property("test"), QVariant(13));
+ QCOMPARE(obj->property("test"), QVariant(13));
- delete obj;
+ delete obj;
}
// New context properties
{
- QQmlComponent component(&engine);
+ QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
- QObject *obj = component.create(&ctxt2);
+ QObject *obj = component.create(&ctxt2);
- QCOMPARE(obj->property("test"), QVariant(19));
+ QCOMPARE(obj->property("test"), QVariant(19));
ctxt2.setContextProperty("a", QVariant(1945));
- QCOMPARE(obj->property("test"), QVariant(1945));
+ QCOMPARE(obj->property("test"), QVariant(1945));
- delete obj;
+ delete obj;
}
// Setting an object-variant context property
// Changes in context properties
{
- QQmlComponent component(&engine);
+ QQmlComponent component(&engine);
component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
- QObject *obj = component.create(&ctxt);
+ QObject *obj = component.create(&ctxt);
- QCOMPARE(obj->property("test"), QVariant(12));
+ QCOMPARE(obj->property("test"), QVariant(12));
to.setA(14);
- QCOMPARE(obj->property("test"), QVariant(14));
+ QCOMPARE(obj->property("test"), QVariant(14));
- delete obj;
+ delete obj;
}
}
void tst_qqmlproperty::qmlmetaproperty_object_string()
{
- QObject object;
- PropertyObject dobject;
+ QObject object;
+ PropertyObject dobject;
{
QQmlProperty prop(&object, QString("defaultProperty"));
void tst_qqmlproperty::qmlmetaproperty_object_string_context()
{
- QObject object;
- PropertyObject dobject;
+ QObject object;
+ PropertyObject dobject;
{
QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext());
void tst_qqmlproperty::name()
{
- {
+ {
QQmlProperty p;
QCOMPARE(p.name(), QString());
}
void tst_qqmlproperty::read()
{
- // Invalid
+ // Invalid
{
QQmlProperty p;
QCOMPARE(p.read(), QVariant());
QCOMPARE(p.read(), QVariant());
}
- // Automatic signal property
+ // Automatic signal property
{
PropertyObject o;
QQmlProperty p(&o, "onPropertyWithNotifyChanged");