diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-23 12:24:23 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-08-23 12:24:23 +0200 |
commit | 20f97f06ce54c31e32cf58cfd1b7cae3617c1661 (patch) | |
tree | 77c38da3112396d66bebd167434f628e0115c6e6 | |
parent | e7cc0a1a047ebe864f17e7d354214458cf87554e (diff) |
Get rid of var_extension char array
-rw-r--r-- | build2/bin/target.cxx | 60 | ||||
-rw-r--r-- | build2/cc/target.cxx | 8 | ||||
-rw-r--r-- | build2/cli/target.cxx | 4 | ||||
-rw-r--r-- | build2/cxx/target.cxx | 20 | ||||
-rw-r--r-- | libbuild2/bash/target.cxx | 4 | ||||
-rw-r--r-- | libbuild2/context.cxx | 2 | ||||
-rw-r--r-- | libbuild2/context.hxx | 3 | ||||
-rw-r--r-- | libbuild2/scope.cxx | 4 | ||||
-rw-r--r-- | libbuild2/target.hxx | 8 | ||||
-rw-r--r-- | libbuild2/target.txx | 11 |
10 files changed, 59 insertions, 65 deletions
diff --git a/build2/bin/target.cxx b/build2/bin/target.cxx index 6ea0988..9074317 100644 --- a/build2/bin/target.cxx +++ b/build2/bin/target.cxx @@ -105,8 +105,8 @@ namespace build2 &objx::static_type, &m_factory<obje, obj>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -118,8 +118,8 @@ namespace build2 &bmix::static_type, &m_factory<bmie, bmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -131,8 +131,8 @@ namespace build2 &hbmix::static_type, &m_factory<hbmie, hbmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -144,8 +144,8 @@ namespace build2 &objx::static_type, &m_factory<obja, obj>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -157,8 +157,8 @@ namespace build2 &bmix::static_type, &m_factory<bmia, bmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -170,8 +170,8 @@ namespace build2 &hbmix::static_type, &m_factory<hbmia, hbmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -183,8 +183,8 @@ namespace build2 &objx::static_type, &m_factory<objs, obj>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -196,8 +196,8 @@ namespace build2 &bmix::static_type, &m_factory<bmis, bmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -209,8 +209,8 @@ namespace build2 &hbmix::static_type, &m_factory<hbmis, hbmi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -222,8 +222,8 @@ namespace build2 &libux::static_type, &target_factory<libue>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -235,8 +235,8 @@ namespace build2 &libux::static_type, &m_factory<libua, libul>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -248,8 +248,8 @@ namespace build2 &libux::static_type, &m_factory<libus, libul>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &target_search, // Note: not _file(); don't look for an existing file. false @@ -372,8 +372,8 @@ namespace build2 &file::static_type, &m_factory<liba, lib>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &file_search, false @@ -385,8 +385,8 @@ namespace build2 &file::static_type, &m_factory<libs, lib>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &file_search, false @@ -447,8 +447,8 @@ namespace build2 &file::static_type, &target_factory<libi>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, nullptr>, - &target_pattern_var<var_extension, nullptr>, + &target_extension_var<nullptr>, + &target_pattern_var<nullptr>, nullptr, &file_search, false diff --git a/build2/cc/target.cxx b/build2/cc/target.cxx index c637e60..89b9391 100644 --- a/build2/cc/target.cxx +++ b/build2/cc/target.cxx @@ -33,8 +33,8 @@ namespace build2 &cc::static_type, &target_factory<h>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, h_ext_def>, - &target_pattern_var<var_extension, h_ext_def>, + &target_extension_var<h_ext_def>, + &target_pattern_var<h_ext_def>, nullptr, &file_search, false @@ -48,8 +48,8 @@ namespace build2 &cc::static_type, &target_factory<c>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, c_ext_def>, - &target_pattern_var<var_extension, c_ext_def>, + &target_extension_var<c_ext_def>, + &target_pattern_var<c_ext_def>, nullptr, &file_search, false diff --git a/build2/cli/target.cxx b/build2/cli/target.cxx index caa12b0..2fd70f7 100644 --- a/build2/cli/target.cxx +++ b/build2/cli/target.cxx @@ -23,8 +23,8 @@ namespace build2 &file::static_type, &target_factory<cli>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, cli_ext_def>, - &target_pattern_var<var_extension, cli_ext_def>, + &target_extension_var<cli_ext_def>, + &target_pattern_var<cli_ext_def>, nullptr, &file_search, false diff --git a/build2/cxx/target.cxx b/build2/cxx/target.cxx index 025bf9d..45463f3 100644 --- a/build2/cxx/target.cxx +++ b/build2/cxx/target.cxx @@ -19,8 +19,8 @@ namespace build2 &cc::static_type, &target_factory<hxx>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, hxx_ext_def>, - &target_pattern_var<var_extension, hxx_ext_def>, + &target_extension_var<hxx_ext_def>, + &target_pattern_var<hxx_ext_def>, nullptr, &file_search, false @@ -33,8 +33,8 @@ namespace build2 &cc::static_type, &target_factory<ixx>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, ixx_ext_def>, - &target_pattern_var<var_extension, ixx_ext_def>, + &target_extension_var<ixx_ext_def>, + &target_pattern_var<ixx_ext_def>, nullptr, &file_search, false @@ -47,8 +47,8 @@ namespace build2 &cc::static_type, &target_factory<txx>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, txx_ext_def>, - &target_pattern_var<var_extension, txx_ext_def>, + &target_extension_var<txx_ext_def>, + &target_pattern_var<txx_ext_def>, nullptr, &file_search, false @@ -61,8 +61,8 @@ namespace build2 &cc::static_type, &target_factory<cxx>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, cxx_ext_def>, - &target_pattern_var<var_extension, cxx_ext_def>, + &target_extension_var<cxx_ext_def>, + &target_pattern_var<cxx_ext_def>, nullptr, &file_search, false @@ -75,8 +75,8 @@ namespace build2 &cc::static_type, &target_factory<mxx>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, mxx_ext_def>, - &target_pattern_var<var_extension, mxx_ext_def>, + &target_extension_var<mxx_ext_def>, + &target_pattern_var<mxx_ext_def>, nullptr, &file_search, false diff --git a/libbuild2/bash/target.cxx b/libbuild2/bash/target.cxx index 7313316..386842b 100644 --- a/libbuild2/bash/target.cxx +++ b/libbuild2/bash/target.cxx @@ -20,8 +20,8 @@ namespace build2 &file::static_type, &target_factory<bash>, nullptr, /* fixed_extension */ - &target_extension_var<var_extension, bash_ext_def>, - &target_pattern_var<var_extension, bash_ext_def>, + &target_extension_var<bash_ext_def>, + &target_pattern_var<bash_ext_def>, nullptr, &file_search, false diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index 1e744c4..b1b45eb 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -861,6 +861,4 @@ namespace build2 vector_view<opspec>&, bool, const location&); - - const char var_extension[10] = "extension"; } diff --git a/libbuild2/context.hxx b/libbuild2/context.hxx index a947ca3..59c70e3 100644 --- a/libbuild2/context.hxx +++ b/libbuild2/context.hxx @@ -525,9 +525,6 @@ namespace build2 vector_view<opspec>&, bool lifted, const location&); - - //@@ CTX TMP - LIBBUILD2_SYMEXPORT extern const char var_extension[10]; // "extension" } #include <libbuild2/context.ixx> diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx index ab81333..298c1b0 100644 --- a/libbuild2/scope.cxx +++ b/libbuild2/scope.cxx @@ -801,12 +801,12 @@ namespace build2 // dt->default_extension = ext && dt->fixed_extension == nullptr - ? &target_extension_var<var_extension, nullptr> + ? &target_extension_var<nullptr> : nullptr; dt->pattern = dt->fixed_extension != nullptr ? nullptr /*&target_pattern_fix<???>*/ : - dt->default_extension != nullptr ? &target_pattern_var<var_extension, nullptr> : + dt->default_extension != nullptr ? &target_pattern_var<nullptr> : nullptr; // There is actually a difference between "fixed fixed" (like man1{}) and diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index f1c9d5f..b0d46e9 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -1806,14 +1806,14 @@ namespace build2 string&, optional<string>&, const location&, bool); - // Get the extension from the variable or use the default if none set. If - // the default is NULL, then return NULL. + // Get the extension from the `extension` variable or use the default if + // none set. If the default is NULL, then return NULL. // - template <const char* var, const char* def> + template <const char* def> optional<string> target_extension_var (const target_key&, const scope&, const char*, bool); - template <const char* var, const char* def> + template <const char* def> bool target_pattern_var (const target_type&, const scope&, string&, optional<string>&, const location&, diff --git a/libbuild2/target.txx b/libbuild2/target.txx index 8b17383..17c38c8 100644 --- a/libbuild2/target.txx +++ b/libbuild2/target.txx @@ -90,12 +90,11 @@ namespace build2 target_extension_var_impl (const target_type& tt, const string& tn, const scope& s, - const char* var, const char* def) { // Include target type/pattern-specific variables. // - if (auto l = s.find (s.ctx.var_pool[var], tt, tn)) + if (auto l = s.find (*s.ctx.var_extension, tt, tn)) { // Help the user here and strip leading '.' from the extension. // @@ -106,17 +105,17 @@ namespace build2 return def != nullptr ? optional<string> (def) : nullopt; } - template <const char* var, const char* def> + template <const char* def> optional<string> target_extension_var (const target_key& tk, const scope& s, const char*, bool) { - return target_extension_var_impl (*tk.type, *tk.name, s, var, def); + return target_extension_var_impl (*tk.type, *tk.name, s, def); } - template <const char* var, const char* def> + template <const char* def> bool target_pattern_var (const target_type& tt, const scope& s, @@ -144,7 +143,7 @@ namespace build2 // Use empty name as a target since we only want target type/pattern- // specific variables that match any target ('*' but not '*.txt'). // - if ((e = target_extension_var_impl (tt, string (), s, var, def))) + if ((e = target_extension_var_impl (tt, string (), s, def))) return true; } } |