summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2014-11-06 17:13:41 +0100
committerMilian Wolff <milian.wolff@kdab.com>2014-11-14 16:05:50 +0100
commit896d3af6bc1ba60b96d037d45260d5bb9fe5c782 (patch)
treecb8babf1d9606373fcb96ba8765605e804c4428f /src
parentb2afcc98c0783749c5b22616b97b95538ea27e9e (diff)
Enforce unsigned values for INDEXBITS template parameter.
We use shift operations on those values and they are only defined for positive values. So better enforce this by the compiler. Change-Id: I602bd69c6fb0dfbd843eb2d30578a4a7f29f95bb Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/resources/qhandle.h6
-rw-r--r--src/core/resources/qhandlemanager.h14
-rw-r--r--src/core/resources/qresourcesmanager.h10
-rw-r--r--src/render/backend/framegraph/renderpassfilternode_p.h2
-rw-r--r--src/render/backend/framegraph/techniquefilternode_p.h2
-rw-r--r--src/render/backend/renderentity_p.h4
6 files changed, 19 insertions, 19 deletions
diff --git a/src/core/resources/qhandle.h b/src/core/resources/qhandle.h
index 7dce18fbb..e87fafe75 100644
--- a/src/core/resources/qhandle.h
+++ b/src/core/resources/qhandle.h
@@ -49,10 +49,10 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class QHandleManager;
-template <typename T, int INDEXBITS = 16>
+template <typename T, uint INDEXBITS = 16>
class QHandle
{
public:
@@ -106,7 +106,7 @@ private:
};
};
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
QDebug operator<<(QDebug dbg, const QHandle<T, INDEXBITS> &h)
{
QString binNumber = QString::number(h.handle(), 2).rightJustified(32, QChar::fromLatin1('0'));
diff --git a/src/core/resources/qhandlemanager.h b/src/core/resources/qhandlemanager.h
index 5eeecdf5e..5a67d131b 100644
--- a/src/core/resources/qhandlemanager.h
+++ b/src/core/resources/qhandlemanager.h
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
-template <typename T, int INDEXBITS = 16>
+template <typename T, uint INDEXBITS = 16>
class QHandleManager
{
public:
@@ -107,7 +107,7 @@ private:
QVector<HandleEntry<T> > m_entries;
};
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
void QHandleManager<T, INDEXBITS>::reset()
{
m_activeEntryCount = 0;
@@ -119,7 +119,7 @@ void QHandleManager<T, INDEXBITS>::reset()
m_entries[QHandle<T, INDEXBITS>::MaxIndex].m_endOfFreeList = true;
}
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
QHandle<T, INDEXBITS> QHandleManager<T, INDEXBITS>::acquire(T *d)
{
typedef QHandle<T, INDEXBITS> qHandle;
@@ -143,7 +143,7 @@ QHandle<T, INDEXBITS> QHandleManager<T, INDEXBITS>::acquire(T *d)
return qHandle(newIndex, m_entries[newIndex].m_counter);
}
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
void QHandleManager<T, INDEXBITS>::release(const QHandle<T, INDEXBITS> &handle)
{
const quint32 index = handle.index();
@@ -159,7 +159,7 @@ void QHandleManager<T, INDEXBITS>::release(const QHandle<T, INDEXBITS> &handle)
// Needed in case the QResourcesManager has reordered
// memory so that the handle still points to valid data
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
void QHandleManager<T, INDEXBITS>::update(const QHandle<T, INDEXBITS> &handle, T *d)
{
const quint32 index = handle.index();
@@ -168,7 +168,7 @@ void QHandleManager<T, INDEXBITS>::update(const QHandle<T, INDEXBITS> &handle, T
m_entries[index].m_data = d;
}
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
T *QHandleManager<T, INDEXBITS>::data(const QHandle<T, INDEXBITS> &handle, bool *ok)
{
const quint32 index = handle.index();
@@ -185,7 +185,7 @@ T *QHandleManager<T, INDEXBITS>::data(const QHandle<T, INDEXBITS> &handle, bool
return d;
}
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
const T *QHandleManager<T, INDEXBITS>::constData(const QHandle<T, INDEXBITS> &handle, bool *ok) const
{
const quint32 index = handle.index();
diff --git a/src/core/resources/qresourcesmanager.h b/src/core/resources/qresourcesmanager.h
index 0a521b346..d1fc218bc 100644
--- a/src/core/resources/qresourcesmanager.h
+++ b/src/core/resources/qresourcesmanager.h
@@ -133,7 +133,7 @@ struct Int2Type
};
};
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class ArrayAllocatingPolicy
{
public:
@@ -219,7 +219,7 @@ private:
};
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class ArrayPreallocationPolicy
{
public:
@@ -272,7 +272,7 @@ private:
};
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class ListAllocatingPolicy
{
public:
@@ -328,8 +328,8 @@ private:
{}
};
-template <typename T, typename C, int INDEXBITS = 16,
- template <typename, int> class AllocatingPolicy = ArrayAllocatingPolicy,
+template <typename T, typename C, uint INDEXBITS = 16,
+ template <typename, uint> class AllocatingPolicy = ArrayAllocatingPolicy,
template <class> class LockingPolicy = NonLockingPolicy
>
class QResourcesManager
diff --git a/src/render/backend/framegraph/renderpassfilternode_p.h b/src/render/backend/framegraph/renderpassfilternode_p.h
index fc3e390e8..819338e76 100644
--- a/src/render/backend/framegraph/renderpassfilternode_p.h
+++ b/src/render/backend/framegraph/renderpassfilternode_p.h
@@ -52,7 +52,7 @@ namespace Qt3D {
class QAnnotation;
class QRenderPassFilter;
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class QHandle;
namespace Render {
diff --git a/src/render/backend/framegraph/techniquefilternode_p.h b/src/render/backend/framegraph/techniquefilternode_p.h
index 976d8c603..eeb50b66e 100644
--- a/src/render/backend/framegraph/techniquefilternode_p.h
+++ b/src/render/backend/framegraph/techniquefilternode_p.h
@@ -55,7 +55,7 @@ namespace Qt3D {
class QAnnotation;
class QTechniqueFilter;
-template <typename T, int INDEXBITS>
+template <typename T, uint INDEXBITS>
class QHandle;
namespace Render {
diff --git a/src/render/backend/renderentity_p.h b/src/render/backend/renderentity_p.h
index d165d1177..6461814d0 100644
--- a/src/render/backend/renderentity_p.h
+++ b/src/render/backend/renderentity_p.h
@@ -98,7 +98,7 @@ public:
void addComponent(QComponent *component);
void removeComponent(QComponent *component);
- template<class Backend, int INDEXBITS>
+ template<class Backend, uint INDEXBITS>
QHandle<Backend, INDEXBITS> componentHandle() const
{
return QHandle<Backend, INDEXBITS>();
@@ -131,7 +131,7 @@ public:
return componentList;
}
- template<class Backend, int INDEXBITS>
+ template<class Backend, uint INDEXBITS>
QList<QHandle<Backend, INDEXBITS> > componentHandlesInTree() const
{
QList<QHandle<Backend, INDEXBITS> > handles;