summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-30 13:10:19 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-30 13:10:27 (GMT)
commitc30f9b1cdefc2fa26d89bc692001a4f1050f6038 (patch)
tree2c862b3be88b4b600f6ac515d4c76fb039c8df2f /Source/cmSystemTools.cxx
parentbcec7d0778eb87ea58d720d9e20710dc2cdfdab6 (diff)
parent8c92db829b41243790c7dcc5300227f591a727a8 (diff)
downloadCMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.zip
CMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.tar.gz
CMake-c30f9b1cdefc2fa26d89bc692001a4f1050f6038.tar.bz2
Merge topic 'functional-callbacks'
8c92db829b MessageCallback: Remove unused bool& argument bcee24aecc Use `std::function` for callbacks Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: vvs31415 <vstakhovsky@fastmail.com> Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de> Merge-request: !2872
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx47
1 files changed, 21 insertions, 26 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 9c4afec..a9cf0c6 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -76,6 +76,15 @@
# include <malloc.h> /* for malloc/free on QNX */
#endif
+namespace {
+
+cmSystemTools::InterruptCallback s_InterruptCallback;
+cmSystemTools::MessageCallback s_MessageCallback;
+cmSystemTools::OutputCallback s_StderrCallback;
+cmSystemTools::OutputCallback s_StdoutCallback;
+
+} // namespace
+
static bool cm_isspace(char c)
{
return ((c & 0x80) == 0) && isspace(c);
@@ -161,15 +170,6 @@ bool cmSystemTools::s_FatalErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;
-cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
-cmSystemTools::OutputCallback cmSystemTools::s_StdoutCallback;
-cmSystemTools::OutputCallback cmSystemTools::s_StderrCallback;
-cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback;
-void* cmSystemTools::s_MessageCallbackClientData;
-void* cmSystemTools::s_StdoutCallbackClientData;
-void* cmSystemTools::s_StderrCallbackClientData;
-void* cmSystemTools::s_InterruptCallbackClientData;
-
// replace replace with with as many times as it shows up in source.
// write the result into source.
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -277,42 +277,38 @@ void cmSystemTools::Error(const std::string& m)
cmSystemTools::Message(message, "Error");
}
-void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
+void cmSystemTools::SetInterruptCallback(InterruptCallback f)
{
- s_InterruptCallback = f;
- s_InterruptCallbackClientData = clientData;
+ s_InterruptCallback = std::move(f);
}
bool cmSystemTools::GetInterruptFlag()
{
if (s_InterruptCallback) {
- return (*s_InterruptCallback)(s_InterruptCallbackClientData);
+ return s_InterruptCallback();
}
return false;
}
-void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData)
+void cmSystemTools::SetMessageCallback(MessageCallback f)
{
- s_MessageCallback = f;
- s_MessageCallbackClientData = clientData;
+ s_MessageCallback = std::move(f);
}
-void cmSystemTools::SetStdoutCallback(OutputCallback f, void* clientData)
+void cmSystemTools::SetStdoutCallback(OutputCallback f)
{
- s_StdoutCallback = f;
- s_StdoutCallbackClientData = clientData;
+ s_StdoutCallback = std::move(f);
}
-void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
+void cmSystemTools::SetStderrCallback(OutputCallback f)
{
- s_StderrCallback = f;
- s_StderrCallbackClientData = clientData;
+ s_StderrCallback = std::move(f);
}
void cmSystemTools::Stderr(const std::string& s)
{
if (s_StderrCallback) {
- (*s_StderrCallback)(s.c_str(), s.length(), s_StderrCallbackClientData);
+ s_StderrCallback(s.c_str(), s.length());
} else {
std::cerr << s << std::flush;
}
@@ -321,7 +317,7 @@ void cmSystemTools::Stderr(const std::string& s)
void cmSystemTools::Stdout(const std::string& s)
{
if (s_StdoutCallback) {
- (*s_StdoutCallback)(s.c_str(), s.length(), s_StdoutCallbackClientData);
+ s_StdoutCallback(s.c_str(), s.length());
} else {
std::cout << s << std::flush;
}
@@ -333,8 +329,7 @@ void cmSystemTools::Message(const char* m1, const char* title)
return;
}
if (s_MessageCallback) {
- (*s_MessageCallback)(m1, title, s_DisableMessages,
- s_MessageCallbackClientData);
+ s_MessageCallback(m1, title);
return;
}
std::cerr << m1 << std::endl << std::flush;