src: refactor options parsing · nodejs/node@8fd55ff

@@ -44,6 +44,8 @@ IsolateData::IsolateData(Isolate* isolate,

4444

if (platform_ != nullptr)

4545

platform_->RegisterIsolate(this, event_loop);

464647+

options_.reset(new PerIsolateOptions(*per_process_opts->per_isolate));

48+4749

// Create string and private symbol properties as internalized one byte

4850

// strings after the platform is properly initialized.

4951

//

@@ -116,9 +118,6 @@ Environment::Environment(IsolateData* isolate_data,

116118

emit_env_nonstring_warning_(true),

117119

makecallback_cntr_(0),

118120

should_abort_on_uncaught_toggle_(isolate_, 1),

119-

#if HAVE_INSPECTOR

120-

inspector_agent_(new inspector::Agent(this)),

121-

#endif

122121

http_parser_buffer_(nullptr),

123122

fs_stats_field_array_(isolate_, kFsStatsFieldsLength * 2),

124123

fs_stats_field_bigint_array_(isolate_, kFsStatsFieldsLength * 2),

@@ -128,6 +127,19 @@ Environment::Environment(IsolateData* isolate_data,

128127

v8::Context::Scope context_scope(context);

129128

set_as_external(v8::External::New(isolate(), this));

130129130+

// We create new copies of the per-Environment option sets, so that it is

131+

// easier to modify them after Environment creation. The defaults are

132+

// part of the per-Isolate option set, for which in turn the defaults are

133+

// part of the per-process option set.

134+

options_.reset(new EnvironmentOptions(*isolate_data->options()->per_env));

135+

options_->debug_options.reset(new DebugOptions(*options_->debug_options));

136+137+

#if HAVE_INSPECTOR

138+

// We can only create the inspector agent after having cloned the options.

139+

inspector_agent_ =

140+

std::unique_ptr<inspector::Agent>(new inspector::Agent(this));

141+

#endif

142+131143

AssignToContext(context, ContextInfo(""));

132144133145

destroy_async_id_list_.reserve(512);

@@ -176,10 +188,8 @@ Environment::~Environment() {

176188

delete[] http_parser_buffer_;

177189

}

178190179-

void Environment::Start(int argc,

180-

const char* const* argv,

181-

int exec_argc,

182-

const char* const* exec_argv,

191+

void Environment::Start(const std::vector<std::string>& args,

192+

const std::vector<std::string>& exec_args,

183193

bool start_profiler_idle_notifier) {

184194

HandleScope handle_scope(isolate());

185195

Context::Scope context_scope(context());

@@ -222,7 +232,7 @@ void Environment::Start(int argc,

222232

process_template->GetFunction()->NewInstance(context()).ToLocalChecked();

223233

set_process_object(process_object);

224234225-

SetupProcessObject(this, argc, argv, exec_argc, exec_argv);

235+

SetupProcessObject(this, args, exec_args);

226236227237

static uv_once_t init_once = UV_ONCE_INIT;

228238

uv_once(&init_once, InitThreadLocalOnce);