mirror of
https://github.com/marzer/tomlplusplus.git
synced 2024-10-06 06:49:43 +00:00
minor refactor
This commit is contained in:
parent
31cf6efbb9
commit
6e7942788d
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
@ -43,7 +43,7 @@ jobs:
|
||||
CXX_LD=$linker meson setup build --buildtype=debug -Dcompile_library=${{ matrix.compile }} -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false -Dasan_examples=true
|
||||
|
||||
- name: Build
|
||||
run: meson compile -C build
|
||||
run: meson compile -C build --jobs -1
|
||||
|
||||
- name: Test
|
||||
run: meson test -C build --verbose
|
||||
@ -76,7 +76,7 @@ jobs:
|
||||
run: meson setup --vsenv -Dcompile_library=${{ matrix.compile }} -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false build
|
||||
|
||||
- name: Build
|
||||
run: meson compile -C build
|
||||
run: meson compile -C build --jobs -1
|
||||
|
||||
- name: Test
|
||||
run: meson test -C build --verbose
|
||||
|
@ -106,7 +106,7 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
elems_ = std::move(rhs.elems_);
|
||||
elems_ = std::move(rhs.elems_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) // because, honestly, what the fuck macOS & MinGW??
|
||||
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define TOML_OVERALIGNED
|
||||
#else
|
||||
#define TOML_OVERALIGNED alignas(32)
|
||||
@ -3745,10 +3745,7 @@ TOML_ANON_NAMESPACE_START
|
||||
{
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_PARSE_FILE_ERROR(msg, path) \
|
||||
throw parse_error \
|
||||
{ \
|
||||
msg, source_position{}, std::make_shared<const std::string>(std::move(path)) \
|
||||
}
|
||||
throw parse_error{ msg, source_position{}, std::make_shared<const std::string>(std::move(path)) }
|
||||
#else
|
||||
#define TOML_PARSE_FILE_ERROR(msg, path) \
|
||||
return parse_result \
|
||||
|
@ -100,8 +100,8 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
map_ = std::move(rhs.map_);
|
||||
inline_ = rhs.inline_;
|
||||
map_ = std::move(rhs.map_);
|
||||
inline_ = rhs.inline_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -316,8 +316,8 @@ TOML_NAMESPACE_START
|
||||
value& operator=(const value& rhs) noexcept
|
||||
{
|
||||
node::operator=(rhs);
|
||||
val_ = rhs.val_;
|
||||
flags_ = rhs.flags_;
|
||||
val_ = rhs.val_;
|
||||
flags_ = rhs.flags_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -327,8 +327,8 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
val_ = std::move(rhs.val_);
|
||||
flags_ = rhs.flags_;
|
||||
val_ = std::move(rhs.val_);
|
||||
flags_ = rhs.flags_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
@ -107,14 +107,14 @@ TEST_CASE("formatters")
|
||||
const auto data_time = toml::time{ 20, 33, 0 };
|
||||
const auto data = toml::table{
|
||||
{ "integers"sv,
|
||||
toml::table{ { "zero"sv, 0 },
|
||||
toml::table{ { "zero"sv, 0 },
|
||||
{ "one"sv, 1 },
|
||||
{ "dec"sv, 10 },
|
||||
{ "bin"sv, 10, toml::value_flags::format_as_binary },
|
||||
{ "oct"sv, 10, toml::value_flags::format_as_octal },
|
||||
{ "hex"sv, 10, toml::value_flags::format_as_hexadecimal } } },
|
||||
{ "floats"sv,
|
||||
toml::table{ { "pos_zero"sv, +0.0 },
|
||||
toml::table{ { "pos_zero"sv, +0.0 },
|
||||
{ "neg_zero"sv, -0.0 },
|
||||
{ "one"sv, 1.0 },
|
||||
{ "pos_inf"sv, +std::numeric_limits<double>::infinity() },
|
||||
@ -125,27 +125,27 @@ TEST_CASE("formatters")
|
||||
} },
|
||||
|
||||
{ "dates and times"sv,
|
||||
toml::table{
|
||||
toml::table{
|
||||
|
||||
{ "dates"sv, toml::table{ { "val"sv, data_date } } },
|
||||
|
||||
{ "times"sv, toml::table{ { "val"sv, data_time } } },
|
||||
|
||||
{ "date-times"sv,
|
||||
toml::table{
|
||||
toml::table{
|
||||
|
||||
{ "local"sv, toml::table{ { "val"sv, toml::date_time{ data_date, data_time } } } },
|
||||
{ "offset"sv,
|
||||
toml::table{
|
||||
toml::table{
|
||||
{ "val"sv, toml::date_time{ data_date, data_time, toml::time_offset{} } } } } } } } },
|
||||
|
||||
{ "bools"sv,
|
||||
toml::table{ { "true"sv, true }, //
|
||||
toml::table{ { "true"sv, true }, //
|
||||
{ "false"sv, false } } },
|
||||
|
||||
{
|
||||
"strings"sv,
|
||||
toml::array{ R"()"sv,
|
||||
"strings"sv,
|
||||
toml::array{ R"()"sv,
|
||||
R"(string)"sv,
|
||||
R"(string with a single quote in it: ')"sv,
|
||||
R"(string with a double quote in it: ")"sv,
|
||||
@ -154,7 +154,7 @@ TEST_CASE("formatters")
|
||||
},
|
||||
|
||||
{ "a"sv,
|
||||
toml::table{ { "val", true },
|
||||
toml::table{ { "val", true },
|
||||
{ "b"sv, toml::table{ { "val", true }, { "c"sv, toml::table{ { "val", true } } } } } } }
|
||||
|
||||
};
|
||||
|
@ -84,8 +84,8 @@ namespace toml
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char*, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char* const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::string, true);
|
||||
@ -97,8 +97,8 @@ namespace toml
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char8_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(char (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t*, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const char8_t* const, true);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::u8string, true);
|
||||
@ -110,8 +110,8 @@ namespace toml
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t (&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t(&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(wchar_t (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t (&&)[2], false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t*, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(const wchar_t* const, false);
|
||||
CHECK_CAN_REPRESENT_NATIVE(std::wstring, !!TOML_ENABLE_WINDOWS_COMPAT);
|
||||
@ -196,14 +196,14 @@ namespace toml
|
||||
CHECK_VALUE_OR(char* const, const char*);
|
||||
CHECK_VALUE_OR(char[2], const char*);
|
||||
CHECK_VALUE_OR(char (&)[2], const char*);
|
||||
CHECK_VALUE_OR(char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR(char (&&)[2], const char*);
|
||||
CHECK_VALUE_OR(const char*, const char*);
|
||||
CHECK_VALUE_OR(const char*&, const char*);
|
||||
CHECK_VALUE_OR(const char*&&, const char*);
|
||||
CHECK_VALUE_OR(const char* const, const char*);
|
||||
CHECK_VALUE_OR(const char[2], const char*);
|
||||
CHECK_VALUE_OR(const char (&)[2], const char*);
|
||||
CHECK_VALUE_OR(const char(&&)[2], const char*);
|
||||
CHECK_VALUE_OR(const char (&&)[2], const char*);
|
||||
CHECK_VALUE_OR(std::string_view, std::string_view);
|
||||
CHECK_VALUE_OR(std::string_view&, std::string_view);
|
||||
CHECK_VALUE_OR(std::string_view&&, std::string_view);
|
||||
@ -223,14 +223,14 @@ namespace toml
|
||||
CHECK_VALUE_OR(char8_t* const, const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t (&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(char8_t (&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*&, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t*&&, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t* const, const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t (&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t(&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(const char8_t (&&)[2], const char8_t*);
|
||||
CHECK_VALUE_OR(std::u8string_view, std::u8string_view);
|
||||
CHECK_VALUE_OR(std::u8string_view&, std::u8string_view);
|
||||
CHECK_VALUE_OR(std::u8string_view&&, std::u8string_view);
|
||||
@ -251,14 +251,14 @@ namespace toml
|
||||
CHECK_VALUE_OR(wchar_t* const, std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t (&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(wchar_t (&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*&, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t*&&, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t* const, std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t (&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t(&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(const wchar_t (&&)[2], std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view&, std::wstring);
|
||||
CHECK_VALUE_OR(std::wstring_view&&, std::wstring);
|
||||
|
@ -86,7 +86,7 @@ exception_modes = [ true, false ]
|
||||
unreleased_feature_modes = [ false, true ]
|
||||
cpp20_modes = [ false, true ]
|
||||
test_executables = []
|
||||
counter = 0
|
||||
test_counter = 0
|
||||
test_base_args = []
|
||||
test_base_args += universal_args
|
||||
test_base_args += devel_args
|
||||
@ -104,19 +104,76 @@ foreach cpp20 : cpp20_modes
|
||||
continue
|
||||
endif
|
||||
foreach exceptions : exception_modes
|
||||
if (not exceptions) and get_option('compile_library')
|
||||
|
||||
# skip this target if exceptions are disabled and we're compiling the library;
|
||||
# disabling exceptions requires header-only mode here
|
||||
if not exceptions and get_option('compile_library')
|
||||
continue
|
||||
endif
|
||||
|
||||
# skip this target if we've disabled exceptions and enabled fast math, because both are already tested
|
||||
# separately and don't interact in any way meaningful enough to warrant a combined permutation
|
||||
if not exceptions and fast_math
|
||||
continue
|
||||
endif
|
||||
|
||||
# ... same for 'unreleased features' and fast math
|
||||
if unrel and fast_math
|
||||
continue
|
||||
endif
|
||||
|
||||
test_name = ''
|
||||
test_overrides = []
|
||||
test_overrides += overrides
|
||||
test_args = []
|
||||
test_args += test_base_args
|
||||
|
||||
single_header = (counter % 2 == 1)
|
||||
tl_optional = (counter % 4 == 2 and exceptions and not get_option('compile_library') and has_tl_optional)
|
||||
address_sanitizer = (is_clang and not (single_header or tl_optional or fast_math)) and get_option('asan_tests')
|
||||
ub_sanitizer = (is_clang and not (single_header or tl_optional or fast_math)) and get_option('ubsan_tests')
|
||||
# use the single-header version for some tests to ensure it is the same (no header generation failures)
|
||||
single_header_conditions = [
|
||||
test_counter % 2 == 1,
|
||||
not get_option('compile_library')
|
||||
]
|
||||
single_header = true
|
||||
foreach cond : single_header_conditions
|
||||
single_header = single_header and cond
|
||||
endforeach
|
||||
|
||||
# use tl::optional to test that the TOML_OPTIONAL_TYPE config option works as advertised
|
||||
tl_optional_conditions = [
|
||||
test_counter % 3 == 2,
|
||||
not get_option('compile_library'),
|
||||
exceptions # requires exceptions in its API
|
||||
]
|
||||
tl_optional = true
|
||||
foreach cond : tl_optional_conditions
|
||||
tl_optional = tl_optional and cond
|
||||
endforeach
|
||||
|
||||
# use asan in the tests
|
||||
address_sanitizer_conditions = [
|
||||
get_option('asan_tests'),
|
||||
is_clang,
|
||||
not tl_optional,
|
||||
not fast_math,
|
||||
not get_option('compile_library')
|
||||
]
|
||||
address_sanitizer = true
|
||||
foreach cond : address_sanitizer_conditions
|
||||
address_sanitizer = address_sanitizer and cond
|
||||
endforeach
|
||||
|
||||
# use ubsan in the tests
|
||||
ub_sanitizer_conditions = [
|
||||
get_option('ubsan_tests'),
|
||||
is_clang,
|
||||
not tl_optional,
|
||||
not fast_math,
|
||||
not get_option('compile_library')
|
||||
]
|
||||
ub_sanitizer = true
|
||||
foreach cond : ub_sanitizer_conditions
|
||||
ub_sanitizer = ub_sanitizer and cond
|
||||
endforeach
|
||||
|
||||
if cpp20
|
||||
test_name = 'cpp20'
|
||||
@ -185,10 +242,13 @@ foreach cpp20 : cpp20_modes
|
||||
if single_header
|
||||
test_args += '-DUSE_SINGLE_HEADER=1'
|
||||
endif
|
||||
if tl_optional
|
||||
test_args += '-DUSE_TARTANLLAMA_OPTIONAL=1'
|
||||
test_name = test_name + '_tlopt'
|
||||
endif
|
||||
|
||||
# uncomment this bit to see which tests are using tl-optional
|
||||
# (off by default because it's not super meaningful - tl-optional is itself very thorougly tested)
|
||||
# if tl_optional
|
||||
# test_args += '-DUSE_TARTANLLAMA_OPTIONAL=1'
|
||||
# test_name = test_name + '_tlopt'
|
||||
# endif
|
||||
|
||||
test_executables += [[
|
||||
test_name,
|
||||
@ -201,7 +261,7 @@ foreach cpp20 : cpp20_modes
|
||||
)
|
||||
]]
|
||||
|
||||
counter = counter + 1
|
||||
test_counter = test_counter + 1
|
||||
|
||||
endforeach # exceptions
|
||||
endforeach # fast_math
|
||||
|
@ -90,6 +90,8 @@
|
||||
<None Include=".github\ISSUE_TEMPLATE\feature_request.md" />
|
||||
<None Include=".github\ISSUE_TEMPLATE\spec_bug_report.md" />
|
||||
<None Include=".github\pull_request_template.md" />
|
||||
<None Include=".github\workflows\ci.yaml" />
|
||||
<None Include=".github\workflows\gh-pages.yaml" />
|
||||
<None Include=".gitignore" />
|
||||
<None Include=".runsettings" />
|
||||
<None Include="CHANGELOG.md" />
|
||||
|
@ -223,6 +223,12 @@
|
||||
<None Include="include\meson.build">
|
||||
<Filter>include</Filter>
|
||||
</None>
|
||||
<None Include=".github\workflows\ci.yaml">
|
||||
<Filter>.github\workflows</Filter>
|
||||
</None>
|
||||
<None Include=".github\workflows\gh-pages.yaml">
|
||||
<Filter>.github\workflows</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include=".circleci">
|
||||
@ -252,6 +258,9 @@
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{5ae94dae-1dce-4522-a33a-230bdb075921}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include=".github\workflows">
|
||||
<UniqueIdentifier>{f9731b43-6c33-4209-9e53-e65af54f80c4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="toml++.natvis" />
|
||||
|
55
toml.hpp
55
toml.hpp
@ -842,6 +842,8 @@
|
||||
#define TOML_UINT128 __uint128_t
|
||||
#endif
|
||||
|
||||
//******** impl/version.h ********************************************************************************************
|
||||
|
||||
#define TOML_LIB_MAJOR 3
|
||||
#define TOML_LIB_MINOR 0
|
||||
#define TOML_LIB_PATCH 1
|
||||
@ -850,6 +852,8 @@
|
||||
#define TOML_LANG_MINOR 0
|
||||
#define TOML_LANG_PATCH 0
|
||||
|
||||
//******** impl/preprocessor.h ***************************************************************************************
|
||||
|
||||
#define TOML_LIB_SINGLE_HEADER 1
|
||||
|
||||
#define TOML_MAKE_VERSION(major, minor, patch) \
|
||||
@ -2602,11 +2606,14 @@ TOML_NAMESPACE_START
|
||||
}
|
||||
TOML_NAMESPACE_END;
|
||||
|
||||
//******** impl/node.h ***********************************************************************************************
|
||||
//******** impl/std_utility.h ****************************************************************************************
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#include <utility>
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/node.h ***********************************************************************************************
|
||||
|
||||
TOML_PUSH_WARNINGS;
|
||||
#ifdef _MSC_VER
|
||||
#pragma push_macro("min")
|
||||
@ -3203,13 +3210,21 @@ TOML_IMPL_NAMESPACE_END;
|
||||
#endif
|
||||
TOML_POP_WARNINGS;
|
||||
|
||||
//******** impl/node_view.h ******************************************************************************************
|
||||
//******** impl/std_vector.h *****************************************************************************************
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/std_initializer_list.h *******************************************************************************
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#include <initializer_list>
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/node_view.h ******************************************************************************************
|
||||
|
||||
TOML_PUSH_WARNINGS;
|
||||
#ifdef _MSC_VER
|
||||
#pragma push_macro("min")
|
||||
@ -3989,8 +4004,8 @@ TOML_NAMESPACE_START
|
||||
value& operator=(const value& rhs) noexcept
|
||||
{
|
||||
node::operator=(rhs);
|
||||
val_ = rhs.val_;
|
||||
flags_ = rhs.flags_;
|
||||
val_ = rhs.val_;
|
||||
flags_ = rhs.flags_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -3999,8 +4014,8 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
val_ = std::move(rhs.val_);
|
||||
flags_ = rhs.flags_;
|
||||
val_ = std::move(rhs.val_);
|
||||
flags_ = rhs.flags_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -6106,12 +6121,15 @@ TOML_NAMESPACE_END;
|
||||
#endif
|
||||
TOML_POP_WARNINGS;
|
||||
|
||||
//******** impl/table.h **********************************************************************************************
|
||||
//******** impl/std_map.h ********************************************************************************************
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#include <map>
|
||||
#include <iterator>
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/table.h **********************************************************************************************
|
||||
|
||||
TOML_PUSH_WARNINGS;
|
||||
#ifdef _MSC_VER
|
||||
#pragma push_macro("min")
|
||||
@ -8156,11 +8174,16 @@ TOML_POP_WARNINGS;
|
||||
|
||||
#if TOML_ENABLE_PARSER
|
||||
|
||||
//******** impl/std_except.h *****************************************************************************************
|
||||
|
||||
TOML_DISABLE_WARNINGS;
|
||||
#if TOML_EXCEPTIONS
|
||||
#include <stdexcept>
|
||||
#endif
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/parse_error.h ****************************************************************************************
|
||||
|
||||
TOML_PUSH_WARNINGS;
|
||||
#ifdef _MSC_VER
|
||||
#pragma push_macro("min")
|
||||
@ -10164,7 +10187,7 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
elems_ = std::move(rhs.elems_);
|
||||
elems_ = std::move(rhs.elems_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -10534,8 +10557,8 @@ TOML_NAMESPACE_START
|
||||
if (&rhs != this)
|
||||
{
|
||||
node::operator=(std::move(rhs));
|
||||
map_ = std::move(rhs.map_);
|
||||
inline_ = rhs.inline_;
|
||||
map_ = std::move(rhs.map_);
|
||||
inline_ = rhs.inline_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -10747,7 +10770,7 @@ TOML_NAMESPACE_END;
|
||||
#endif
|
||||
TOML_POP_WARNINGS;
|
||||
|
||||
//******** impl/unicode.inl ******************************************************************************************
|
||||
//******** impl/simd.h ***********************************************************************************************
|
||||
|
||||
#if TOML_ENABLE_SIMD
|
||||
|
||||
@ -10777,6 +10800,9 @@ TOML_DISABLE_WARNINGS;
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
TOML_ENABLE_WARNINGS;
|
||||
|
||||
//******** impl/unicode.inl ******************************************************************************************
|
||||
|
||||
TOML_PUSH_WARNINGS;
|
||||
#ifdef _MSC_VER
|
||||
#pragma push_macro("min")
|
||||
@ -11040,7 +11066,7 @@ TOML_ANON_NAMESPACE_START
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) // because, honestly, what the fuck macOS & MinGW??
|
||||
#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define TOML_OVERALIGNED
|
||||
#else
|
||||
#define TOML_OVERALIGNED alignas(32)
|
||||
@ -14552,10 +14578,7 @@ TOML_ANON_NAMESPACE_START
|
||||
{
|
||||
#if TOML_EXCEPTIONS
|
||||
#define TOML_PARSE_FILE_ERROR(msg, path) \
|
||||
throw parse_error \
|
||||
{ \
|
||||
msg, source_position{}, std::make_shared<const std::string>(std::move(path)) \
|
||||
}
|
||||
throw parse_error{ msg, source_position{}, std::make_shared<const std::string>(std::move(path)) }
|
||||
#else
|
||||
#define TOML_PARSE_FILE_ERROR(msg, path) \
|
||||
return parse_result \
|
||||
|
@ -19,9 +19,10 @@ class Preprocessor:
|
||||
__re_pragma_once = re.compile(r'^\s*#\s*pragma\s+once\s*$', re.M)
|
||||
|
||||
def __init__(self, file):
|
||||
self.__processed_files = set()
|
||||
self.__once_only = set()
|
||||
self.__current_level = 0
|
||||
self.__directory_stack = [ Path.cwd() ]
|
||||
self.__include_stack = []
|
||||
self.__entry_root = ''
|
||||
self.__string = self.__preprocess(file)
|
||||
|
||||
@ -33,9 +34,10 @@ class Preprocessor:
|
||||
incl = Path(incl.strip().replace('\\',r'/'))
|
||||
if not incl.is_absolute():
|
||||
incl = Path(self.__directory_stack[-1], incl).resolve()
|
||||
self.__processed_files.add(incl)
|
||||
if incl in self.__once_only:
|
||||
return ''
|
||||
|
||||
self.__include_stack.append(incl)
|
||||
|
||||
text = utils.read_all_text_from_file(incl, logger=True).strip() + '\n'
|
||||
text = text.replace('\r\n', '\n') # convert windows newlines
|
||||
@ -43,28 +45,40 @@ class Preprocessor:
|
||||
self.__directory_stack.append(incl.parent)
|
||||
if self.__re_pragma_once.search(text):
|
||||
self.__once_only.add(incl)
|
||||
if self.__current_level == 0 and self.__entry_root == '':
|
||||
if len(self.__include_stack) == 1 and self.__entry_root == '':
|
||||
self.__entry_root = str(incl.parent).replace('\\',r'/')
|
||||
if self.__current_level > 0:
|
||||
if len(self.__include_stack) > 1:
|
||||
text = self.__re_pragma_once.sub('', text)
|
||||
|
||||
self.__current_level += 1
|
||||
text = self.__re_includes.sub(lambda m : self.__preprocess(m), text, 0)
|
||||
self.__current_level -= 1
|
||||
|
||||
if self.__current_level == 1:
|
||||
header = str(incl).replace('\\',r'/')
|
||||
if header.startswith(self.__entry_root):
|
||||
header = header[len(self.__entry_root):].strip('/')
|
||||
header = utils.make_divider(header, 10, pattern = r'*')
|
||||
text = f'\n\n{header}\n\n{text}'
|
||||
incl_normalized = str(incl).replace('\\',r'/')
|
||||
if incl_normalized.startswith(self.__entry_root):
|
||||
incl_normalized = incl_normalized[len(self.__entry_root):].strip('/')
|
||||
|
||||
if len(self.__include_stack) > 1 and incl_normalized not in (r'impl/header_start.h', r'impl/header_end.h'):
|
||||
header = utils.make_divider(incl_normalized, 10, pattern = r'*')
|
||||
footer = ''
|
||||
if len(self.__include_stack) > 2:
|
||||
footer = str(self.__include_stack[-2]).replace('\\',r'/')
|
||||
if footer.startswith(self.__entry_root):
|
||||
footer = footer[len(self.__entry_root):].strip('/')
|
||||
footer = utils.make_divider(footer, 10, pattern = r'*')
|
||||
|
||||
text = f'\n\n{header}\n\n{text}\n\n{footer}'.rstrip()
|
||||
|
||||
self.__include_stack.pop()
|
||||
self.__directory_stack.pop()
|
||||
return '\n\n' + text + '\n\n'
|
||||
|
||||
def __str__(self):
|
||||
return self.__string
|
||||
|
||||
def processed_files(self):
|
||||
out = list(self.__processed_files)
|
||||
out.sort()
|
||||
return out
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
@ -93,6 +107,9 @@ def main():
|
||||
toml_h = re.sub(rf'\n{comment_line}{blank_line}+{comment_line}', '\n', toml_h)
|
||||
toml_h = re.sub(rf'([{{,])\s*\n(?:{comment_line}|{blank_line})+', r'\1\n', toml_h)
|
||||
toml_h = re.sub(rf'{comment_line}+', '\n', toml_h)
|
||||
# consecutive header separators
|
||||
header_separator = r'(?://\*\*\*\**[ \t]+[a-zA-Z0-9_/.-]+[ \t]+\*\*\*\*+\n)'
|
||||
toml_h = re.sub(rf'(?:{header_separator}{blank_line}*)+({header_separator})', r'\1', toml_h)
|
||||
# weird spacing edge case between } and pp directives
|
||||
toml_h = re.sub('\n[}]\n#', r'\n}\n\n#', toml_h, re.S)
|
||||
# enable warnings -> disable warnings
|
||||
@ -201,6 +218,7 @@ def main():
|
||||
r'TOML_EXPORTED_CLASS',
|
||||
r'TOML_EXPORTED_FREE_FUNCTION',
|
||||
r'TOML_EXPORTED_MEMBER_FUNCTION',
|
||||
r'TOML_EXPORTED_STATIC_FUNCTION',
|
||||
r'TOML_HEADER_ONLY',
|
||||
r'TOML_LANG_MAJOR',
|
||||
r'TOML_LANG_MINOR',
|
||||
|
Loading…
Reference in New Issue
Block a user