src: elevate namespaces in node_worker.cc
In node_worker.cc there are few instances where v8 namespaced entitites are used inline. Elevate them with `using` semantics. PR-URL: https://github.com/nodejs/node/pull/27568 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
07e0395a81
commit
99b196d4ba
@ -16,6 +16,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using node::options_parser::kDisallowedInEnvironment;
|
using node::options_parser::kDisallowedInEnvironment;
|
||||||
|
using v8::Array;
|
||||||
using v8::ArrayBuffer;
|
using v8::ArrayBuffer;
|
||||||
using v8::Boolean;
|
using v8::Boolean;
|
||||||
using v8::Context;
|
using v8::Context;
|
||||||
@ -27,6 +28,7 @@ using v8::Integer;
|
|||||||
using v8::Isolate;
|
using v8::Isolate;
|
||||||
using v8::Local;
|
using v8::Local;
|
||||||
using v8::Locker;
|
using v8::Locker;
|
||||||
|
using v8::MaybeLocal;
|
||||||
using v8::Number;
|
using v8::Number;
|
||||||
using v8::Object;
|
using v8::Object;
|
||||||
using v8::SealHandleScope;
|
using v8::SealHandleScope;
|
||||||
@ -414,30 +416,30 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
if (!args[0]->IsNullOrUndefined()) {
|
if (!args[0]->IsNullOrUndefined()) {
|
||||||
Utf8Value value(
|
Utf8Value value(
|
||||||
args.GetIsolate(),
|
args.GetIsolate(),
|
||||||
args[0]->ToString(env->context()).FromMaybe(v8::Local<v8::String>()));
|
args[0]->ToString(env->context()).FromMaybe(Local<String>()));
|
||||||
url.append(value.out(), value.length());
|
url.append(value.out(), value.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1]->IsArray()) {
|
if (args[1]->IsArray()) {
|
||||||
v8::Local<v8::Array> array = args[1].As<v8::Array>();
|
Local<Array> array = args[1].As<Array>();
|
||||||
// The first argument is reserved for program name, but we don't need it
|
// The first argument is reserved for program name, but we don't need it
|
||||||
// in workers.
|
// in workers.
|
||||||
has_explicit_exec_argv = true;
|
has_explicit_exec_argv = true;
|
||||||
std::vector<std::string> exec_argv = {""};
|
std::vector<std::string> exec_argv = {""};
|
||||||
uint32_t length = array->Length();
|
uint32_t length = array->Length();
|
||||||
for (uint32_t i = 0; i < length; i++) {
|
for (uint32_t i = 0; i < length; i++) {
|
||||||
v8::Local<v8::Value> arg;
|
Local<Value> arg;
|
||||||
if (!array->Get(env->context(), i).ToLocal(&arg)) {
|
if (!array->Get(env->context(), i).ToLocal(&arg)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
v8::MaybeLocal<v8::String> arg_v8_string =
|
MaybeLocal<String> arg_v8_string =
|
||||||
arg->ToString(env->context());
|
arg->ToString(env->context());
|
||||||
if (arg_v8_string.IsEmpty()) {
|
if (arg_v8_string.IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utf8Value arg_utf8_value(
|
Utf8Value arg_utf8_value(
|
||||||
args.GetIsolate(),
|
args.GetIsolate(),
|
||||||
arg_v8_string.FromMaybe(v8::Local<v8::String>()));
|
arg_v8_string.FromMaybe(Local<String>()));
|
||||||
std::string arg_string(arg_utf8_value.out(), arg_utf8_value.length());
|
std::string arg_string(arg_utf8_value.out(), arg_utf8_value.length());
|
||||||
exec_argv.push_back(arg_string);
|
exec_argv.push_back(arg_string);
|
||||||
}
|
}
|
||||||
@ -459,7 +461,7 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// The first argument is program name.
|
// The first argument is program name.
|
||||||
invalid_args.erase(invalid_args.begin());
|
invalid_args.erase(invalid_args.begin());
|
||||||
if (errors.size() > 0 || invalid_args.size() > 0) {
|
if (errors.size() > 0 || invalid_args.size() > 0) {
|
||||||
v8::Local<v8::Value> error;
|
Local<Value> error;
|
||||||
if (!ToV8Value(env->context(),
|
if (!ToV8Value(env->context(),
|
||||||
errors.size() > 0 ? errors : invalid_args)
|
errors.size() > 0 ? errors : invalid_args)
|
||||||
.ToLocal(&error)) {
|
.ToLocal(&error)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user