diff options
author | Gus Caplan <me@gus.host> | 2019-11-12 09:30:02 +0300 |
---|---|---|
committer | Gus Caplan <me@gus.host> | 2020-05-14 20:39:23 +0300 |
commit | 5ae5262f448295e314393dad4c491259793cea3f (patch) | |
tree | 412178bf21e1eb5e5727fcad1744233c0931ef5e /src/node_options-inl.h | |
parent | 241ed44a0b06db45c97681c164fc1098e7c9f0d2 (diff) |
src: add support for TLA
PR-URL: https://github.com/nodejs/node/pull/30370
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'src/node_options-inl.h')
-rw-r--r-- | src/node_options-inl.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/node_options-inl.h b/src/node_options-inl.h index 682a1c6c47d..4e1a12296bc 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -138,10 +138,9 @@ void OptionsParser<Options>::Implies(const char* from, const char* to) { auto it = options_.find(to); CHECK_NE(it, options_.end()); - CHECK_EQ(it->second.type, kBoolean); - implications_.emplace(from, Implication { - it->second.field, true - }); + CHECK(it->second.type == kBoolean || it->second.type == kV8Option); + implications_.emplace( + from, Implication{it->second.type, to, it->second.field, true}); } template <typename Options> @@ -150,9 +149,8 @@ void OptionsParser<Options>::ImpliesNot(const char* from, auto it = options_.find(to); CHECK_NE(it, options_.end()); CHECK_EQ(it->second.type, kBoolean); - implications_.emplace(from, Implication { - it->second.field, false - }); + implications_.emplace( + from, Implication{it->second.type, to, it->second.field, false}); } template <typename Options> @@ -196,9 +194,11 @@ template <typename ChildOptions> auto OptionsParser<Options>::Convert( typename OptionsParser<ChildOptions>::Implication original, ChildOptions* (Options::* get_child)()) { - return Implication { - Convert(original.target_field, get_child), - original.target_value + return Implication{ + original.type, + original.name, + Convert(original.target_field, get_child), + original.target_value, }; } @@ -366,19 +366,23 @@ void OptionsParser<Options>::Parse( break; } - if (it == options_.end()) { - v8_args->push_back(arg); - continue; - } - { auto implications = implications_.equal_range(name); for (auto it = implications.first; it != implications.second; ++it) { - *it->second.target_field->template Lookup<bool>(options) = - it->second.target_value; + if (it->second.type == kV8Option) { + v8_args->push_back(it->second.name); + } else { + *it->second.target_field->template Lookup<bool>(options) = + it->second.target_value; + } } } + if (it == options_.end()) { + v8_args->push_back(arg); + continue; + } + const OptionInfo& info = it->second; std::string value; if (info.type != kBoolean && info.type != kNoOp && info.type != kV8Option) { |