diff options
Diffstat (limited to 'src/declarative/qml/qmlvme_p.h')
-rw-r--r-- | src/declarative/qml/qmlvme_p.h | 32 |
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; }; |