diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-08-10 02:45:28 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-08-22 23:37:19 +0200 |
commit | 29a71bae40ffa0bbc8ba6b2bdf051a09987da7f7 (patch) | |
tree | 1d66e5b012218ede32c5219d9918d2e2a897ee7b /src/env.h | |
parent | 92880f31da1eca98a42e0f61708b10d9d8d83955 (diff) | |
download | android-node-v8-29a71bae40ffa0bbc8ba6b2bdf051a09987da7f7.tar.gz android-node-v8-29a71bae40ffa0bbc8ba6b2bdf051a09987da7f7.tar.bz2 android-node-v8-29a71bae40ffa0bbc8ba6b2bdf051a09987da7f7.zip |
src: refactor options parsing
This is a major refactor of our Node’s parser. See `node_options.cc`
for how it is used, and `node_options-inl.h` for the bulk
of its implementation.
Unfortunately, the implementation has come to have some
complexity, in order to meet the following goals:
- Make it easy to *use* for defining or changing options.
- Keep it (mostly) backwards-compatible.
- No tests were harmed as part of this commit.
- Be as consistent as possible.
- In particular, options can now generally accept arguments
through both `--foo=bar` notation and `--foo bar` notation.
We were previously very inconsistent on this point.
- Separate into different levels of scope, namely
per-process (global), per-Isolate and per-Environment
(+ debug options).
- Allow programmatic accessibility in the future.
- This includes a possible expansion for `--help` output.
This commit also leaves a number of `TODO` comments, mostly for
improving consistency even more (possibly with having to modify
tests), improving embedder support, as well as removing pieces of
exposed configuration variables that should never have become
part of the public API but unfortunately are at this point.
PR-URL: https://github.com/nodejs/node/pull/22392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'src/env.h')
-rw-r--r-- | src/env.h | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -34,6 +34,7 @@ #include "uv.h" #include "v8.h" #include "node.h" +#include "node_options.h" #include "node_http2_state.h" #include <list> @@ -365,6 +366,7 @@ class IsolateData { inline uv_loop_t* event_loop() const; inline uint32_t* zero_fill_field() const; inline MultiIsolatePlatform* platform() const; + inline std::shared_ptr<PerIsolateOptions> options(); #define VP(PropertyName, StringValue) V(v8::Private, PropertyName) #define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName) @@ -398,6 +400,7 @@ class IsolateData { uv_loop_t* const event_loop_; uint32_t* const zero_fill_field_; MultiIsolatePlatform* platform_; + std::shared_ptr<PerIsolateOptions> options_; DISALLOW_COPY_AND_ASSIGN(IsolateData); }; @@ -582,10 +585,8 @@ class Environment { tracing::AgentWriterHandle* tracing_agent_writer); ~Environment(); - void Start(int argc, - const char* const* argv, - int exec_argc, - const char* const* exec_argv, + void Start(const std::vector<std::string>& args, + const std::vector<std::string>& exec_args, bool start_profiler_idle_notifier); typedef void (*HandleCleanupCb)(Environment* env, @@ -882,6 +883,8 @@ class Environment { v8::EmbedderGraph* graph, void* data); + inline std::shared_ptr<EnvironmentOptions> options(); + private: inline void CreateImmediate(native_immediate_callback cb, void* data, @@ -912,6 +915,8 @@ class Environment { size_t makecallback_cntr_; std::vector<double> destroy_async_id_list_; + std::shared_ptr<EnvironmentOptions> options_; + AliasedBuffer<uint32_t, v8::Uint32Array> should_abort_on_uncaught_toggle_; int should_not_abort_scope_counter_ = 0; |