summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlvme_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qmlvme_p.h')
-rw-r--r--src/declarative/qml/qmlvme_p.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
index a15bd08..9c45dc1 100644
--- a/src/declarative/qml/qmlvme_p.h
+++ b/src/declarative/qml/qmlvme_p.h
@@ -53,10 +53,11 @@
// We mean it.
//
+#include "qmlerror.h"
+#include "qbitfield_p.h"
+
#include <QtCore/QString>
#include <QtCore/QStack>
-#include <qmlerror.h>
-#include <private/qbitfield_p.h>
QT_BEGIN_NAMESPACE
@@ -66,6 +67,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 +109,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;
};