From ce6ea7c927b9f80f219a7783ce725bea4c24091f Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 19 Mar 2021 10:40:03 -0400 Subject: Refactor: Move some common code into separate file This code is going to be needed by both cmCMakePresetsFile and cmCMakePresetsFileReadJSON when the upcoming condition types are created. Move it into a header file. --- Source/CMakeLists.txt | 1 + Source/cmCMakePresetsFile.cxx | 20 +++----------------- Source/cmCMakePresetsFileInternal.h | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 Source/cmCMakePresetsFileInternal.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8b11a53..938745c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -198,6 +198,7 @@ set(SRCS cmCMakePath.cxx cmCMakePresetsFile.cxx cmCMakePresetsFile.h + cmCMakePresetsFileInternal.h cmCMakePresetsFileReadJSON.cxx cmCommandArgumentParserHelper.cxx cmCommonTargetGenerator.cxx diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index 1d95953..c0b0981 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -9,16 +9,10 @@ #include #include +#include "cmCMakePresetsFileInternal.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#define CHECK_OK(expr) \ - { \ - auto _result = expr; \ - if (_result != ReadFileResult::READ_OK) \ - return _result; \ - } - #define CHECK_EXPAND(out, field, expanders, version) \ { \ switch (ExpandMacros(field, expanders, version)) { \ @@ -44,6 +38,8 @@ using ReadFileResult = cmCMakePresetsFile::ReadFileResult; using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; using BuildPreset = cmCMakePresetsFile::BuildPreset; using TestPreset = cmCMakePresetsFile::TestPreset; +using ExpandMacroResult = cmCMakePresetsFileInternal::ExpandMacroResult; +using MacroExpander = cmCMakePresetsFileInternal::MacroExpander; void InheritString(std::string& child, const std::string& parent) { @@ -166,16 +162,6 @@ bool IsValidMacroNamespace(const std::string& str) [&str](const char* prefix) -> bool { return str == prefix; }); } -enum class ExpandMacroResult -{ - Ok, - Ignore, - Error, -}; - -using MacroExpander = std::function; - ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, const std::vector& macroExpanders, int version); diff --git a/Source/cmCMakePresetsFileInternal.h b/Source/cmCMakePresetsFileInternal.h new file mode 100644 index 0000000..f05b8ce --- /dev/null +++ b/Source/cmCMakePresetsFileInternal.h @@ -0,0 +1,22 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCMakePresetsFile.h" + +#define CHECK_OK(expr) \ + { \ + auto _result = expr; \ + if (_result != ReadFileResult::READ_OK) \ + return _result; \ + } + +namespace cmCMakePresetsFileInternal { +enum class ExpandMacroResult +{ + Ok, + Ignore, + Error, +}; + +using MacroExpander = std::function; +} -- cgit v0.12