refactor: Fix readability-use-concise-preprocessor-directives

This commit is contained in:
Lars Toenning
2025-10-25 23:04:01 +02:00
parent 7579ce8ba4
commit 707eaf0495
16 changed files with 31 additions and 30 deletions

View File

@@ -48,6 +48,7 @@ Checks: >
cppcoreguidelines-init-variables,
readability-static-accessed-through-instance,
readability-simplify-boolean-expr,
readability-use-concise-preprocessor-directives,
CheckOptions:
- key: readability-identifier-naming.ClassCase

View File

@@ -14,7 +14,7 @@
*/
#ifndef WITH_STATIC
# if defined(BUILD_SWIFT_CORE_LIB)
# ifdef BUILD_SWIFT_CORE_LIB
# define SWIFT_CORE_EXPORT Q_DECL_EXPORT
# else
# define SWIFT_CORE_EXPORT Q_DECL_IMPORT

View File

@@ -13,7 +13,7 @@
* Export a class or function from the library
*/
#ifndef WITH_STATIC
# if defined(BUILD_SWIFT_GUI_LIB)
# ifdef BUILD_SWIFT_GUI_LIB
# define SWIFT_GUI_EXPORT Q_DECL_EXPORT
# else
# define SWIFT_GUI_EXPORT Q_DECL_IMPORT

View File

@@ -3,7 +3,7 @@
#include "joystick.h"
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
# include "win/joystickwindows.h"
#elif defined(Q_OS_LINUX)
# include "linux/joysticklinux.h"
@@ -20,7 +20,7 @@ namespace swift::input
std::unique_ptr<IJoystick> IJoystick::create(QObject *parent)
{
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
std::unique_ptr<IJoystick> ptr(new CJoystickWindows(parent));
#elif defined(Q_OS_LINUX)
std::unique_ptr<IJoystick> ptr(new CJoystickLinux(parent));

View File

@@ -3,7 +3,7 @@
#include "keyboard.h"
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
# include "win/keyboardwindows.h"
#elif defined(Q_OS_LINUX)
# include "linux/keyboardlinux.h"
@@ -19,7 +19,7 @@ namespace swift::input
std::unique_ptr<IKeyboard> IKeyboard::create(QObject *parent)
{
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
std::unique_ptr<IKeyboard> ptr(new CKeyboardWindows(parent));
#elif defined(Q_OS_LINUX)
std::unique_ptr<IKeyboard> ptr(new CKeyboardLinux(parent));

View File

@@ -14,7 +14,7 @@
*/
#ifndef WITH_STATIC
# if defined(BUILD_SWIFT_INPUT_LIB)
# ifdef BUILD_SWIFT_INPUT_LIB
# define SWIFT_INPUT_EXPORT Q_DECL_EXPORT
# else
# define SWIFT_INPUT_EXPORT Q_DECL_IMPORT

View File

@@ -12,7 +12,7 @@
#include "misc/algorithm.h"
#if defined(Q_OS_POSIX)
#ifdef Q_OS_POSIX
# include <errno.h>
# include <stdio.h>
#elif defined(Q_OS_WIN32)
@@ -29,7 +29,7 @@ namespace swift::misc
{
bool ok = true;
{
#if defined(Q_OS_WIN32)
#ifdef Q_OS_WIN32
QNtfsPermissionCheckGuard permissionGuard;
#endif
if ((mode & CAtomicFile::ReadOnly) && !fileInfo.isReadable()) { ok = false; }
@@ -71,7 +71,7 @@ namespace swift::misc
{
if (!isOpen()) { return; }
#if defined(Q_OS_WIN32)
#ifdef Q_OS_WIN32
FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(handle())));
#endif
@@ -118,7 +118,7 @@ namespace swift::misc
36, QChar('0'));
}
#if defined(Q_OS_POSIX)
#ifdef Q_OS_POSIX
void CAtomicFile::replaceOriginal()
{
auto result = ::rename(qPrintable(fileName()), qPrintable(m_originalFilename));

View File

@@ -5,7 +5,7 @@
#include <QtGlobal>
#if defined(Q_OS_WIN32)
#ifdef Q_OS_WIN32
# include <windows.h>
#elif defined(Q_OS_UNIX)
# include <ctime>
@@ -14,7 +14,7 @@
namespace swift::misc
{
#if defined(Q_OS_WIN32)
#ifdef Q_OS_WIN32
static int getCpuTimeMs(const FILETIME &kernelTime, const FILETIME &userTime)
{

View File

@@ -8,7 +8,7 @@
#include <QFile>
#include <QFileInfo>
#if defined(Q_OS_MACOS)
#ifdef Q_OS_MACOS
# include <libproc.h>
#elif defined(Q_OS_WIN)
# ifndef NOMINMAX
@@ -30,7 +30,7 @@ namespace swift::misc
return QStringLiteral("{ %1, %2 }").arg(QString::number(m_pid), m_name);
}
#if defined(Q_OS_LINUX)
#ifdef Q_OS_LINUX
QString CProcessInfo::processNameFromId(qint64 pid)
{
QString path = QFileInfo(QStringLiteral("/proc/%1/exe").arg(pid)).symLinkTarget();

View File

@@ -15,7 +15,7 @@
#include "misc/fileutils.h"
#include "misc/swiftdirectories.h"
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
# include <ShlObj.h>
#endif
@@ -47,7 +47,7 @@ namespace swift::misc::simulation::xplane
return lastLine;
}
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
QString getWindowsLocalAppDataPath()
{
QString result;
@@ -85,7 +85,7 @@ namespace swift::misc::simulation::xplane
{
//! \fixme KB 8/17 we could also use the runtime CBuildConfig decision here, which looks nicer (I personally
//! always try to avoid ifdef)
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
return CFileUtils::appendFilePathsAndFixUnc(getWindowsLocalAppDataPath(), xplaneInstallFile);
#elif defined(Q_OS_LINUX)
static const QString xp(".x-plane");

View File

@@ -12,7 +12,7 @@
#include <QMutexLocker>
#include <QStringBuilder>
#if defined(Q_CC_MSVC)
#ifdef Q_CC_MSVC
# include <Windows.h>
# pragma warning(push)
@@ -33,13 +33,13 @@
namespace swift::misc
{
#if defined(QT_DEBUG)
#ifdef QT_DEBUG
QStringList getStackTrace() { return getStackTraceAlways(); }
#else
QStringList getStackTrace() { return { "No stack trace with release build" }; }
#endif
#if defined(Q_OS_WIN32)
#ifdef Q_OS_WIN32
QStringList getStackTraceAlways()
{
static QMutex mutex;

View File

@@ -13,7 +13,7 @@
* Export a class or function from the library
*/
#ifndef WITH_STATIC
# if defined(BUILD_SWIFT_MISC_LIB)
# ifdef BUILD_SWIFT_MISC_LIB
# define SWIFT_MISC_EXPORT Q_DECL_EXPORT
# else
# define SWIFT_MISC_EXPORT Q_DECL_IMPORT

View File

@@ -13,12 +13,12 @@
# include "crashpad/client/simulate_crash.h"
#endif
#if defined(Q_CC_MSVC)
#ifdef Q_CC_MSVC
# include <Windows.h>
# include <intrin.h>
#endif
#if defined(Q_CC_CLANG)
#ifdef Q_CC_CLANG
# if __has_builtin(__builtin_debugtrap)
# define SWIFT_BUILTIN_DEBUGTRAP __builtin_debugtrap
# elif __has_builtin(__builtin_debugger)
@@ -39,8 +39,8 @@ namespace swift::misc::private_ns
Q_UNUSED(message)
Q_UNUSED(audit)
#if defined(QT_DEBUG)
# if defined(Q_CC_MSVC)
#ifdef QT_DEBUG
# ifdef Q_CC_MSVC
if (!audit || IsDebuggerPresent())
{
__debugbreak();

View File

@@ -14,7 +14,7 @@
*/
#ifndef WITH_STATIC
# if defined(BUILD_SIMULATORPLUGINCOMMON_LIB)
# ifdef BUILD_SIMULATORPLUGINCOMMON_LIB
# define SIMULATORPLUGINCOMMON_EXPORT Q_DECL_EXPORT
# else
# define SIMULATORPLUGINCOMMON_EXPORT Q_DECL_IMPORT

View File

@@ -14,7 +14,7 @@
*/
#ifndef WITH_STATIC
# if defined(BUILD_SWIFT_SOUND_LIB)
# ifdef BUILD_SWIFT_SOUND_LIB
# define SWIFT_SOUND_EXPORT Q_DECL_EXPORT
# else
# define SWIFT_SOUND_EXPORT Q_DECL_IMPORT

View File

@@ -26,7 +26,7 @@
#include "misc/logmessage.h"
#include "misc/threadutils.h"
#if defined(Q_OS_MACOS)
#ifdef Q_OS_MACOS
# include "input/macos/macosinpututils.h"
#endif
@@ -422,7 +422,7 @@ void SwiftGuiStd::verifyPrerequisites()
}
else { msgs.push_back(sGui->getIContextSimulator()->verifyPrerequisites()); }
#if defined(Q_OS_MACOS)
#ifdef Q_OS_MACOS
if (!swift::input::CMacOSInputUtils::hasAccess())
{
// A log message about missing permissions is already emitted when initializing the keyboard.