summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorClemens Wasser <clemens.wasser@gmail.com>2023-06-16 17:47:42 (GMT)
committerClemens Wasser <clemens.wasser@gmail.com>2023-06-22 16:11:45 (GMT)
commit1bb0e59318f8160560d4010b95724de1cba36e7c (patch)
tree41a8d9ae75b2f4cfa535200c2cedb0920e21515e /Source
parent64821d8a267585c0d4d9350f162690c2c518860b (diff)
downloadCMake-1bb0e59318f8160560d4010b95724de1cba36e7c.zip
CMake-1bb0e59318f8160560d4010b95724de1cba36e7c.tar.gz
CMake-1bb0e59318f8160560d4010b95724de1cba36e7c.tar.bz2
codecvt: Extrace codecvt::Encoding to remove codecvt includes
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDebuggerVariablesHelper.cxx14
-rw-r--r--Source/cmGeneratedFileStream.cxx6
-rw-r--r--Source/cmGeneratedFileStream.h10
-rw-r--r--Source/cmGlobalGenerator.cxx4
-rw-r--r--Source/cmGlobalGenerator.h7
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h7
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx12
-rw-r--r--Source/cmGlobalNinjaGenerator.h6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h6
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
-rw-r--r--Source/cm_codecvt.cxx12
-rw-r--r--Source/cm_codecvt.hxx13
-rw-r--r--Source/cm_codecvt_Encoding.hxx12
13 files changed, 62 insertions, 55 deletions
diff --git a/Source/cmDebuggerVariablesHelper.cxx b/Source/cmDebuggerVariablesHelper.cxx
index 1322b20..b2e85f2 100644
--- a/Source/cmDebuggerVariablesHelper.cxx
+++ b/Source/cmDebuggerVariablesHelper.cxx
@@ -10,7 +10,7 @@
#include <map>
#include <sstream>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmDebuggerStackFrame.h"
#include "cmDebuggerVariables.h"
@@ -578,17 +578,17 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
return {};
}
- auto makeFileEncodingString = [](codecvt::Encoding encoding) {
+ auto makeFileEncodingString = [](codecvt_Encoding encoding) {
switch (encoding) {
- case codecvt::Encoding::None:
+ case codecvt_Encoding::None:
return "None";
- case codecvt::Encoding::UTF8:
+ case codecvt_Encoding::UTF8:
return "UTF8";
- case codecvt::Encoding::UTF8_WITH_BOM:
+ case codecvt_Encoding::UTF8_WITH_BOM:
return "UTF8_WITH_BOM";
- case codecvt::Encoding::ANSI:
+ case codecvt_Encoding::ANSI:
return "ANSI";
- case codecvt::Encoding::ConsoleOutput:
+ case codecvt_Encoding::ConsoleOutput:
return "ConsoleOutput";
default:
return "Unknown";
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 133bf5f..e669f68 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -16,7 +16,7 @@
cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding)
{
#ifndef CMAKE_BOOTSTRAP
- if (encoding != codecvt::None) {
+ if (encoding != codecvt_Encoding::None) {
this->imbue(std::locale(this->getloc(), new codecvt(encoding)));
}
#else
@@ -35,13 +35,13 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name,
cmSystemTools::ReportLastSystemError("");
}
#ifndef CMAKE_BOOTSTRAP
- if (encoding != codecvt::None) {
+ if (encoding != codecvt_Encoding::None) {
this->imbue(std::locale(this->getloc(), new codecvt(encoding)));
}
#else
static_cast<void>(encoding);
#endif
- if (encoding == codecvt::UTF8_WITH_BOM) {
+ if (encoding == codecvt_Encoding::UTF8_WITH_BOM) {
// Write the BOM encoding header into the file
char magic[] = { static_cast<char>(0xEF), static_cast<char>(0xBB),
static_cast<char>(0xBF) };
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index bfc121f..a26616d 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -8,7 +8,7 @@
#include "cmsys/FStream.hxx"
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
// This is the first base class of cmGeneratedFileStream. It will be
// created before and destroyed after the ofstream portion and can
@@ -77,13 +77,13 @@ class cmGeneratedFileStream
{
public:
using Stream = cmsys::ofstream;
- using Encoding = codecvt::Encoding;
+ using Encoding = codecvt_Encoding;
/**
* This constructor prepares a default stream. The open method must
* be used before writing to the stream.
*/
- cmGeneratedFileStream(Encoding encoding = codecvt::None);
+ cmGeneratedFileStream(codecvt_Encoding encoding = codecvt_Encoding::None);
/**
* This constructor takes the name of the file to be generated. It
@@ -92,7 +92,7 @@ public:
* second argument is set to true.
*/
cmGeneratedFileStream(std::string const& name, bool quiet = false,
- Encoding encoding = codecvt::None);
+ codecvt_Encoding encoding = codecvt_Encoding::None);
/**
* The destructor checks the stream status to be sure the temporary
@@ -151,5 +151,5 @@ public:
* Write a specific string using an alternate encoding.
* Afterward, the original encoding is restored.
*/
- void WriteAltEncoding(std::string const& data, Encoding encoding);
+ void WriteAltEncoding(std::string const& data, codecvt_Encoding encoding);
};
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5175aae..e334b96 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -142,6 +142,10 @@ cmGlobalGenerator::~cmGlobalGenerator()
{
this->ClearGeneratorMembers();
}
+codecvt_Encoding cmGlobalGenerator::GetMakefileEncoding() const
+{
+ return codecvt_Encoding::None;
+}
#if !defined(CMAKE_BOOTSTRAP)
Json::Value cmGlobalGenerator::GetJson() const
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 9aefaff..bc59514 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -19,7 +19,7 @@
#include <cmext/algorithm>
#include <cmext/string_view>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmBuildOptions.h"
#include "cmCustomCommandLines.h"
@@ -120,10 +120,7 @@ public:
}
/** Get encoding used by generator for makefile files */
- virtual codecvt::Encoding GetMakefileEncoding() const
- {
- return codecvt::None;
- }
+ virtual codecvt_Encoding GetMakefileEncoding() const;
#if !defined(CMAKE_BOOTSTRAP)
/** Get a JSON object describing the generator. */
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 436ebca..bc8fc34 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -7,7 +7,7 @@
#include <string>
#include <vector>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmGlobalGeneratorFactory.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -38,9 +38,10 @@ public:
static std::string GetActualName() { return "NMake Makefiles"; }
/** Get encoding used by generator for makefile files */
- codecvt::Encoding GetMakefileEncoding() const override
+ codecvt_Encoding GetMakefileEncoding() const override
{
- return this->NMakeSupportsUTF8 ? codecvt::UTF8_WITH_BOM : codecvt::ANSI;
+ return this->NMakeSupportsUTF8 ? codecvt_Encoding::UTF8_WITH_BOM
+ : codecvt_Encoding::ANSI;
}
/** Get the documentation entry for this generator. */
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index e20f157..65851f3 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -566,7 +566,7 @@ std::unique_ptr<cmLocalGenerator> cmGlobalNinjaGenerator::CreateLocalGenerator(
cm::make_unique<cmLocalNinjaGenerator>(this, mf));
}
-codecvt::Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const
+codecvt_Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const
{
return this->NinjaExpectedEncoding;
}
@@ -799,7 +799,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
if (this->NinjaSupportsCodePage) {
this->CheckNinjaCodePage();
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
#endif
}
@@ -830,9 +830,9 @@ void cmGlobalNinjaGenerator::CheckNinjaCodePage()
lineView.substr(cmStrLen("Build file encoding: "));
if (encoding == "UTF-8") {
// Ninja expects UTF-8. We use that internally. No conversion needed.
- this->NinjaExpectedEncoding = codecvt::None;
+ this->NinjaExpectedEncoding = codecvt_Encoding::None;
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
found = true;
break;
@@ -842,10 +842,10 @@ void cmGlobalNinjaGenerator::CheckNinjaCodePage()
this->GetCMakeInstance()->IssueMessage(
MessageType::WARNING,
"Could not determine Ninja's code page, defaulting to UTF-8");
- this->NinjaExpectedEncoding = codecvt::None;
+ this->NinjaExpectedEncoding = codecvt_Encoding::None;
}
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index bfbe57f..95d64e3 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -16,7 +16,7 @@
#include <cm/optional>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmBuildOptions.h"
#include "cmGeneratedFileStream.h"
@@ -192,7 +192,7 @@ public:
bool IsNinja() const override { return true; }
/** Get encoding used by generator for ninja files */
- codecvt::Encoding GetMakefileEncoding() const override;
+ codecvt_Encoding GetMakefileEncoding() const override;
static cmDocumentationEntry GetDocumentation();
@@ -590,7 +590,7 @@ private:
bool NinjaSupportsMetadataOnRegeneration = false;
bool NinjaSupportsCodePage = false;
- codecvt::Encoding NinjaExpectedEncoding = codecvt::None;
+ codecvt_Encoding NinjaExpectedEncoding = codecvt_Encoding::None;
bool DiagnosedCxxModuleNinjaSupport = false;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 3008c18..7d5b703 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmGlobalGenerator.h"
#include "cmTargetDepend.h"
@@ -119,9 +119,9 @@ public:
/** Get encoding used by generator for generated source files
*/
- codecvt::Encoding GetMakefileEncoding() const override
+ codecvt_Encoding GetMakefileEncoding() const override
{
- return codecvt::ANSI;
+ return codecvt_Encoding::ANSI;
}
class TargetSet : public std::set<cmGeneratorTarget const*>
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5f27856..1dd48b3 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -17,7 +17,7 @@
#include <cmext/algorithm>
#include <cmext/string_view>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
@@ -2129,12 +2129,12 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
// FIXME: Find a better way to determine the response file encoding,
// perhaps using tool-specific platform information variables.
// For now, use the makefile encoding as a heuristic.
- codecvt::Encoding responseEncoding =
+ codecvt_Encoding responseEncoding =
this->GlobalGenerator->GetMakefileEncoding();
// Non-MSVC tooling doesn't understand BOM encoded files.
- if (responseEncoding == codecvt::UTF8_WITH_BOM &&
+ if (responseEncoding == codecvt_Encoding::UTF8_WITH_BOM &&
(language == "CUDA" || !this->Makefile->IsOn("MSVC"))) {
- responseEncoding = codecvt::UTF8;
+ responseEncoding = codecvt_Encoding::UTF8;
}
// Create the response file.
diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx
index 12877b8..7b3349b 100644
--- a/Source/cm_codecvt.cxx
+++ b/Source/cm_codecvt.cxx
@@ -13,19 +13,19 @@
# include "cm_utf8.h"
#endif
-codecvt::codecvt(Encoding e)
+codecvt::codecvt(codecvt_Encoding e)
#if defined(_WIN32)
: m_codepage(0)
#endif
{
switch (e) {
- case codecvt::ConsoleOutput:
+ case codecvt_Encoding::ConsoleOutput:
#if defined(_WIN32)
m_noconv = false;
m_codepage = GetConsoleOutputCP();
break;
#endif
- case codecvt::ANSI:
+ case codecvt_Encoding::ANSI:
#if defined(_WIN32)
m_noconv = false;
m_codepage = CP_ACP;
@@ -33,10 +33,10 @@ codecvt::codecvt(Encoding e)
#endif
// We don't know which ANSI encoding to use for other platforms than
// Windows so we don't do any conversion there
- case codecvt::UTF8:
- case codecvt::UTF8_WITH_BOM:
+ case codecvt_Encoding::UTF8:
+ case codecvt_Encoding::UTF8_WITH_BOM:
// Assume internal encoding is UTF-8
- case codecvt::None:
+ case codecvt_Encoding::None:
// No encoding
default:
this->m_noconv = true;
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index f628de7..eb98e98 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -7,21 +7,14 @@
#include <cwchar>
#include <locale>
+#include "cm_codecvt_Encoding.hxx"
+
class codecvt : public std::codecvt<char, char, mbstate_t>
{
public:
- enum Encoding
- {
- None,
- UTF8,
- UTF8_WITH_BOM,
- ANSI,
- ConsoleOutput,
- };
-
#ifndef CMAKE_BOOTSTRAP
- codecvt(Encoding e);
+ codecvt(codecvt_Encoding e);
protected:
~codecvt() override;
diff --git a/Source/cm_codecvt_Encoding.hxx b/Source/cm_codecvt_Encoding.hxx
new file mode 100644
index 0000000..b91ad8f
--- /dev/null
+++ b/Source/cm_codecvt_Encoding.hxx
@@ -0,0 +1,12 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+enum class codecvt_Encoding
+{
+ None,
+ UTF8,
+ UTF8_WITH_BOM,
+ ANSI,
+ ConsoleOutput,
+};