Commit cef4391ab38 for nodejs
commit cef4391ab3866cd64b967ad9e343d4367ac897dc
Author: Ilyas Shabi <ilyasshabi94@gmail.com>
Date: Fri Nov 27 09:43:43 2026 +0100
src: use V8 using declarations consistently
Signed-off-by: ishabi <ilyasshabi94@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67732
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
diff --git a/src/env.cc b/src/env.cc
index ab31d4457fd..10adc705b93 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -53,18 +53,30 @@ using v8::BackingStore;
using v8::BackingStoreInitializationMode;
using v8::Boolean;
using v8::Context;
+using v8::CppHeapPointerTag;
+using v8::CpuProfile;
+using v8::CpuProfiler;
+using v8::CpuProfilingMode;
+using v8::CpuProfilingOptions;
+using v8::CpuProfilingResult;
+using v8::CpuProfilingStatus;
using v8::EmbedderGraph;
using v8::EscapableHandleScope;
using v8::ExternalMemoryAccounter;
using v8::Function;
+using v8::GCCallbackFlags;
+using v8::GCType;
using v8::Global;
using v8::HandleScope;
using v8::HeapProfiler;
using v8::HeapSpaceStatistics;
+using v8::HeapStatistics;
using v8::Integer;
using v8::Isolate;
+using v8::Just;
using v8::JustVoid;
using v8::Local;
+using v8::LocalVector;
using v8::Maybe;
using v8::MaybeLocal;
using v8::NewStringType;
@@ -73,6 +85,7 @@ using v8::Number;
using v8::Object;
using v8::ObjectTemplate;
using v8::Private;
+using v8::ProfilerId;
using v8::Promise;
using v8::PromiseHookType;
using v8::Script;
@@ -103,7 +116,7 @@ void AsyncHooks::ResetPromiseHooks(Local<Function> init,
}
Local<Array> AsyncHooks::GetPromiseHooks(Isolate* isolate) const {
- v8::LocalVector<Value> values(isolate, js_promise_hooks_.size());
+ LocalVector<Value> values(isolate, js_promise_hooks_.size());
for (size_t i = 0; i < js_promise_hooks_.size(); ++i) {
if (js_promise_hooks_[i].IsEmpty()) {
values[i] = Undefined(isolate);
@@ -522,7 +535,7 @@ void IsolateData::CreateProperties() {
// One byte because our strings are ASCII and we can safely skip V8's UTF-8
// decoding step.
- v8::Isolate::Scope isolate_scope(isolate_);
+ Isolate::Scope isolate_scope(isolate_);
HandleScope handle_scope(isolate_);
#define V(PropertyName, StringValue) \
@@ -682,9 +695,8 @@ IsolateData::~IsolateData() {
// Deprecated API, embedders should use v8::Object::Wrap() directly instead.
void SetCppgcReference(Isolate* isolate,
Local<Object> object,
- v8::Object::Wrappable* wrappable) {
- v8::Object::Wrap<v8::CppHeapPointerTag::kDefaultTag>(
- isolate, object, wrappable);
+ Object::Wrappable* wrappable) {
+ Object::Wrap<CppHeapPointerTag::kDefaultTag>(isolate, object, wrappable);
}
void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
@@ -740,7 +752,7 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() {
USE(cb->Call(env_->context(), Undefined(isolate), arraysize(args), args));
}
-void Environment::AssignToContext(Local<v8::Context> context,
+void Environment::AssignToContext(Local<Context> context,
Realm* realm,
const ContextInfo& info) {
context->SetAlignedPointerInEmbedderDataV2(ContextEmbedderIndex::kEnvironment,
@@ -766,7 +778,7 @@ void Environment::AssignToContext(Local<v8::Context> context,
TrackContext(context);
}
-void Environment::UnassignFromContext(Local<v8::Context> context) {
+void Environment::UnassignFromContext(Local<Context> context) {
if (!context.IsEmpty()) {
context->SetAlignedPointerInEmbedderDataV2(
ContextEmbedderIndex::kEnvironment,
@@ -1594,7 +1606,7 @@ MaybeLocal<Value> Environment::RunSnapshotSerializeCallback() const {
if (!snapshot_serialize_callback().IsEmpty()) {
Context::Scope context_scope(context());
return handle_scope.EscapeMaybe(snapshot_serialize_callback()->Call(
- context(), v8::Undefined(isolate()), 0, nullptr));
+ context(), Undefined(isolate()), 0, nullptr));
}
return handle_scope.Escape(Undefined(isolate()));
}
@@ -1604,7 +1616,7 @@ MaybeLocal<Value> Environment::RunSnapshotDeserializeMain() const {
if (!snapshot_deserialize_main().IsEmpty()) {
Context::Scope context_scope(context());
return handle_scope.EscapeMaybe(snapshot_deserialize_main()->Call(
- context(), v8::Undefined(isolate()), 0, nullptr));
+ context(), Undefined(isolate()), 0, nullptr));
}
return handle_scope.Escape(Undefined(isolate()));
}
@@ -1660,23 +1672,23 @@ Maybe<bool> Environment::CheckUnsettledTopLevelAwait() const {
if (!ctx->Global()
->GetPrivate(ctx, entry_point_promise_private_symbol())
.ToLocal(&entry_point_promise)) {
- return v8::Nothing<bool>();
+ return Nothing<bool>();
}
if (!entry_point_promise->IsPromise()) {
- return v8::Just(true);
+ return Just(true);
}
if (entry_point_promise.As<Promise>()->State() !=
Promise::PromiseState::kPending) {
- return v8::Just(true);
+ return Just(true);
}
if (!ctx->Global()
->GetPrivate(ctx, entry_point_module_private_symbol())
.ToLocal(&value)) {
- return v8::Nothing<bool>();
+ return Nothing<bool>();
}
if (!value->IsObject()) {
- return v8::Just(true);
+ return Just(true);
}
Local<Object> object = value.As<Object>();
CHECK(BaseObject::IsBaseObject(isolate_data_, object));
@@ -2411,8 +2423,9 @@ void Environment::AddPointerCompressionHeapWarningCallback() {
pointer_compression_heap_warning_callback_added_ = true;
// Only full GCs: the heap that survives a mark-compact is the closest
// approximation of the live heap, and young-generation GCs are frequent.
- isolate_->AddGCEpilogueCallback(
- PointerCompressionHeapWarningCallback, this, v8::kGCTypeMarkSweepCompact);
+ isolate_->AddGCEpilogueCallback(PointerCompressionHeapWarningCallback,
+ this,
+ GCType::kGCTypeMarkSweepCompact);
}
void Environment::RemovePointerCompressionHeapWarningCallback() {
@@ -2422,12 +2435,14 @@ void Environment::RemovePointerCompressionHeapWarningCallback() {
this);
}
-void Environment::PointerCompressionHeapWarningCallback(
- Isolate* isolate, v8::GCType type, v8::GCCallbackFlags flags, void* data) {
+void Environment::PointerCompressionHeapWarningCallback(Isolate* isolate,
+ GCType type,
+ GCCallbackFlags flags,
+ void* data) {
Environment* env = static_cast<Environment*>(data);
if (env->pointer_compression_heap_warning_scheduled_) return;
- v8::HeapStatistics stats;
+ HeapStatistics stats;
isolate->GetHeapStatistics(&stats);
const uint64_t used = stats.used_heap_size();
if (used < env->pointer_compression_heap_likely_threshold_ &&
@@ -2759,25 +2774,23 @@ void Environment::RunWeakRefCleanup() {
isolate()->ClearKeptObjects();
}
-v8::CpuProfilingResult Environment::StartCpuProfile(
+CpuProfilingResult Environment::StartCpuProfile(
const CpuProfileOptions& options) {
HandleScope handle_scope(isolate());
if (!cpu_profiler_) {
- cpu_profiler_ = v8::CpuProfiler::New(isolate());
- }
- v8::CpuProfilingOptions start_options(
- v8::CpuProfilingMode::kLeafNodeLineNumbers,
- options.max_samples,
- options.sampling_interval_us);
- v8::CpuProfilingResult result =
- cpu_profiler_->Start(std::move(start_options));
- if (result.status == v8::CpuProfilingStatus::kStarted) {
+ cpu_profiler_ = CpuProfiler::New(isolate());
+ }
+ CpuProfilingOptions start_options(CpuProfilingMode::kLeafNodeLineNumbers,
+ options.max_samples,
+ options.sampling_interval_us);
+ CpuProfilingResult result = cpu_profiler_->Start(std::move(start_options));
+ if (result.status == CpuProfilingStatus::kStarted) {
pending_profiles_.push_back(result.id);
}
return result;
}
-v8::CpuProfile* Environment::StopCpuProfile(v8::ProfilerId profile_id) {
+CpuProfile* Environment::StopCpuProfile(ProfilerId profile_id) {
if (!cpu_profiler_) {
return nullptr;
}
@@ -2786,7 +2799,7 @@ v8::CpuProfile* Environment::StopCpuProfile(v8::ProfilerId profile_id) {
if (it == pending_profiles_.end()) {
return nullptr;
}
- v8::CpuProfile* profile = cpu_profiler_->Stop(*it);
+ CpuProfile* profile = cpu_profiler_->Stop(*it);
pending_profiles_.erase(it);
return profile;
}
diff --git a/src/node_v8.cc b/src/node_v8.cc
index 9758826ae8b..49e4a0ca113 100644
--- a/src/node_v8.cc
+++ b/src/node_v8.cc
@@ -44,8 +44,11 @@ using v8::CpuProfilingStatus;
using v8::DictionaryTemplate;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
+using v8::GCCallbackFlags;
+using v8::GCType;
using v8::HandleScope;
using v8::HeapCodeStatistics;
+using v8::HeapProfiler;
using v8::HeapSpaceStatistics;
using v8::HeapStatistics;
using v8::Integer;
@@ -56,6 +59,7 @@ using v8::MaybeLocal;
using v8::Number;
using v8::Object;
using v8::ScriptCompiler;
+using v8::SnapshotCreator;
using v8::String;
using v8::Uint32;
using v8::V8;
@@ -147,7 +151,7 @@ BindingData::BindingData(Realm* realm,
}
bool BindingData::PrepareForSerialization(Local<Context> context,
- v8::SnapshotCreator* creator) {
+ SnapshotCreator* creator) {
DCHECK_NULL(internal_field_info_);
internal_field_info_ = InternalFieldInfoBase::New<InternalFieldInfo>(type());
internal_field_info_->heap_statistics_buffer =
@@ -191,7 +195,7 @@ void CachedDataVersionTag(const FunctionCallbackInfo<Value>& args) {
void SetHeapSnapshotNearHeapLimit(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsUint32());
Environment* env = Environment::GetCurrent(args);
- uint32_t limit = args[0].As<v8::Uint32>()->Value();
+ uint32_t limit = args[0].As<Uint32>()->Value();
CHECK_GT(limit, 0);
std::string dir = env->options()->diagnostic_dir;
@@ -208,7 +212,7 @@ void SetHeapSnapshotNearHeapLimit(const FunctionCallbackInfo<Value>& args) {
void SetHeapProfileNearHeapLimit(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsUint32());
Environment* env = Environment::GetCurrent(args);
- uint32_t limit = args[0].As<v8::Uint32>()->Value();
+ uint32_t limit = args[0].As<Uint32>()->Value();
CHECK_GT(limit, 0);
std::string dir = env->options()->diagnostic_dir;
@@ -230,8 +234,8 @@ void SetPointerCompressionHeapWarningThresholds(
CHECK(args[0]->IsNumber());
CHECK(args[1]->IsNumber());
Environment* env = Environment::GetCurrent(args);
- double likely = args[0].As<v8::Number>()->Value();
- double certain = args[1].As<v8::Number>()->Value();
+ double likely = args[0].As<Number>()->Value();
+ double certain = args[1].As<Number>()->Value();
CHECK_GE(likely, 0);
CHECK_GE(certain, 0);
env->set_pointer_compression_heap_warning_thresholds(
@@ -254,7 +258,7 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) {
HeapSpaceStatistics s;
Isolate* const isolate = args.GetIsolate();
CHECK(args[0]->IsUint32());
- size_t space_index = static_cast<size_t>(args[0].As<v8::Uint32>()->Value());
+ size_t space_index = static_cast<size_t>(args[0].As<Uint32>()->Value());
isolate->GetHeapSpaceStatistics(&s, space_index);
AliasedFloat64Array& buffer = data->heap_space_statistics_buffer;
@@ -367,17 +371,17 @@ void GetHashSeed(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(BigInt::NewFromUnsigned(isolate, hash_seed));
}
-static const char* GetGCTypeName(v8::GCType gc_type) {
+static const char* GetGCTypeName(GCType gc_type) {
switch (gc_type) {
- case v8::GCType::kGCTypeScavenge:
+ case GCType::kGCTypeScavenge:
return "Scavenge";
- case v8::GCType::kGCTypeMinorMarkSweep:
+ case GCType::kGCTypeMinorMarkSweep:
return "MinorMarkSweep";
- case v8::GCType::kGCTypeMarkSweepCompact:
+ case GCType::kGCTypeMarkSweepCompact:
return "MarkSweepCompact";
- case v8::GCType::kGCTypeIncrementalMarking:
+ case GCType::kGCTypeIncrementalMarking:
return "IncrementalMarking";
- case v8::GCType::kGCTypeProcessWeakCallbacks:
+ case GCType::kGCTypeProcessWeakCallbacks:
return "ProcessWeakCallbacks";
default:
return "Unknown";
@@ -620,8 +624,8 @@ static void GetCppHeapStatistics(const FunctionCallbackInfo<Value>& args) {
}
static void BeforeGCCallback(Isolate* isolate,
- v8::GCType gc_type,
- v8::GCCallbackFlags flags,
+ GCType gc_type,
+ GCCallbackFlags flags,
void* data) {
GCProfiler* profiler = static_cast<GCProfiler*>(data);
if (profiler->current_gc_type != 0) {
@@ -638,8 +642,8 @@ static void BeforeGCCallback(Isolate* isolate,
}
static void AfterGCCallback(Isolate* isolate,
- v8::GCType gc_type,
- v8::GCCallbackFlags flags,
+ GCType gc_type,
+ GCCallbackFlags flags,
void* data) {
GCProfiler* profiler = static_cast<GCProfiler*>(data);
if (profiler->current_gc_type != gc_type) {
@@ -715,7 +719,7 @@ void GCProfiler::Start(const FunctionCallbackInfo<Value>& args) {
profiler->state = GCProfiler::GCProfilerState::kStarted;
}
-void GCProfiler::Stop(const FunctionCallbackInfo<v8::Value>& args) {
+void GCProfiler::Stop(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
GCProfiler* profiler;
ASSIGN_OR_RETURN_UNWRAP(&profiler, args.This());
@@ -818,16 +822,16 @@ void Initialize(Local<Object> target,
SetMethod(context, target, "stopHeapProfile", StopHeapProfile);
{
- constexpr uint32_t kSamplingNoFlags = static_cast<uint32_t>(
- v8::HeapProfiler::SamplingFlags::kSamplingNoFlags);
- constexpr uint32_t kSamplingForceGC = static_cast<uint32_t>(
- v8::HeapProfiler::SamplingFlags::kSamplingForceGC);
- constexpr uint32_t kSamplingIncludeObjectsCollectedByMajorGC =
- static_cast<uint32_t>(v8::HeapProfiler::SamplingFlags::
- kSamplingIncludeObjectsCollectedByMajorGC);
- constexpr uint32_t kSamplingIncludeObjectsCollectedByMinorGC =
- static_cast<uint32_t>(v8::HeapProfiler::SamplingFlags::
- kSamplingIncludeObjectsCollectedByMinorGC);
+ constexpr uint32_t kSamplingNoFlags =
+ static_cast<uint32_t>(HeapProfiler::SamplingFlags::kSamplingNoFlags);
+ constexpr uint32_t kSamplingForceGC =
+ static_cast<uint32_t>(HeapProfiler::SamplingFlags::kSamplingForceGC);
+ constexpr uint32_t kSamplingIncludeObjectsCollectedByMajorGC = static_cast<
+ uint32_t>(
+ HeapProfiler::SamplingFlags::kSamplingIncludeObjectsCollectedByMajorGC);
+ constexpr uint32_t kSamplingIncludeObjectsCollectedByMinorGC = static_cast<
+ uint32_t>(
+ HeapProfiler::SamplingFlags::kSamplingIncludeObjectsCollectedByMinorGC);
NODE_DEFINE_CONSTANT(target, kSamplingNoFlags);
NODE_DEFINE_CONSTANT(target, kSamplingForceGC);
diff --git a/src/node_worker.cc b/src/node_worker.cc
index c767f9ff52d..36cf67dd730 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -22,6 +22,7 @@
using node::kAllowedInEnvvar;
using node::kDisallowedInEnvvar;
+using v8::AccessorNameGetterCallback;
using v8::Array;
using v8::ArrayBuffer;
using v8::Boolean;
@@ -34,6 +35,7 @@ using v8::Float64Array;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::HandleScope;
+using v8::HeapProfiler;
using v8::HeapStatistics;
using v8::Integer;
using v8::Isolate;
@@ -41,11 +43,13 @@ using v8::Local;
using v8::Locker;
using v8::Maybe;
using v8::MaybeLocal;
+using v8::Name;
using v8::NewStringType;
using v8::Null;
using v8::Number;
using v8::Object;
using v8::ObjectTemplate;
+using v8::PropertyCallbackInfo;
using v8::ResourceConstraints;
using v8::SealHandleScope;
using v8::String;
@@ -1077,7 +1081,7 @@ void Worker::StartHeapProfile(const FunctionCallbackInfo<Value>& args) {
bool scheduled = w->RequestInterrupt([taker = std::move(taker), env, options](
Environment* worker_env) mutable {
- v8::HeapProfiler* profiler = worker_env->isolate()->GetHeapProfiler();
+ HeapProfiler* profiler = worker_env->isolate()->GetHeapProfiler();
bool success = profiler->StartSamplingHeapProfiler(
options.sample_interval, options.stack_depth, options.flags);
env->SetImmediateThreadsafe(
@@ -1434,14 +1438,12 @@ void GetEnvMessagePort(const FunctionCallbackInfo<Value>& args) {
// Per-thread values of the `worker` binding are lazy properties of the
// per-isolate template, so that a bootstrapped context carries none of them
// and can be deserialized by any thread.
-void ThreadIdGetter(Local<v8::Name>,
- const v8::PropertyCallbackInfo<Value>& info) {
+void ThreadIdGetter(Local<Name>, const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
info.GetReturnValue().Set(static_cast<double>(env->thread_id()));
}
-void ThreadNameGetter(Local<v8::Name>,
- const v8::PropertyCallbackInfo<Value>& info) {
+void ThreadNameGetter(Local<Name>, const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
Local<String> name;
if (String::NewFromUtf8(info.GetIsolate(),
@@ -1453,19 +1455,18 @@ void ThreadNameGetter(Local<v8::Name>,
}
}
-void IsMainThreadGetter(Local<v8::Name>,
- const v8::PropertyCallbackInfo<Value>& info) {
+void IsMainThreadGetter(Local<Name>, const PropertyCallbackInfo<Value>& info) {
info.GetReturnValue().Set(Environment::GetCurrent(info)->is_main_thread());
}
-void OwnsProcessStateGetter(Local<v8::Name>,
- const v8::PropertyCallbackInfo<Value>& info) {
+void OwnsProcessStateGetter(Local<Name>,
+ const PropertyCallbackInfo<Value>& info) {
info.GetReturnValue().Set(
Environment::GetCurrent(info)->owns_process_state());
}
-void ResourceLimitsGetter(Local<v8::Name>,
- const v8::PropertyCallbackInfo<Value>& info) {
+void ResourceLimitsGetter(Local<Name>,
+ const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
if (env->worker_context() != nullptr) {
info.GetReturnValue().Set(
@@ -1477,7 +1478,7 @@ void CreateWorkerPerIsolateProperties(IsolateData* isolate_data,
Local<ObjectTemplate> target) {
{
Isolate* isolate = isolate_data->isolate();
- auto lazy = [&](const char* name, v8::AccessorNameGetterCallback getter) {
+ auto lazy = [&](const char* name, AccessorNameGetterCallback getter) {
target->SetLazyDataProperty(OneByteString(isolate, name), getter);
};
lazy("threadId", ThreadIdGetter);
diff --git a/src/util.cc b/src/util.cc
index 17947492862..de01b4343bd 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -88,12 +88,32 @@ namespace node {
using v8::ArrayBuffer;
using v8::ArrayBufferView;
using v8::BackingStore;
+using v8::BackingStoreInitializationMode;
+using v8::BackingStoreOnFailureMode;
+using v8::CFunction;
+using v8::ConstructorBehavior;
using v8::Context;
+using v8::CppHeap;
+using v8::CppHeapCreateParams;
+using v8::Function;
+using v8::FunctionCallback;
using v8::FunctionTemplate;
+using v8::Int32;
using v8::Isolate;
+using v8::JSON;
+using v8::Just;
using v8::Local;
+using v8::Maybe;
+using v8::MaybeLocal;
+using v8::MemorySpan;
+using v8::NewStringType;
+using v8::Nothing;
+using v8::Number;
using v8::Object;
+using v8::SideEffectType;
+using v8::Signature;
using v8::String;
+using v8::Symbol;
using v8::Template;
using v8::Value;
@@ -288,59 +308,57 @@ std::string DiagnosticFilename::MakeFilename(
return oss.str();
}
-Local<v8::FunctionTemplate> NewFunctionTemplate(
- v8::Isolate* isolate,
- v8::FunctionCallback callback,
- Local<v8::Signature> signature,
- v8::ConstructorBehavior behavior,
- v8::SideEffectType side_effect_type,
- const v8::CFunction* c_function) {
- return v8::FunctionTemplate::New(isolate,
- callback,
- Local<v8::Value>(),
- signature,
- 0,
- behavior,
- side_effect_type,
- c_function);
-}
-
-void SetMethod(Local<v8::Context> context,
- Local<v8::Object> that,
+Local<FunctionTemplate> NewFunctionTemplate(Isolate* isolate,
+ FunctionCallback callback,
+ Local<Signature> signature,
+ ConstructorBehavior behavior,
+ SideEffectType side_effect_type,
+ const CFunction* c_function) {
+ return FunctionTemplate::New(isolate,
+ callback,
+ Local<Value>(),
+ signature,
+ 0,
+ behavior,
+ side_effect_type,
+ c_function);
+}
+
+void SetMethod(Local<Context> context,
+ Local<Object> that,
const std::string_view name,
- v8::FunctionCallback callback) {
+ FunctionCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
- Local<v8::Function> function =
- NewFunctionTemplate(isolate,
- callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect)
- ->GetFunction(context)
- .ToLocalChecked();
+ Local<Function> function = NewFunctionTemplate(isolate,
+ callback,
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect)
+ ->GetFunction(context)
+ .ToLocalChecked();
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(context, name_string, function).Check();
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
}
-void SetMethod(v8::Isolate* isolate,
- v8::Local<v8::Template> that,
+void SetMethod(Isolate* isolate,
+ Local<Template> that,
const std::string_view name,
- v8::FunctionCallback callback) {
- Local<v8::FunctionTemplate> t =
+ FunctionCallback callback) {
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect);
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
@@ -348,63 +366,62 @@ void SetMethod(v8::Isolate* isolate,
void SetFastMethod(Isolate* isolate,
Local<Template> that,
const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::CFunction* c_function) {
- Local<v8::FunctionTemplate> t =
+ FunctionCallback slow_callback,
+ const CFunction* c_function) {
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
slow_callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect,
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect,
c_function);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
-void SetFastMethod(Local<v8::Context> context,
- Local<v8::Object> that,
+void SetFastMethod(Local<Context> context,
+ Local<Object> that,
const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::CFunction* c_function) {
+ FunctionCallback slow_callback,
+ const CFunction* c_function) {
Isolate* isolate = Isolate::GetCurrent();
- Local<v8::Function> function =
- NewFunctionTemplate(isolate,
- slow_callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect,
- c_function)
- ->GetFunction(context)
- .ToLocalChecked();
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ Local<Function> function = NewFunctionTemplate(isolate,
+ slow_callback,
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect,
+ c_function)
+ ->GetFunction(context)
+ .ToLocalChecked();
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(context, name_string, function).Check();
}
-void SetFastMethodNoSideEffect(Local<v8::Context> context,
- Local<v8::Object> that,
+void SetFastMethodNoSideEffect(Local<Context> context,
+ Local<Object> that,
const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::CFunction* c_function) {
+ FunctionCallback slow_callback,
+ const CFunction* c_function) {
Isolate* isolate = Isolate::GetCurrent();
- Local<v8::Function> function =
+ Local<Function> function =
NewFunctionTemplate(isolate,
slow_callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect,
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect,
c_function)
->GetFunction(context)
.ToLocalChecked();
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(context, name_string, function).Check();
}
@@ -412,19 +429,19 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
void SetFastMethodNoSideEffect(Isolate* isolate,
Local<Template> that,
const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::CFunction* c_function) {
- Local<v8::FunctionTemplate> t =
+ FunctionCallback slow_callback,
+ const CFunction* c_function) {
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
slow_callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect,
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect,
c_function);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
@@ -432,205 +449,203 @@ void SetFastMethodNoSideEffect(Isolate* isolate,
void SetFastMethod(Isolate* isolate,
Local<Template> that,
const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::MemorySpan<const v8::CFunction>& methods) {
- Local<v8::FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads(
+ FunctionCallback slow_callback,
+ const MemorySpan<const CFunction>& methods) {
+ Local<FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads(
isolate,
slow_callback,
Local<Value>(),
- Local<v8::Signature>(),
+ Local<Signature>(),
0,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect,
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect,
methods);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
-void SetFastMethodNoSideEffect(
- Isolate* isolate,
- Local<Template> that,
- const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::MemorySpan<const v8::CFunction>& methods) {
- Local<v8::FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads(
+void SetFastMethodNoSideEffect(Isolate* isolate,
+ Local<Template> that,
+ const std::string_view name,
+ FunctionCallback slow_callback,
+ const MemorySpan<const CFunction>& methods) {
+ Local<FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads(
isolate,
slow_callback,
Local<Value>(),
- Local<v8::Signature>(),
+ Local<Signature>(),
0,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect,
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect,
methods);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
-void SetFastMethodNoSideEffect(
- Local<v8::Context> context,
- Local<v8::Object> that,
- const std::string_view name,
- v8::FunctionCallback slow_callback,
- const v8::MemorySpan<const v8::CFunction>& methods) {
+void SetFastMethodNoSideEffect(Local<Context> context,
+ Local<Object> that,
+ const std::string_view name,
+ FunctionCallback slow_callback,
+ const MemorySpan<const CFunction>& methods) {
Isolate* isolate = Isolate::GetCurrent();
- Local<v8::Function> function = FunctionTemplate::NewWithCFunctionOverloads(
- isolate,
- slow_callback,
- Local<Value>(),
- Local<v8::Signature>(),
- 0,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect,
- methods)
- ->GetFunction(context)
- .ToLocalChecked();
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ Local<Function> function = FunctionTemplate::NewWithCFunctionOverloads(
+ isolate,
+ slow_callback,
+ Local<Value>(),
+ Local<Signature>(),
+ 0,
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect,
+ methods)
+ ->GetFunction(context)
+ .ToLocalChecked();
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(context, name_string, function).Check();
}
-void SetMethodNoSideEffect(Local<v8::Context> context,
- Local<v8::Object> that,
+void SetMethodNoSideEffect(Local<Context> context,
+ Local<Object> that,
const std::string_view name,
- v8::FunctionCallback callback) {
+ FunctionCallback callback) {
Isolate* isolate = Isolate::GetCurrent();
- Local<v8::Function> function =
+ Local<Function> function =
NewFunctionTemplate(isolate,
callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect)
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect)
->GetFunction(context)
.ToLocalChecked();
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(context, name_string, function).Check();
function->SetName(name_string); // NODE_SET_METHOD() compatibility.
}
void SetMethodNoSideEffect(Isolate* isolate,
- Local<v8::Template> that,
+ Local<Template> that,
const std::string_view name,
- v8::FunctionCallback callback) {
- Local<v8::FunctionTemplate> t =
+ FunctionCallback callback) {
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
- Local<v8::Signature>(),
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect);
+ Local<Signature>(),
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->Set(name_string, t);
}
-void SetProtoDispose(v8::Isolate* isolate,
- v8::Local<v8::FunctionTemplate> that,
- v8::FunctionCallback callback) {
- Local<v8::Signature> signature = v8::Signature::New(isolate, that);
- Local<v8::FunctionTemplate> t =
+void SetProtoDispose(Isolate* isolate,
+ Local<FunctionTemplate> that,
+ FunctionCallback callback) {
+ Local<Signature> signature = Signature::New(isolate, that);
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
signature,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect);
- that->PrototypeTemplate()->Set(v8::Symbol::GetDispose(isolate), t);
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
+ that->PrototypeTemplate()->Set(Symbol::GetDispose(isolate), t);
}
-void SetProtoAsyncDispose(v8::Isolate* isolate,
- v8::Local<v8::FunctionTemplate> that,
- v8::FunctionCallback callback) {
- Local<v8::Signature> signature = v8::Signature::New(isolate, that);
- Local<v8::FunctionTemplate> t =
+void SetProtoAsyncDispose(Isolate* isolate,
+ Local<FunctionTemplate> that,
+ FunctionCallback callback) {
+ Local<Signature> signature = Signature::New(isolate, that);
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
signature,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect);
- that->PrototypeTemplate()->Set(v8::Symbol::GetAsyncDispose(isolate), t);
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
+ that->PrototypeTemplate()->Set(Symbol::GetAsyncDispose(isolate), t);
}
-void SetProtoMethod(v8::Isolate* isolate,
- Local<v8::FunctionTemplate> that,
+void SetProtoMethod(Isolate* isolate,
+ Local<FunctionTemplate> that,
const std::string_view name,
- v8::FunctionCallback callback) {
- Local<v8::Signature> signature = v8::Signature::New(isolate, that);
- Local<v8::FunctionTemplate> t =
+ FunctionCallback callback) {
+ Local<Signature> signature = Signature::New(isolate, that);
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
signature,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect);
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->PrototypeTemplate()->Set(name_string, t);
t->SetClassName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
}
-void SetProtoMethodNoSideEffect(v8::Isolate* isolate,
- Local<v8::FunctionTemplate> that,
+void SetProtoMethodNoSideEffect(Isolate* isolate,
+ Local<FunctionTemplate> that,
const std::string_view name,
- v8::FunctionCallback callback) {
- Local<v8::Signature> signature = v8::Signature::New(isolate, that);
- Local<v8::FunctionTemplate> t =
+ FunctionCallback callback) {
+ Local<Signature> signature = Signature::New(isolate, that);
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
signature,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasNoSideEffect);
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasNoSideEffect);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->PrototypeTemplate()->Set(name_string, t);
t->SetClassName(name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
}
-void SetInstanceMethod(v8::Isolate* isolate,
- Local<v8::FunctionTemplate> that,
+void SetInstanceMethod(Isolate* isolate,
+ Local<FunctionTemplate> that,
const std::string_view name,
- v8::FunctionCallback callback) {
- Local<v8::Signature> signature = v8::Signature::New(isolate, that);
- Local<v8::FunctionTemplate> t =
+ FunctionCallback callback) {
+ Local<Signature> signature = Signature::New(isolate, that);
+ Local<FunctionTemplate> t =
NewFunctionTemplate(isolate,
callback,
signature,
- v8::ConstructorBehavior::kThrow,
- v8::SideEffectType::kHasSideEffect);
+ ConstructorBehavior::kThrow,
+ SideEffectType::kHasSideEffect);
// kInternalized strings are created in the old space.
- const v8::NewStringType type = v8::NewStringType::kInternalized;
- Local<v8::String> name_string =
- v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
+ const NewStringType type = NewStringType::kInternalized;
+ Local<String> name_string =
+ String::NewFromUtf8(isolate, name.data(), type, name.size())
.ToLocalChecked();
that->InstanceTemplate()->Set(name_string, t);
t->SetClassName(name_string);
}
-void SetConstructorFunction(Local<v8::Context> context,
- Local<v8::Object> that,
+void SetConstructorFunction(Local<Context> context,
+ Local<Object> that,
const char* name,
- Local<v8::FunctionTemplate> tmpl,
+ Local<FunctionTemplate> tmpl,
SetConstructorFunctionFlag flag) {
Isolate* isolate = Isolate::GetCurrent();
SetConstructorFunction(
@@ -688,8 +703,8 @@ std::unique_ptr<BackingStore> AdoptIntoBackingStore(
std::unique_ptr<BackingStore> store = ArrayBuffer::NewBackingStore(
isolate,
byte_length,
- v8::BackingStoreInitializationMode::kUninitialized,
- v8::BackingStoreOnFailureMode::kReturnNull);
+ BackingStoreInitializationMode::kUninitialized,
+ BackingStoreOnFailureMode::kReturnNull);
if (store && byte_length > 0) memcpy(store->Data(), data, byte_length);
if (data != nullptr) deleter(data, byte_length, deleter_data);
return store;
@@ -709,8 +724,8 @@ RAIIIsolateWithoutEntering::RAIIIsolateWithoutEntering(const SnapshotData* data)
SnapshotBuilder::InitializeIsolateParams(data, ¶ms);
}
params.array_buffer_allocator = allocator_.get();
- params.cpp_heap = v8::CppHeap::Create(per_process::v8_platform.Platform(),
- v8::CppHeapCreateParams{{}})
+ params.cpp_heap = CppHeap::Create(per_process::v8_platform.Platform(),
+ CppHeapCreateParams{{}})
.release();
Isolate::Initialize(isolate_, params);
}
@@ -726,8 +741,7 @@ RAIIIsolate::~RAIIIsolate() {}
// Returns a string representation of the input value, including type.
// JavaScript implementation is available in lib/internal/errors.js
-std::string DetermineSpecificErrorType(Environment* env,
- v8::Local<v8::Value> input) {
+std::string DetermineSpecificErrorType(Environment* env, Local<Value> input) {
if (input->IsFunction()) {
return "function";
} else if (input->IsString()) {
@@ -741,18 +755,16 @@ std::string DetermineSpecificErrorType(Environment* env,
// Stringify the input value.
Local<String> stringified =
- v8::JSON::Stringify(env->context(), input).ToLocalChecked();
+ JSON::Stringify(env->context(), input).ToLocalChecked();
Utf8Value stringified_value(env->isolate(), stringified);
return SPrintF("type string (%s)", stringified_value.out());
} else if (input->IsObject()) {
- v8::Local<v8::String> constructor_name =
- input.As<v8::Object>()->GetConstructorName();
+ Local<String> constructor_name = input.As<Object>()->GetConstructorName();
Utf8Value name(env->isolate(), constructor_name);
return SPrintF("an instance of %s", name.out());
} else if (input->IsSymbol()) {
- v8::MaybeLocal<v8::String> str =
- input.As<v8::Symbol>()->ToDetailString(env->context());
- v8::Local<v8::String> js_str;
+ MaybeLocal<String> str = input.As<Symbol>()->ToDetailString(env->context());
+ Local<String> js_str;
if (!str.ToLocal(&js_str)) {
return "Symbol";
}
@@ -765,7 +777,7 @@ std::string DetermineSpecificErrorType(Environment* env,
input->ToString(env->context()).ToLocalChecked());
if (input->IsNumber() || input->IsInt32() || input->IsUint32()) {
- auto value = input.As<v8::Number>()->Value();
+ auto value = input.As<Number>()->Value();
if (std::isnan(value)) {
return "type number (NaN)";
} else if (std::isinf(value)) {
@@ -781,24 +793,23 @@ std::string DetermineSpecificErrorType(Environment* env,
return utf8_value.ToString();
}
-v8::Maybe<int32_t> GetValidatedFd(Environment* env,
- v8::Local<v8::Value> input) {
+Maybe<int32_t> GetValidatedFd(Environment* env, Local<Value> input) {
if (!input->IsInt32() && !input->IsNumber()) {
std::string error_type = node::DetermineSpecificErrorType(env, input);
THROW_ERR_INVALID_ARG_TYPE(env,
"The \"fd\" argument must be of type "
"number. Received %s",
error_type.c_str());
- return v8::Nothing<int32_t>();
+ return Nothing<int32_t>();
}
- const double fd = input.As<v8::Number>()->Value();
+ const double fd = input.As<Number>()->Value();
const bool is_out_of_range = fd < 0 || fd > INT32_MAX;
if (is_out_of_range || !IsSafeJsInt(input)) {
Local<String> str;
if (!input->ToDetailString(env->context()).ToLocal(&str)) {
- return v8::Nothing<int32_t>();
+ return Nothing<int32_t>();
}
Utf8Value utf8_value(env->isolate(), str);
if (is_out_of_range && !std::isinf(fd)) {
@@ -814,28 +825,28 @@ v8::Maybe<int32_t> GetValidatedFd(Environment* env,
"Received %s",
utf8_value.out());
}
- return v8::Nothing<int32_t>();
+ return Nothing<int32_t>();
}
- return v8::Just(static_cast<int32_t>(fd));
+ return Just(static_cast<int32_t>(fd));
}
-v8::Maybe<int> GetValidFileMode(Environment* env,
- v8::Local<v8::Value> input,
- uv_fs_type type) {
+Maybe<int> GetValidFileMode(Environment* env,
+ Local<Value> input,
+ uv_fs_type type) {
// Allow only int32 or null/undefined values.
if (input->IsNumber()) {
// We cast the input to v8::Number to avoid overflows.
- auto num = input.As<v8::Number>()->Value();
+ auto num = input.As<Number>()->Value();
// Handle infinity and NaN values
if (std::isinf(num) || std::isnan(num)) {
THROW_ERR_OUT_OF_RANGE(env, "mode is out of range");
- return v8::Nothing<int>();
+ return Nothing<int>();
}
} else if (!input->IsNullOrUndefined()) {
THROW_ERR_INVALID_ARG_TYPE(env, "mode must be int32 or null/undefined");
- return v8::Nothing<int>();
+ return Nothing<int>();
}
int min = kMinimumAccessMode;
@@ -848,30 +859,30 @@ v8::Maybe<int> GetValidFileMode(Environment* env,
min = kMinimumCopyMode;
max = kMaximumCopyMode;
def = input->IsNullOrUndefined() ? kDefaultCopyMode
- : input.As<v8::Int32>()->Value();
+ : input.As<Int32>()->Value();
}
if (input->IsNullOrUndefined()) {
- return v8::Just(def);
+ return Just(def);
}
- const int mode = input.As<v8::Int32>()->Value();
+ const int mode = input.As<Int32>()->Value();
if (mode < min || mode > max) {
THROW_ERR_OUT_OF_RANGE(
env, "mode is out of range: >= %d && <= %d", min, max);
- return v8::Nothing<int>();
+ return Nothing<int>();
}
- return v8::Just(mode);
+ return Just(mode);
}
-v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
- std::string_view str,
- v8::Isolate* isolate) {
- if (isolate == nullptr) isolate = v8::Isolate::GetCurrent();
- if (str.size() >= static_cast<size_t>(v8::String::kMaxLength)) [[unlikely]] {
+MaybeLocal<Value> ToV8Value(Local<Context> context,
+ std::string_view str,
+ Isolate* isolate) {
+ if (isolate == nullptr) isolate = Isolate::GetCurrent();
+ if (str.size() >= static_cast<size_t>(String::kMaxLength)) [[unlikely]] {
ThrowErrStringTooLong(isolate);
- return v8::MaybeLocal<v8::Value>();
+ return MaybeLocal<Value>();
}
return StringBytes::Encode(isolate, str.data(), str.size(), UTF8);
}