Skip to content

Commit 31ca5dc

Browse files
gireeshpunathildanbev
authored andcommitted
src: promote v8 name spaces with using
there are several places where v8 artifacts appear with scope resolution operator inline with the source. Elevate them for improved readability as well as to follow the convention. PR-URL: #22641 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 594a84d commit 31ca5dc

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

src/node.cc

+45-35
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,14 @@ using v8::Array;
132132
using v8::ArrayBuffer;
133133
using v8::Boolean;
134134
using v8::Context;
135+
using v8::DEFAULT;
136+
using v8::DontEnum;
135137
using v8::EscapableHandleScope;
136138
using v8::Exception;
137139
using v8::Function;
138140
using v8::FunctionCallbackInfo;
139141
using v8::HandleScope;
142+
using v8::Int32;
140143
using v8::Integer;
141144
using v8::Isolate;
142145
using v8::Just;
@@ -145,19 +148,27 @@ using v8::Locker;
145148
using v8::Maybe;
146149
using v8::MaybeLocal;
147150
using v8::Message;
151+
using v8::MicrotasksPolicy;
148152
using v8::Name;
149153
using v8::NamedPropertyHandlerConfiguration;
154+
using v8::NewStringType;
155+
using v8::None;
150156
using v8::Nothing;
151157
using v8::Null;
152158
using v8::Number;
153159
using v8::Object;
154160
using v8::ObjectTemplate;
155161
using v8::Promise;
162+
using v8::PropertyAttribute;
156163
using v8::PropertyCallbackInfo;
164+
using v8::ReadOnly;
165+
using v8::Script;
166+
using v8::ScriptCompiler;
157167
using v8::ScriptOrigin;
158168
using v8::SealHandleScope;
159169
using v8::SideEffectType;
160170
using v8::String;
171+
using v8::TracingController;
161172
using v8::TryCatch;
162173
using v8::Undefined;
163174
using v8::V8;
@@ -190,12 +201,12 @@ std::shared_ptr<PerProcessOptions> per_process_opts {
190201
new PerProcessOptions() };
191202

192203
static Mutex node_isolate_mutex;
193-
static v8::Isolate* node_isolate;
204+
static Isolate* node_isolate;
194205

195206
// Ensures that __metadata trace events are only emitted
196207
// when tracing is enabled.
197208
class NodeTraceStateObserver :
198-
public v8::TracingController::TraceStateObserver {
209+
public TracingController::TraceStateObserver {
199210
public:
200211
void OnTraceEnabled() override {
201212
char name_buffer[512];
@@ -278,12 +289,12 @@ class NodeTraceStateObserver :
278289
UNREACHABLE();
279290
}
280291

281-
explicit NodeTraceStateObserver(v8::TracingController* controller) :
292+
explicit NodeTraceStateObserver(TracingController* controller) :
282293
controller_(controller) {}
283294
~NodeTraceStateObserver() override {}
284295

285296
private:
286-
v8::TracingController* controller_;
297+
TracingController* controller_;
287298
};
288299

289300
static struct {
@@ -692,20 +703,20 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) {
692703
} // anonymous namespace
693704

694705

695-
void AddPromiseHook(v8::Isolate* isolate, promise_hook_func fn, void* arg) {
706+
void AddPromiseHook(Isolate* isolate, promise_hook_func fn, void* arg) {
696707
Environment* env = Environment::GetCurrent(isolate);
697708
env->AddPromiseHook(fn, arg);
698709
}
699710

700-
void AddEnvironmentCleanupHook(v8::Isolate* isolate,
711+
void AddEnvironmentCleanupHook(Isolate* isolate,
701712
void (*fun)(void* arg),
702713
void* arg) {
703714
Environment* env = Environment::GetCurrent(isolate);
704715
env->AddCleanupHook(fun, arg);
705716
}
706717

707718

708-
void RemoveEnvironmentCleanupHook(v8::Isolate* isolate,
719+
void RemoveEnvironmentCleanupHook(Isolate* isolate,
709720
void (*fun)(void* arg),
710721
void* arg) {
711722
Environment* env = Environment::GetCurrent(isolate);
@@ -759,7 +770,7 @@ MaybeLocal<Value> MakeCallback(Isolate* isolate,
759770
Local<Value> argv[],
760771
async_context asyncContext) {
761772
Local<String> method_string =
762-
String::NewFromUtf8(isolate, method, v8::NewStringType::kNormal)
773+
String::NewFromUtf8(isolate, method, NewStringType::kNormal)
763774
.ToLocalChecked();
764775
return MakeCallback(isolate, recv, method_string, argc, argv, asyncContext);
765776
}
@@ -945,7 +956,7 @@ void AppendExceptionLine(Environment* env,
945956
arrow[off + 1] = '\0';
946957

947958
Local<String> arrow_str = String::NewFromUtf8(env->isolate(), arrow,
948-
v8::NewStringType::kNormal).ToLocalChecked();
959+
NewStringType::kNormal).ToLocalChecked();
949960

950961
const bool can_set_arrow = !arrow_str.IsEmpty() && !err_obj.IsEmpty();
951962
// If allocating arrow_str failed, print it out. There's not much else to do.
@@ -1071,8 +1082,8 @@ static MaybeLocal<Value> ExecuteString(Environment* env,
10711082
try_catch.SetVerbose(false);
10721083

10731084
ScriptOrigin origin(filename);
1074-
MaybeLocal<v8::Script> script =
1075-
v8::Script::Compile(env->context(), source, &origin);
1085+
MaybeLocal<Script> script =
1086+
Script::Compile(env->context(), source, &origin);
10761087
if (script.IsEmpty()) {
10771088
ReportException(env, try_catch);
10781089
env->Exit(3);
@@ -1526,7 +1537,7 @@ void FatalException(Isolate* isolate,
15261537
!code->IsInt32()) {
15271538
exit(1);
15281539
}
1529-
exit(code.As<v8::Int32>()->Value());
1540+
exit(code.As<Int32>()->Value());
15301541
}
15311542
}
15321543
}
@@ -1575,20 +1586,20 @@ static Maybe<bool> ProcessEmitWarningGeneric(Environment* env,
15751586
// do proper error checking for string creation.
15761587
if (!String::NewFromUtf8(env->isolate(),
15771588
warning,
1578-
v8::NewStringType::kNormal).ToLocal(&args[argc++])) {
1589+
NewStringType::kNormal).ToLocal(&args[argc++])) {
15791590
return Nothing<bool>();
15801591
}
15811592
if (type != nullptr) {
15821593
if (!String::NewFromOneByte(env->isolate(),
15831594
reinterpret_cast<const uint8_t*>(type),
1584-
v8::NewStringType::kNormal)
1595+
NewStringType::kNormal)
15851596
.ToLocal(&args[argc++])) {
15861597
return Nothing<bool>();
15871598
}
15881599
if (code != nullptr &&
15891600
!String::NewFromOneByte(env->isolate(),
15901601
reinterpret_cast<const uint8_t*>(code),
1591-
v8::NewStringType::kNormal)
1602+
NewStringType::kNormal)
15921603
.ToLocal(&args[argc++])) {
15931604
return Nothing<bool>();
15941605
}
@@ -1733,7 +1744,7 @@ static void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
17331744
Local<Object> module = Object::New(env->isolate());
17341745
Local<Object> exports = Object::New(env->isolate());
17351746
Local<String> exports_prop = String::NewFromUtf8(env->isolate(), "exports",
1736-
v8::NewStringType::kNormal).ToLocalChecked();
1747+
NewStringType::kNormal).ToLocalChecked();
17371748
module->Set(exports_prop, exports);
17381749

17391750
if (mod->nm_context_register_func != nullptr) {
@@ -1817,16 +1828,15 @@ namespace {
18171828
obj->DefineOwnProperty(env->context(), \
18181829
OneByteString(env->isolate(), str), \
18191830
var, \
1820-
v8::ReadOnly).FromJust(); \
1831+
ReadOnly).FromJust(); \
18211832
} while (0)
18221833

18231834
#define READONLY_DONT_ENUM_PROPERTY(obj, str, var) \
18241835
do { \
18251836
obj->DefineOwnProperty(env->context(), \
18261837
OneByteString(env->isolate(), str), \
18271838
var, \
1828-
static_cast<v8::PropertyAttribute>(v8::ReadOnly | \
1829-
v8::DontEnum)) \
1839+
static_cast<PropertyAttribute>(ReadOnly|DontEnum)) \
18301840
.FromJust(); \
18311841
} while (0)
18321842

@@ -1846,8 +1856,8 @@ void SetupProcessObject(Environment* env,
18461856
ProcessTitleGetter,
18471857
env->is_main_thread() ? ProcessTitleSetter : nullptr,
18481858
env->as_external(),
1849-
v8::DEFAULT,
1850-
v8::None,
1859+
DEFAULT,
1860+
None,
18511861
SideEffectType::kHasNoSideEffect).FromJust());
18521862

18531863
// process.version
@@ -1976,7 +1986,7 @@ void SetupProcessObject(Environment* env,
19761986
for (size_t i = 0; i < args.size(); ++i) {
19771987
arguments->Set(env->context(), i,
19781988
String::NewFromUtf8(env->isolate(), args[i].c_str(),
1979-
v8::NewStringType::kNormal).ToLocalChecked())
1989+
NewStringType::kNormal).ToLocalChecked())
19801990
.FromJust();
19811991
}
19821992
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "argv"), arguments);
@@ -1986,7 +1996,7 @@ void SetupProcessObject(Environment* env,
19861996
for (size_t i = 0; i < exec_args.size(); ++i) {
19871997
exec_arguments->Set(env->context(), i,
19881998
String::NewFromUtf8(env->isolate(), exec_args[i].c_str(),
1989-
v8::NewStringType::kNormal).ToLocalChecked())
1999+
NewStringType::kNormal).ToLocalChecked())
19902000
.FromJust();
19912001
}
19922002
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execArgv"),
@@ -2022,7 +2032,7 @@ void SetupProcessObject(Environment* env,
20222032
String::NewFromUtf8(
20232033
env->isolate(),
20242034
env->options()->eval_string.c_str(),
2025-
v8::NewStringType::kNormal).ToLocalChecked());
2035+
NewStringType::kNormal).ToLocalChecked());
20262036
}
20272037

20282038
// -p, --print
@@ -2048,7 +2058,7 @@ void SetupProcessObject(Environment* env,
20482058
for (unsigned int i = 0; i < preload_modules.size(); ++i) {
20492059
Local<String> module = String::NewFromUtf8(env->isolate(),
20502060
preload_modules[i].c_str(),
2051-
v8::NewStringType::kNormal)
2061+
NewStringType::kNormal)
20522062
.ToLocalChecked();
20532063
array->Set(i, module);
20542064
}
@@ -2135,11 +2145,11 @@ void SetupProcessObject(Environment* env,
21352145
if (uv_exepath(exec_path, &exec_path_len) == 0) {
21362146
exec_path_value = String::NewFromUtf8(env->isolate(),
21372147
exec_path,
2138-
v8::NewStringType::kInternalized,
2148+
NewStringType::kInternalized,
21392149
exec_path_len).ToLocalChecked();
21402150
} else {
21412151
exec_path_value = String::NewFromUtf8(env->isolate(), args[0].c_str(),
2142-
v8::NewStringType::kInternalized).ToLocalChecked();
2152+
NewStringType::kInternalized).ToLocalChecked();
21432153
}
21442154
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "execPath"),
21452155
exec_path_value);
@@ -2303,15 +2313,15 @@ void LoadEnvironment(Environment* env) {
23032313
global->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "global"), global);
23042314

23052315
// Create binding loaders
2306-
v8::Local<v8::Function> get_binding_fn =
2316+
Local<Function> get_binding_fn =
23072317
env->NewFunctionTemplate(GetBinding)->GetFunction(env->context())
23082318
.ToLocalChecked();
23092319

2310-
v8::Local<v8::Function> get_linked_binding_fn =
2320+
Local<Function> get_linked_binding_fn =
23112321
env->NewFunctionTemplate(GetLinkedBinding)->GetFunction(env->context())
23122322
.ToLocalChecked();
23132323

2314-
v8::Local<v8::Function> get_internal_binding_fn =
2324+
Local<Function> get_internal_binding_fn =
23152325
env->NewFunctionTemplate(GetInternalBinding)->GetFunction(env->context())
23162326
.ToLocalChecked();
23172327

@@ -2843,7 +2853,7 @@ void RunAtExit(Environment* env) {
28432853
}
28442854

28452855

2846-
uv_loop_t* GetCurrentEventLoop(v8::Isolate* isolate) {
2856+
uv_loop_t* GetCurrentEventLoop(Isolate* isolate) {
28472857
HandleScope handle_scope(isolate);
28482858
auto context = isolate->GetCurrentContext();
28492859
if (context.IsEmpty())
@@ -2976,7 +2986,7 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() {
29762986

29772987
MultiIsolatePlatform* CreatePlatform(
29782988
int thread_pool_size,
2979-
v8::TracingController* tracing_controller) {
2989+
TracingController* tracing_controller) {
29802990
return new NodePlatform(thread_pool_size, tracing_controller);
29812991
}
29822992

@@ -2999,8 +3009,8 @@ Local<Context> NewContext(Isolate* isolate,
29993009
// Run lib/internal/per_context.js
30003010
Context::Scope context_scope(context);
30013011
Local<String> per_context = NodePerContextSource(isolate);
3002-
v8::ScriptCompiler::Source per_context_src(per_context, nullptr);
3003-
Local<v8::Script> s = v8::ScriptCompiler::Compile(
3012+
ScriptCompiler::Source per_context_src(per_context, nullptr);
3013+
Local<Script> s = ScriptCompiler::Compile(
30043014
context,
30053015
&per_context_src).ToLocalChecked();
30063016
s->Run(context).ToLocalChecked();
@@ -3109,7 +3119,7 @@ Isolate* NewIsolate(ArrayBufferAllocator* allocator) {
31093119

31103120
isolate->AddMessageListener(OnMessage);
31113121
isolate->SetAbortOnUncaughtExceptionCallback(ShouldAbortOnUncaughtException);
3112-
isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
3122+
isolate->SetMicrotasksPolicy(MicrotasksPolicy::kExplicit);
31133123
isolate->SetFatalErrorHandler(OnFatalError);
31143124
isolate->SetAllowWasmCodeGenerationCallback(AllowWasmCodeGenerationCallback);
31153125

0 commit comments

Comments
 (0)