summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlvme_p.h
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-02 08:54:43 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-02 08:54:43 (GMT)
commit5247ee562f76a51b8a81735d7da709d1b9b63796 (patch)
treebbe2b7e2b538082ee158ccef7e8f7d1020798e47 /src/declarative/qml/qmlvme_p.h
parentbd22fbc0447faa58f3a4ab52ed5545f12a47cd5c (diff)
parentb1ca4dbd2935cb2647aa1650a5185cb918ecb21d (diff)
downloadQt-5247ee562f76a51b8a81735d7da709d1b9b63796.zip
Qt-5247ee562f76a51b8a81735d7da709d1b9b63796.tar.gz
Qt-5247ee562f76a51b8a81735d7da709d1b9b63796.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlvme_p.h')
-rw-r--r--src/declarative/qml/qmlvme_p.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
index a15bd08..a61d05a 100644
--- a/src/declarative/qml/qmlvme_p.h
+++ b/src/declarative/qml/qmlvme_p.h
@@ -56,7 +56,7 @@
#include <QtCore/QString>
#include <QtCore/QStack>
#include <qmlerror.h>
-#include <private/qbitfield_p.h>
+#include "qbitfield_p.h"
QT_BEGIN_NAMESPACE
@@ -66,6 +66,34 @@ class QmlCompiledData;
class QmlCompiledData;
class QmlContext;
+template<typename T, int N = 128>
+class QmlVMEStack {
+public:
+ QmlVMEStack() : index(-1), maxSize(N), data(fixedData) {}
+ ~QmlVMEStack() { if (data != fixedData) qFree(fixedData); }
+
+ bool isEmpty() const { return index == -1; }
+ const T &top() const { return data[index]; }
+ void push(const T &i) { ++index; if (index == maxSize) realloc(); data[index] = i; }
+ const T &pop() { --index; return data[index + 1]; }
+ int count() const { return index + 1; }
+ const T &at(int idx) { return data[idx]; }
+
+private:
+ void realloc() {
+ maxSize += N;
+ if (data != fixedData) {
+ data = (T*)qRealloc(data, maxSize * sizeof(T));
+ } else {
+ data = (T*)qMalloc(maxSize * sizeof(T));
+ }
+ }
+ int index;
+ int maxSize;
+ T *data;
+ T fixedData[N];
+};
+
class QmlVME
{
public:
@@ -80,7 +108,7 @@ public:
QList<QmlError> errors() const;
private:
- QObject *run(QStack<QObject *> &, QmlContext *, QmlCompiledData *,
+ QObject *run(QmlVMEStack<QObject *> &, QmlContext *, QmlCompiledData *,
int start, int count, const QBitField &);
QList<QmlError> vmeErrors;
};