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;
}
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)
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)
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,
m_expression = str.toUtf8();
- v4function = evalFunction(ctxt, obj, code, url, m_lineNumber)->v4Value();
+ v4function = evalFunction(ctxt, obj, code, url, m_lineNumber);
}
/*!
QQmlBoundSignalExpression::~QQmlBoundSignalExpression()
{
- qPersistentDispose(m_v8function);
- qPersistentDispose(m_v8qmlscope);
}
QString QQmlBoundSignalExpression::expressionIdentifier(QQmlJavaScriptExpression *e)
{
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 {
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.
}
}
if (!hasParameterInfo()) {
- QQmlJavaScriptExpression::evaluate(context(), m_v8function, 0);
+ QQmlJavaScriptExpression::evaluate(context(), **m_v8function, 0);
} else {
QV8Engine *engine = ep->v8engine();
QVarLengthArray<int, 9> dummy;
}
}
- 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.
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
QQmlExpressionPrivate::~QQmlExpressionPrivate()
{
- qPersistentDispose(v8qmlscope);
- qPersistentDispose(v8function);
}
void QQmlExpressionPrivate::init(QQmlContextData *ctxt, const QString &expr, QObject *me)
d->expressionUtf8.clear();
d->expressionFunctionValid = false;
d->expressionFunctionRewritten = false;
- qPersistentDispose(d->v8function);
- qPersistentDispose(d->v8qmlscope);
}
// Must be called with a valid handle scope
expressionFunctionValid = true;
}
- return evaluate(context(), v8function, isUndefined);
+ return evaluate(context(), **v8function, isUndefined);
}
QVariant QQmlExpressionPrivate::value(bool *isUndefined)
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;
}
// 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);
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()) {
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);
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()) {
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()
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();
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)
}
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;
data->lineNumber);
}
- return v8methods[index];
+ return v8::Handle<v8::Function>(v8methods[index]);
}
v8::Handle<v8::Value> QQmlVMEMetaObject::readVarProperty(int id)
}
// 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)
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);
QQmlPropertyValueInterceptor *interceptors;
- v8::Persistent<v8::Function> *v8methods;
+ QV4::PersistentValue *v8methods;
v8::Handle<v8::Function> method(int);
v8::Handle<v8::Value> readVarProperty(int);
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();