2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

Make the generate_cpp17.py script python version agnostic and add smoke test that the script works (fixes #57)

This commit is contained in:
Antony Polukhin
2020-10-21 14:38:35 +03:00
parent 8c4934c17d
commit ed4505ca05
2 changed files with 22 additions and 17 deletions

View File

@@ -79,33 +79,33 @@ constexpr void tie_as_tuple(T& /*val*/, size_t_<I>) noexcept {
indexes = " a"
print PROLOGUE
print(PROLOGUE)
funcs_count = 100 if len(sys.argv) == 1 else int(sys.argv[1])
max_args_on_a_line = len(ascii_letters)
for i in xrange(1, funcs_count):
for i in range(1, funcs_count):
if i % max_args_on_a_line == 0:
indexes += ",\n "
else:
indexes += ","
if i >= max_args_on_a_line:
indexes += ascii_letters[i / max_args_on_a_line - 1]
indexes += ascii_letters[i // max_args_on_a_line - 1]
indexes += ascii_letters[i % max_args_on_a_line]
print "template <class T>"
print "constexpr auto tie_as_tuple(T& val, size_t_<" + str(i + 1) + ">) noexcept {"
print("template <class T>")
print("constexpr auto tie_as_tuple(T& val, size_t_<" + str(i + 1) + ">) noexcept {")
if i < max_args_on_a_line:
print " auto& [" + indexes.strip() + "] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate."
print " return ::boost::pfr::detail::make_tuple_of_references(" + indexes.strip() + ");"
print(" auto& [" + indexes.strip() + "] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate.")
print(" return ::boost::pfr::detail::make_tuple_of_references(" + indexes.strip() + ");")
else:
print " auto& ["
print indexes
print " ] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate."
print ""
print " return ::boost::pfr::detail::make_tuple_of_references("
print indexes
print " );"
print(" auto& [")
print(indexes)
print(" ] = val; // ====================> Boost.PFR: User-provided type is not a SimpleAggregate.")
print("")
print(" return ::boost::pfr::detail::make_tuple_of_references(")
print(indexes)
print(" );")
print "}\n"
print("}\n")
print EPILOGUE
print(EPILOGUE)

View File

@@ -5,6 +5,7 @@
# http://www.boost.org/LICENSE_1_0.txt)
#
import python ;
import testing ;
import ../../config/checks/config : requires ;
@@ -16,7 +17,6 @@ project
[ requires cxx14_constexpr ]
;
########## BEGIN of helpers to detect Loophole trick support
actions mp_simple_run_action
@@ -125,3 +125,8 @@ for local source_file in [ glob ./compile-fail/*.cpp ]
pfr_tests += [ compile-fail $(source_file) : $(LOOPHOLE_ENGINE) : $(target_name)_lh ] ;
pfr_tests += [ compile-fail $(source_file) : $(CLASSIC_ENGINE) : $(target_name)_classic ] ;
}
if [ python.configured ]
{
testing.make-test run-pyd : ../misc/generate_cpp17.py ;
}