Merge pull request #1242 from whot/wip/janitor

Some ifdef cleanup
This commit is contained in:
Povilas Kanapickas 2021-08-31 04:44:45 +03:00 committed by GitHub
commit 27f7e7ba9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 16 deletions

View File

@ -292,6 +292,8 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list (APPEND libs Wtsapi32 Userenv Wininet comsuppw Shlwapi) list (APPEND libs Wtsapi32 Userenv Wininet comsuppw Shlwapi)
add_definitions ( add_definitions (
/DSYSAPI_WIN32=1
/DWINAPI_MSWINDOWS=1
/DWIN32 /DWIN32
/D_WINDOWS /D_WINDOWS
/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS

View File

@ -133,10 +133,10 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
return true; return true;
} }
bool
ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
#if WINAPI_MSWINDOWS #if WINAPI_MSWINDOWS
bool
ArgParser::parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
if (isArg(i, argc, argv, NULL, "--service")) { if (isArg(i, argc, argv, NULL, "--service")) {
LOG((CLOG_WARN "obsolete argument --service, use barrierd instead.")); LOG((CLOG_WARN "obsolete argument --service, use barrierd instead."));
argsBase.m_shouldExit = true; argsBase.m_shouldExit = true;
@ -153,25 +153,46 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con
} }
return true; return true;
#elif WINAPI_XWINDOWS }
#endif
#if WINAPI_CARBON
bool
ArgParser::parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
// no options for carbon
return false;
}
#endif
#if WINAPI_XWINDOWS
bool
ArgParser::parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
if (isArg(i, argc, argv, "-display", "--display", 1)) { if (isArg(i, argc, argv, "-display", "--display", 1)) {
// use alternative display // use alternative display
argsBase.m_display = argv[++i]; argsBase.m_display = argv[++i];
} }
else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) { else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) {
argsBase.m_disableXInitThreads = true; argsBase.m_disableXInitThreads = true;
} } else {
else {
// option not supported here // option not supported here
return false; return false;
} }
return true; return true;
}
#endif
bool
ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
#if WINAPI_MSWINDOWS
return parseMSWindowsArg(argsBase, argc, argv, i);
#elif WINAPI_CARBON #elif WINAPI_CARBON
// no options for carbon return parseCarbonArg(argsBase, argc, argv, i);
return false; #elif WINAPI_XWINDOWS
return parseXWindowsArg(argsBase, argc, argv, i);
#endif #endif
} }

View File

@ -53,6 +53,9 @@ private:
bool checkUnexpectedArgs(); bool checkUnexpectedArgs();
static ArgsBase& argsBase() { return *m_argsBase; } static ArgsBase& argsBase() { return *m_argsBase; }
bool parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
bool parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
bool parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
private: private:
App* m_app; App* m_app;

View File

@ -18,13 +18,8 @@
#pragma once #pragma once
#if defined(_WIN32) #if HAVE_CONFIG_H
# define SYSAPI_WIN32 1
# define WINAPI_MSWINDOWS 1
#elif HAVE_CONFIG_H
# include "config.h" # include "config.h"
#else
# error "config.h missing"
#endif #endif
// VC++ has built-in sized types // VC++ has built-in sized types