Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativedata_p.h
index 2a5eace..0f75d62 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.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 // We mean it.
 //
 
-#include <QtScript/qscriptvalue.h>
 #include <private/qobject_p.h>
-#include "private/qdeclarativeguard_p.h"
+
+#include <private/qv8_p.h>
 
 QT_BEGIN_NAMESPACE
 
+template <class Key, class T> class QHash;
+class QDeclarativeGuardImpl;
 class QDeclarativeCompiledData;
 class QDeclarativeAbstractBinding;
 class QDeclarativeContext;
@@ -66,30 +68,34 @@ class QDeclarativePropertyCache;
 class QDeclarativeContextData;
 class QDeclarativeNotifier;
 class QDeclarativeDataExtended;
+class QDeclarativeNotifierEndpoint;
 // This class is structured in such a way, that simply zero'ing it is the
 // default state for elemental object allocations.  This is crucial in the
 // workings of the QDeclarativeInstruction::CreateSimpleObject instruction.
 // Don't change anything here without first considering that case!
-class Q_AUTOTEST_EXPORT QDeclarativeData : public QAbstractDeclarativeData
+class Q_DECLARATIVE_EXPORT QDeclarativeData : public QAbstractDeclarativeData
 {
 public:
     QDeclarativeData()
         : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), 
-          context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), 
-          bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), 
-          scriptValue(0), objectDataRefCount(0), propertyCache(0), guards(0), extendedData(0) {
+          hasTaintedV8Object(false), notifyList(0), context(0), outerContext(0), bindings(0), 
+          nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), 
+          lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0), 
+          propertyCache(0), guards(0), extendedData(0) {
           init(); 
-      }
+    }
 
     static inline void init() {
         QAbstractDeclarativeData::destroyed = destroyed;
         QAbstractDeclarativeData::parentChanged = parentChanged;
         QAbstractDeclarativeData::objectNameChanged = objectNameChanged;
+        QAbstractDeclarativeData::signalEmitted = signalEmitted;
     }
 
     static void destroyed(QAbstractDeclarativeData *, QObject *);
     static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
     static void objectNameChanged(QAbstractDeclarativeData *, QObject *);
+    static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **);
 
     void destroyed(QObject *);
     void parentChanged(QObject *, QObject *);
@@ -103,7 +109,25 @@ public:
     quint32 ownContext:1;
     quint32 indestructible:1;
     quint32 explicitIndestructibleSet:1;
-    quint32 dummy:28;
+    quint32 hasTaintedV8Object:1;
+    quint32 dummy:27;
+
+    struct NotifyList {
+        quint64 connectionMask;
+
+        quint16 maximumTodoIndex;
+        quint16 notifiesSize;
+
+        QDeclarativeNotifierEndpoint *todo;
+        QDeclarativeNotifierEndpoint**notifies;
+        void layout();
+    private:
+        void layout(QDeclarativeNotifierEndpoint*);
+    };
+    NotifyList *notifyList;
+    
+    inline QDeclarativeNotifierEndpoint *notify(int index);
+    void addNotify(int index, QDeclarativeNotifierEndpoint *);
 
     // The context that created the C++ object
     QDeclarativeContextData *context; 
@@ -128,13 +152,12 @@ public:
     QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context?
     unsigned int deferredIdx;
 
-    // ### Can we make this QScriptValuePrivate so we incur no additional allocation
-    // cost?
-    QScriptValue *scriptValue;
-    quint32 objectDataRefCount;
+    quint32 v8objectid;
+    v8::Persistent<v8::Object> v8object;
+
     QDeclarativePropertyCache *propertyCache;
 
-    QDeclarativeGuard<QObject> *guards;
+    QDeclarativeGuardImpl *guards;
 
     static QDeclarativeData *get(const QObject *object, bool create = false) {
         QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
@@ -160,30 +183,23 @@ private:
     mutable QDeclarativeDataExtended *extendedData;
 };
 
-template<class T>
-void QDeclarativeGuard<T>::addGuard()
+QDeclarativeNotifierEndpoint *QDeclarativeData::notify(int index)
 {
-    Q_ASSERT(!prev);
-
-    if (QObjectPrivate::get(o)->wasDeleted) 
-        return;
-
-    QDeclarativeData *data = QDeclarativeData::get(o, true);
-    next = data->guards;
-    if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
-    data->guards = reinterpret_cast<QDeclarativeGuard<QObject> *>(this);
-    prev = &data->guards;
-}
-
-template<class T>
-void QDeclarativeGuard<T>::remGuard()
-{
-    Q_ASSERT(prev);
+    Q_ASSERT(index <= 0xFFFF);
+
+    if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) {
+        return 0;
+    } else if (index < notifyList->notifiesSize) {
+        return notifyList->notifies[index];
+    } else if (index <= notifyList->maximumTodoIndex) {
+        notifyList->layout();
+    }
 
-    if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = prev;
-    *prev = next;
-    next = 0;
-    prev = 0;
+    if (index < notifyList->notifiesSize) {
+        return notifyList->notifies[index];
+    } else {
+        return 0;
+    }
 }
 
 QT_END_NAMESPACE