/****************************************************************************
**
-** 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$
**
****************************************************************************/
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();
};
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
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;
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>);
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;