Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / v8 / qv8engine_p.h
index 7df4c52..f46a660 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$
 **
 ****************************************************************************/
@@ -230,25 +230,10 @@ private:
 public:
     static void garbageCollectorPrologueCallback(v8::GCType, v8::GCCallbackFlags);
     static void registerGcPrologueCallback();
-    static void releaseWorkerThreadGcPrologueCallbackData();
-
-    class Q_AUTOTEST_EXPORT Referencer {
-    public:
-        ~Referencer();
-        void addRelationship(QObject *object, v8::Persistent<v8::Value> handle);
-        void addRelationship(QObject *object, QObject *other);
-        void dispose();
-    private:
-        Referencer();
-        static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *qobjectOwner, bool *shouldBeStrong);
-        v8::Persistent<v8::Object> strongReferencer;
-        v8::Persistent<v8::Context> context;
-        friend class QV8GCCallback::ThreadData;
-    };
 
     class Q_AUTOTEST_EXPORT Node {
     public:
-        typedef void (*PrologueCallback)(Referencer *r, Node *node);
+        typedef void (*PrologueCallback)(Node *node);
         Node(PrologueCallback callback);
         ~Node();
 
@@ -257,19 +242,6 @@ public:
     };
 
     static void addGcCallbackNode(Node *node);
-
-private:
-    class ThreadData {
-    public:
-        ThreadData() : gcPrologueCallbackRegistered(false) { }
-        ~ThreadData();
-        Referencer referencer;
-        bool gcPrologueCallbackRegistered;
-        QIntrusiveList<Node, &Node::node> gcCallbackNodes;
-    };
-
-    static void initializeThreadData();
-    static QThreadStorage<ThreadData *> threadData;
 };
 
 class Q_DECLARATIVE_EXPORT QV8Engine
@@ -460,11 +432,31 @@ public:
     void startTimer(const QString &timerName);
     qint64 stopTimer(const QString &timerName, bool *wasRunning);
 
+    // used for console.count()
+    int consoleCountHelper(const QString &file, int line, int column);
+
     QObject *qtObjectFromJS(v8::Handle<v8::Value> value);
     QSet<int> visitedConversionObjects;
 
     static QDateTime qtDateTimeFromJsDate(double jsDate);
 
+    void addRelationshipForGC(QObject *object, v8::Persistent<v8::Value> handle);
+    void addRelationshipForGC(QObject *object, QObject *other);
+
+    struct ThreadData {
+        ThreadData();
+        ~ThreadData();
+        v8::Isolate* isolate;
+        bool gcPrologueCallbackRegistered;
+        QIntrusiveList<QV8GCCallback::Node, &QV8GCCallback::Node::node> gcCallbackNodes;
+    };
+
+    static bool hasThreadData();
+    static ThreadData* threadData();
+    static void ensurePerThreadIsolate();
+
+    v8::Persistent<v8::Object> m_strongReferencer;
+
 protected:
     QJSEngine* q;
     QDeclarativeEngine *m_engine;
@@ -497,6 +489,8 @@ protected:
     QElapsedTimer m_time;
     QHash<QString, qint64> m_startedTimers;
 
+    QHash<QString, quint32> m_consoleCount;
+
     QVariant toBasicVariant(v8::Handle<v8::Value>);
 
     void initializeGlobal(v8::Handle<v8::Object>);
@@ -504,6 +498,8 @@ protected:
     double qtDateTimeToJsDate(const QDateTime &dt);
 
 private:
+    static v8::Persistent<v8::Object> *findOwnerAndStrength(QObject *object, bool *shouldBeStrong);
+
     typedef QScriptIntrusiveList<QJSValuePrivate, &QJSValuePrivate::m_node> ValueList;
     ValueList m_values;
     typedef QScriptIntrusiveList<QJSValueIteratorPrivate, &QJSValueIteratorPrivate::m_node> ValueIteratorList;