From c76ff457079bf5901a6bb55377c14aeee856a354 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Mar 2016 16:02:06 +0200 Subject: Cleanup variable typing --- build2/bin/module.cxx | 32 ++++++++++++++++---------------- build2/cli/module.cxx | 8 ++++---- build2/context.cxx | 16 ++++++++-------- build2/cxx/module.cxx | 28 ++++++++++++++-------------- build2/dist/module.cxx | 16 ++++++++-------- build2/install/module.cxx | 8 +++----- build2/test/module.cxx | 12 ++++++------ build2/test/rule.cxx | 10 +++++----- build2/variable | 7 +++++++ 9 files changed, 71 insertions(+), 66 deletions(-) diff --git a/build2/bin/module.cxx b/build2/bin/module.cxx index eb4d771..702e762 100644 --- a/build2/bin/module.cxx +++ b/build2/bin/module.cxx @@ -47,22 +47,22 @@ namespace build2 { auto& v (var_pool); - v.find ("config.bin.ar", string_type); //@@ VAR path_type - v.find ("config.bin.ranlib", string_type); //@@ VAR path_type - - v.find ("config.bin.lib", string_type); - v.find ("config.bin.exe.lib", strings_type); - v.find ("config.bin.liba.lib", strings_type); - v.find ("config.bin.libso.lib", strings_type); - v.find ("config.bin.rpath", strings_type); //@@ VAR paths_type - - v.find ("bin.lib", string_type); - v.find ("bin.exe.lib", strings_type); - v.find ("bin.liba.lib", strings_type); - v.find ("bin.libso.lib", strings_type); - v.find ("bin.rpath", strings_type); //@@ VAR paths_type - - v.find ("bin.libprefix", string_type); + v.find ("config.bin.ar"); //@@ VAR path_type + v.find ("config.bin.ranlib"); //@@ VAR path_type + + v.find ("config.bin.lib"); + v.find ("config.bin.exe.lib"); + v.find ("config.bin.liba.lib"); + v.find ("config.bin.libso.lib"); + v.find ("config.bin.rpath"); //@@ VAR paths_type + + v.find ("bin.lib"); + v.find ("bin.exe.lib"); + v.find ("bin.liba.lib"); + v.find ("bin.libso.lib"); + v.find ("bin.rpath"); //@@ VAR paths_type + + v.find ("bin.libprefix"); } // Register target types. diff --git a/build2/cli/module.cxx b/build2/cli/module.cxx index 8ec2db9..6497766 100644 --- a/build2/cli/module.cxx +++ b/build2/cli/module.cxx @@ -55,12 +55,12 @@ namespace build2 { auto& v (var_pool); - v.find ("config.cli.configured", bool_type); + v.find ("config.cli.configured"); - v.find ("config.cli", string_type); //@@ VAR type + v.find ("config.cli"); //@@ VAR type - v.find ("config.cli.options", strings_type); - v.find ("cli.options", strings_type); + v.find ("config.cli.options"); + v.find ("cli.options"); } // Register target types. diff --git a/build2/context.cxx b/build2/context.cxx index 49edc1c..dc84e63 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -63,19 +63,19 @@ namespace build2 { auto& v (var_pool); - v.find ("src_root", dir_path_type); - v.find ("out_root", dir_path_type); - v.find ("src_base", dir_path_type); - v.find ("out_base", dir_path_type); + v.find ("src_root"); + v.find ("out_root"); + v.find ("src_base"); + v.find ("out_base"); - v.find ("project", string_type); - v.find ("amalgamation", dir_path_type); + v.find ("project"); + v.find ("amalgamation"); - // Shouldn't be typed since the value requires pre-processing. + // Not typed since the value requires pre-processing. // v.find ("subprojects", nullptr, '='); - v.find ("extension", string_type); + v.find ("extension"); } // Create global scope. For Win32 this is not a "real" root path. diff --git a/build2/cxx/module.cxx b/build2/cxx/module.cxx index 9baccae..7c6a4dd 100644 --- a/build2/cxx/module.cxx +++ b/build2/cxx/module.cxx @@ -62,24 +62,24 @@ namespace build2 { auto& v (var_pool); - v.find ("config.cxx", string_type); //@@ VAR type + v.find ("config.cxx"); //@@ VAR type - v.find ("config.cxx.poptions", strings_type); - v.find ("config.cxx.coptions", strings_type); - v.find ("config.cxx.loptions", strings_type); - v.find ("config.cxx.libs", strings_type); + v.find ("config.cxx.poptions"); + v.find ("config.cxx.coptions"); + v.find ("config.cxx.loptions"); + v.find ("config.cxx.libs"); - v.find ("cxx.poptions", strings_type); - v.find ("cxx.coptions", strings_type); - v.find ("cxx.loptions", strings_type); - v.find ("cxx.libs", strings_type); + v.find ("cxx.poptions"); + v.find ("cxx.coptions"); + v.find ("cxx.loptions"); + v.find ("cxx.libs"); - v.find ("cxx.export.poptions", strings_type); - v.find ("cxx.export.coptions", strings_type); - v.find ("cxx.export.loptions", strings_type); - v.find ("cxx.export.libs", strings_type); + v.find ("cxx.export.poptions"); + v.find ("cxx.export.coptions"); + v.find ("cxx.export.loptions"); + v.find ("cxx.export.libs"); - v.find ("cxx.std", string_type); + v.find ("cxx.std"); } // Register target types. diff --git a/build2/dist/module.cxx b/build2/dist/module.cxx index a205a72..6f40b33 100644 --- a/build2/dist/module.cxx +++ b/build2/dist/module.cxx @@ -39,20 +39,20 @@ namespace build2 { auto& v (var_pool); - v.find ("dist", bool_type); + v.find ("dist"); - v.find ("dist.package", string_type); + v.find ("dist.package"); - v.find ("dist.root", dir_path_type); - v.find ("config.dist.root", dir_path_type); + v.find ("dist.root"); + v.find ("config.dist.root"); //@@ VAR type // - v.find ("dist.cmd", string_type); - v.find ("config.dist.cmd", string_type); + v.find ("dist.cmd"); + v.find ("config.dist.cmd"); - v.find ("dist.archives", strings_type); - v.find ("config.dist.archives", strings_type); + v.find ("dist.archives"); + v.find ("config.dist.archives"); } } diff --git a/build2/install/module.cxx b/build2/install/module.cxx index 754fcb5..579d454 100644 --- a/build2/install/module.cxx +++ b/build2/install/module.cxx @@ -50,8 +50,7 @@ namespace build2 vn = "config.install."; vn += name; vn += var; - const variable& vr ( - var_pool.find (move (vn), &value_traits::value_type)); + const variable& vr (var_pool.find (move (vn))); cv = dv != nullptr ? &config::required (r, vr, *dv, override).first.get () @@ -61,8 +60,7 @@ namespace build2 vn = "install."; vn += name; vn += var; - const variable& vr ( - var_pool.find (move (vn), &value_traits::value_type)); + const variable& vr (var_pool.find (move (vn))); value& v (r.assign (vr)); @@ -139,7 +137,7 @@ namespace build2 { auto& v (var_pool); - v.find ("install", dir_path_type); + v.find ("install"); } // Register our alias and file installer rule. diff --git a/build2/test/module.cxx b/build2/test/module.cxx index c8c0fa7..10948ab 100644 --- a/build2/test/module.cxx +++ b/build2/test/module.cxx @@ -38,12 +38,12 @@ namespace build2 { auto& v (var_pool); - v.find ("test", bool_type); - v.find ("test.input", name_type); - v.find ("test.output", name_type); - v.find ("test.roundtrip", name_type); - v.find ("test.options", strings_type); - v.find ("test.arguments", strings_type); + v.find ("test"); + v.find ("test.input"); + v.find ("test.output"); + v.find ("test.roundtrip"); + v.find ("test.options"); + v.find ("test.arguments"); } } diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx index 39b7d01..efe265b 100644 --- a/build2/test/rule.cxx +++ b/build2/test/rule.cxx @@ -68,7 +68,7 @@ namespace build2 // if (!l.defined ()) l = t.base_scope ()[ - var_pool.find (string("test.") + t.type ().name, bool_type)]; + var_pool.find (string("test.") + t.type ().name)]; r = l && as (*l); } @@ -146,9 +146,9 @@ namespace build2 string n ("test."); n += t.type ().name; - const variable& in (var_pool.find (n + ".input", name_type)); - const variable& on (var_pool.find (n + ".output", name_type)); - const variable& rn (var_pool.find (n + ".roundtrip", name_type)); + const variable& in (var_pool.find (n + ".input")); + const variable& on (var_pool.find (n + ".output")); + const variable& rn (var_pool.find (n + ".roundtrip")); // We should only keep value(s) that were specified together // in the innermost scope. @@ -292,7 +292,7 @@ namespace build2 var += t.type ().name; var += '.'; var += n; - l = t.base_scope ()[var_pool.find (var, strings_type)]; + l = t.base_scope ()[var_pool.find (var)]; } if (l) diff --git a/build2/variable b/build2/variable index 1a52566..579339e 100644 --- a/build2/variable +++ b/build2/variable @@ -630,6 +630,13 @@ namespace build2 using variable_pool_base = std::unordered_set; struct variable_pool: private variable_pool_base { + template + const variable& + find (string name, char p = '\0') + { + return find (name, nullptr, &value_traits::value_type, p); + } + const variable& find (string name, const build2::value_type* t = nullptr, char p = '\0') { -- cgit v1.1