aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-07 08:54:12 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-07 12:46:55 +0200
commit0ae4fb4647d6b286805e01763341c126000155ea (patch)
tree39fa8356dc87f55a36b79349f4a0cf71264fb601 /src
parent5963aead75991ea8b0fded251e18ef75f099ab8f (diff)
Change some v8::Persistent to QV4::PersistentValue
Change-Id: I2c4e98cf7e778de9aafabdbd68e6682106343d12 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/debugger/qqmlenginedebugservice.cpp3
-rw-r--r--src/qml/qml/qqmlbinding.cpp8
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp10
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h4
-rw-r--r--src/qml/qml/qqmlexpression.cpp6
-rw-r--r--src/qml/qml/qqmlexpression_p.h4
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp26
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h8
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp20
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h4
-rw-r--r--src/qml/qml/v4/qv4value_p.h2
11 files changed, 44 insertions, 51 deletions
diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp
index c4c8cb2fcf..bf52c42d54 100644
--- a/src/qml/debugger/qqmlenginedebugservice.cpp
+++ b/src/qml/debugger/qqmlenginedebugservice.cpp
@@ -742,7 +742,8 @@ bool QQmlEngineDebugService::setMethodBody(int objectId, const QString &method,
Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
- vmeMetaObject->setVmeMethod(prop->coreIndex, QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
+ vmeMetaObject->setVmeMethod(prop->coreIndex,
+ QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
return true;
}
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 4aebec4d60..9e1a1522af 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -112,7 +112,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContext *ctxt)
QString code = rewriteBinding(str);
m_expression = str.toUtf8();
- v4function = evalFunction(context(), obj, code, QString(), 0)->v4Value();
+ v4function = evalFunction(context(), obj, code, QString(), 0);
}
QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
@@ -159,7 +159,7 @@ QQmlBinding::QQmlBinding(const QQmlScriptString &script, QObject *obj, QQmlConte
m_lineNumber = scriptPrivate->lineNumber;
m_columnNumber = scriptPrivate->columnNumber;
- v4function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber)->v4Value();
+ v4function = evalFunction(context(), scopeObject(), code, QString(), m_lineNumber);
}
QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt)
@@ -174,7 +174,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, QQmlContextData *ctxt
QString code = rewriteBinding(str);
m_expression = str.toUtf8();
- v4function = evalFunction(ctxt, obj, code, QString(), 0)->v4Value();
+ v4function = evalFunction(ctxt, obj, code, QString(), 0);
}
QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
@@ -197,7 +197,7 @@ QQmlBinding::QQmlBinding(const QString &str, bool isRewritten, QObject *obj,
m_expression = str.toUtf8();
- v4function = evalFunction(ctxt, obj, code, url, m_lineNumber)->v4Value();
+ v4function = evalFunction(ctxt, obj, code, url, m_lineNumber);
}
/*!
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 683f5280d0..ff61fdede3 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -121,8 +121,6 @@ void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope)
QQmlBoundSignalExpression::~QQmlBoundSignalExpression()
{
- qPersistentDispose(m_v8function);
- qPersistentDispose(m_v8qmlscope);
}
QString QQmlBoundSignalExpression::expressionIdentifier(QQmlJavaScriptExpression *e)
@@ -140,7 +138,7 @@ QString QQmlBoundSignalExpression::expression() const
{
if (m_expressionFunctionValid) {
Q_ASSERT (context() && engine());
- return m_v8function->v4Value().toQString();
+ return m_v8function->toQString();
} else if (!m_expressionUtf8.isEmpty()) {
return QString::fromUtf8(m_expressionUtf8);
} else {
@@ -208,7 +206,7 @@ void QQmlBoundSignalExpression::evaluate(void **a)
m_fileName, m_line, &m_v8qmlscope);
}
- if (m_v8function.IsEmpty() || m_v8function->IsNull()) {
+ if (m_v8function->isDeleted() || m_v8function->isNull()) {
ep->dereferenceScarceResources();
return; // could not evaluate function. Not valid.
}
@@ -218,7 +216,7 @@ void QQmlBoundSignalExpression::evaluate(void **a)
}
if (!hasParameterInfo()) {
- QQmlJavaScriptExpression::evaluate(context(), m_v8function, 0);
+ QQmlJavaScriptExpression::evaluate(context(), **m_v8function, 0);
} else {
QV8Engine *engine = ep->v8engine();
QVarLengthArray<int, 9> dummy;
@@ -251,7 +249,7 @@ void QQmlBoundSignalExpression::evaluate(void **a)
}
}
- QQmlJavaScriptExpression::evaluate(context(), m_v8function, argCount, args.data(), 0);
+ QQmlJavaScriptExpression::evaluate(context(), **m_v8function, argCount, args.data(), 0);
}
}
ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 910e1e3f1e..33fa5be0a9 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -99,8 +99,8 @@ private:
void init(QQmlContextData *ctxt, QObject *scope);
bool hasParameterInfo() const { return m_parameterCountForJS > 0; }
- v8::Persistent<v8::Object> m_v8qmlscope;
- v8::Persistent<v8::Function> m_v8function;
+ QV4::PersistentValue m_v8qmlscope;
+ QV4::PersistentValue m_v8function;
//either expressionUtf8 or expression will be used (but not both).
//once m_v8function is valid, we clear both expressions, and
diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp
index 29f53f3372..0f225228b3 100644
--- a/src/qml/qml/qqmlexpression.cpp
+++ b/src/qml/qml/qqmlexpression.cpp
@@ -67,8 +67,6 @@ QQmlExpressionPrivate::QQmlExpressionPrivate()
QQmlExpressionPrivate::~QQmlExpressionPrivate()
{
- qPersistentDispose(v8qmlscope);
- qPersistentDispose(v8function);
}
void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr, QObject *me)
@@ -335,8 +333,6 @@ void QQmlExpression::setExpression(const QString &expression)
d->expressionUtf8.clear();
d->expressionFunctionValid = false;
d->expressionFunctionRewritten = false;
- qPersistentDispose(d->v8function);
- qPersistentDispose(d->v8qmlscope);
}
// Must be called with a valid handle scope
@@ -358,7 +354,7 @@ v8::Handle<v8::Value> QQmlExpressionPrivate::v8value(bool *isUndefined)
expressionFunctionValid = true;
}
- return evaluate(context(), v8function, isUndefined);
+ return evaluate(context(), **v8function, isUndefined);
}
QVariant QQmlExpressionPrivate::value(bool *isUndefined)
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
index e31d189d6d..4577878290 100644
--- a/src/qml/qml/qqmlexpression_p.h
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -105,8 +105,8 @@ public:
QString expression;
QByteArray expressionUtf8;
- v8::Persistent<v8::Object> v8qmlscope;
- v8::Persistent<v8::Function> v8function;
+ QV4::PersistentValue v8qmlscope;
+ QV4::PersistentValue v8function;
QString url; // This is a QString for a reason. QUrls are slooooooow...
quint16 line;
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 05c6c242ba..cd8837073a 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -326,11 +326,11 @@ void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message,
}
// Callee owns the persistent handle
-v8::Persistent<v8::Function>
+QV4::PersistentValue
QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
const char *code, int codeLength,
const QString &filename, quint16 line,
- v8::Persistent<v8::Object> *qmlscope)
+ QV4::PersistentValue *qmlscope)
{
QQmlEngine *engine = ctxt->engine;
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
@@ -347,7 +347,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
if (!message.IsEmpty())
QQmlExpressionPrivate::exceptionToError(message, error);
ep->warning(error);
- return v8::Persistent<v8::Function>();
+ return QV4::PersistentValue();
}
v8::Handle<v8::Value> result = script->Run(scopeobject);
if (tc.HasCaught()) {
@@ -359,17 +359,18 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
if (!message.IsEmpty())
QQmlExpressionPrivate::exceptionToError(message, error);
ep->warning(error);
- return v8::Persistent<v8::Function>();
+ return QV4::PersistentValue();
}
- if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
- return qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(result));
+ if (qmlscope)
+ *qmlscope = scopeobject->v4Value();
+ return result->v4Value();
}
// Callee owns the persistent handle
-v8::Persistent<v8::Function>
+QV4::PersistentValue
QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
const QString &code, const QString &filename, quint16 line,
- v8::Persistent<v8::Object> *qmlscope)
+ QV4::PersistentValue *qmlscope)
{
QQmlEngine *engine = ctxt->engine;
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
@@ -386,7 +387,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
if (!message.IsEmpty())
QQmlExpressionPrivate::exceptionToError(message, error);
ep->warning(error);
- return v8::Persistent<v8::Function>();
+ return QV4::PersistentValue();
}
v8::Handle<v8::Value> result = script->Run(scopeobject);
if (tc.HasCaught()) {
@@ -398,10 +399,11 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
if (!message.IsEmpty())
QQmlExpressionPrivate::exceptionToError(message, error);
ep->warning(error);
- return v8::Persistent<v8::Function>();
+ return QV4::PersistentValue();
}
- if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
- return qPersistentNew<v8::Function>(v8::Handle<v8::Function>::Cast(result));
+ if (qmlscope)
+ *qmlscope = scopeobject->v4Value();
+ return result->v4Value();
}
void QQmlJavaScriptExpression::clearGuards()
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index c1d3d1395f..0d3b7b9063 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -148,14 +148,14 @@ public:
QQmlDelayedError *delayedError();
static void exceptionToError(v8::Handle<v8::Message>, QQmlError &);
- static v8::Persistent<v8::Function> evalFunction(QQmlContextData *ctxt, QObject *scope,
+ static QV4::PersistentValue evalFunction(QQmlContextData *ctxt, QObject *scope,
const QString &code, const QString &filename,
quint16 line,
- v8::Persistent<v8::Object> *qmlscope = 0);
- static v8::Persistent<v8::Function> evalFunction(QQmlContextData *ctxt, QObject *scope,
+ QV4::PersistentValue *qmlscope = 0);
+ static QV4::PersistentValue evalFunction(QQmlContextData *ctxt, QObject *scope,
const char *code, int codeLength,
const QString &filename, quint16 line,
- v8::Persistent<v8::Object> *qmlscope = 0);
+ QV4::PersistentValue *qmlscope = 0);
protected:
~QQmlJavaScriptExpression();
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 6fc9579503..9121f138b2 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -602,10 +602,6 @@ QQmlVMEMetaObject::~QQmlVMEMetaObject()
if (parent.isT1()) parent.asT1()->objectDestroyed(object);
delete [] data;
delete [] aliasEndpoints;
-
- for (int ii = 0; v8methods && ii < metaData->methodCount; ++ii) {
- qPersistentDispose(v8methods[ii]);
- }
delete [] v8methods;
if (metaData->varPropertyCount)
@@ -974,9 +970,9 @@ v8::Handle<v8::Function> QQmlVMEMetaObject::method(int index)
}
if (!v8methods)
- v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
+ v8methods = new QV4::PersistentValue[metaData->methodCount];
- if (v8methods[index].IsEmpty()) {
+ if (v8methods[index]->isDeleted()) {
QQmlVMEMetaData::MethodData *data = metaData->methodData() + index;
const char *body = ((const char*)metaData) + data->bodyOffset;
@@ -991,7 +987,7 @@ v8::Handle<v8::Function> QQmlVMEMetaObject::method(int index)
data->lineNumber);
}
- return v8methods[index];
+ return v8::Handle<v8::Function>(v8methods[index]);
}
v8::Handle<v8::Value> QQmlVMEMetaObject::readVarProperty(int id)
@@ -1177,22 +1173,20 @@ v8::Handle<v8::Function> QQmlVMEMetaObject::vmeMethod(int index)
}
// Used by debugger
-void QQmlVMEMetaObject::setVmeMethod(int index, v8::Persistent<v8::Function> value)
+void QQmlVMEMetaObject::setVmeMethod(int index, QV4::PersistentValue function)
{
if (index < methodOffset()) {
Q_ASSERT(parentVMEMetaObject());
- return parentVMEMetaObject()->setVmeMethod(index, value);
+ return parentVMEMetaObject()->setVmeMethod(index, function);
}
int plainSignals = metaData->signalCount + metaData->propertyCount + metaData->aliasCount;
Q_ASSERT(index >= (methodOffset() + plainSignals) && index < (methodOffset() + plainSignals + metaData->methodCount));
if (!v8methods)
- v8methods = new v8::Persistent<v8::Function>[metaData->methodCount];
+ v8methods = new QV4::PersistentValue[metaData->methodCount];
int methodIndex = index - methodOffset() - plainSignals;
- if (!v8methods[methodIndex].IsEmpty())
- qPersistentDispose(v8methods[methodIndex]);
- v8methods[methodIndex] = value;
+ v8methods[methodIndex] = function;
}
v8::Handle<v8::Value> QQmlVMEMetaObject::vmeProperty(int index)
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index 8b80d7f176..ea9ccf209b 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -168,7 +168,7 @@ public:
void registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor);
v8::Handle<v8::Function> vmeMethod(int index);
quint16 vmeMethodLineNumber(int index);
- void setVmeMethod(int index, v8::Persistent<v8::Function>);
+ void setVmeMethod(int index, QV4::PersistentValue function);
v8::Handle<v8::Value> vmeProperty(int index);
void setVMEProperty(int index, v8::Handle<v8::Value> v);
@@ -216,7 +216,7 @@ public:
QQmlPropertyValueInterceptor *interceptors;
- v8::Persistent<v8::Function> *v8methods;
+ QV4::PersistentValue *v8methods;
v8::Handle<v8::Function> method(int);
v8::Handle<v8::Value> readVarProperty(int);
diff --git a/src/qml/qml/v4/qv4value_p.h b/src/qml/qml/v4/qv4value_p.h
index d583826c23..9e56df0db6 100644
--- a/src/qml/qml/v4/qv4value_p.h
+++ b/src/qml/qml/v4/qv4value_p.h
@@ -579,6 +579,8 @@ public:
Value *operator->() { return &d->value; }
Value *operator*() { return &d->value; }
+ const Value *operator->() const { return &d->value; }
+ const Value *operator*() const { return &d->value; }
ExecutionEngine *engine() {
Managed *m = d->value.asManaged();