Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeexpression.cpp
index 27bd8f8..25d85f4 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the QtDeclarative module of the Qt Toolkit.
 **
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 
 #include "qdeclarativeexpression.h"
-#include "private/qdeclarativeexpression_p.h"
+#include "qdeclarativeexpression_p.h"
 
-#include "private/qdeclarativeengine_p.h"
-#include "private/qdeclarativecontext_p.h"
-#include "private/qdeclarativerewrite_p.h"
-#include "private/qdeclarativescriptstring_p.h"
-#include "private/qdeclarativecompiler_p.h"
+#include "qdeclarativeengine_p.h"
+#include "qdeclarativecontext_p.h"
+#include "qdeclarativerewrite_p.h"
+#include "qdeclarativescriptstring_p.h"
+#include "qdeclarativecompiler_p.h"
 
 #include <QtCore/qdebug.h>
 
@@ -70,16 +70,19 @@ bool QDeclarativeDelayedError::addError(QDeclarativeEnginePrivate *e)
 
 QDeclarativeJavaScriptExpression::QDeclarativeJavaScriptExpression()
 : m_requiresThisObject(0), m_useSharedContext(0), m_notifyOnValueChanged(0), 
-  m_scopeObject(0), m_notifyObject(0), m_notifyIndex(-1)
+  m_scopeObject(0), guardCapture(0)
 {
 }
 
 QDeclarativeJavaScriptExpression::~QDeclarativeJavaScriptExpression()
 {
+    if (guardCapture) guardCapture->expression = 0;
+    clearGuards();
 }
 
 QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate()
-: expressionFunctionValid(true), extractExpressionFromFunction(false), line(-1), dataRef(0)
+: expressionFunctionValid(true), expressionFunctionRewritten(false),
+  extractExpressionFromFunction(false), line(-1), dataRef(0)
 {
 }
 
@@ -99,6 +102,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QS
     QDeclarativeAbstractExpression::setContext(ctxt);
     setScopeObject(me);
     expressionFunctionValid = false;
+    expressionFunctionRewritten = false;
 }
 
 void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, v8::Handle<v8::Function> func,
@@ -110,23 +114,22 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, v8::Hand
     v8function = qPersistentNew<v8::Function>(func);
     setUseSharedContext(false);
     expressionFunctionValid = true;
+    expressionFunctionRewritten = false;
     extractExpressionFromFunction = true;
 }
 
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr, bool isRewritten,
-                                         QObject *me, const QString &srcUrl, int lineNumber)
+void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr,
+                                         bool isRewritten, QObject *me, const QString &srcUrl,
+                                         int lineNumber, int columnNumber)
 {
     url = srcUrl;
     line = lineNumber;
+    column = columnNumber;
 
     expression = expr;
 
-    if (!isRewritten) {
-        expressionFunctionValid = false;
-    } else {
-        v8function = evalFunction(ctxt, me, expression, url, line, &v8qmlscope);
-        expressionFunctionValid = true;
-    }
+    expressionFunctionValid = false;
+    expressionFunctionRewritten = isRewritten;
 
     QDeclarativeAbstractExpression::setContext(ctxt);
     setScopeObject(me);
@@ -144,17 +147,24 @@ QDeclarativeExpressionPrivate::evalFunction(QDeclarativeContextData *ctxt, QObje
     // XXX TODO: Implement script caching, like we used to do with QScriptProgram in the
     // QtScript days
     v8::HandleScope handle_scope;
-    v8::Context::Scope ctxtscope(ep->v8engine.context());
+    v8::Context::Scope ctxtscope(ep->v8engine()->context());
     
     v8::TryCatch tc;
-    v8::Local<v8::Object> scopeobject = ep->v8engine.qmlScope(ctxt, scope);
-    v8::Local<v8::Script> script = ep->v8engine.qmlModeCompile(code, filename, line);
+    v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
+    v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line);
+    if (tc.HasCaught()) return v8::Persistent<v8::Function>();
     v8::Local<v8::Value> result = script->Run(scopeobject);
     if (tc.HasCaught()) return v8::Persistent<v8::Function>();
     if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
     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, int columnNumber)
+{
+    return new QDeclarativeExpression(ctxt, object, expr, isRewritten, url, lineNumber, columnNumber, *new QDeclarativeExpressionPrivate);
+}
+
 /*!
     \class QDeclarativeExpression
     \since 4.7
@@ -183,8 +193,6 @@ QDeclarativeExpressionPrivate::evalFunction(QDeclarativeContextData *ctxt, QObje
     \endcode
 */
 
-static int QDeclarativeExpression_notifyIdx = -1;
-
 /*!
     Create an invalid QDeclarativeExpression.
 
@@ -194,26 +202,17 @@ static int QDeclarativeExpression_notifyIdx = -1;
 QDeclarativeExpression::QDeclarativeExpression()
 : QObject(*new QDeclarativeExpressionPrivate, 0)
 {
-    Q_D(QDeclarativeExpression);
-
-    if (QDeclarativeExpression_notifyIdx == -1) 
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*!  \internal */
 QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, 
                                                QObject *object, const QString &expr, bool isRewritten,
-                                               const QString &url, int lineNumber, 
+                                               const QString &url, int lineNumber, int columnNumber,
                                                QDeclarativeExpressionPrivate &dd)
 : QObject(dd, 0)
 {
     Q_D(QDeclarativeExpression);
-    d->init(ctxt, expr, isRewritten, object, url, lineNumber);
-
-    if (QDeclarativeExpression_notifyIdx == -1) 
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
+    d->init(ctxt, expr, isRewritten, object, url, lineNumber, columnNumber);
 }
 
 /*!
@@ -242,7 +241,7 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s
     } else {
         QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(script.context());
 
-        QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(script.scopeObject()));
+        QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(script.context()->engine());
         QDeclarativeCompiledData *cdata = 0;
         QDeclarativeTypeData *typeData = 0;
         if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
@@ -251,21 +250,19 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s
         }
 
         if (cdata)
-            d->init(ctxtdata, cdata->primitives.at(id), cdata, script.scopeObject(),
-                    cdata->name, script.d.data()->lineNumber);
+            d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
+                    cdata->name, script.d.data()->lineNumber, script.d.data()->columnNumber);
         else
            defaultConstruction = true;
 
+        if (cdata)
+            cdata->release();
         if (typeData)
             typeData->release();
     }
 
     if (defaultConstruction)
         d->init(QDeclarativeContextData::get(script.context()), script.script(), script.scopeObject());
-
-    if (QDeclarativeExpression_notifyIdx == -1)
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*!
@@ -283,10 +280,6 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt,
 {
     Q_D(QDeclarativeExpression);
     d->init(QDeclarativeContextData::get(ctxt), expression, scope);
-
-    if (QDeclarativeExpression_notifyIdx == -1) 
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*! 
@@ -298,10 +291,6 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
 {
     Q_D(QDeclarativeExpression);
     d->init(ctxt, expression, scope);
-
-    if (QDeclarativeExpression_notifyIdx == -1) 
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*!  \internal */
@@ -311,10 +300,6 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
 {
     Q_D(QDeclarativeExpression);
     d->init(ctxt, expression, scope);
-
-    if (QDeclarativeExpression_notifyIdx == -1) 
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*!  
@@ -333,11 +318,6 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
 
     Q_D(QDeclarativeExpression);
     d->init(ctxt, function, scope);
-
-    if (QDeclarativeExpression_notifyIdx == -1)
-        QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-
-    d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
 }
 
 /*!
@@ -394,6 +374,7 @@ void QDeclarativeExpression::setExpression(const QString &expression)
     d->resetNotifyOnValueChanged();
     d->expression = expression;
     d->expressionFunctionValid = false;
+    d->expressionFunctionRewritten = false;
     qPersistentDispose(d->v8function);
     qPersistentDispose(d->v8qmlscope);
 }
@@ -407,10 +388,8 @@ void QDeclarativeExpressionPrivate::exceptionToError(v8::Handle<v8::Message> mes
     v8::Handle<v8::String> description = message->Get();
     int lineNumber = message->GetLineNumber();
 
-    Q_ASSERT(name->IsString());
-
-    v8::Local<v8::String> file = name->ToString();
-    if (file->Length() == 0) 
+    v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
+    if (file.IsEmpty() || file->Length() == 0) 
         error.setUrl(QUrl(QLatin1String("<Unknown File>")));
     else 
         error.setUrl(QUrl(QV8Engine::toStringStatic(file)));
@@ -428,31 +407,17 @@ void QDeclarativeExpressionPrivate::exceptionToError(v8::Handle<v8::Message> mes
 void QDeclarativeJavaScriptExpression::setNotifyOnValueChanged(bool v)
 {
     m_notifyOnValueChanged = v;
-    if (!v) guardList.clear();
+    if (!v) clearGuards();
 }
 
 void QDeclarativeJavaScriptExpression::resetNotifyOnValueChanged()
 {
-    guardList.clear();
-}
-
-void QDeclarativeJavaScriptExpression::setNotifyObject(QObject *object, int index)
-{
-    guardList.clear();
-
-    m_notifyObject = object;
-    m_notifyIndex = index;
-
-    if (!object || index == -1) {
-        m_notifyObject = 0;
-        m_notifyIndex = -1;
-    }
+    clearGuards();
 }
 
 v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::Function> function, bool *isUndefined)
 {
     Q_ASSERT(context() && context()->engine);
-    Q_ASSERT(!notifyOnValueChanged() || (m_notifyObject && m_notifyIndex != -1));
 
     if (function.IsEmpty() || function->IsUndefined()) {
         if (isUndefined) *isUndefined = true;
@@ -461,12 +426,15 @@ v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::F
 
     QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine);
 
-    bool lastCaptureProperties = ep->captureProperties;
-    QPODVector<QDeclarativeEnginePrivate::CapturedProperty> lastCapturedProperties;
-    ep->captureProperties = notifyOnValueChanged();
+    Q_ASSERT(notifyOnValueChanged() || activeGuards.isEmpty());
+    GuardCapture capture(this);
+
+    QDeclarativeEnginePrivate::PropertyCapture *lastPropertyCapture = ep->propertyCapture;
+    ep->propertyCapture = notifyOnValueChanged()?&capture:0;
 
-    if (ep->capturedProperties.count())
-        ep->capturedProperties.copyAndClear(lastCapturedProperties);
+
+    if (notifyOnValueChanged())
+        capture.guards.copyAndClear(activeGuards);
 
     QDeclarativeContextData *lastSharedContext = 0;
     QObject *lastSharedScope = 0;
@@ -475,7 +443,7 @@ v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::F
 
     // All code that follows must check with watcher before it accesses data members 
     // incase we have been deleted.
-    QDeclarativeDeleteWatcher watcher(this);
+    QDeleteWatcher watcher(this);
 
     if (sharedContext) {
         lastSharedContext = ep->sharedContext;
@@ -487,9 +455,9 @@ v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::F
     v8::Local<v8::Value> result;
     {
         v8::TryCatch try_catch;
-        v8::Handle<v8::Object> This = ep->v8engine.global();
+        v8::Handle<v8::Object> This = ep->v8engine()->global();
         if (scopeObject() && requiresThisObject()) {
-            v8::Handle<v8::Value> value = ep->v8engine.newQObject(scopeObject());
+            v8::Handle<v8::Value> value = ep->v8engine()->newQObject(scopeObject());
             if (value->IsObject()) This = v8::Handle<v8::Object>::Cast(value);
         }
 
@@ -500,7 +468,7 @@ v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::F
 
         if (watcher.wasDeleted()) {
         } else if (try_catch.HasCaught()) {
-            v8::Context::Scope scope(ep->v8engine.context());
+            v8::Context::Scope scope(ep->v8engine()->context());
             v8::Local<v8::Message> message = try_catch.Message();
             if (!message.IsEmpty()) {
                 QDeclarativeExpressionPrivate::exceptionToError(message, error);
@@ -517,119 +485,104 @@ v8::Local<v8::Value> QDeclarativeJavaScriptExpression::evaluate(v8::Handle<v8::F
         ep->sharedScope = lastSharedScope;
     }
 
-    if (!watcher.wasDeleted() && notifyOnValueChanged()) {
-        guardList.updateGuards(m_notifyObject, m_notifyIndex, expressionString(), 
-                               ep->capturedProperties);
+    if (capture.errorString) {
+        for (int ii = 0; ii < capture.errorString->count(); ++ii)
+            qWarning("%s", qPrintable(capture.errorString->at(ii)));
+        delete capture.errorString;
+        capture.errorString = 0;
     }
 
-    if (lastCapturedProperties.count())
-        lastCapturedProperties.copyAndClear(ep->capturedProperties);
-    else
-        ep->capturedProperties.clear();
+    while (Guard *g = capture.guards.takeFirst())
+        g->Delete();
 
-    ep->captureProperties = lastCaptureProperties;
+    ep->propertyCapture = lastPropertyCapture;
 
     return result;
 }
 
-void QDeclarativeJavaScriptExpression::GuardList::updateGuards(QObject *notifyObject, int notifyIndex,
-                                                               const QStringRef &expression,
-                                                               const CapturedProperties &properties)
+void QDeclarativeJavaScriptExpression::GuardCapture::captureProperty(QDeclarativeNotifier *n)
 {
-    Q_ASSERT(notifyObject);
-    Q_ASSERT(notifyIndex != -1);
-
-    if (properties.count() == 0) {
-        clear();
-        return;
-    }
+    if (expression) {
 
-    if (properties.count() != length) {
-        QDeclarativeNotifierEndpoint *newGuardList = new QDeclarativeNotifierEndpoint[properties.count()];
+        // Try and find a matching guard
+        while (!guards.isEmpty() && !guards.first()->isConnected(n))
+            guards.takeFirst()->Delete();
 
-        for (int ii = 0; ii < qMin(length, properties.count()); ++ii) 
-           endpoints[ii].copyAndClear(newGuardList[ii]);
+        Guard *g = 0;
+        if (!guards.isEmpty()) {
+            g = guards.takeFirst();
+            g->cancelNotify();
+            Q_ASSERT(g->isConnected(n));
+        } else {
+            g = Guard::New(expression);
+            g->connect(n);
+        }
 
-        delete [] endpoints;
-        endpoints = newGuardList;
-        length = properties.count();
+        expression->activeGuards.append(g);
     }
+}
 
-    bool outputWarningHeader = false;
-    bool noChanges = true;
-    for (int ii = 0; ii < properties.count(); ++ii) {
-        QDeclarativeNotifierEndpoint &guard = endpoints[ii];
-        const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
-
-        guard.target = notifyObject;
-        guard.targetMethod = notifyIndex;
-
-        if (property.notifier != 0) {
-
-            if (!noChanges && guard.isConnected(property.notifier)) {
-                // Nothing to do
-
-            } else {
-                noChanges = false;
-
-                bool existing = false;
-                for (int jj = 0; !existing && jj < ii; ++jj) 
-                    if (endpoints[jj].isConnected(property.notifier)) 
-                        existing = true;
-
-                if (existing) {
-                    // duplicate
-                    guard.disconnect();
-                } else {
-                    guard.connect(property.notifier);
-                }
+void QDeclarativeJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
+{
+    if (expression) {
+        if (n == -1) {
+            if (!errorString) {
+                errorString = new QStringList;
+                QString preamble = QLatin1String("QDeclarativeExpression: Expression ") +
+                                   expression->expressionIdentifier() +
+                                   QLatin1String(" depends on non-NOTIFYable properties:");
+                errorString->append(preamble);
             }
 
+            const QMetaObject *metaObj = o->metaObject();
+            QMetaProperty metaProp = metaObj->property(c);
 
-        } else if (property.notifyIndex != -1) {
+            QString error = QLatin1String("    ") +
+                            QString::fromUtf8(metaObj->className()) +
+                            QLatin1String("::") +
+                            QString::fromUtf8(metaProp.name());
+            errorString->append(error);
+        } else {
 
-            if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) {
-                // Nothing to do
+            // Try and find a matching guard
+            while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
+                guards.takeFirst()->Delete();
 
+            Guard *g = 0;
+            if (!guards.isEmpty()) {
+                g = guards.takeFirst();
+                g->cancelNotify();
+                Q_ASSERT(g->isConnected(o, n));
             } else {
-                noChanges = false;
-
-                bool existing = false;
-                for (int jj = 0; !existing && jj < ii; ++jj) 
-                    if (endpoints[jj].isConnected(property.object, property.notifyIndex)) 
-                        existing = true;
-
-                if (existing) {
-                    // duplicate
-                    guard.disconnect();
-                } else {
-                    guard.connect(property.object, property.notifyIndex);
-                }
-            }
-
-        } else if (!expression.isEmpty()) {
-            if (!outputWarningHeader) {
-                outputWarningHeader = true;
-                qWarning() << "QDeclarativeExpression: Expression" << expression
-                           << "depends on non-NOTIFYable properties:";
+                g = Guard::New(expression);
+                g->connect(o, n);
             }
 
-            const QMetaObject *metaObj = property.object->metaObject();
-            QMetaProperty metaProp = metaObj->property(property.coreIndex);
-
-            qWarning().nospace() << "    " << metaObj->className() << "::" << metaProp.name();
+            expression->activeGuards.append(g);
         }
     }
 }
 
+void QDeclarativeJavaScriptExpression::clearGuards()
+{
+    while (Guard *g = activeGuards.takeFirst())
+        g->Delete();
+}
+
 // Must be called with a valid handle scope
 v8::Local<v8::Value> QDeclarativeExpressionPrivate::v8value(QObject *secondaryScope, bool *isUndefined)
 {
     if (!expressionFunctionValid) {
+        bool ok = true;
+
         QDeclarativeRewrite::RewriteBinding rewriteBinding;
         rewriteBinding.setName(name);
-        bool ok = true;
-        const QString code = rewriteBinding(expression, &ok);
+        QString code;
+        if (expressionFunctionRewritten)
+            code = expression;
+        else
+            code = rewriteBinding(expression, &ok);
+
         if (ok) v8function = evalFunction(context(), scopeObject(), code, url, line, &v8qmlscope);
         setUseSharedContext(false);
         expressionFunctionValid = true;
@@ -640,9 +593,9 @@ v8::Local<v8::Value> QDeclarativeExpressionPrivate::v8value(QObject *secondarySc
         v8::Local<v8::Value> result;
         QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine);
         QObject *restoreSecondaryScope = 0;
-        restoreSecondaryScope = ep->v8engine.contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope);
+        restoreSecondaryScope = ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, secondaryScope);
         result = evaluate(v8function, isUndefined);
-        ep->v8engine.contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope);
+        ep->v8engine()->contextWrapper()->setSecondaryScope(v8qmlscope, restoreSecondaryScope);
         return result;
     } else {
         return evaluate(v8function, isUndefined);
@@ -665,8 +618,9 @@ QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isU
 
     {
         v8::HandleScope handle_scope;
+        v8::Context::Scope context_scope(ep->v8engine()->context());
         v8::Local<v8::Value> result = v8value(secondaryScope, isUndefined);
-        rv = ep->v8engine.toVariant(result, qMetaTypeId<QList<QObject*> >());
+        rv = ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >());
     }
 
     ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
@@ -742,14 +696,25 @@ int QDeclarativeExpression::lineNumber() const
 }
 
 /*!
+    Returns the source file column number for this expression.  The source location
+    must have been previously set by calling setSourceLocation().
+*/
+int QDeclarativeExpression::columnNumber() const
+{
+    Q_D(const QDeclarativeExpression);
+    return d->column;
+}
+
+/*!
     Set the location of this expression to \a line of \a url. This information
     is used by the script engine.
 */
-void QDeclarativeExpression::setSourceLocation(const QString &url, int line)
+void QDeclarativeExpression::setSourceLocation(const QString &url, int line, int column)
 {
     Q_D(QDeclarativeExpression);
     d->url = url;
     d->line = line;
+    d->column = column;
 }
 
 /*!
@@ -801,12 +766,6 @@ QDeclarativeError QDeclarativeExpression::error() const
     return d->error;
 }
 
-/*! \internal */
-void QDeclarativeExpressionPrivate::_q_notify()
-{
-    emitValueChanged();
-}
-
 /*!
     \fn void QDeclarativeExpression::valueChanged()
 
@@ -815,7 +774,7 @@ void QDeclarativeExpressionPrivate::_q_notify()
     calling QDeclarativeExpression::evaluate()) before this signal will be emitted.
 */
 
-void QDeclarativeExpressionPrivate::emitValueChanged()
+void QDeclarativeExpressionPrivate::expressionChanged()
 {
     Q_Q(QDeclarativeExpression);
     emit q->valueChanged();