forked from qt-creator/qt-creator
Runextensions/hasCallOperator: Fix build with MSVC2015 Update 2
Looks like MSVC has issues (internal compiler error) with the "templates in templates" when used from within a namespace, as well as a few other problems... Simplify the code paths for hasCallOperator. Change-Id: I934401a884398967ac95d7e218525cc316d9000a Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -38,6 +38,24 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
// hasCallOperator & Co must be outside of any namespace
|
||||||
|
// because of internal compiler error with MSVC2015 Update 2
|
||||||
|
|
||||||
|
using testCallOperatorYes = char;
|
||||||
|
using testCallOperatorNo = struct { char foo[2]; };
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
static testCallOperatorYes testCallOperator(decltype(&C::operator()));
|
||||||
|
|
||||||
|
template<typename>
|
||||||
|
static testCallOperatorNo testCallOperator(...);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct hasCallOperator
|
||||||
|
{
|
||||||
|
static const bool value = (sizeof(testCallOperator<T>(0)) == sizeof(testCallOperatorYes));
|
||||||
|
};
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -54,21 +72,6 @@ namespace Internal {
|
|||||||
a QFutureInterface& as its first parameter and returns void.
|
a QFutureInterface& as its first parameter and returns void.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct hasCallOperator
|
|
||||||
{
|
|
||||||
using yes = char;
|
|
||||||
using no = struct { char foo[2]; };
|
|
||||||
|
|
||||||
template<typename C>
|
|
||||||
static yes test(decltype(&C::operator()));
|
|
||||||
|
|
||||||
template<typename C>
|
|
||||||
static no test(...);
|
|
||||||
|
|
||||||
static const bool value = (sizeof(test<T>(0)) == sizeof(yes));
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Function>
|
template <typename Function>
|
||||||
struct resultType;
|
struct resultType;
|
||||||
|
|
||||||
|
@@ -248,35 +248,16 @@ bool Manager::isBuildingDefinition(const QString &id) const
|
|||||||
return m_isBuildingDefinition.contains(id);
|
return m_isBuildingDefinition.contains(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManagerProcessor
|
static const int kMaxProgress = 200;
|
||||||
{
|
|
||||||
public:
|
|
||||||
ManagerProcessor();
|
|
||||||
// TODO: make move-only when we can require MSVC2015
|
|
||||||
|
|
||||||
void operator()(QFutureInterface<Manager::RegisterData> &future);
|
static void processHighlightingFiles(QFutureInterface<Manager::RegisterData> &future,
|
||||||
|
QStringList definitionPaths)
|
||||||
QStringList m_definitionsPaths;
|
|
||||||
static const int kMaxProgress;
|
|
||||||
};
|
|
||||||
|
|
||||||
const int ManagerProcessor::kMaxProgress = 200;
|
|
||||||
|
|
||||||
ManagerProcessor::ManagerProcessor()
|
|
||||||
{
|
|
||||||
const HighlighterSettings &settings = TextEditorSettings::highlighterSettings();
|
|
||||||
m_definitionsPaths.append(settings.definitionFilesPath());
|
|
||||||
if (settings.useFallbackLocation())
|
|
||||||
m_definitionsPaths.append(settings.fallbackDefinitionFilesPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ManagerProcessor::operator()(QFutureInterface<Manager::RegisterData> &future)
|
|
||||||
{
|
{
|
||||||
future.setProgressRange(0, kMaxProgress);
|
future.setProgressRange(0, kMaxProgress);
|
||||||
|
|
||||||
Manager::RegisterData data;
|
Manager::RegisterData data;
|
||||||
// iterate through paths in order, high priority > low priority
|
// iterate through paths in order, high priority > low priority
|
||||||
foreach (const QString &path, m_definitionsPaths) {
|
foreach (const QString &path, definitionPaths) {
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -322,7 +303,13 @@ void Manager::registerHighlightingFiles()
|
|||||||
if (!m_registeringWatcher.isRunning()) {
|
if (!m_registeringWatcher.isRunning()) {
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
QFuture<RegisterData> future = Utils::runAsync(ManagerProcessor());
|
QStringList definitionsPaths;
|
||||||
|
const HighlighterSettings &settings = TextEditorSettings::highlighterSettings();
|
||||||
|
definitionsPaths.append(settings.definitionFilesPath());
|
||||||
|
if (settings.useFallbackLocation())
|
||||||
|
definitionsPaths.append(settings.fallbackDefinitionFilesPath());
|
||||||
|
|
||||||
|
QFuture<RegisterData> future = Utils::runAsync(processHighlightingFiles, definitionsPaths);
|
||||||
m_registeringWatcher.setFuture(future);
|
m_registeringWatcher.setFuture(future);
|
||||||
} else {
|
} else {
|
||||||
m_hasQueuedRegistration = true;
|
m_hasQueuedRegistration = true;
|
||||||
|
@@ -80,6 +80,12 @@ public:
|
|||||||
|
|
||||||
static DefinitionMetaDataPtr parseMetadata(const QFileInfo &fileInfo);
|
static DefinitionMetaDataPtr parseMetadata(const QFileInfo &fileInfo);
|
||||||
|
|
||||||
|
struct RegisterData
|
||||||
|
{
|
||||||
|
QHash<QString, QString> m_idByName;
|
||||||
|
QHash<QString, QString> m_idByMimeType;
|
||||||
|
QHash<QString, DefinitionMetaDataPtr> m_definitionsMetaData;
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
void registerHighlightingFilesFinished();
|
void registerHighlightingFilesFinished();
|
||||||
void downloadAvailableDefinitionsListFinished();
|
void downloadAvailableDefinitionsListFinished();
|
||||||
@@ -100,12 +106,6 @@ private:
|
|||||||
QHash<QString, QSharedPointer<HighlightDefinition> > m_definitions;
|
QHash<QString, QSharedPointer<HighlightDefinition> > m_definitions;
|
||||||
QHash<QString, DefinitionMetaDataPtr> m_availableDefinitions;
|
QHash<QString, DefinitionMetaDataPtr> m_availableDefinitions;
|
||||||
|
|
||||||
struct RegisterData
|
|
||||||
{
|
|
||||||
QHash<QString, QString> m_idByName;
|
|
||||||
QHash<QString, QString> m_idByMimeType;
|
|
||||||
QHash<QString, DefinitionMetaDataPtr> m_definitionsMetaData;
|
|
||||||
};
|
|
||||||
RegisterData m_register;
|
RegisterData m_register;
|
||||||
bool m_hasQueuedRegistration;
|
bool m_hasQueuedRegistration;
|
||||||
QFutureWatcher<RegisterData> m_registeringWatcher;
|
QFutureWatcher<RegisterData> m_registeringWatcher;
|
||||||
|
Reference in New Issue
Block a user