return output->indexForString(rewrite);
}
+QString QDeclarativeCompiler::rewriteSignalHandler(const QString &handler, const QString &name)
+{
+ QDeclarativeRewrite::RewriteSignalHandler rewriteSignalHandler;
+ return rewriteSignalHandler(handler, name);
+}
+
// Ensures that the dynamic meta specification on obj is valid
bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj)
{
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType
int rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name); // for QDeclarativeCustomParser::rewriteBinding
+ QString rewriteSignalHandler(const QString &handler, const QString &name); // for QDeclarativeCustomParser::rewriteSignalHandler
private:
typedef QDeclarativeCompiledData::Instruction Instruction;
return compiler->rewriteBinding(value, name);
}
+/*!
+ Returns a rewritten \a handler. \a name
+ is used as the name of the rewritten function.
+*/
+QString QDeclarativeCustomParser::rewriteSignalHandler(const QString &handler, const QString &name)
+{
+ return compiler->rewriteSignalHandler(handler, name);
+}
+
QT_END_NAMESPACE
const QMetaObject *resolveType(const QString&) const;
QDeclarativeBinding::Identifier rewriteBinding(const QDeclarativeScript::Variant&, const QString&);
+ QString rewriteSignalHandler(const QString&, const QString&);
private:
QList<QDeclarativeError> exceptions;
return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
}
+QDeclarativeExpression *QDeclarativeExpressionPrivate::create(QDeclarativeContextData *ctxt, QObject *object, const QString &expr, bool isRewritten,
+ const QString &url, int lineNumber)
+{
+ return new QDeclarativeExpression(ctxt, object, expr, isRewritten, url, lineNumber, *new QDeclarativeExpressionPrivate);
+}
+
/*!
\class QDeclarativeExpression
\since 4.7
static v8::Persistent<v8::Function> evalFunction(QDeclarativeContextData *ctxt, QObject *scope,
const QString &code, const QString &filename, int line,
v8::Persistent<v8::Object> *qmlscope = 0);
+ static QDeclarativeExpression *create(QDeclarativeContextData *, QObject *, const QString &, bool,
+ const QString &, int);
bool expressionFunctionValid:1;
bool extractExpressionFromFunction:1;
#include "qdeclarativeconnections_p.h"
-#include <qdeclarativeexpression.h>
+#include <private/qdeclarativeexpression_p.h>
#include <private/qdeclarativeproperty_p.h>
#include <private/qdeclarativeboundsignal_p.h>
#include <qdeclarativecontext.h>
QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value);
if (v.isScript()) {
ds << propName;
- ds << v.asScript();
+ ds << rewriteSignalHandler(v.asScript(), propName);
ds << propLine;
} else {
error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected"));
if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) {
QDeclarativeBoundSignal *signal =
new QDeclarativeBoundSignal(target(), prop.method(), this);
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(this), 0, script);
+
+ QString location;
+ QDeclarativeContextData *ctxtdata = 0;
QDeclarativeData *ddata = QDeclarativeData::get(this);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expression->setSourceLocation(ddata->outerContext->url.toString(), line);
+ if (ddata) {
+ ctxtdata = ddata->outerContext;
+ if (ctxtdata && !ctxtdata->url.isEmpty())
+ location = ddata->outerContext->url.toString();
+ }
+
+ QDeclarativeExpression *expression = ctxtdata ?
+ QDeclarativeExpressionPrivate::create(ctxtdata, 0, script, true, location, line) : 0;
signal->setExpression(expression);
d->boundsignals += signal;
} else {