From f7839148306215f153a8467edcaffa3d2ec53c79 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 28 Jul 2011 18:39:55 +1000 Subject: Fix alias warnings in QDeclarativeVME --- src/declarative/qml/qdeclarativevme.cpp | 72 +++++++++++++++++++++++++++++++-- src/declarative/qml/qdeclarativevme_p.h | 32 ++------------- 2 files changed, 72 insertions(+), 32 deletions(-) diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 06aed98..221e52c 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -74,6 +74,27 @@ QT_BEGIN_NAMESPACE +// A simple stack wrapper around QVarLengthArray +template +class QDeclarativeVMEStack : private QVarLengthArray +{ +private: + typedef QVarLengthArray VLA; + int _index; + +public: + inline QDeclarativeVMEStack(); + inline bool isEmpty() const; + inline const T &top() const; + inline void push(const T &o); + inline T pop(); + inline int count() const; + inline const T &at(int index) const; +}; + +// We do this so we can forward declare the type in the qdeclarativevme_p.h header +class QDeclarativeVMEObjectStack : public QDeclarativeVMEStack {}; + QDeclarativeVME::QDeclarativeVME() { } @@ -99,10 +120,12 @@ struct ListInstance QDeclarativeListProperty qListProperty; }; +Q_DECLARE_TYPEINFO(ListInstance, Q_PRIMITIVE_TYPE | Q_MOVABLE_TYPE); + QObject *QDeclarativeVME::run(QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, int start, int count, const QBitField &bindingSkipList) { - QDeclarativeVMEStack stack; + QDeclarativeVMEObjectStack stack; if (start == -1) start = 0; if (count == -1) count = comp->bytecode.count(); @@ -121,7 +144,7 @@ void QDeclarativeVME::runDeferred(QObject *object) QDeclarativeCompiledData *comp = data->deferredComponent; int start = data->deferredIdx + 1; int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount; - QDeclarativeVMEStack stack; + QDeclarativeVMEObjectStack stack; stack.push(object); run(stack, ctxt, comp, start, count, QBitField()); @@ -143,7 +166,7 @@ static void removeBindingOnProperty(QObject *o, int index) #define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index) -QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, +QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack, QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, int start, int count, @@ -1054,5 +1077,48 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData } } +template +QDeclarativeVMEStack::QDeclarativeVMEStack() +: _index(-1) +{ +} + +template +bool QDeclarativeVMEStack::isEmpty() const { + return _index == -1; +} + +template +const T &QDeclarativeVMEStack::top() const { + return at(_index); +} + +template +void QDeclarativeVMEStack::push(const T &o) { + _index++; + + Q_ASSERT(_index <= VLA::size()); + if (_index == VLA::size()) + append(o); + else + VLA::data()[_index] = o; +} + +template +T QDeclarativeVMEStack::pop() { + Q_ASSERT(_index >= 0); + --_index; + return VLA::data()[_index + 1]; +} + +template +int QDeclarativeVMEStack::count() const { + return _index + 1; +} + +template +const T &QDeclarativeVMEStack::at(int index) const { + return VLA::data()[index]; +} QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativevme_p.h b/src/declarative/qml/qdeclarativevme_p.h index 6b7b93f..b7f110f 100644 --- a/src/declarative/qml/qdeclarativevme_p.h +++ b/src/declarative/qml/qdeclarativevme_p.h @@ -58,6 +58,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -67,34 +68,7 @@ class QDeclarativeCompiledData; class QDeclarativeCompiledData; class QDeclarativeContextData; -template -class QDeclarativeVMEStack { -public: - QDeclarativeVMEStack() : index(-1), maxSize(N), data((T *)fixedData) {} - ~QDeclarativeVMEStack() { if (data != (T *)fixedData) qFree(data); } - - 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 != (T *)fixedData) { - data = (T*)qRealloc(data, maxSize * sizeof(T)); - } else { - data = (T*)qMalloc(maxSize * sizeof(T)); - } - } - int index; - int maxSize; - T *data; - char fixedData[N * sizeof(T)]; -}; - +class QDeclarativeVMEObjectStack; class QDeclarativeVME { public: @@ -109,7 +83,7 @@ public: QList errors() const; private: - QObject *run(QDeclarativeVMEStack &, + QObject *run(QDeclarativeVMEObjectStack &, QDeclarativeContextData *, QDeclarativeCompiledData *, int start, int count, const QBitField &); -- cgit v0.12