From 0d6a0f1371d899c4105bc4383550ca1cb6b132b2 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:13 +0200 Subject: qmake: qmakeDeleteCacheClear() function can be template now Merge-request: 756 Reviewed-by: Olivier Goffart --- qmake/cachekeys.h | 9 +++------ qmake/generators/makefile.cpp | 4 ++-- qmake/option.cpp | 2 +- qmake/project.cpp | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/qmake/cachekeys.h b/qmake/cachekeys.h index 63bd224..c5c1631 100644 --- a/qmake/cachekeys.h +++ b/qmake/cachekeys.h @@ -166,12 +166,9 @@ struct FileFixifyCacheKey inline uint qHash(const FileFixifyCacheKey &f) { return f.hashCode(); } // ------------------------------------------------------------------------------------------------- -// As MSVC 6.0 can't handle template functions that well, we need a separate function for each type -inline void qmakeDeleteCacheClear_QMapStringInt(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QStringList(void *i) { delete reinterpret_cast(i); } -inline void qmakeDeleteCacheClear_QHashFixStringCacheKeyQString(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QHashFileInfoCacheKeyQFileInfo(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QHashFileFixifyCacheKeyQString(void *i) { delete reinterpret_cast *>(i); } +template +inline void qmakeDeleteCacheClear(void *i) { delete reinterpret_cast(i); } + inline void qmakeFreeCacheClear(void *i) { free(i); } typedef void (*qmakeCacheClearFunc)(void *); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 45a96f5..74c7977 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2712,7 +2712,7 @@ MakefileGenerator::fileInfo(QString file) const static QFileInfo noInfo = QFileInfo(); if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFileInfoCacheKeyQFileInfo, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FileInfoCacheKey cacheKey(file); QFileInfo value = cache->value(cacheKey, noInfo); @@ -2791,7 +2791,7 @@ MakefileGenerator::fileFixify(const QString& file, const QString &out_d, const Q static QHash *cache = 0; if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFileFixifyCacheKeyQString, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FileFixifyCacheKey cacheKey(ret, out_d, in_d, fix, canon); QString cacheVal = cache->value(cacheKey); diff --git a/qmake/option.cpp b/qmake/option.cpp index 8db3797..27e7c18 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -621,7 +621,7 @@ Option::fixString(QString string, uchar flags) static QHash *cache = 0; if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFixStringCacheKeyQString, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FixStringCacheKey cacheKey(string, flags); if(cache->contains(cacheKey)) { diff --git a/qmake/project.cpp b/qmake/project.cpp index cb02923..29d4242 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -87,7 +87,7 @@ QMap qmake_expandFunctions() static QMap *qmake_expand_functions = 0; if(!qmake_expand_functions) { qmake_expand_functions = new QMap; - qmakeAddCacheClear(qmakeDeleteCacheClear_QMapStringInt, (void**)&qmake_expand_functions); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&qmake_expand_functions); qmake_expand_functions->insert("member", E_MEMBER); qmake_expand_functions->insert("first", E_FIRST); qmake_expand_functions->insert("last", E_LAST); @@ -1631,7 +1631,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QMap, (void**)&feature_roots); } debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(), feature_roots->join("::").toLatin1().constData()); -- cgit v0.12